Description:
Change image for each contract.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -103,6 +103,7 | |||
|
103 | 103 | var start_x = random_generator.Next(0, 50); |
|
104 | 104 | var start_y = random_generator.Next(0, 50); |
|
105 | 105 | |
|
106 | var image_index = random_generator.Next(1, 7); | |
|
106 | 107 | |
|
107 | 108 | int max_squares = (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares; |
|
108 | 109 | int min_squares = (message.min_squares == null) ? DEFAULT_MIN_SQUARES : (int)message.min_squares; |
@@ -128,6 +129,7 | |||
|
128 | 129 | //Round to the nearest $5 |
|
129 | 130 | amount = (decimal)((contract_amount / 5) * 5) |
|
130 | 131 | }); |
|
132 | AddComponent(contract, new ImageComponent {ImageIndex = image_index}); | |
|
131 | 133 | AddComponent(contract, new WindowTypeComponent { type = Window.Contract}); |
|
132 | 134 | AddComponent(contract, new VisibilityComponent { visible = false}); |
|
133 | 135 | } |
@@ -25,14 +25,15 | |||
|
25 | 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 | 29 | getContractDetails(Entity entity) { |
|
30 | 30 | |
|
31 | 31 | var name = GetComponent<NameComponent>(entity).DisplayName; |
|
32 | 32 | var status = GetComponent<ContractStatusComponent>(entity).status; |
|
33 | 33 | var amount = GetComponent<BudgetLineComponent>(entity).amount; |
|
34 | 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 | 51 | case Window.Contracts: |
|
51 | 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 | 56 | foreach(var e in contracts) |
|
56 | 57 | { |
@@ -63,7 +64,7 | |||
|
63 | 64 | |
|
64 | 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 | 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 | 37 | bool newShow = true; |
@@ -74,7 +74,7 | |||
|
74 | 74 | ImGui.SetNextWindowSize(new Num.Vector2(320, 340)); |
|
75 | 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( |
|
|
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 | 79 | ImGui.Separator(); |
|
80 | 80 | switch (status) |
@@ -17,11 +17,11 | |||
|
17 | 17 | { |
|
18 | 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 | 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 | 26 | bool newShow = true; |
|
27 | 27 |
You need to be logged in to leave comments.
Login now