Description:
Refactor contract button code.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -71,37 +71,37 | |||||
|
71 |
|
71 | ||
|
72 | ImGui.PushStyleColor(ImGuiCol.Button, grey); |
|
72 | ImGui.PushStyleColor(ImGuiCol.Button, grey); |
|
73 | ImGui.PushStyleColor(ImGuiCol.Text, black); |
|
73 | ImGui.PushStyleColor(ImGuiCol.Text, black); |
|
74 |
ImGui.SetNextWindowSize(new Num.Vector2(320, 3 |
|
74 | ImGui.SetNextWindowSize(new Num.Vector2(320, 360)); |
|
75 |
ImGui.Begin(string.Format("Contract {0}" |
|
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(imageIndex), map.GetSourceUVEnd(imageIndex), 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) |
|
81 |
|
|
81 | { |
|
82 |
|
|
82 | case ContractStatus.Proposed: |
|
83 |
|
|
83 | ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.95f, 1f), status.ToString()); |
|
84 |
|
|
84 | break; |
|
85 |
|
|
85 | case ContractStatus.Active: |
|
86 |
|
|
86 | case ContractStatus.Accepted: |
|
87 |
|
|
87 | ImGui.TextColored(new Num.Vector4(0.25f, 0.95f, 0.25f, 1f), status.ToString()); |
|
88 |
|
|
88 | break; |
|
89 |
|
|
89 | case ContractStatus.Rejected: |
|
90 |
|
|
90 | case ContractStatus.Broken: |
|
91 |
|
|
91 | case ContractStatus.Expired: |
|
92 |
|
|
92 | // if (ContractsWindow.show_all) |
|
93 |
|
|
93 | // { |
|
94 |
|
94 | ||
|
95 |
|
|
95 | // ImGui.TextColored(new Num.Vector4(0.95f, 0.25f, 0.25f, 1f), contract.status.ToString()); |
|
96 |
|
|
96 | // } |
|
97 |
|
|
97 | ImGui.TextColored(new Num.Vector4(0.95f, 0.25f, 0.25f, 1f), status.ToString()); |
|
98 | break; |
|
||
|
99 | case ContractStatus.Completed: |
|
||
|
100 | ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.25f, 1f), status.ToString()); |
|
||
|
101 | break; |
|
||
|
102 | default: |
|
||
|
103 | break; |
|
98 | break; |
|
104 | } |
|
99 | case ContractStatus.Completed: |
|
|
100 | ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.25f, 1f), status.ToString()); | ||
|
|
101 | break; | ||
|
|
102 | default: | ||
|
|
103 | break; | ||
|
|
104 | } | ||
|
105 | ImGui.Text(string.Format("Amount: ${0}/mo.", amount)); |
|
105 | ImGui.Text(string.Format("Amount: ${0}/mo.", amount)); |
|
106 |
|
106 | ||
|
107 | if (delta_trees != null) |
|
107 | if (delta_trees != null) |
@@ -127,37 +127,7 | |||||
|
127 | ImGui.TextColored(color, delta_trees); |
|
127 | ImGui.TextColored(color, delta_trees); |
|
128 | } |
|
128 | } |
|
129 |
|
129 | ||
|
130 |
|
130 | ContractStatusButtons(engine, entity, status); | |
|
131 |
|
|||
|
132 | if (status == ContractStatus.Proposed) |
|
||
|
133 | { |
|
||
|
134 | if (ImGui.Button("Accept")) |
|
||
|
135 | { |
|
||
|
136 | System.Console.Write(string.Format("{0} selected", entity)); |
|
||
|
137 |
|
|||
|
138 | engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = entity, newStatus = ContractStatus.Accepted }); |
|
||
|
139 |
|
|||
|
140 | } |
|
||
|
141 | ImGui.SameLine(); |
|
||
|
142 | if (ImGui.Button("Reject")) |
|
||
|
143 | { |
|
||
|
144 | System.Console.Write(string.Format("{0} rejected", entity)); |
|
||
|
145 |
|
|||
|
146 | engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = entity, newStatus = ContractStatus.Rejected }); |
|
||
|
147 |
|
|||
|
148 | } |
|
||
|
149 |
|
|||
|
150 | } |
|
||
|
151 | else if (status == ContractStatus.Accepted) |
|
||
|
152 | { |
|
||
|
153 | if (ImGui.Button("Cancel")) |
|
||
|
154 | { |
|
||
|
155 | System.Console.Write(string.Format("{0} canceled", entity)); |
|
||
|
156 |
|
|||
|
157 | engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = entity, newStatus = ContractStatus.Broken }); |
|
||
|
158 | } |
|
||
|
159 |
|
|||
|
160 | } |
|
||
|
161 |
|
131 | ||
|
162 | if (ImGui.Button("Okay")) |
|
132 | if (ImGui.Button("Okay")) |
|
163 | { |
|
133 | { |
@@ -182,5 +152,38 | |||||
|
182 | engine.selectedMessages.Add(new SelectMessage { Entity = entity }); |
|
152 | engine.selectedMessages.Add(new SelectMessage { Entity = entity }); |
|
183 |
|
153 | ||
|
184 | } |
|
154 | } |
|
|
155 | |||
|
|
156 | public static void ContractStatusButtons(ImGuiWindowBridgeEngine engine, Entity entity, ContractStatus status) | ||
|
|
157 | { | ||
|
|
158 | if (status == ContractStatus.Proposed) | ||
|
|
159 | { | ||
|
|
160 | if (ImGui.Button("Accept")) | ||
|
|
161 | { | ||
|
|
162 | System.Console.Write(string.Format("{0} selected", entity)); | ||
|
|
163 | |||
|
|
164 | engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = entity, newStatus = ContractStatus.Accepted }); | ||
|
|
165 | |||
|
|
166 | } | ||
|
|
167 | ImGui.SameLine(); | ||
|
|
168 | if (ImGui.Button("Reject")) | ||
|
|
169 | { | ||
|
|
170 | System.Console.Write(string.Format("{0} rejected", entity)); | ||
|
|
171 | |||
|
|
172 | engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = entity, newStatus = ContractStatus.Rejected }); | ||
|
|
173 | |||
|
|
174 | } | ||
|
|
175 | |||
|
|
176 | } | ||
|
|
177 | else if (status == ContractStatus.Accepted) | ||
|
|
178 | { | ||
|
|
179 | if (ImGui.Button("Cancel")) | ||
|
|
180 | { | ||
|
|
181 | System.Console.Write(string.Format("{0} canceled", entity)); | ||
|
|
182 | |||
|
|
183 | engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = entity, newStatus = ContractStatus.Broken }); | ||
|
|
184 | } | ||
|
|
185 | |||
|
|
186 | } | ||
|
|
187 | } | ||
|
185 | } |
|
188 | } |
|
186 | } |
|
189 | } |
@@ -144,35 +144,7 | |||||
|
144 |
|
144 | ||
|
145 | } |
|
145 | } |
|
146 |
|
146 | ||
|
147 | if (selected.status == ContractStatus.Proposed) |
|
147 | ContractWindow.ContractStatusButtons(engine, selected.entity, selected.status); |
|
148 | { |
|
||
|
149 | if (ImGui.Button("Accept")) |
|
||
|
150 | { |
|
||
|
151 | System.Console.Write(string.Format("{0} selected", ContractsWindow.selected.entity)); |
|
||
|
152 |
|
|||
|
153 | engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = ContractsWindow.selected.entity, newStatus = ContractStatus.Accepted }); |
|
||
|
154 |
|
|||
|
155 | } |
|
||
|
156 | ImGui.SameLine(); |
|
||
|
157 | if (ImGui.Button("Reject")) |
|
||
|
158 | { |
|
||
|
159 | System.Console.Write(string.Format("{0} rejected", ContractsWindow.selected.entity)); |
|
||
|
160 |
|
|||
|
161 | engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = ContractsWindow.selected.entity, newStatus = ContractStatus.Rejected }); |
|
||
|
162 |
|
|||
|
163 | } |
|
||
|
164 |
|
|||
|
165 | } |
|
||
|
166 | else if (selected.status == ContractStatus.Accepted) |
|
||
|
167 | { |
|
||
|
168 | if (ImGui.Button("Cancel")) |
|
||
|
169 | { |
|
||
|
170 | System.Console.Write(string.Format("{0} canceled", ContractsWindow.selected.entity)); |
|
||
|
171 |
|
|||
|
172 | engine.contractStatusMessages.Add(new ChangeContractStatusMessage { Entity = ContractsWindow.selected.entity, newStatus = ContractStatus.Broken }); |
|
||
|
173 | } |
|
||
|
174 |
|
|||
|
175 | } |
|
||
|
176 |
|
148 | ||
|
177 | ImGui.Separator(); |
|
149 | ImGui.Separator(); |
|
178 | if (ImGui.Button("Okay")) |
|
150 | if (ImGui.Button("Okay")) |
You need to be logged in to leave comments.
Login now