Description:
Add indicators to ContractsWindow.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r390:fa7d5e7e6a22 -

@@ -63,6 +63,10
63 63
64 64 private Simulation Simulation;
65 65
66 public DateTime DateTime { get {
67 return this.Simulation.DateTime;
68 }}
69
66 70 public ImGuiWindowBridgeEngine(DebugWindow debugWindow,
67 71 ImFontPtr font, ImFontPtr italicFont,
68 72 Simulation simulation)
@@ -41,7 +41,7
41 41 Logging.Spy(entity.ID, "ID");
42 42 if (EntityExists(windowMessage.Entity) && entity.ID == windowMessage.Entity.ID)
43 43 {
44 AddComponent(entity, new VisibilityComponent { visible = windowMessage.Visibility });
44 SetComponent(entity, new VisibilityComponent { visible = windowMessage.Visibility });
45 45 Logging.Success("Set Visibility.");
46 46
47 47 }
@@ -57,7 +57,7
57 57 if (EntityExists(windowMessage.Entity) && entity.ID == windowMessage.Entity.ID)
58 58 {
59 59 var visibilityComponent = GetComponent<VisibilityComponent>(entity);
60 AddComponent(entity, new VisibilityComponent { visible = !visibilityComponent.visible });
60 SetComponent(entity, new VisibilityComponent { visible = !visibilityComponent.visible });
61 61
62 62 }
63 63 }
@@ -18,6 +18,7
18 18
19 19 namespace isometricparkfna.Renderers
20 20 {
21
21 22 class ImGuiWindowRenderer : GeneralRenderer
22 23 {
23 24 private ImFontPtr italicFont;
@@ -35,7 +36,7
35 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 40 getContractDetails(Entity entity)
40 41 {
41 42
@@ -43,11 +44,15
43 44 var status = GetComponent<ContractStatusComponent>(entity).status;
44 45 var amount = GetComponent<BudgetLineComponent>(entity).amount;
45 46 var tree_delta = GetComponent<TreeDeltaComponent>(entity).deltaTreesName;
47 var date_time = GetComponent<ContractStatusComponent>(entity).date;
46 48 var image_index = GetComponent<ImageComponent>(entity).ImageIndex;
47 49 var description = "";
48 50
49 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 57 if (HasComponent<RelatedOrganizationComponent>(entity))
53 58 {
@@ -57,13 +62,25
57 62 name = name_component.DisplayName;
58 63 description = name_component.Description;
59 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 public override void Render()
83 public override void Render()
67 84 {
68 85
69 86 var width = gdm.PreferredBackBufferWidth;
@@ -85,7 +102,7
85 102 case Window.Contracts:
86 103 var contracts = ReadEntities<AreaComponent>();
87 104
88 var contract_data = new List<(Entity, string, string, ContractStatus, decimal, string, int, Vector2)>();
105 var contract_data = new List<ContractDetails>();
89 106
90 107 foreach (var e in contracts)
91 108 {
@@ -98,11 +115,9
98 115
99 116 var data = getContractDetails(entity);
100 117
101 // var area_size = GetComponent<AreaComponent>(entity).squares.Length;
102 var area = GetComponent<AreaComponent>(entity).squares;
103 var area_size = GetComponent<AreaComponent>(entity).squares.Length;
118 var area = GetComponent<AreaComponent>(data.entity).squares;
104 119
105 ContractWindow.Render(this.BridgeEngine.font, this.italicFont, this.BridgeEngine, entity, data.name, data.description, data.status, data.amount, data.delta_trees, area_size, data.image_index, data.square);
120 ContractWindow.Render(this.BridgeEngine.font, this.italicFont, this.BridgeEngine, data);
106 121
107 122 break;
108 123 case Window.MainMenu:
@@ -16,6 +16,18
16 16
17 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 31 public static class ContractWindow
20 32 {
21 33
@@ -32,7 +44,7
32 44 ContractWindow._imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture);
33 45 }
34 46
35 public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int area_size, int imageIndex, Vector2 square)
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 50 bool newShow = true;
@@ -45,7 +57,7
45 57 StyleSets.defaultSet.push();
46 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 62 if (ContractWindow.hadFocus.ContainsKey(title) &&
51 63 ContractWindow.hadFocus[title])
@@ -53,7 +65,7
53 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 69 ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
58 70
59 71 if (ContractWindow.hadFocus.ContainsKey(title) &&
@@ -70,21 +82,21
70 82 ContractWindow.hadFocus.Add(title, ImGui.IsWindowFocused());
71 83 }
72 84
73 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
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 87 ImGui.PushFont(italicFont);
76 ImGui.TextWrapped(description);
88 ImGui.TextWrapped(details.description);
77 89 ImGui.PopFont();
78 90
79 91 ImGui.Separator();
80 switch (status)
92 switch (details.status)
81 93 {
82 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 96 break;
85 97 case ContractStatus.Active:
86 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 100 break;
89 101 case ContractStatus.Rejected:
90 102 case ContractStatus.Broken:
@@ -94,18 +106,18
94 106
95 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 110 break;
99 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 113 break;
102 114 default:
103 115 break;
104 116 }
105 ImGui.Text(string.Format("Amount: ${0}/mo.", amount));
106 ImGui.Text(string.Format("Size: {0} acres", area_size));
117 ImGui.Text(string.Format("Amount: ${0}/mo.", details.amount));
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 122 ImGui.Text("Sustainability: ");
111 123 ImGui.SameLine();
@@ -122,7 +134,7
122 134
123 135 ImGui.SameLine();
124 136 var color = new Num.Vector4(1f, 1f, 1f, 1f);
125 switch (delta_trees)
137 switch (details.delta_trees)
126 138 {
127 139 case "Unsustainable":
128 140 color = new Num.Vector4(0.95f, 0.25f, 0.25f, 1f);
@@ -135,10 +147,10
135 147 color = new Num.Vector4(0.95f, 0.65f, 0.25f, 1f);
136 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 155 ImGui.Separator();
144 156
@@ -149,8 +161,8
149 161 ImGui.SameLine();
150 162 if (ImGui.Button("Jump To"))
151 163 {
152 int adjustedx = (int)square.X;
153 int adjustedy = (int)square.Y;
164 int adjustedx = (int)details.square.X;
165 int adjustedy = (int)details.square.Y;
154 166
155 167 int screenx = (adjustedx - adjustedy) * Tile.TileSpriteWidth / 2;
156 168 int screeny = (adjustedx + adjustedy) * Tile.TileSpriteHeight / 2;
@@ -169,10 +181,10
169 181
170 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 20 public static bool show_all;
21 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 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 30 bool newShow = true;
30 31
@@ -99,6 +100,21
99 100 default:
100 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 119 ImGui.ListBoxFooter();
104 120
@@ -128,9 +144,8
128 144 break;
129 145 }
130 146 ImGui.TextColored(color, ContractsWindow.selected.delta_trees);
131 }
132 147
133
148 }
134 149 if (ImGui.Button("Open"))
135 150 {
136 151 System.Console.Write(string.Format("{0} opened", ContractsWindow.selected.entity));
@@ -159,9 +174,7
159 174 Logging.Trace("Contracts toggled.");
160 175 engine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.Contracts });
161 176 }
162
163 177 engine.selectedMessages.Add(new SelectMessage { Entity = selected.entity });
164
165 178 }
166 179 }
167 180 }
@@ -72,7 +72,7
72 72 {
73 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 77 else
78 78 {
You need to be logged in to leave comments. Login now