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 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 109 if (show)
109 110 {
110 111 ImGui.PushFont(font);
@@ -142,7 +143,7
142 143 string buttonText = child.data.choice;
143 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 167 ImGui.PopStyleColor(8);
167 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 177 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice);
180 178
181 179 var json2 = new FileInfo(@"Content/grammar.json");
@@ -188,8 +186,7
188 186 this.remainingDialog = new Queue<Node<DialogOption>>();
189 187
190 188 this.remainingDialog.Enqueue(DialogTrees.flatten(DialogTrees.testTree, this.grammar));
191
192
189
193 190 //font = fontBakeResult.CreateSpriteFont(GraphicsDevice);
194 191 monoFont = bakedMono.CreateSpriteFont(GraphicsDevice);
195 192
@@ -498,23 +495,23
498 495 }
499 496
500 497 protected override void Draw(GameTime gameTime)
501 {
502 // Render stuff in here. Do NOT run game logic in here!
498 {
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();
509 stopWatch.Start();
510 GraphicsDevice.Clear(Color.CornflowerBlue);
511 batch.Begin(SpriteSortMode.BackToFront,
512 BlendState.AlphaBlend,
513 null,
514 null,
515 null,
516 null,
517 camera.get_transformation(GraphicsDevice));
505 Stopwatch stopWatch = new Stopwatch();
506 stopWatch.Start();
507 GraphicsDevice.Clear(Color.CornflowerBlue);
508 batch.Begin(SpriteSortMode.BackToFront,
509 BlendState.AlphaBlend,
510 null,
511 null,
512 null,
513 null,
514 camera.get_transformation(GraphicsDevice));
518 515
519 516 //New tile stuff
520 517 /*
@@ -558,70 +555,71
558 555 //reset
559 556 this.tilesDrawn = 0;
560 557
561 for (int y = 0; y < this.squaresDown; y++)
562 {
558 for (int y = 0; y < this.squaresDown; y++)
559 {
563 560
564 for (int x = 0; x < this.squaresAcross; x++)
565 {
561 for (int x = 0; x < this.squaresAcross; x++)
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)) {
572 batch.Draw(
573 Tile.TileSetTexture,
574 new Rectangle(
575 screenx,
576 screeny,
577 Tile.TileWidth, Tile.TileHeight),
578 Tile.GetSourceRectangle(1),
579 Color.White,
580 0.0f,
581 Vector2.Zero,
582 SpriteEffects.None,
583 0.9f);
568 if (this.cull(x, y))
569 {
570 batch.Draw(
571 Tile.TileSetTexture,
572 new Rectangle(
573 screenx,
574 screeny,
575 Tile.TileWidth, Tile.TileHeight),
576 Tile.GetSourceRectangle(1),
577 Color.White,
578 0.0f,
579 Vector2.Zero,
580 SpriteEffects.None,
581 0.9f);
584 582
585 this.tilesDrawn++;
586 }
583 this.tilesDrawn++;
584 }
585
587 586
588
589 }
587 }
590 588
591 }
589 }
592 590 #endregion draw_tiles
593 591
594 592 #region draw_gridlines
595 593
596 594 if (this.showGrid)
597 {
598 //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++)
600 {
595 {
596 //need to go one extra so gridlines include the far side of the final tile:
597 for (int y = 0; y < (this.squaresDown + 1); y++)
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,
605 new Vector2(((0 - y) * Tile.TileSpriteWidth / 2), (0 + y) * Tile.TileSpriteHeight / 2) + adjust,
606 //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,
608 Color.White, 0.8f);
602 Line.drawLine(batch,
603 new Vector2(((0 - y) * Tile.TileSpriteWidth / 2), (0 + y) * Tile.TileSpriteHeight / 2) + adjust,
604 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
605 new Vector2((this.squaresAcross - (y)) * Tile.TileSpriteWidth / 2, (this.squaresAcross + (y)) * Tile.TileSpriteHeight / 2) + adjust,
606 Color.White, 0.8f);
609 607
610 }
608 }
611 609
612 for (int x = 0; x < (this.squaresAcross + 1); x++)
613 {
610 for (int x = 0; x < (this.squaresAcross + 1); x++)
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,
618 new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust,
619 //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,
621 Color.White, 0.8f);
615 Line.drawLine(batch,
616 new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust,
617 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
618 new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust,
619 Color.White, 0.8f);
622 620
623 }
624 }
621 }
622 }
625 623 #endregion draw_gridlines
626 624
627 625
@@ -665,12 +663,21
665 663 */
666 664
667 665 drawTileAt(4, 4, 140, 3);
668 drawTileAt(6, 4, 141, 3);
669 drawTileAt(8, 4, 142, 2);
670 drawTileAt(10, 4, 142, 3);
666 drawTileAt(6, 4, 141, 3);
667 drawTileAt(8, 4, 142, 2);
668 drawTileAt(10, 4, 142, 3);
671 669
672 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 681 #endregion draw_cursor
675 682 /*
676 683
@@ -695,120 +702,150
695 702
696 703 #region draw_trees
697 704 for (int i = 0; i < this.simulation.map.MapHeight; i++)
698 {
699 for (int j = 0; j < this.simulation.map.MapWidth; j += 1)
700 {
705 {
706 for (int j = 0; j < this.simulation.map.MapWidth; j += 1)
707 {
701 708
702 if (this.simulation.map.cells[i][j].hasTree)
703 { //until we actually simulate:
704 if((i+j)%8 == 0)
709 if (this.simulation.map.cells[i][j].hasTree)
710 { //until we actually simulate:
711 if ((i + j) % 8 == 0)
705 712 {
706 drawTileAt(i, j, 141, 2);
707 }
708 else
713 drawTileAt(i, j, 141, 2);
714 }
715 else
709 716 {
710 drawTileAt(i, j, 142, 2);
711 }
712 }
713 }
714 }
717 drawTileAt(i, j, 142, 2);
718 }
719 }
720 }
721 }
715 722 #endregion draw_trees
716 723
717 724 drawTileAt(2, 2, 140, 2);
718 drawTileAt(1, 1, 140, 2);
719 drawTileAt(3, 2, 140, 2);
725 drawTileAt(1, 1, 140, 2);
726 drawTileAt(3, 2, 140, 2);
720 727
721 batch.End();
728 batch.End();
722 729
723 730 #region draw_header
724 731 batch.Begin(SpriteSortMode.BackToFront,
725 BlendState.AlphaBlend,
726 null,
727 null,
728 null,
729 null);
732 BlendState.AlphaBlend,
733 null,
734 null,
735 null,
736 null);
730 737
731 bool has_tree = false;
732 if (MathUtils.Between(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.Between(this.mouseGrid.Y, 0, this.squaresAcross))
738 bool has_tree = false;
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;
735 //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);
737 }
738 //*/
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);
741 has_tree = this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].hasTree;
742 //batch.DrawString(font, has_tree.ToString(), new Vector2(500, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
743 //batch.DrawString(font, has_tree.ToString(), new Vector2(499, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f);
744 }
745 //*/
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);
753 batch.DrawString(monoFont, header_middle, new Vector2(middle_start, 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);
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 761 #endregion draw_header
755 762
756 763
757 764 batch.End();
758 765
759 #region debug_window
760 //Calcs for debug window:
761 if ((this.frameCounter % 15) == 0) {
762 past_fps.Enqueue(this.frameRate);
766 #region debug_window
767 //Calcs for debug window:
768 if ((this.frameCounter % 15) == 0)
769 {
770 past_fps.Enqueue(this.frameRate);
763 771
764 }
772 }
765 773
766 DebugInfo debugInfo = new DebugInfo
767 {
768 fps = this.frameRate,
769 pastFps = past_fps.ToArray(),
770 cameraPosition = camera.position,
771 drawTime = this.drawTime,
772 treeCount = this.simulation.map.tree_count,
773 mouseGrid = this.mouseGrid,
774 hasTree = has_tree,
775 tilesDrawn = this.tilesDrawn
776 };
777
778 //Finally, draw the debug window
779 _imGuiRenderer.BeforeLayout(gameTime);
774 DebugInfo debugInfo = new DebugInfo
775 {
776 fps = this.frameRate,
777 pastFps = past_fps.ToArray(),
778 cameraPosition = camera.position,
779 drawTime = this.drawTime,
780 treeCount = this.simulation.map.tree_count,
781 mouseGrid = this.mouseGrid,
782 hasTree = has_tree,
783 tilesDrawn = this.tilesDrawn
784 };
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);
784 debugWindow.Layout(debugInfo, additionalInfo,ref show_another_window);
789 var additionalInfo = new Dictionary<string, string>();
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" },
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?" },
790 // new DialogOption{ response="Oh yeah, of course.", choice="..." }};
794 //String[] messages = { "Message1", "Message2" };
795
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,
796 ref this.simulation.paused, debugWindow.monoFont, this.currentNode);
797 }
798
803 this.currentNode = DialogInterface.RenderDialog(ref this.showInitial,
804 ref this.simulation.paused, debugWindow.monoFont, this.currentNode);
805 }
799 806
800
801 807
802 _imGuiRenderer.AfterLayout();
808 _imGuiRenderer.AfterLayout();
803 809
804 810 #endregion debug_window
805 811
806 812
807 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);
811 }
812
813
832 //Bottom right
833 Line.drawLine(batch,
834 new Vector2(((x + 1 - y) * Tile.TileSpriteWidth / 2), (x + 1 + y) * Tile.TileSpriteHeight / 2) + adjust2,
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