Description:
Add indicators to ContractsWindow.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -63,6 +63,10 | |||||
|
63 |
|
63 | ||
|
64 | private Simulation Simulation; |
|
64 | private Simulation Simulation; |
|
65 |
|
65 | ||
|
|
66 | public DateTime DateTime { get { | ||
|
|
67 | return this.Simulation.DateTime; | ||
|
|
68 | }} | ||
|
|
69 | |||
|
66 | public ImGuiWindowBridgeEngine(DebugWindow debugWindow, |
|
70 | public ImGuiWindowBridgeEngine(DebugWindow debugWindow, |
|
67 | ImFontPtr font, ImFontPtr italicFont, |
|
71 | ImFontPtr font, ImFontPtr italicFont, |
|
68 | Simulation simulation) |
|
72 | Simulation simulation) |
@@ -41,7 +41,7 | |||||
|
41 | Logging.Spy(entity.ID, "ID"); |
|
41 | Logging.Spy(entity.ID, "ID"); |
|
42 | if (EntityExists(windowMessage.Entity) && entity.ID == windowMessage.Entity.ID) |
|
42 | if (EntityExists(windowMessage.Entity) && entity.ID == windowMessage.Entity.ID) |
|
43 | { |
|
43 | { |
|
44 |
|
|
44 | SetComponent(entity, new VisibilityComponent { visible = windowMessage.Visibility }); |
|
45 | Logging.Success("Set Visibility."); |
|
45 | Logging.Success("Set Visibility."); |
|
46 |
|
46 | ||
|
47 | } |
|
47 | } |
@@ -57,7 +57,7 | |||||
|
57 | if (EntityExists(windowMessage.Entity) && entity.ID == windowMessage.Entity.ID) |
|
57 | if (EntityExists(windowMessage.Entity) && entity.ID == windowMessage.Entity.ID) |
|
58 | { |
|
58 | { |
|
59 | var visibilityComponent = GetComponent<VisibilityComponent>(entity); |
|
59 | var visibilityComponent = GetComponent<VisibilityComponent>(entity); |
|
60 |
|
|
60 | SetComponent(entity, new VisibilityComponent { visible = !visibilityComponent.visible }); |
|
61 |
|
61 | ||
|
62 | } |
|
62 | } |
|
63 | } |
|
63 | } |
@@ -18,6 +18,7 | |||||
|
18 |
|
18 | ||
|
19 | namespace isometricparkfna.Renderers |
|
19 | namespace isometricparkfna.Renderers |
|
20 | { |
|
20 | { |
|
|
21 | |||
|
21 | class ImGuiWindowRenderer : GeneralRenderer |
|
22 | class ImGuiWindowRenderer : GeneralRenderer |
|
22 | { |
|
23 | { |
|
23 | private ImFontPtr italicFont; |
|
24 | private ImFontPtr italicFont; |
@@ -35,7 +36,7 | |||||
|
35 | this.gdm = gdm; |
|
36 | this.gdm = gdm; |
|
36 | } |
|
37 | } |
|
37 |
|
38 | ||
|
38 | private (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square) |
|
39 | private ContractDetails |
|
39 | getContractDetails(Entity entity) |
|
40 | getContractDetails(Entity entity) |
|
40 | { |
|
41 | { |
|
41 |
|
42 | ||
@@ -43,11 +44,15 | |||||
|
43 | var status = GetComponent<ContractStatusComponent>(entity).status; |
|
44 | var status = GetComponent<ContractStatusComponent>(entity).status; |
|
44 | var amount = GetComponent<BudgetLineComponent>(entity).amount; |
|
45 | var amount = GetComponent<BudgetLineComponent>(entity).amount; |
|
45 | var tree_delta = GetComponent<TreeDeltaComponent>(entity).deltaTreesName; |
|
46 | var tree_delta = GetComponent<TreeDeltaComponent>(entity).deltaTreesName; |
|
|
47 | var date_time = GetComponent<ContractStatusComponent>(entity).date; | ||
|
46 | var image_index = GetComponent<ImageComponent>(entity).ImageIndex; |
|
48 | var image_index = GetComponent<ImageComponent>(entity).ImageIndex; |
|
47 | var description = ""; |
|
49 | var description = ""; |
|
48 |
|
50 | ||
|
49 | var square = GetComponent<AreaComponent>(entity).squares[0]; |
|
51 | var square = GetComponent<AreaComponent>(entity).squares[0]; |
|
50 |
|
52 | ||
|
|
53 | var age = (this.BridgeEngine.DateTime - date_time).TotalDays; | ||
|
|
54 | var area_size = GetComponent<AreaComponent>(entity).squares.Length; | ||
|
|
55 | |||
|
51 |
|
56 | ||
|
52 | if (HasComponent<RelatedOrganizationComponent>(entity)) |
|
57 | if (HasComponent<RelatedOrganizationComponent>(entity)) |
|
53 | { |
|
58 | { |
@@ -57,13 +62,25 | |||||
|
57 | name = name_component.DisplayName; |
|
62 | name = name_component.DisplayName; |
|
58 | description = name_component.Description; |
|
63 | description = name_component.Description; |
|
59 | image_index = GetComponent<ImageComponent>(related_organization).ImageIndex; |
|
64 | image_index = GetComponent<ImageComponent>(related_organization).ImageIndex; |
|
|
65 | |||
|
60 | } |
|
66 | } |
|
61 |
|
67 | ||
|
62 | return (entity, name, description, status, amount, tree_delta, image_index, square); |
|
68 | return new ContractDetails { |
|
|
69 | entity = entity, | ||
|
|
70 | name = name, | ||
|
|
71 | description = description, | ||
|
|
72 | status = status, | ||
|
|
73 | amount = amount, | ||
|
|
74 | delta_trees = tree_delta, | ||
|
|
75 | image_index = image_index, | ||
|
|
76 | age = age, | ||
|
|
77 | area_size = area_size, | ||
|
|
78 | square = square | ||
|
|
79 | }; | ||
|
63 |
|
80 | ||
|
64 | } |
|
81 | } |
|
65 |
|
82 | ||
|
66 |
|
|
83 | public override void Render() |
|
67 | { |
|
84 | { |
|
68 |
|
85 | ||
|
69 | var width = gdm.PreferredBackBufferWidth; |
|
86 | var width = gdm.PreferredBackBufferWidth; |
@@ -85,7 +102,7 | |||||
|
85 | case Window.Contracts: |
|
102 | case Window.Contracts: |
|
86 | var contracts = ReadEntities<AreaComponent>(); |
|
103 | var contracts = ReadEntities<AreaComponent>(); |
|
87 |
|
104 | ||
|
88 |
var contract_data = new List< |
|
105 | var contract_data = new List<ContractDetails>(); |
|
89 |
|
106 | ||
|
90 | foreach (var e in contracts) |
|
107 | foreach (var e in contracts) |
|
91 | { |
|
108 | { |
@@ -98,11 +115,9 | |||||
|
98 |
|
115 | ||
|
99 | var data = getContractDetails(entity); |
|
116 | var data = getContractDetails(entity); |
|
100 |
|
117 | ||
|
101 |
|
|
118 | var area = GetComponent<AreaComponent>(data.entity).squares; |
|
102 | var area = GetComponent<AreaComponent>(entity).squares; |
|
||
|
103 | var area_size = GetComponent<AreaComponent>(entity).squares.Length; |
|
||
|
104 |
|
119 | ||
|
105 |
ContractWindow.Render(this.BridgeEngine.font, this.italicFont, this.BridgeEngine, |
|
120 | ContractWindow.Render(this.BridgeEngine.font, this.italicFont, this.BridgeEngine, data); |
|
106 |
|
121 | ||
|
107 | break; |
|
122 | break; |
|
108 | case Window.MainMenu: |
|
123 | case Window.MainMenu: |
@@ -16,6 +16,18 | |||||
|
16 |
|
16 | ||
|
17 | namespace isometricparkfna.UI |
|
17 | namespace isometricparkfna.UI |
|
18 | { |
|
18 | { |
|
|
19 | public struct ContractDetails { | ||
|
|
20 | public Entity entity; | ||
|
|
21 | public string name; | ||
|
|
22 | public string description; | ||
|
|
23 | public ContractStatus status; | ||
|
|
24 | public decimal amount; | ||
|
|
25 | public string delta_trees; | ||
|
|
26 | public double age; //in days | ||
|
|
27 | public int image_index; | ||
|
|
28 | public int area_size; | ||
|
|
29 | public Vector2 square; | ||
|
|
30 | } | ||
|
19 | public static class ContractWindow |
|
31 | public static class ContractWindow |
|
20 | { |
|
32 | { |
|
21 |
|
33 | ||
@@ -32,7 +44,7 | |||||
|
32 | ContractWindow._imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture); |
|
44 | ContractWindow._imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture); |
|
33 | } |
|
45 | } |
|
34 |
|
46 | ||
|
35 |
public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, |
|
47 | public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, ContractDetails details /*Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int area_size, int imageIndex, Vector2 square*/) |
|
36 |
|
48 | ||
|
37 | { |
|
49 | { |
|
38 | bool newShow = true; |
|
50 | bool newShow = true; |
@@ -45,7 +57,7 | |||||
|
45 | StyleSets.defaultSet.push(); |
|
57 | StyleSets.defaultSet.push(); |
|
46 | ImGui.SetNextWindowSize(new Num.Vector2(320, 420)); |
|
58 | ImGui.SetNextWindowSize(new Num.Vector2(320, 420)); |
|
47 |
|
59 | ||
|
48 | var title = string.Format("Contract {0} ## {1}", name, entity.ID); |
|
60 | var title = string.Format("Contract {0} ## {1}", details.name, details.entity.ID); |
|
49 |
|
61 | ||
|
50 | if (ContractWindow.hadFocus.ContainsKey(title) && |
|
62 | if (ContractWindow.hadFocus.ContainsKey(title) && |
|
51 | ContractWindow.hadFocus[title]) |
|
63 | ContractWindow.hadFocus[title]) |
@@ -53,7 +65,7 | |||||
|
53 | ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white); |
|
65 | ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white); |
|
54 | } |
|
66 | } |
|
55 |
|
67 | ||
|
56 | ImGui.Begin(name, ref newShow, |
|
68 | ImGui.Begin(details.name, ref newShow, |
|
57 | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings); |
|
69 | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings); |
|
58 |
|
70 | ||
|
59 | if (ContractWindow.hadFocus.ContainsKey(title) && |
|
71 | if (ContractWindow.hadFocus.ContainsKey(title) && |
@@ -70,21 +82,21 | |||||
|
70 | ContractWindow.hadFocus.Add(title, ImGui.IsWindowFocused()); |
|
82 | ContractWindow.hadFocus.Add(title, ImGui.IsWindowFocused()); |
|
71 | } |
|
83 | } |
|
72 |
|
84 | ||
|
73 |
ImGui.Image(_imGuiTexture, new Num.Vector2(250, 200), map.GetSourceUVStart( |
|
85 | ImGui.Image(_imGuiTexture, new Num.Vector2(250, 200), map.GetSourceUVStart(details.image_index), map.GetSourceUVEnd(details.image_index), Num.Vector4.One, Num.Vector4.Zero); // Here, the previously loaded texture is used |
|
74 |
|
86 | ||
|
75 | ImGui.PushFont(italicFont); |
|
87 | ImGui.PushFont(italicFont); |
|
76 | ImGui.TextWrapped(description); |
|
88 | ImGui.TextWrapped(details.description); |
|
77 | ImGui.PopFont(); |
|
89 | ImGui.PopFont(); |
|
78 |
|
90 | ||
|
79 | ImGui.Separator(); |
|
91 | ImGui.Separator(); |
|
80 | switch (status) |
|
92 | switch (details.status) |
|
81 | { |
|
93 | { |
|
82 | case ContractStatus.Proposed: |
|
94 | case ContractStatus.Proposed: |
|
83 | ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.95f, 1f), status.ToString()); |
|
95 | ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.95f, 1f), details.status.ToString()); |
|
84 | break; |
|
96 | break; |
|
85 | case ContractStatus.Active: |
|
97 | case ContractStatus.Active: |
|
86 | case ContractStatus.Accepted: |
|
98 | case ContractStatus.Accepted: |
|
87 | ImGui.TextColored(new Num.Vector4(0.25f, 0.95f, 0.25f, 1f), status.ToString()); |
|
99 | ImGui.TextColored(new Num.Vector4(0.25f, 0.95f, 0.25f, 1f), details.status.ToString()); |
|
88 | break; |
|
100 | break; |
|
89 | case ContractStatus.Rejected: |
|
101 | case ContractStatus.Rejected: |
|
90 | case ContractStatus.Broken: |
|
102 | case ContractStatus.Broken: |
@@ -94,18 +106,18 | |||||
|
94 |
|
106 | ||
|
95 | // ImGui.TextColored(new Num.Vector4(0.95f, 0.25f, 0.25f, 1f), contract.status.ToString()); |
|
107 | // ImGui.TextColored(new Num.Vector4(0.95f, 0.25f, 0.25f, 1f), contract.status.ToString()); |
|
96 | // } |
|
108 | // } |
|
97 | ImGui.TextColored(new Num.Vector4(0.95f, 0.25f, 0.25f, 1f), status.ToString()); |
|
109 | ImGui.TextColored(new Num.Vector4(0.95f, 0.25f, 0.25f, 1f), details.status.ToString()); |
|
98 | break; |
|
110 | break; |
|
99 | case ContractStatus.Completed: |
|
111 | case ContractStatus.Completed: |
|
100 | ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.25f, 1f), status.ToString()); |
|
112 | ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.25f, 1f), details.status.ToString()); |
|
101 | break; |
|
113 | break; |
|
102 | default: |
|
114 | default: |
|
103 | break; |
|
115 | break; |
|
104 | } |
|
116 | } |
|
105 | ImGui.Text(string.Format("Amount: ${0}/mo.", amount)); |
|
117 | ImGui.Text(string.Format("Amount: ${0}/mo.", details.amount)); |
|
106 | ImGui.Text(string.Format("Size: {0} acres", area_size)); |
|
118 | ImGui.Text(string.Format("Size: {0} acres", details.area_size)); |
|
107 |
|
119 | ||
|
108 | if (delta_trees != null) |
|
120 | if (details.delta_trees != null) |
|
109 | { |
|
121 | { |
|
110 | ImGui.Text("Sustainability: "); |
|
122 | ImGui.Text("Sustainability: "); |
|
111 | ImGui.SameLine(); |
|
123 | ImGui.SameLine(); |
@@ -122,7 +134,7 | |||||
|
122 |
|
134 | ||
|
123 | ImGui.SameLine(); |
|
135 | ImGui.SameLine(); |
|
124 | var color = new Num.Vector4(1f, 1f, 1f, 1f); |
|
136 | var color = new Num.Vector4(1f, 1f, 1f, 1f); |
|
125 | switch (delta_trees) |
|
137 | switch (details.delta_trees) |
|
126 | { |
|
138 | { |
|
127 | case "Unsustainable": |
|
139 | case "Unsustainable": |
|
128 | color = new Num.Vector4(0.95f, 0.25f, 0.25f, 1f); |
|
140 | color = new Num.Vector4(0.95f, 0.25f, 0.25f, 1f); |
@@ -135,10 +147,10 | |||||
|
135 | color = new Num.Vector4(0.95f, 0.65f, 0.25f, 1f); |
|
147 | color = new Num.Vector4(0.95f, 0.65f, 0.25f, 1f); |
|
136 | break; |
|
148 | break; |
|
137 | } |
|
149 | } |
|
138 | ImGui.TextColored(color, delta_trees); |
|
150 | ImGui.TextColored(color, details.delta_trees); |
|
139 | } |
|
151 | } |
|
140 |
|
152 | ||
|
141 | ContractStatusButtons(engine, entity, status); |
|
153 | ContractStatusButtons(engine, details.entity, details.status); |
|
142 |
|
154 | ||
|
143 | ImGui.Separator(); |
|
155 | ImGui.Separator(); |
|
144 |
|
156 | ||
@@ -149,8 +161,8 | |||||
|
149 | ImGui.SameLine(); |
|
161 | ImGui.SameLine(); |
|
150 | if (ImGui.Button("Jump To")) |
|
162 | if (ImGui.Button("Jump To")) |
|
151 | { |
|
163 | { |
|
152 | int adjustedx = (int)square.X; |
|
164 | int adjustedx = (int)details.square.X; |
|
153 | int adjustedy = (int)square.Y; |
|
165 | int adjustedy = (int)details.square.Y; |
|
154 |
|
166 | ||
|
155 | int screenx = (adjustedx - adjustedy) * Tile.TileSpriteWidth / 2; |
|
167 | int screenx = (adjustedx - adjustedy) * Tile.TileSpriteWidth / 2; |
|
156 | int screeny = (adjustedx + adjustedy) * Tile.TileSpriteHeight / 2; |
|
168 | int screeny = (adjustedx + adjustedy) * Tile.TileSpriteHeight / 2; |
@@ -169,10 +181,10 | |||||
|
169 |
|
181 | ||
|
170 | if (!newShow) |
|
182 | if (!newShow) |
|
171 | { |
|
183 | { |
|
172 | engine.messages.Add(new ToggleWindowMessage {Window = Window.Contract, Entity = entity }); |
|
184 | engine.messages.Add(new ToggleWindowMessage {Window = Window.Contract, Entity = details.entity }); |
|
173 | } |
|
185 | } |
|
174 |
|
186 | ||
|
175 | engine.selectedMessages.Add(new SelectMessage { Entity = entity }); |
|
187 | engine.selectedMessages.Add(new SelectMessage { Entity = details.entity }); |
|
176 |
|
188 | ||
|
177 | } |
|
189 | } |
|
178 |
|
190 |
@@ -20,11 +20,12 | |||||
|
20 | public static bool show_all; |
|
20 | public static bool show_all; |
|
21 | public static bool had_focus = false; |
|
21 | public static bool had_focus = false; |
|
22 |
|
22 | ||
|
23 | private static (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square) selected; |
|
23 | // private static (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int age, int image_index, Vector2 square) selected; |
|
|
24 | private static ContractDetails selected; | ||
|
24 |
|
25 | ||
|
25 |
|
26 | ||
|
26 | public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, |
|
27 | public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, |
|
27 | List<(Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square)> contracts) |
|
28 | List<ContractDetails> contracts) |
|
28 | { |
|
29 | { |
|
29 | bool newShow = true; |
|
30 | bool newShow = true; |
|
30 |
|
31 | ||
@@ -99,6 +100,21 | |||||
|
99 | default: |
|
100 | default: |
|
100 | break; |
|
101 | break; |
|
101 | } |
|
102 | } |
|
|
103 | |||
|
|
104 | if ((contract.status == ContractStatus.Proposed) | ||
|
|
105 | && (contract.age > (30 * 5))) | ||
|
|
106 | { | ||
|
|
107 | ImGui.SameLine(); | ||
|
|
108 | ImGui.TextColored(StyleSets.red, "(!)"); | ||
|
|
109 | |||
|
|
110 | if (ImGui.IsItemHovered()) | ||
|
|
111 | { | ||
|
|
112 | ImGui.BeginTooltip(); | ||
|
|
113 | ImGui.Text("Offer is about to expire."); | ||
|
|
114 | ImGui.EndTooltip(); | ||
|
|
115 | } | ||
|
|
116 | } | ||
|
|
117 | |||
|
102 | } |
|
118 | } |
|
103 | ImGui.ListBoxFooter(); |
|
119 | ImGui.ListBoxFooter(); |
|
104 |
|
120 | ||
@@ -128,9 +144,8 | |||||
|
128 | break; |
|
144 | break; |
|
129 | } |
|
145 | } |
|
130 | ImGui.TextColored(color, ContractsWindow.selected.delta_trees); |
|
146 | ImGui.TextColored(color, ContractsWindow.selected.delta_trees); |
|
131 | } |
|
||
|
132 |
|
147 | ||
|
133 |
|
148 | } | |
|
134 | if (ImGui.Button("Open")) |
|
149 | if (ImGui.Button("Open")) |
|
135 | { |
|
150 | { |
|
136 | System.Console.Write(string.Format("{0} opened", ContractsWindow.selected.entity)); |
|
151 | System.Console.Write(string.Format("{0} opened", ContractsWindow.selected.entity)); |
@@ -159,9 +174,7 | |||||
|
159 | Logging.Trace("Contracts toggled."); |
|
174 | Logging.Trace("Contracts toggled."); |
|
160 | engine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.Contracts }); |
|
175 | engine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.Contracts }); |
|
161 | } |
|
176 | } |
|
162 |
|
|||
|
163 | engine.selectedMessages.Add(new SelectMessage { Entity = selected.entity }); |
|
177 | engine.selectedMessages.Add(new SelectMessage { Entity = selected.entity }); |
|
164 |
|
|||
|
165 | } |
|
178 | } |
|
166 | } |
|
179 | } |
|
167 | } |
|
180 | } |
@@ -72,7 +72,7 | |||||
|
72 | { |
|
72 | { |
|
73 | if (bridgeEngine.showContractIndicator) |
|
73 | if (bridgeEngine.showContractIndicator) |
|
74 | { |
|
74 | { |
|
75 | return Menu.activeButtonIndicator("\ue0c2 Contracts", bridgeEngine.windowStatuses[Window.Contracts], StyleSets.selected, StyleSets.white, "(!)", StyleSets.red, "Contracts about to expire:\n" + string.Join("\n", bridgeEngine.contracts)); |
|
75 | return Menu.activeButtonIndicator("\ue0c2 Contracts", bridgeEngine.windowStatuses[Window.Contracts], StyleSets.selected, StyleSets.white, "(!)", StyleSets.red, "Contract offre is about to expire:\n" + string.Join("\n", bridgeEngine.contracts)); |
|
76 | } |
|
76 | } |
|
77 | else |
|
77 | else |
|
78 | { |
|
78 | { |
You need to be logged in to leave comments.
Login now