Description:
Actually warn about expiring contracts.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r389:1df5074f5e1b -

@@ -27,7 +27,9
27 [Reads(typeof(VisibilityComponent),
27 [Reads(typeof(VisibilityComponent),
28 typeof(WindowTypeComponent),
28 typeof(WindowTypeComponent),
29 typeof(TrespassingPolicyComponent),
29 typeof(TrespassingPolicyComponent),
30 typeof(ContractStatusComponent))]
30 typeof(ContractStatusComponent),
31 typeof(RelatedOrganizationComponent),
32 typeof(NameAndDescriptionComponent))]
31 public class ImGuiWindowBridgeEngine : Engine
33 public class ImGuiWindowBridgeEngine : Engine
32 {
34 {
33
35
@@ -53,13 +55,17
53 public Dictionary<Window, bool> windowStatuses {get;}
55 public Dictionary<Window, bool> windowStatuses {get;}
54
56
55 public bool showContractIndicator;
57 public bool showContractIndicator;
58 public List<string> contracts;
56
59
57 public ImFontPtr font;
60 public ImFontPtr font;
58 public ImFontPtr italicFont;
61 public ImFontPtr italicFont;
59 private DebugWindow debugWindow;
62 private DebugWindow debugWindow;
60
63
64 private Simulation Simulation;
65
61 public ImGuiWindowBridgeEngine(DebugWindow debugWindow,
66 public ImGuiWindowBridgeEngine(DebugWindow debugWindow,
62 ImFontPtr font, ImFontPtr italicFont)
67 ImFontPtr font, ImFontPtr italicFont,
68 Simulation simulation)
63 {
69 {
64 this.messages = new List<ToggleWindowMessage>();
70 this.messages = new List<ToggleWindowMessage>();
65 this.typeMessages = new List<ToggleWindowTypeMessage>();
71 this.typeMessages = new List<ToggleWindowTypeMessage>();
@@ -80,6 +86,10
80 this.font = font;
86 this.font = font;
81 this.italicFont = italicFont;
87 this.italicFont = italicFont;
82 this.debugWindow = debugWindow;
88 this.debugWindow = debugWindow;
89 this.Simulation = simulation;
90
91
92 this.contracts = new List<string>();
83
93
84
94
85 //Prepopulate:
95 //Prepopulate:
@@ -172,14 +182,25
172
182
173 //reset
183 //reset
174 this.showContractIndicator = false;
184 this.showContractIndicator = false;
185 this.contracts.Clear();
175 foreach(var entity in ReadEntities<ContractStatusComponent>())
186 foreach(var entity in ReadEntities<ContractStatusComponent>())
176 {
187 {
177 var contractStatus = GetComponent<ContractStatusComponent>(entity);
188 var contractStatus = GetComponent<ContractStatusComponent>(entity);
178 if(contractStatus.date > new DateTime(2021, 4, 1))
189 var age = this.Simulation.DateTime - contractStatus.date;
190 if((age.TotalDays > (5*30) )
191 && (contractStatus.status == ContractStatus.Proposed))
179 {
192 {
180 this.showContractIndicator = true;
193 try {
194 this.showContractIndicator = true;
195 var organizationEntity = GetComponent<RelatedOrganizationComponent>(entity).Entity;
196 var name = GetComponent<NameAndDescriptionComponent>(organizationEntity).DisplayName;
197 this.contracts.Add(name);
198 }
199 catch (Exception e)
200 {
201 Logging.Error(string.Format("Exception: {0}", e.ToString()));
202 }
181 }
203 }
182
183 }
204 }
184
205
185
206
@@ -248,7 +248,7
248 WorldBuilder.AddEngine(new GameStateEngine());
248 WorldBuilder.AddEngine(new GameStateEngine());
249 WorldBuilder.AddEngine(this.simulation.BridgeEngine);
249 WorldBuilder.AddEngine(this.simulation.BridgeEngine);
250 WorldBuilder.AddEngine(new CameraBridgeEngine(this.camera));
250 WorldBuilder.AddEngine(new CameraBridgeEngine(this.camera));
251 this.imGuiWindowBridgeEngine = new ImGuiWindowBridgeEngine(this.debugWindow, debugWindow.monoFont, debugWindow.italicFont);
251 this.imGuiWindowBridgeEngine = new ImGuiWindowBridgeEngine(this.debugWindow, debugWindow.monoFont, debugWindow.italicFont, this.simulation);
252 WorldBuilder.AddEngine(this.imGuiWindowBridgeEngine);
252 WorldBuilder.AddEngine(this.imGuiWindowBridgeEngine);
253 WorldBuilder.AddEngine(new ContractStatusEngine(this.simulation));
253 WorldBuilder.AddEngine(new ContractStatusEngine(this.simulation));
254
254
@@ -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, "Contract Offer X will expire");
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));
76 }
76 }
77 else
77 else
78 {
78 {
@@ -103,7 +103,7
103 if (contractsButton(bridgeEngine))
103 if (contractsButton(bridgeEngine))
104 {
104 {
105 Logging.Trace("Contracts toggled.");
105 Logging.Trace("Contracts toggled.");
106 Logging.Spy(bridgeEngine.windowStatuses, "statuses");
106 // Logging.Spy(bridgeEngine.windowStatuses, "statuses");
107 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Contracts});
107 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Contracts});
108 }
108 }
109 //Budget isn't connected to an entity yet:
109 //Budget isn't connected to an entity yet:
You need to be logged in to leave comments. Login now