Description:
Add proper marker for highlighting squares.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r46:9c98448d319b -

@@ -105,6 +105,7
105 {
105 {
106 public static Node<DialogOption> RenderDialog(ref bool show, ref bool paused, ImFontPtr font, Node<DialogOption> currentNode)
106 public static Node<DialogOption> RenderDialog(ref bool show, ref bool paused, ImFontPtr font, Node<DialogOption> currentNode)
107 {
107 {
108 Node<DialogOption> new_child = currentNode;
108 if (show)
109 if (show)
109 {
110 {
110 ImGui.PushFont(font);
111 ImGui.PushFont(font);
@@ -142,7 +143,7
142 string buttonText = child.data.choice;
143 string buttonText = child.data.choice;
143 if (ImGui.Button(buttonText))
144 if (ImGui.Button(buttonText))
144 {
145 {
145 return child;
146 new_child = child;
146 }
147 }
147 }
148 }
148 }
149 }
@@ -166,7 +167,7
166 ImGui.PopStyleColor(8);
167 ImGui.PopStyleColor(8);
167 ImGui.PopFont();
168 ImGui.PopFont();
168 }
169 }
169 return currentNode;
170 return new_child;
170
171
171 }
172 }
172 }
173 }
@@ -174,8 +174,6
174 }
174 }
175 );
175 );
176
176
177
178
179 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice);
177 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice);
180
178
181 var json2 = new FileInfo(@"Content/grammar.json");
179 var json2 = new FileInfo(@"Content/grammar.json");
@@ -188,8 +186,7
188 this.remainingDialog = new Queue<Node<DialogOption>>();
186 this.remainingDialog = new Queue<Node<DialogOption>>();
189
187
190 this.remainingDialog.Enqueue(DialogTrees.flatten(DialogTrees.testTree, this.grammar));
188 this.remainingDialog.Enqueue(DialogTrees.flatten(DialogTrees.testTree, this.grammar));
191
189
192
193 //font = fontBakeResult.CreateSpriteFont(GraphicsDevice);
190 //font = fontBakeResult.CreateSpriteFont(GraphicsDevice);
194 monoFont = bakedMono.CreateSpriteFont(GraphicsDevice);
191 monoFont = bakedMono.CreateSpriteFont(GraphicsDevice);
195
192
@@ -498,23 +495,23
498 }
495 }
499
496
500 protected override void Draw(GameTime gameTime)
497 protected override void Draw(GameTime gameTime)
501 {
498 {
502 // Render stuff in here. Do NOT run game logic in here!
499 // Render stuff in here. Do NOT run game logic in here!
503
500
504 frameCounter++;
501 frameCounter++;
505
502
506 string fps = string.Format("fps: {0}", frameRate);
503 string fps = string.Format("fps: {0}", frameRate);
507
504
508 Stopwatch stopWatch = new Stopwatch();
505 Stopwatch stopWatch = new Stopwatch();
509 stopWatch.Start();
506 stopWatch.Start();
510 GraphicsDevice.Clear(Color.CornflowerBlue);
507 GraphicsDevice.Clear(Color.CornflowerBlue);
511 batch.Begin(SpriteSortMode.BackToFront,
508 batch.Begin(SpriteSortMode.BackToFront,
512 BlendState.AlphaBlend,
509 BlendState.AlphaBlend,
513 null,
510 null,
514 null,
511 null,
515 null,
512 null,
516 null,
513 null,
517 camera.get_transformation(GraphicsDevice));
514 camera.get_transformation(GraphicsDevice));
518
515
519 //New tile stuff
516 //New tile stuff
520 /*
517 /*
@@ -558,70 +555,71
558 //reset
555 //reset
559 this.tilesDrawn = 0;
556 this.tilesDrawn = 0;
560
557
561 for (int y = 0; y < this.squaresDown; y++)
558 for (int y = 0; y < this.squaresDown; y++)
562 {
559 {
563
560
564 for (int x = 0; x < this.squaresAcross; x++)
561 for (int x = 0; x < this.squaresAcross; x++)
565 {
562 {
566
563
567 int screenx = (x - y) * Tile.TileSpriteWidth/2;
564 int screenx = (x - y) * Tile.TileSpriteWidth / 2;
568
565
569 int screeny = (x + y) * Tile.TileSpriteHeight / 2;
566 int screeny = (x + y) * Tile.TileSpriteHeight / 2;
570
567
571 if (this.cull(x, y)) {
568 if (this.cull(x, y))
572 batch.Draw(
569 {
573 Tile.TileSetTexture,
570 batch.Draw(
574 new Rectangle(
571 Tile.TileSetTexture,
575 screenx,
572 new Rectangle(
576 screeny,
573 screenx,
577 Tile.TileWidth, Tile.TileHeight),
574 screeny,
578 Tile.GetSourceRectangle(1),
575 Tile.TileWidth, Tile.TileHeight),
579 Color.White,
576 Tile.GetSourceRectangle(1),
580 0.0f,
577 Color.White,
581 Vector2.Zero,
578 0.0f,
582 SpriteEffects.None,
579 Vector2.Zero,
583 0.9f);
580 SpriteEffects.None,
581 0.9f);
584
582
585 this.tilesDrawn++;
583 this.tilesDrawn++;
586 }
584 }
585
587
586
588
587 }
589 }
590
588
591 }
589 }
592 #endregion draw_tiles
590 #endregion draw_tiles
593
591
594 #region draw_gridlines
592 #region draw_gridlines
595
593
596 if (this.showGrid)
594 if (this.showGrid)
597 {
595 {
598 //need to go one extra so gridlines include the far side of the final tile:
596 //need to go one extra so gridlines include the far side of the final tile:
599 for (int y = 0; y < (this.squaresDown + 1); y++)
597 for (int y = 0; y < (this.squaresDown + 1); y++)
600 {
598 {
601
599
602 Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved
600 Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved
603
601
604 Line.drawLine(batch,
602 Line.drawLine(batch,
605 new Vector2(((0 - y) * Tile.TileSpriteWidth / 2), (0 + y) * Tile.TileSpriteHeight / 2) + adjust,
603 new Vector2(((0 - y) * Tile.TileSpriteWidth / 2), (0 + y) * Tile.TileSpriteHeight / 2) + adjust,
606 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
604 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
607 new Vector2((this.squaresAcross - (y)) * Tile.TileSpriteWidth / 2, (this.squaresAcross + (y)) * Tile.TileSpriteHeight / 2) + adjust,
605 new Vector2((this.squaresAcross - (y)) * Tile.TileSpriteWidth / 2, (this.squaresAcross + (y)) * Tile.TileSpriteHeight / 2) + adjust,
608 Color.White, 0.8f);
606 Color.White, 0.8f);
609
607
610 }
608 }
611
609
612 for (int x = 0; x < (this.squaresAcross + 1); x++)
610 for (int x = 0; x < (this.squaresAcross + 1); x++)
613 {
611 {
614
612
615 Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved
613 Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved
616
614
617 Line.drawLine(batch,
615 Line.drawLine(batch,
618 new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust,
616 new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust,
619 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
617 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
620 new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust,
618 new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust,
621 Color.White, 0.8f);
619 Color.White, 0.8f);
622
620
623 }
621 }
624 }
622 }
625 #endregion draw_gridlines
623 #endregion draw_gridlines
626
624
627
625
@@ -665,12 +663,21
665 */
663 */
666
664
667 drawTileAt(4, 4, 140, 3);
665 drawTileAt(4, 4, 140, 3);
668 drawTileAt(6, 4, 141, 3);
666 drawTileAt(6, 4, 141, 3);
669 drawTileAt(8, 4, 142, 2);
667 drawTileAt(8, 4, 142, 2);
670 drawTileAt(10, 4, 142, 3);
668 drawTileAt(10, 4, 142, 3);
671
669
672 #region draw_cursor
670 #region draw_cursor
673 drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines
671 //drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines
672
673 //TODO figure out why it has to be -1
674 if (MathUtils.Between(this.mouseGrid.X, -1, this.simulation.map.MapWidth)
675 && MathUtils.Between(this.mouseGrid.Y, -1, this.simulation.map.MapHeight))
676 {
677 OutlineSquare(this.mouseGrid.X, this.mouseGrid.Y, Color.Yellow);
678 }
679
680
674 #endregion draw_cursor
681 #endregion draw_cursor
675 /*
682 /*
676
683
@@ -695,120 +702,150
695
702
696 #region draw_trees
703 #region draw_trees
697 for (int i = 0; i < this.simulation.map.MapHeight; i++)
704 for (int i = 0; i < this.simulation.map.MapHeight; i++)
698 {
705 {
699 for (int j = 0; j < this.simulation.map.MapWidth; j += 1)
706 for (int j = 0; j < this.simulation.map.MapWidth; j += 1)
700 {
707 {
701
708
702 if (this.simulation.map.cells[i][j].hasTree)
709 if (this.simulation.map.cells[i][j].hasTree)
703 { //until we actually simulate:
710 { //until we actually simulate:
704 if((i+j)%8 == 0)
711 if ((i + j) % 8 == 0)
705 {
712 {
706 drawTileAt(i, j, 141, 2);
713 drawTileAt(i, j, 141, 2);
707 }
714 }
708 else
715 else
709 {
716 {
710 drawTileAt(i, j, 142, 2);
717 drawTileAt(i, j, 142, 2);
711 }
718 }
712 }
719 }
713 }
720 }
714 }
721 }
715 #endregion draw_trees
722 #endregion draw_trees
716
723
717 drawTileAt(2, 2, 140, 2);
724 drawTileAt(2, 2, 140, 2);
718 drawTileAt(1, 1, 140, 2);
725 drawTileAt(1, 1, 140, 2);
719 drawTileAt(3, 2, 140, 2);
726 drawTileAt(3, 2, 140, 2);
720
727
721 batch.End();
728 batch.End();
722
729
723 #region draw_header
730 #region draw_header
724 batch.Begin(SpriteSortMode.BackToFront,
731 batch.Begin(SpriteSortMode.BackToFront,
725 BlendState.AlphaBlend,
732 BlendState.AlphaBlend,
726 null,
733 null,
727 null,
734 null,
728 null,
735 null,
729 null);
736 null);
730
737
731 bool has_tree = false;
738 bool has_tree = false;
732 if (MathUtils.Between(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.Between(this.mouseGrid.Y, 0, this.squaresAcross))
739 if (MathUtils.Between(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.Between(this.mouseGrid.Y, 0, this.squaresAcross))
733 {
740 {
734 has_tree = this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].hasTree;
741 has_tree = this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].hasTree;
735 //batch.DrawString(font, has_tree.ToString(), new Vector2(500, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
742 //batch.DrawString(font, has_tree.ToString(), new Vector2(500, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
736 //batch.DrawString(font, has_tree.ToString(), new Vector2(499, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f);
743 //batch.DrawString(font, has_tree.ToString(), new Vector2(499, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f);
737 }
744 }
738 //*/
745 //*/
739
740
741 String header_left = String.Format("${0:}|{1:} treesβš˜π‚·πŸŒ³", this.simulation.money, this.simulation.map.tree_count);
742 String header_middle = String.Format("{0:MMMMM yyyy} ({1:})", this.simulation.DateTime, this.simulation.Season);
743
744 this.Window.Title = String.Format("Isometric Park [{0:}]",header_middle);
745 Vector2 dimensions = monoFont.MeasureString(header_middle);
746
747 float middle_start = (FNAGame.width / 2) - (dimensions.X / 2);
748
749 FilledRectangle.drawFilledRectangle(batch, new Rectangle(0, 0, width, (int)dimensions.Y), Color.White, 0.51f);
750
746
751
747
752 batch.DrawString(monoFont, header_left, new Vector2(1, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
748 String header_left = String.Format("${0:}|{1:} treesβš˜π‚·πŸŒ³", this.simulation.money, this.simulation.map.tree_count);
753 batch.DrawString(monoFont, header_middle, new Vector2(middle_start, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
749 String header_middle = String.Format("{0:MMMMM yyyy} ({1:})", this.simulation.DateTime, this.simulation.Season);
750
751 this.Window.Title = String.Format("Isometric Park [{0:}]", header_middle);
752 Vector2 dimensions = monoFont.MeasureString(header_middle);
753
754 float middle_start = (FNAGame.width / 2) - (dimensions.X / 2);
755
756 FilledRectangle.drawFilledRectangle(batch, new Rectangle(0, 0, width, (int)dimensions.Y), Color.White, 0.51f);
757
758
759 batch.DrawString(monoFont, header_left, new Vector2(1, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
760 batch.DrawString(monoFont, header_middle, new Vector2(middle_start, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
754 #endregion draw_header
761 #endregion draw_header
755
762
756
763
757 batch.End();
764 batch.End();
758
765
759 #region debug_window
766 #region debug_window
760 //Calcs for debug window:
767 //Calcs for debug window:
761 if ((this.frameCounter % 15) == 0) {
768 if ((this.frameCounter % 15) == 0)
762 past_fps.Enqueue(this.frameRate);
769 {
770 past_fps.Enqueue(this.frameRate);
763
771
764 }
772 }
765
773
766 DebugInfo debugInfo = new DebugInfo
774 DebugInfo debugInfo = new DebugInfo
767 {
775 {
768 fps = this.frameRate,
776 fps = this.frameRate,
769 pastFps = past_fps.ToArray(),
777 pastFps = past_fps.ToArray(),
770 cameraPosition = camera.position,
778 cameraPosition = camera.position,
771 drawTime = this.drawTime,
779 drawTime = this.drawTime,
772 treeCount = this.simulation.map.tree_count,
780 treeCount = this.simulation.map.tree_count,
773 mouseGrid = this.mouseGrid,
781 mouseGrid = this.mouseGrid,
774 hasTree = has_tree,
782 hasTree = has_tree,
775 tilesDrawn = this.tilesDrawn
783 tilesDrawn = this.tilesDrawn
776 };
784 };
777
778 //Finally, draw the debug window
779 _imGuiRenderer.BeforeLayout(gameTime);
780
785
781 var additionalInfo = new Dictionary<string, string>();
786 //Finally, draw the debug window
787 _imGuiRenderer.BeforeLayout(gameTime);
782
788
783 additionalInfo.Add("Tracery Test", this.output);
789 var additionalInfo = new Dictionary<string, string>();
784 debugWindow.Layout(debugInfo, additionalInfo,ref show_another_window);
785
790
786 //String[] messages = { "Message1", "Message2" };
791 additionalInfo.Add("Tracery Test", this.output);
792 debugWindow.Layout(debugInfo, additionalInfo, ref show_another_window);
787
793
788 //DialogOption[] dialog = { new DialogOption{ response="Welcome to your new park, director! You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out.", choice="Okay" },
794 //String[] messages = { "Message1", "Message2" };
789 // new DialogOption{ response="Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budgetβ€”it'd sure be nice if you park were self-sufficient so we could drop that expense!", choice="And I need to keep the forest healthy, too, right?" },
795
790 // new DialogOption{ response="Oh yeah, of course.", choice="..." }};
796 //DialogOption[] dialog = { new DialogOption{ response="Welcome to your new park, director! You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out.", choice="Okay" },
797 // new DialogOption{ response="Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budgetβ€”it'd sure be nice if you park were self-sufficient so we could drop that expense!", choice="And I need to keep the forest healthy, too, right?" },
798 // new DialogOption{ response="Oh yeah, of course.", choice="..." }};
791
799
792
800
793 if (this.currentNode != null)
801 if (this.currentNode != null)
794 {
802 {
795 this.currentNode = DialogInterface.RenderDialog(ref this.showInitial,
803 this.currentNode = DialogInterface.RenderDialog(ref this.showInitial,
796 ref this.simulation.paused, debugWindow.monoFont, this.currentNode);
804 ref this.simulation.paused, debugWindow.monoFont, this.currentNode);
797 }
805 }
798
799
806
800
801
807
802 _imGuiRenderer.AfterLayout();
808 _imGuiRenderer.AfterLayout();
803
809
804 #endregion debug_window
810 #endregion debug_window
805
811
806
812
807 stopWatch.Stop();
813 stopWatch.Stop();
808 this.drawTime = stopWatch.Elapsed;
814 this.drawTime = stopWatch.Elapsed;
815
816 base.Draw(gameTime);
817 }
818
819 private void OutlineSquare(float x, float y, Color color)
820 {
821 Vector2 adjust2 = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved
822
823 //Upper right
824 //float x = this.mouseGrid.X;
825 //float y = this.mouseGrid.Y;
826 Line.drawLine(batch,
827 new Vector2(((x - y) * Tile.TileSpriteWidth / 2), (x + y) * Tile.TileSpriteHeight / 2) + adjust2,
828 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
829 new Vector2(((x - y + 1) * Tile.TileSpriteWidth / 2), (x + y + 1) * Tile.TileSpriteHeight / 2) + adjust2,
830 color, 0.79f);
809
831
810 base.Draw(gameTime);
832 //Bottom right
811 }
833 Line.drawLine(batch,
812
834 new Vector2(((x + 1 - y) * Tile.TileSpriteWidth / 2), (x + 1 + y) * Tile.TileSpriteHeight / 2) + adjust2,
813
835 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
836 new Vector2(((x + 1 - (y + 1)) * Tile.TileSpriteWidth / 2), (x + 1 + (y + 1)) * Tile.TileSpriteHeight / 2) + adjust2,
837 color, 0.79f);
838 //Bottom left
839 Line.drawLine(batch,
840 new Vector2(((x - (y + 1)) * Tile.TileSpriteWidth / 2), (x + y + 1) * Tile.TileSpriteHeight / 2) + adjust2,
841 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
842 new Vector2(((x + 1 - (y + 1)) * Tile.TileSpriteWidth / 2), (x + 1 + (y + 1)) * Tile.TileSpriteHeight / 2) + adjust2,
843 color, 0.79f);
844 //Upper left
845 Line.drawLine(batch,
846 new Vector2(((x - y) * Tile.TileSpriteWidth / 2), (x + y) * Tile.TileSpriteHeight / 2) + adjust2,
847 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
848 new Vector2(((x - (y + 1)) * Tile.TileSpriteWidth / 2), (x + (y + 1)) * Tile.TileSpriteHeight / 2) + adjust2,
849 color, 0.79f);
850 }
814 }
851 }
You need to be logged in to leave comments. Login now