# HG changeset patch # User alys # Date 2021-04-04 01:51:40 # Node ID bbbf23e975ceb906058645f2f804b8f9f10ad785 # Parent 7ca17e8b6a7ca2f08352f74d852f105e97ce5451 Some refactoring. (grafted from 111182ff6d2d689a5333793d865bb649093ec9a7) diff --git a/isometric-park-fna/Engines/GameBridgeEngine.cs b/isometric-park-fna/Engines/GameBridgeEngine.cs --- a/isometric-park-fna/Engines/GameBridgeEngine.cs +++ b/isometric-park-fna/Engines/GameBridgeEngine.cs @@ -7,7 +7,7 @@ namespace isometricparkfna.Engines { - [Receives(typeof(ToggleDebugWindowMessage))] + [Receives(typeof(ToggleWindowMessage))] class GameBridgeEngine : Engine { @@ -20,10 +20,24 @@ public override void Update(double dt) { - foreach (ref readonly var motionMessage in ReadMessages()) + foreach (ref readonly var windowMessage in ReadMessages()) { + switch (windowMessage.Window) { + case Window.Debug: + game.show_another_window = !game.show_another_window; + break; + case Window.Budget: + game.showBudget = !game.showBudget; + break; + case Window.Forest: + game.showForest = !game.showForest; + break; + case Window.News: + game.showNews = !game.showNews; + break; - game.show_another_window = !game.show_another_window; + } + } diff --git a/isometric-park-fna/Engines/InputEngine.cs b/isometric-park-fna/Engines/InputEngine.cs --- a/isometric-park-fna/Engines/InputEngine.cs +++ b/isometric-park-fna/Engines/InputEngine.cs @@ -9,7 +9,7 @@ - [Sends(typeof(ToggleDebugWindowMessage))] + [Sends(typeof(ToggleWindowMessage))] public class InputEngine : Engine { private KeyboardState keyboardPrev; @@ -23,15 +23,32 @@ var keyboardCur = Keyboard.GetState(); +#region misc_keys if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash)) { - // this.show_another_window = !this.show_another_window; - // - SendMessage(new ToggleDebugWindowMessage()); + SendMessage(new ToggleWindowMessage{Window = Window.Debug}); + + } + if (keyboardCur.IsKeyDown(Keys.B) && keyboardPrev.IsKeyUp(Keys.B)) + { + SendMessage(new ToggleWindowMessage{Window = Window.Budget}); + + } + if (keyboardCur.IsKeyDown(Keys.F) && keyboardPrev.IsKeyUp(Keys.F)) + { + SendMessage(new ToggleWindowMessage{Window = Window.Forest}); + + } + if (keyboardCur.IsKeyDown(Keys.N) && keyboardPrev.IsKeyUp(Keys.N)) + { + SendMessage(new ToggleWindowMessage{Window = Window.News}); } +#endif +#endregion misc_keys + this.keyboardPrev = keyboardCur; } } diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -74,15 +74,15 @@ private List newsItems; - private bool showGrid; - private bool showTrees; + public bool showGrid; + public bool showTrees; private Grammar grammar; private string output; private GraphicsDeviceManager gdm; - private bool showBudget; + public bool showBudget; private BudgetWindow budgetWindow; - private bool showForest; - private bool showNews; + public bool showForest; + public bool showNews; //Encompass private WorldBuilder WorldBuilder = new WorldBuilder(); @@ -368,12 +368,6 @@ System.Console.WriteLine("Quitting"); Environment.Exit(0); } - if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash)) - { - // this.show_another_window = !this.show_another_window; - - } - if (keyboardCur.IsKeyDown(Keys.G) && keyboardPrev.IsKeyUp(Keys.G)) { this.showGrid = !this.showGrid; @@ -386,21 +380,6 @@ } #endif - if (keyboardCur.IsKeyDown(Keys.B) && keyboardPrev.IsKeyUp(Keys.B)) - { - this.showBudget = !this.showBudget; - - } - if (keyboardCur.IsKeyDown(Keys.F) && keyboardPrev.IsKeyUp(Keys.F)) - { - this.showForest = !this.showForest; - - } - if (keyboardCur.IsKeyDown(Keys.N) && keyboardPrev.IsKeyUp(Keys.N)) - { - this.showNews = !this.showNews; - - } if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C)) { this.camera.Jump(Vector2.Zero); @@ -477,12 +456,14 @@ this.camera.Move(new Vector2(0, 4)); } +#if DEBUG if (mouseCur.RightButton == ButtonState.Pressed) { Vector2 cameraMiddle = this.camera.position + new Vector2(FNAGame.width / 2, FNAGame.height / 2); Vector2 delta = this.camera.position - this.original_point; this.camera.Jump(this.original_point); } +#endif #endregion input diff --git a/isometric-park-fna/Messages/ToggleWindowMessage.cs b/isometric-park-fna/Messages/ToggleWindowMessage.cs --- a/isometric-park-fna/Messages/ToggleWindowMessage.cs +++ b/isometric-park-fna/Messages/ToggleWindowMessage.cs @@ -2,11 +2,16 @@ namespace isometricparkfna.Messages { - // public enum Window { - // DEBUG - // } + public enum Window { + Debug, + Budget, + Forest, + News + } - public struct ToggleDebugWindowMessage : IMessage//, IHasEntity + public struct ToggleWindowMessage : IMessage//, IHasEntity { + + public Window Window; } }