Description:
Incomplete version of BudgetWindow handling in Encompass. (grafted from 5999c7ab440ff7e9e9d5e85a1c21f8df8a65f3d0)
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r174:aaef990ac4b5 -

@@ -0,0 +1,11
1 using Encompass;
2
3 namespace isometricparkfna.Components {
4
5 public struct BudgetComponent : IComponent {
6 public Budget currentBudget;
7 public Budget priorBudget;
8
9 }
10
11 }
@@ -0,0 +1,12
1
2 using Encompass;
3
4 namespace isometricparkfna.Components {
5
6 public struct BudgetWindowComponent : IComponent {
7 public Budget currentBudget;
8 public Budget priorBudget;
9
10 }
11
12 }
@@ -0,0 +1,8
1 using Encompass;
2
3 namespace isometricparkfna.Components {
4
5 public struct VisibilityComponent : IComponent {
6 public bool visible;
7 }
8 }
@@ -0,0 +1,39
1
2 using Microsoft.Xna.Framework.Input;
3
4 using Encompass;
5
6 using isometricparkfna.Messages;
7 using isometricparkfna.Components;
8
9 namespace isometricparkfna.Engines {
10
11 // [Receives()]
12 [Reads(typeof(BudgetComponent))]
13 [Writes(typeof(BudgetComponent))]
14 class SimulationBridgeEngine : Engine
15 {
16 public Simulation simulation;
17
18 public SimulationBridgeEngine(Simulation simulation)
19 {
20 this.simulation = simulation;
21 }
22
23 public override void Update(double dt)
24 {
25
26 foreach (ref readonly var entity in ReadEntities<BudgetComponent>())
27 {
28 ref readonly var budgetComponent = ref GetComponent<BudgetComponent>(entity);
29
30 SetComponent(entity, new BudgetComponent{currentBudget = this.simulation.latestBudget,
31 priorBudget = this.simulation.previousBudget});
32 }
33
34 }
35
36
37 }
38
39 }
@@ -0,0 +1,35
1 using Encompass;
2
3 namespace isometricparkfna.Renderers
4 {
5 public class BudgetWindowRenderer : GeneralRenderer
6 {
7 private SpriteBatch batch;
8 private SpriteFont font;
9
10
11 public BudgetWindowRenderer(SpriteBatch batch, SpriteFont font)
12 {
13 this.batch = batch;
14 this.font = font;
15 }
16
17
18 public override void Render()
19 {
20
21 var budgetWindow = new BudgetWindow(new Budget { }, this.monoFont, 0, 0);
22
23 foreach (ref readonly var entity in ReadEntities<BudgetComponent>())
24 {
25 // budgetWindow.update
26 // this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget);
27
28 }
29
30
31
32
33 }
34 }
35 }
@@ -18,6 +18,7
18 18 using isometricparkfna.Utils;
19 19 using isometricparkfna.UI;
20 20 using isometricparkfna.Engines;
21 using isometricparkfna.Components;
21 22
22 23 using ImGuiNET.SampleProgram.XNA;
23 24 using ImGuiNET;
@@ -180,8 +181,17
180 181 //let's see if this works:
181 182 // WorldBuilder = new WorldBuilder();
182 183 var dummy_entity = WorldBuilder.CreateEntity();
184
185
186 // WorldBuilder.AddGeneralRenderer(new BudgetWindowRenderer(this.batch, this.monoFont));
183 187 WorldBuilder.AddEngine(new InputEngine());
184 188 WorldBuilder.AddEngine(new GameBridgeEngine(this));
189 WorldBuilder.AddEngine(new SimulationBridgeEngine(this.simulation));
190
191 var budgetWindow = WorldBuilder.CreateEntity();
192 WorldBuilder.SetComponent(budgetWindow, new VisibilityComponent{visible = true});
193 WorldBuilder.SetComponent(budgetWindow, new BudgetComponent());
194
185 195 World = WorldBuilder.Build();
186 196
187 197 var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
@@ -462,7 +472,7
462 472
463 473 if (this.showBudget)
464 474 {
465 this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget);
475 // this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget);
466 476 }
467 477
468 478
@@ -42,6 +42,7
42 42 <Compile Include="ImGuiRenderer.cs" />
43 43 <Compile Include="FilledRectangle.cs" />
44 44 <Compile Include="Simulation.cs" />
45 <Compile Include="Components\*.cs" />
45 46 <Compile Include="Engines\*.cs" />
46 47 <Compile Include="Messages\*.cs" />
47 48 <Compile Include="Utils\MathUtils.cs" />
You need to be logged in to leave comments. Login now