Description:
Fix style and identation.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r348:62f098125aa4 -

@@ -48,8 +48,6
48
48
49 private Camera camera = new Camera(new float[] { 0.25f, 0.5f, 1.0f, 2.0f, 4.0f });
49 private Camera camera = new Camera(new float[] { 0.25f, 0.5f, 1.0f, 2.0f, 4.0f });
50
50
51 private const string VERSION = "0.30.04";
52
53 Random random_generator = new Random();
51 Random random_generator = new Random();
54
52
55 int frameRate = 0;
53 int frameRate = 0;
@@ -67,9 +65,7
67 //new tile stuff
65 //new tile stuff
68 int squaresAcross = 50;
66 int squaresAcross = 50;
69 int squaresDown = 50;
67 int squaresDown = 50;
70 // int baseOffsetX = -14;
68
71 // int baseOffsetY = -14;
72
73 Simulation simulation;
69 Simulation simulation;
74
70
75 public Vector2 mouseGrid;
71 public Vector2 mouseGrid;
@@ -129,8 +125,6
129 }
125 }
130
126
131
127
132
133
134 private FNAGame()
128 private FNAGame()
135 {
129 {
136
130
@@ -149,7 +143,6
149 IsFullScreen = false,
143 IsFullScreen = false,
150 SynchronizeWithVerticalRetrace = true
144 SynchronizeWithVerticalRetrace = true
151 };
145 };
152 //gdm.SynchronizeWithVerticalRetrace = false;
153 IsFixedTimeStep = false;
146 IsFixedTimeStep = false;
154
147
155 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 });
148 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
214 Quad.Initialize(GraphicsDevice, texture);
207 Quad.Initialize(GraphicsDevice, texture);
215 Logging.Success("Initialized Quad texture.");
208 Logging.Success("Initialized Quad texture.");
216 ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap);
209 ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap);
217 OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen);
210 OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen);
218
211
219 //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded:
212 //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded:
220 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice, this.imageMap);
213 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice, this.imageMap);
@@ -267,13 +260,12
267 WorldBuilder.SetComponent(optionsWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Options });
260 WorldBuilder.SetComponent(optionsWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Options });
268
261
269
262
270 var gameEntity = WorldBuilder.CreateEntity();
263 var gameEntity = WorldBuilder.CreateEntity();
271
264
272 WorldBuilder.SetComponent(gameEntity, new GameStateComponent { isPlaying = false});
265 WorldBuilder.SetComponent(gameEntity, new GameStateComponent { isPlaying = false});
273
266
274
267
275 var area = WorldBuilder.CreateEntity();
268 var area = WorldBuilder.CreateEntity();
276 // WorldBuilder.SetComponent(area, new AreaComponent{squares = new[] {new Vector2(4,4), new Vector2(5,4)}});
277 var size = 5;
269 var size = 5;
278 var squares = new Vector2[size * size];
270 var squares = new Vector2[size * size];
279 var start_x = 10;
271 var start_x = 10;
@@ -395,26 +387,26
395
387
396 public void setFont(string font, int size)
388 public void setFont(string font, int size)
397 {
389 {
398 var font_path = DebugWindow.fonts[font];
390 var font_path = DebugWindow.fonts[font];
399
391
400 var baked = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
392 var baked = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
401 size,
393 size,
402 1024,
394 1024,
403 1024,
395 1024,
404 new[]
396 new[]
405 {
397 {
406 CharacterRange.BasicLatin,
398 CharacterRange.BasicLatin,
407 CharacterRange.Latin1Supplement,
399 CharacterRange.Latin1Supplement,
408 CharacterRange.LatinExtendedA,
400 CharacterRange.LatinExtendedA,
409 CharacterRange.Cyrillic,
401 CharacterRange.Cyrillic,
410 CharacterRange.LatinExtendedB,
402 CharacterRange.LatinExtendedB,
411 new CharacterRange((char) 0x00B7)
403 new CharacterRange((char) 0x00B7)
412 }
404 }
413 );
405 );
414
406
415 this.monoFont = baked.CreateSpriteFont(GraphicsDevice);
407 this.monoFont = baked.CreateSpriteFont(GraphicsDevice);
416 }
408 }
417
409
418
410
419 protected override void UnloadContent()
411 protected override void UnloadContent()
420 {
412 {
@@ -504,81 +496,81
504
496
505 KeyboardState keyboardCur = Keyboard.GetState();
497 KeyboardState keyboardCur = Keyboard.GetState();
506 MouseState mouseCur = Mouse.GetState();
498 MouseState mouseCur = Mouse.GetState();
507
499
508 #region input
500 #region input
509 //
501 //
510 #region misc_keys
502 #region misc_keys
511 if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift))
503 if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift))
512 {
504 {
513 sound.Play(volume, pitch, pan);
505 sound.Play(volume, pitch, pan);
514 }
506 }
515 if (keyboardCur.IsKeyDown(Keys.V) && keyboardPrev.IsKeyUp(Keys.V))
507 if (keyboardCur.IsKeyDown(Keys.V) && keyboardPrev.IsKeyUp(Keys.V))
516 {
508 {
517 // debugWindow.swap();
509 // debugWindow.swap();
518 debugWindow.setMonoFont(debugWindow.addFont("Roboto", 25, false));
510 debugWindow.setMonoFont(debugWindow.addFont("Roboto", 25, false));
519 }
511 }
520 #endregion misc_keys
512 #endregion misc_keys
521 #endregion input
513 #endregion input
522
514
523 World.Update(gameTime.ElapsedGameTime.TotalSeconds);
515 World.Update(gameTime.ElapsedGameTime.TotalSeconds);
524 this.simulation.update(gameTime.ElapsedGameTime);
516 this.simulation.update(gameTime.ElapsedGameTime);
525
517
526 if (this.showBudget)
518 if (this.showBudget)
527 {
519 {
528 this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget);
520 this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget);
529 }
521 }
530
522
531
523
532 if (!this.showInitial && this.remainingDialog.Count > 0)
524 if (!this.showInitial && this.remainingDialog.Count > 0)
533 {
525 {
534 this.currentNode = this.remainingDialog.Dequeue();
526 this.currentNode = this.remainingDialog.Dequeue();
535 this.showInitial = true;
527 this.showInitial = true;
536 }
528 }
537
529
538 this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice)));
530 this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice)));
539
531
540 //int gridx = (int)((this.original_point.X-baseOffsetX) / Tile.TileStepX);
532 //int gridx = (int)((this.original_point.X-baseOffsetX) / Tile.TileStepX);
541 /* int gridx = (int)(this.original_point.Y / Tile.TileHeight + this.original_point.X / Tile.TileWidth); */
533 /* int gridx = (int)(this.original_point.Y / Tile.TileHeight + this.original_point.X / Tile.TileWidth); */
542 //int gridy = (int)((this.original_point.Y-baseOffsetY) / (Tile.TileStepY*2));
534 //int gridy = (int)((this.original_point.Y-baseOffsetY) / (Tile.TileStepY*2));
543 /* int gridy = (int)(this.original_point.Y / Tile.TileHeight - this.original_point.X / Tile.TileWidth); */
535 /* int gridy = (int)(this.original_point.Y / Tile.TileHeight - this.original_point.X / Tile.TileWidth); */
544
536
545 //this.mouseGrid = new Vector2(gridx, gridy);
537 //this.mouseGrid = new Vector2(gridx, gridy);
546 this.mouseGrid = this.calculateMousegrid(this.original_point);
538 this.mouseGrid = this.calculateMousegrid(this.original_point);
547
539
548 elapsedTime += gameTime.ElapsedGameTime;
540 elapsedTime += gameTime.ElapsedGameTime;
549
541
550 if (elapsedTime > TimeSpan.FromSeconds(1))
542 if (elapsedTime > TimeSpan.FromSeconds(1))
551 {
543 {
552 elapsedTime -= TimeSpan.FromSeconds(1);
544 elapsedTime -= TimeSpan.FromSeconds(1);
553 frameRate = frameCounter;
545 frameRate = frameCounter;
554 frameCounter = 0;
546 frameCounter = 0;
555 }
547 }
556
548
557 this.keyboardPrev = keyboardCur;
549 this.keyboardPrev = keyboardCur;
558 this.mousePrev = mouseCur;
550 this.mousePrev = mouseCur;
559
551
560 stopWatch.Stop();
552 stopWatch.Stop();
561 this.updateTime = stopWatch.Elapsed;
553 this.updateTime = stopWatch.Elapsed;
562
554
563 base.Update(gameTime);
555 base.Update(gameTime);
564
556
565 }
557 }
566
558
567 protected float calculateDepth() {
559 protected float calculateDepth() {
568 return ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
560 return ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
569 }
561 }
570
562
571 protected Boolean cull(int gridX, int gridY)
563 protected Boolean cull(int gridX, int gridY)
572 {
564 {
573 int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2;
565 int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2;
574 int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2;
566 int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2;
575
567
576 Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice));
568 Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice));
577
569
578 return (!FNAGame.enableCulling ||
570 return (!FNAGame.enableCulling ||
579 (MathUtils.BetweenExclusive(original.X, -Tile.TileSpriteWidth, FNAGame.width)
571 (MathUtils.BetweenExclusive(original.X, -Tile.TileSpriteWidth, FNAGame.width)
580 && MathUtils.BetweenExclusive(original.Y, -Tile.TileSpriteHeight, FNAGame.height)));
572 && MathUtils.BetweenExclusive(original.Y, -Tile.TileSpriteHeight, FNAGame.height)));
581 }
573 }
582
574
583 //Convenience method I'm not super sure about anymore.
575 //Convenience method I'm not super sure about anymore.
584 protected void drawTileAt(int x, int y, int tileIndex, int height)
576 protected void drawTileAt(int x, int y, int tileIndex, int height)
@@ -604,7 +596,7
604 GraphicsDevice.Clear(Color.CornflowerBlue);
596 GraphicsDevice.Clear(Color.CornflowerBlue);
605
597
606 _imGuiRenderer.BeforeLayout(gameTime);
598 _imGuiRenderer.BeforeLayout(gameTime);
607 if (this.isPlaying)
599 if (this.isPlaying)
608 {
600 {
609 batch.Begin(SpriteSortMode.BackToFront,
601 batch.Begin(SpriteSortMode.BackToFront,
610 BlendState.AlphaBlend,
602 BlendState.AlphaBlend,
@@ -677,7 +669,7
677 new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust,
669 new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust,
678 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
670 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
679 new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust,
671 new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust,
680 Color.White, 0.81f);
672 Color.White, 0.81f);
681
673
682 }
674 }
683 }
675 }
@@ -761,7 +753,7
761 Quad.FillSquare2(batch, 8, 5, Color.Teal, .5f, 0.79f);
753 Quad.FillSquare2(batch, 8, 5, Color.Teal, .5f, 0.79f);
762 Quad.FillSquare2(batch, 8, 6, Color.Teal, .25f, 0.79f);
754 Quad.FillSquare2(batch, 8, 6, Color.Teal, .25f, 0.79f);
763 Quad.FillSquare2(batch, 8, 7, Color.Teal, .125f, 0.79f);
755 Quad.FillSquare2(batch, 8, 7, Color.Teal, .125f, 0.79f);
764 #endif
756 #endif
765
757
766
758
767
759
@@ -824,10 +816,9
824 String status_left = "";
816 String status_left = "";
825 if (MathUtils.BetweenExclusive(this.mouseGrid.X, -1, this.simulation.map.MapWidth) && MathUtils.BetweenExclusive(this.mouseGrid.Y, -1, this.simulation.map.MapHeight))
817 if (MathUtils.BetweenExclusive(this.mouseGrid.X, -1, this.simulation.map.MapWidth) && MathUtils.BetweenExclusive(this.mouseGrid.Y, -1, this.simulation.map.MapHeight))
826 {
818 {
827 status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y,
819 status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y,
828 this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].status,
820 this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].status,
829 this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unzoned")
821 this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unzoned"));
830 );
831 }
822 }
832
823
833 String header_left = String.Format("${0:}|{1:} \ue124", this.simulation.money, this.simulation.map.tree_count);
824 String header_left = String.Format("${0:}|{1:} \ue124", this.simulation.money, this.simulation.map.tree_count);
@@ -882,52 +873,52
882 NewsWindow.Render(this.showNews, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine);
873 NewsWindow.Render(this.showNews, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine);
883 }
874 }
884
875
885 bool quit = false;
876 bool quit = false;
886 Menu.Render(debugWindow.monoFont, FNAGame.width, this.imGuiWindowBridgeEngine, ref quit, ref this.simulation.paused, ref this.simulation.currentRate, ref this.showBudget, header_left);
877 Menu.Render(debugWindow.monoFont, FNAGame.width, this.imGuiWindowBridgeEngine, ref quit, ref this.simulation.paused, ref this.simulation.currentRate, ref this.showBudget, header_left);
887
878
888 if (quit) {
879 if (quit) {
889 System.Environment.Exit(0);
880 System.Environment.Exit(0);
890 }
881 }
891
882
892 }
883 }
893 else {
884 else {
894 GraphicsDevice.Clear(Color.Teal);
885 GraphicsDevice.Clear(Color.Teal);
895 batch.Begin(SpriteSortMode.BackToFront,
886 batch.Begin(SpriteSortMode.BackToFront,
896 BlendState.AlphaBlend,
887 BlendState.AlphaBlend,
897 null,
888 null,
898 null,
889 null,
899 null,
890 null,
900 null);
891 null);
901
892
902 Vector2 middle_dimensions = largeMonoFont.MeasureString("Isometric Park");
893 Vector2 middle_dimensions = largeMonoFont.MeasureString("Isometric Park");
903 float middle_start = (int)((FNAGame.width / 2) - (middle_dimensions.X / 2));
894 float middle_start = (int)((FNAGame.width / 2) - (middle_dimensions.X / 2));
904 ImGui.SetNextWindowPos(new Num.Vector2(((FNAGame.width/2) - 40), 200));
895 ImGui.SetNextWindowPos(new Num.Vector2(((FNAGame.width/2) - 40), 200));
905 batch.DrawString(largeMonoFont, "Isometric Park",
896 batch.DrawString(largeMonoFont, "Isometric Park",
906 new Vector2(middle_start, 50),
897 new Vector2(middle_start, 50),
907 Color.Black, 0.0f, Vector2.Zero,
898 Color.Black, 0.0f, Vector2.Zero,
908 1.0f, SpriteEffects.None, 0.5f);
899 1.0f, SpriteEffects.None, 0.5f);
909 batch.DrawString(largeMonoFont, "Isometric Park",
900 batch.DrawString(largeMonoFont, "Isometric Park",
910 new Vector2(middle_start-1, 49),
901 new Vector2(middle_start-1, 49),
911 Color.White, 0.0f, Vector2.Zero,
902 Color.White, 0.0f, Vector2.Zero,
912 1.0f, SpriteEffects.None, 0.51f);
903 1.0f, SpriteEffects.None, 0.51f);
913 World.Draw();
904 World.Draw();
914
905
915 Vector2 version_dimensions = monoFont.MeasureString(typeof(FNAGame).Assembly.GetName().Version.ToString());
906 Vector2 version_dimensions = monoFont.MeasureString(typeof(FNAGame).Assembly.GetName().Version.ToString());
916 batch.DrawString(monoFont,
907 batch.DrawString(monoFont,
917 typeof(FNAGame).Assembly.GetName().Version.ToString(),
908 typeof(FNAGame).Assembly.GetName().Version.ToString(),
918 new Vector2(0, FNAGame.height-version_dimensions.Y),
909 new Vector2(0, FNAGame.height-version_dimensions.Y),
919 Color.White, 0.0f, Vector2.Zero,
910 Color.White, 0.0f, Vector2.Zero,
920 1.0f, SpriteEffects.None, 0.51f);
911 1.0f, SpriteEffects.None, 0.51f);
921
912
922 Vector2 name_dimensions = monoFont.MeasureString("by actuallyalys<3");
913 Vector2 name_dimensions = monoFont.MeasureString("by actuallyalys<3");
923 float name_start = (int)(FNAGame.width / 2) - (name_dimensions.X / 2);
914 float name_start = (int)(FNAGame.width / 2) - (name_dimensions.X / 2);
924
915
925 batch.DrawString(monoFont, "by actuallyalys <3",
916 batch.DrawString(monoFont, "by actuallyalys <3",
926 new Vector2(name_start, 50+middle_dimensions.Y),
917 new Vector2(name_start, 50+middle_dimensions.Y),
927 Color.White, 0.0f, Vector2.Zero,
918 Color.White, 0.0f, Vector2.Zero,
928 1.0f, SpriteEffects.None, 0.51f);
919 1.0f, SpriteEffects.None, 0.51f);
929 batch.End();
920 batch.End();
930 }
921 }
931 #endregion
922 #endregion
932
923
933
924
@@ -1011,15 +1002,12
1011
1002
1012 public void setResolution(Vector2 newResolution, bool fullscreen)
1003 public void setResolution(Vector2 newResolution, bool fullscreen)
1013 {
1004 {
1014 FNAGame.width = (int)newResolution.X;
1005 FNAGame.width = (int)newResolution.X;
1015 FNAGame.height = (int)newResolution.Y;
1006 FNAGame.height = (int)newResolution.Y;
1016
1007
1017 this.gdm.PreferredBackBufferWidth = (int)newResolution.X;
1008 this.gdm.PreferredBackBufferWidth = (int)newResolution.X;
1018 this.gdm.PreferredBackBufferHeight = (int)newResolution.Y;
1009 this.gdm.PreferredBackBufferHeight = (int)newResolution.Y;
1019 this.gdm.IsFullScreen = fullscreen;
1010 this.gdm.IsFullScreen = fullscreen;
1020 this.gdm.ApplyChanges();
1011 this.gdm.ApplyChanges();
1021 }
1012 }
1022
1023
1024
1025 }
1013 }
@@ -13,7 +13,6
13 public static class MainMenu
13 public static class MainMenu
14 {
14 {
15
15
16
17 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine bridgeEngine)
16 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine bridgeEngine)
18 {
17 {
19 //Has to go first so the measurement is correct:
18 //Has to go first so the measurement is correct:
You need to be logged in to leave comments. Login now