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 @@ -48,8 +48,6 @@ private Camera camera = new Camera(new float[] { 0.25f, 0.5f, 1.0f, 2.0f, 4.0f }); - private const string VERSION = "0.30.04"; - Random random_generator = new Random(); int frameRate = 0; @@ -67,9 +65,7 @@ //new tile stuff int squaresAcross = 50; int squaresDown = 50; - // int baseOffsetX = -14; - // int baseOffsetY = -14; - + Simulation simulation; public Vector2 mouseGrid; @@ -129,8 +125,6 @@ } - - private FNAGame() { @@ -149,7 +143,6 @@ IsFullScreen = false, SynchronizeWithVerticalRetrace = true }; - //gdm.SynchronizeWithVerticalRetrace = false; IsFixedTimeStep = false; this.simulation = new Simulation(this.squaresAcross, this.squaresDown, new float[] {16.66667f*240, 16.66667f*120, 16.66667f*60, 16.66667f*30f, 16.66667f*1 }); @@ -214,7 +207,7 @@ Quad.Initialize(GraphicsDevice, texture); Logging.Success("Initialized Quad texture."); ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap); - OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen); + OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen); //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded: this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice, this.imageMap); @@ -267,13 +260,12 @@ WorldBuilder.SetComponent(optionsWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Options }); - var gameEntity = WorldBuilder.CreateEntity(); + var gameEntity = WorldBuilder.CreateEntity(); - WorldBuilder.SetComponent(gameEntity, new GameStateComponent { isPlaying = false}); + WorldBuilder.SetComponent(gameEntity, new GameStateComponent { isPlaying = false}); var area = WorldBuilder.CreateEntity(); - // WorldBuilder.SetComponent(area, new AreaComponent{squares = new[] {new Vector2(4,4), new Vector2(5,4)}}); var size = 5; var squares = new Vector2[size * size]; var start_x = 10; @@ -395,26 +387,26 @@ public void setFont(string font, int size) { - var font_path = DebugWindow.fonts[font]; + var font_path = DebugWindow.fonts[font]; - var baked = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"), - size, - 1024, - 1024, - new[] - { - CharacterRange.BasicLatin, - CharacterRange.Latin1Supplement, - CharacterRange.LatinExtendedA, - CharacterRange.Cyrillic, - CharacterRange.LatinExtendedB, - new CharacterRange((char) 0x00B7) - } - ); + var baked = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"), + size, + 1024, + 1024, + new[] + { + CharacterRange.BasicLatin, + CharacterRange.Latin1Supplement, + CharacterRange.LatinExtendedA, + CharacterRange.Cyrillic, + CharacterRange.LatinExtendedB, + new CharacterRange((char) 0x00B7) + } + ); - this.monoFont = baked.CreateSpriteFont(GraphicsDevice); + this.monoFont = baked.CreateSpriteFont(GraphicsDevice); } - + protected override void UnloadContent() { @@ -504,81 +496,81 @@ KeyboardState keyboardCur = Keyboard.GetState(); MouseState mouseCur = Mouse.GetState(); - - #region input -// - #region misc_keys - if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift)) - { - sound.Play(volume, pitch, pan); - } - if (keyboardCur.IsKeyDown(Keys.V) && keyboardPrev.IsKeyUp(Keys.V)) - { - // debugWindow.swap(); - debugWindow.setMonoFont(debugWindow.addFont("Roboto", 25, false)); - } - #endregion misc_keys - #endregion input + +#region input + // +#region misc_keys + if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift)) + { + sound.Play(volume, pitch, pan); + } + if (keyboardCur.IsKeyDown(Keys.V) && keyboardPrev.IsKeyUp(Keys.V)) + { + // debugWindow.swap(); + debugWindow.setMonoFont(debugWindow.addFont("Roboto", 25, false)); + } +#endregion misc_keys +#endregion input World.Update(gameTime.ElapsedGameTime.TotalSeconds); - this.simulation.update(gameTime.ElapsedGameTime); + this.simulation.update(gameTime.ElapsedGameTime); - if (this.showBudget) - { - this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget); - } + if (this.showBudget) + { + this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget); + } - if (!this.showInitial && this.remainingDialog.Count > 0) - { - this.currentNode = this.remainingDialog.Dequeue(); - this.showInitial = true; - } + if (!this.showInitial && this.remainingDialog.Count > 0) + { + this.currentNode = this.remainingDialog.Dequeue(); + this.showInitial = true; + } - this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice))); + this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice))); - //int gridx = (int)((this.original_point.X-baseOffsetX) / Tile.TileStepX); - /* int gridx = (int)(this.original_point.Y / Tile.TileHeight + this.original_point.X / Tile.TileWidth); */ - //int gridy = (int)((this.original_point.Y-baseOffsetY) / (Tile.TileStepY*2)); - /* int gridy = (int)(this.original_point.Y / Tile.TileHeight - this.original_point.X / Tile.TileWidth); */ + //int gridx = (int)((this.original_point.X-baseOffsetX) / Tile.TileStepX); + /* int gridx = (int)(this.original_point.Y / Tile.TileHeight + this.original_point.X / Tile.TileWidth); */ + //int gridy = (int)((this.original_point.Y-baseOffsetY) / (Tile.TileStepY*2)); + /* int gridy = (int)(this.original_point.Y / Tile.TileHeight - this.original_point.X / Tile.TileWidth); */ - //this.mouseGrid = new Vector2(gridx, gridy); - this.mouseGrid = this.calculateMousegrid(this.original_point); + //this.mouseGrid = new Vector2(gridx, gridy); + this.mouseGrid = this.calculateMousegrid(this.original_point); - elapsedTime += gameTime.ElapsedGameTime; + elapsedTime += gameTime.ElapsedGameTime; - if (elapsedTime > TimeSpan.FromSeconds(1)) - { - elapsedTime -= TimeSpan.FromSeconds(1); - frameRate = frameCounter; - frameCounter = 0; - } + if (elapsedTime > TimeSpan.FromSeconds(1)) + { + elapsedTime -= TimeSpan.FromSeconds(1); + frameRate = frameCounter; + frameCounter = 0; + } - this.keyboardPrev = keyboardCur; - this.mousePrev = mouseCur; + this.keyboardPrev = keyboardCur; + this.mousePrev = mouseCur; - stopWatch.Stop(); - this.updateTime = stopWatch.Elapsed; + stopWatch.Stop(); + this.updateTime = stopWatch.Elapsed; - base.Update(gameTime); + base.Update(gameTime); - } + } - protected float calculateDepth() { - return ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10; - } + protected float calculateDepth() { + return ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10; + } - protected Boolean cull(int gridX, int gridY) - { - int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2; - int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2; + protected Boolean cull(int gridX, int gridY) + { + int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2; + int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2; - Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice)); + Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice)); - return (!FNAGame.enableCulling || - (MathUtils.BetweenExclusive(original.X, -Tile.TileSpriteWidth, FNAGame.width) - && MathUtils.BetweenExclusive(original.Y, -Tile.TileSpriteHeight, FNAGame.height))); - } + return (!FNAGame.enableCulling || + (MathUtils.BetweenExclusive(original.X, -Tile.TileSpriteWidth, FNAGame.width) + && MathUtils.BetweenExclusive(original.Y, -Tile.TileSpriteHeight, FNAGame.height))); + } //Convenience method I'm not super sure about anymore. protected void drawTileAt(int x, int y, int tileIndex, int height) @@ -604,7 +596,7 @@ GraphicsDevice.Clear(Color.CornflowerBlue); _imGuiRenderer.BeforeLayout(gameTime); - if (this.isPlaying) + if (this.isPlaying) { batch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, @@ -677,7 +669,7 @@ new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust, //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight), new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust, - Color.White, 0.81f); + Color.White, 0.81f); } } @@ -761,7 +753,7 @@ Quad.FillSquare2(batch, 8, 5, Color.Teal, .5f, 0.79f); Quad.FillSquare2(batch, 8, 6, Color.Teal, .25f, 0.79f); Quad.FillSquare2(batch, 8, 7, Color.Teal, .125f, 0.79f); -#endif +#endif @@ -824,10 +816,9 @@ String status_left = ""; if (MathUtils.BetweenExclusive(this.mouseGrid.X, -1, this.simulation.map.MapWidth) && MathUtils.BetweenExclusive(this.mouseGrid.Y, -1, this.simulation.map.MapHeight)) { - status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y, - this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].status, - this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unzoned") - ); + status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y, + this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].status, + this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unzoned")); } String header_left = String.Format("${0:}|{1:} \ue124", this.simulation.money, this.simulation.map.tree_count); @@ -882,52 +873,52 @@ NewsWindow.Render(this.showNews, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine); } - bool quit = false; + bool quit = false; Menu.Render(debugWindow.monoFont, FNAGame.width, this.imGuiWindowBridgeEngine, ref quit, ref this.simulation.paused, ref this.simulation.currentRate, ref this.showBudget, header_left); - if (quit) { - System.Environment.Exit(0); - } + if (quit) { + System.Environment.Exit(0); + } } - else { - GraphicsDevice.Clear(Color.Teal); - batch.Begin(SpriteSortMode.BackToFront, - BlendState.AlphaBlend, - null, - null, - null, - null); + else { + GraphicsDevice.Clear(Color.Teal); + batch.Begin(SpriteSortMode.BackToFront, + BlendState.AlphaBlend, + null, + null, + null, + null); - Vector2 middle_dimensions = largeMonoFont.MeasureString("Isometric Park"); - float middle_start = (int)((FNAGame.width / 2) - (middle_dimensions.X / 2)); - ImGui.SetNextWindowPos(new Num.Vector2(((FNAGame.width/2) - 40), 200)); - batch.DrawString(largeMonoFont, "Isometric Park", - new Vector2(middle_start, 50), - Color.Black, 0.0f, Vector2.Zero, - 1.0f, SpriteEffects.None, 0.5f); - batch.DrawString(largeMonoFont, "Isometric Park", - new Vector2(middle_start-1, 49), - Color.White, 0.0f, Vector2.Zero, - 1.0f, SpriteEffects.None, 0.51f); - World.Draw(); + Vector2 middle_dimensions = largeMonoFont.MeasureString("Isometric Park"); + float middle_start = (int)((FNAGame.width / 2) - (middle_dimensions.X / 2)); + ImGui.SetNextWindowPos(new Num.Vector2(((FNAGame.width/2) - 40), 200)); + batch.DrawString(largeMonoFont, "Isometric Park", + new Vector2(middle_start, 50), + Color.Black, 0.0f, Vector2.Zero, + 1.0f, SpriteEffects.None, 0.5f); + batch.DrawString(largeMonoFont, "Isometric Park", + new Vector2(middle_start-1, 49), + Color.White, 0.0f, Vector2.Zero, + 1.0f, SpriteEffects.None, 0.51f); + World.Draw(); - Vector2 version_dimensions = monoFont.MeasureString(typeof(FNAGame).Assembly.GetName().Version.ToString()); - batch.DrawString(monoFont, - typeof(FNAGame).Assembly.GetName().Version.ToString(), - new Vector2(0, FNAGame.height-version_dimensions.Y), - Color.White, 0.0f, Vector2.Zero, - 1.0f, SpriteEffects.None, 0.51f); + Vector2 version_dimensions = monoFont.MeasureString(typeof(FNAGame).Assembly.GetName().Version.ToString()); + batch.DrawString(monoFont, + typeof(FNAGame).Assembly.GetName().Version.ToString(), + new Vector2(0, FNAGame.height-version_dimensions.Y), + Color.White, 0.0f, Vector2.Zero, + 1.0f, SpriteEffects.None, 0.51f); - Vector2 name_dimensions = monoFont.MeasureString("by actuallyalys<3"); - float name_start = (int)(FNAGame.width / 2) - (name_dimensions.X / 2); + Vector2 name_dimensions = monoFont.MeasureString("by actuallyalys<3"); + float name_start = (int)(FNAGame.width / 2) - (name_dimensions.X / 2); - batch.DrawString(monoFont, "by actuallyalys <3", - new Vector2(name_start, 50+middle_dimensions.Y), - Color.White, 0.0f, Vector2.Zero, - 1.0f, SpriteEffects.None, 0.51f); - batch.End(); - } + batch.DrawString(monoFont, "by actuallyalys <3", + new Vector2(name_start, 50+middle_dimensions.Y), + Color.White, 0.0f, Vector2.Zero, + 1.0f, SpriteEffects.None, 0.51f); + batch.End(); + } #endregion @@ -1011,15 +1002,12 @@ public void setResolution(Vector2 newResolution, bool fullscreen) { - FNAGame.width = (int)newResolution.X; - FNAGame.height = (int)newResolution.Y; + FNAGame.width = (int)newResolution.X; + FNAGame.height = (int)newResolution.Y; - this.gdm.PreferredBackBufferWidth = (int)newResolution.X; - this.gdm.PreferredBackBufferHeight = (int)newResolution.Y; - this.gdm.IsFullScreen = fullscreen; - this.gdm.ApplyChanges(); + this.gdm.PreferredBackBufferWidth = (int)newResolution.X; + this.gdm.PreferredBackBufferHeight = (int)newResolution.Y; + this.gdm.IsFullScreen = fullscreen; + this.gdm.ApplyChanges(); } - - - } diff --git a/isometric-park-fna/UI/MainMenu.cs b/isometric-park-fna/UI/MainMenu.cs --- a/isometric-park-fna/UI/MainMenu.cs +++ b/isometric-park-fna/UI/MainMenu.cs @@ -13,7 +13,6 @@ public static class MainMenu { - public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine bridgeEngine) { //Has to go first so the measurement is correct: