Description:
Show imprecise sustainability.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r226:274c635e934a -

1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,8 +1,36
1 using Encompass;
1 using Encompass;
2
2
3 namespace isometricparkfna.Components {
3 namespace isometricparkfna.Components {
4
4 public struct TreeDeltaComponent : IComponent
5 public struct TreeDeltaComponent : IComponent
5 {
6 {
6 public int deltaTrees;
7 public int deltaTrees;
8
9 public string deltaTreesName {
10 get {
11 if (deltaTrees <= -18) {
12 return "Unsustainable";
13 }
14 else if (MathUtils.BetweenExclusive(deltaTrees, -18, -6))
15 {
16 return "Moderately unsustainable";
17 }
18 else if (MathUtils.Between(deltaTrees, -6, 0))
19 {
20 return "Somewhat unsustainable";
21 }
22 else if (deltaTrees == 0)
23 {
24 return "Break even";
25 }
26 else if (deltaTrees > 0)
27 {
28 return "Restoration";
29 }
30
31 return "???";
32
33 }
34 }
7 }
35 }
8 }
36 }
@@ -106,7 +106,7
106
106
107 int contract_amount = random_generator.Next(CONTRACT_MINIMUM, CONTRACT_MAXIMUM);
107 int contract_amount = random_generator.Next(CONTRACT_MINIMUM, CONTRACT_MAXIMUM);
108
108
109 var deltaTrees = random_generator.Next(-12, 0);
109 var deltaTrees = random_generator.Next(-20, 3);
110
110
111 // AddComponent
111 // AddComponent
112 AddComponent(contract, new AreaComponent { squares = squares });
112 AddComponent(contract, new AreaComponent { squares = squares });
@@ -39,7 +39,7
39 case Window.Contracts:
39 case Window.Contracts:
40 var contracts = ReadEntities<AreaComponent>();
40 var contracts = ReadEntities<AreaComponent>();
41
41
42 var contract_data = new List<(Entity, string, ContractStatus, decimal, int)>();
42 var contract_data = new List<(Entity, string, ContractStatus, decimal, string)>();
43
43
44 // var names = contracts.Select(entity => GetComponent<NameComponent>(entity).DisplayName)
44 // var names = contracts.Select(entity => GetComponent<NameComponent>(entity).DisplayName)
45 foreach(var e in contracts)
45 foreach(var e in contracts)
@@ -47,7 +47,7
47 var name = GetComponent<NameComponent>(e).DisplayName;
47 var name = GetComponent<NameComponent>(e).DisplayName;
48 var status = GetComponent<ContractStatusComponent>(e).status;
48 var status = GetComponent<ContractStatusComponent>(e).status;
49 var amount = GetComponent<BudgetLineComponent>(e).amount;
49 var amount = GetComponent<BudgetLineComponent>(e).amount;
50 var tree_delta = GetComponent<TreeDeltaComponent>(e).deltaTrees;
50 var tree_delta = GetComponent<TreeDeltaComponent>(e).deltaTreesName;
51 contract_data.Add((e, name, status, amount, tree_delta));
51 contract_data.Add((e, name, status, amount, tree_delta));
52
52
53 }
53 }
@@ -20,10 +20,10
20 public static decimal selected_amount;
20 public static decimal selected_amount;
21
21
22 public static bool show_all;
22 public static bool show_all;
23 private static int selected_tree_delta;
23 private static string selected_tree_delta;
24
24
25 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine,
25 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine,
26 List<(Entity entity, string name, ContractStatus status, decimal amount, int delta_trees)> contracts)
26 List<(Entity entity, string name, ContractStatus status, decimal amount, string delta_trees)> contracts)
27 {
27 {
28 bool newShow = true;
28 bool newShow = true;
29
29
@@ -109,7 +109,32
109
109
110 ImGui.Separator();
110 ImGui.Separator();
111 ImGui.Text(string.Format("Amount: ${0}/mo.", ContractsWindow.selected_amount));
111 ImGui.Text(string.Format("Amount: ${0}/mo.", ContractsWindow.selected_amount));
112 ImGui.Text(string.Format("Trees: {0}", ContractsWindow.selected_tree_delta));
112
113 if (ContractsWindow.selected_tree_delta != null)
114 {
115 ImGui.Text("Sustainability: ");
116
117
118 ImGui.SameLine();
119 var color = new Num.Vector4(1f, 1f, 1f, 1f);
120 switch (ContractsWindow.selected_tree_delta)
121 {
122 case "Unsustainable":
123 color = new Num.Vector4(0.95f, 0.25f, 0.25f, 1f);
124 break;
125 case "Restoration":
126 color = new Num.Vector4(0.25f, 0.95f, 0.25f, 1f);
127 break;
128 case "Moderately unsustainable":
129 case "Somewhat unsustainable":
130 color = new Num.Vector4(0.95f, 0.65f, 0.25f, 1f);
131 break;
132 }
133 ImGui.TextColored(color, ContractsWindow.selected_tree_delta);
134 }
135
136
137
113 if (selected_status == ContractStatus.Proposed)
138 if (selected_status == ContractStatus.Proposed)
114 {
139 {
115 if (ImGui.Button("Select"))
140 if (ImGui.Button("Select"))
You need to be logged in to leave comments. Login now