Description:
Change image for each contract.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r249:ed2290772a37 -

@@ -103,6 +103,7
103 var start_x = random_generator.Next(0, 50);
103 var start_x = random_generator.Next(0, 50);
104 var start_y = random_generator.Next(0, 50);
104 var start_y = random_generator.Next(0, 50);
105
105
106 var image_index = random_generator.Next(1, 7);
106
107
107 int max_squares = (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares;
108 int max_squares = (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares;
108 int min_squares = (message.min_squares == null) ? DEFAULT_MIN_SQUARES : (int)message.min_squares;
109 int min_squares = (message.min_squares == null) ? DEFAULT_MIN_SQUARES : (int)message.min_squares;
@@ -128,6 +129,7
128 //Round to the nearest $5
129 //Round to the nearest $5
129 amount = (decimal)((contract_amount / 5) * 5)
130 amount = (decimal)((contract_amount / 5) * 5)
130 });
131 });
132 AddComponent(contract, new ImageComponent {ImageIndex = image_index});
131 AddComponent(contract, new WindowTypeComponent { type = Window.Contract});
133 AddComponent(contract, new WindowTypeComponent { type = Window.Contract});
132 AddComponent(contract, new VisibilityComponent { visible = false});
134 AddComponent(contract, new VisibilityComponent { visible = false});
133 }
135 }
@@ -25,14 +25,15
25 this.BridgeEngine = engine;
25 this.BridgeEngine = engine;
26 }
26 }
27
27
28 private (Entity entity, string name, ContractStatus status, decimal amount, string delta_trees)
28 private (Entity entity, string name, ContractStatus status, decimal amount, string delta_trees, int image_index)
29 getContractDetails(Entity entity) {
29 getContractDetails(Entity entity) {
30
30
31 var name = GetComponent<NameComponent>(entity).DisplayName;
31 var name = GetComponent<NameComponent>(entity).DisplayName;
32 var status = GetComponent<ContractStatusComponent>(entity).status;
32 var status = GetComponent<ContractStatusComponent>(entity).status;
33 var amount = GetComponent<BudgetLineComponent>(entity).amount;
33 var amount = GetComponent<BudgetLineComponent>(entity).amount;
34 var tree_delta = GetComponent<TreeDeltaComponent>(entity).deltaTreesName;
34 var tree_delta = GetComponent<TreeDeltaComponent>(entity).deltaTreesName;
35 return (entity, name, status, amount, tree_delta);
35 var image_index = GetComponent<ImageComponent>(entity).ImageIndex;
36 return (entity, name, status, amount, tree_delta, image_index);
36
37
37 }
38 }
38
39
@@ -50,7 +51,7
50 case Window.Contracts:
51 case Window.Contracts:
51 var contracts = ReadEntities<AreaComponent>();
52 var contracts = ReadEntities<AreaComponent>();
52
53
53 var contract_data = new List<(Entity, string, ContractStatus, decimal, string)>();
54 var contract_data = new List<(Entity, string, ContractStatus, decimal, string, int)>();
54
55
55 foreach(var e in contracts)
56 foreach(var e in contracts)
56 {
57 {
@@ -63,7 +64,7
63
64
64 var data = getContractDetails(entity);
65 var data = getContractDetails(entity);
65
66
66 ContractWindow.Render(this.font, this.BridgeEngine, entity, data.name, data.status, data.amount, data.delta_trees);
67 ContractWindow.Render(this.font, this.BridgeEngine, entity, data.name, data.status, data.amount, data.delta_trees, data.image_index);
67
68
68 //Logging.Trace(string.Format("Rendering Contract Window for {0}", data.name));
69 //Logging.Trace(string.Format("Rendering Contract Window for {0}", data.name));
69
70
@@ -31,7 +31,7
31 }
31 }
32
32
33
33
34 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, Entity entity, string name, ContractStatus status, decimal amount, string delta_trees)
34 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, Entity entity, string name, ContractStatus status, decimal amount, string delta_trees, int imageIndex)
35
35
36 {
36 {
37 bool newShow = true;
37 bool newShow = true;
@@ -74,7 +74,7
74 ImGui.SetNextWindowSize(new Num.Vector2(320, 340));
74 ImGui.SetNextWindowSize(new Num.Vector2(320, 340));
75 ImGui.Begin(string.Format("Contract {0}" , name), ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
75 ImGui.Begin(string.Format("Contract {0}" , name), ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
76
76
77 ImGui.Image(_imGuiTexture, new Num.Vector2(250, 200), map.GetSourceUVStart(2), map.GetSourceUVEnd(2), Num.Vector4.One, Num.Vector4.Zero); // Here, the previously loaded texture is used
77 ImGui.Image(_imGuiTexture, new Num.Vector2(250, 200), map.GetSourceUVStart(imageIndex), map.GetSourceUVEnd(imageIndex), Num.Vector4.One, Num.Vector4.Zero); // Here, the previously loaded texture is used
78
78
79 ImGui.Separator();
79 ImGui.Separator();
80 switch (status)
80 switch (status)
@@ -17,11 +17,11
17 {
17 {
18 public static bool show_all;
18 public static bool show_all;
19
19
20 private static (Entity entity, string name, ContractStatus status, decimal amount, string delta_trees) selected;
20 private static (Entity entity, string name, ContractStatus status, decimal amount, string delta_trees, int image_index) selected;
21
21
22
22
23 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine,
23 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine,
24 List<(Entity entity, string name, ContractStatus status, decimal amount, string delta_trees)> contracts)
24 List<(Entity entity, string name, ContractStatus status, decimal amount, string delta_trees, int image_index)> contracts)
25 {
25 {
26 bool newShow = true;
26 bool newShow = true;
27
27
You need to be logged in to leave comments. Login now