From 84c81fec9601a8f8f7165be5265479f99f5b72c9 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Mon, 16 Sep 2019 21:02:00 -0400 Subject: [PATCH] Add in game render preview setting --- .../FileFormats/Layout/BxlytToGL.cs | 70 +++++++++++-------- .../GUI/BFLYT/LayoutEditor.Designer.cs | 36 ++++++++-- File_Format_Library/GUI/BFLYT/LayoutEditor.cs | 17 ++++- File_Format_Library/GUI/BFLYT/LayoutViewer.cs | 8 ++- Switch_Toolbox_Library/Config.cs | 4 ++ Switch_Toolbox_Library/Runtime.cs | 2 + 6 files changed, 98 insertions(+), 39 deletions(-) diff --git a/File_Format_Library/FileFormats/Layout/BxlytToGL.cs b/File_Format_Library/FileFormats/Layout/BxlytToGL.cs index 8c06c7f0..e871e2ae 100644 --- a/File_Format_Library/FileFormats/Layout/BxlytToGL.cs +++ b/File_Format_Library/FileFormats/Layout/BxlytToGL.cs @@ -174,7 +174,7 @@ namespace LayoutBXLYT public static void DrawBoundryPane(BasePane pane, byte effectiveAlpha, List SelectedPanes) { - if (!Runtime.LayoutEditor.DisplayBoundryPane) + if (!Runtime.LayoutEditor.DisplayBoundryPane || Runtime.LayoutEditor.IsGamePreview) return; Vector2[] TexCoords = new Vector2[] { @@ -203,7 +203,7 @@ namespace LayoutBXLYT public static void DrawAlignmentPane(BasePane pane, byte effectiveAlpha, List SelectedPanes) { - if (!Runtime.LayoutEditor.DisplayAlignmentPane) + if (!Runtime.LayoutEditor.DisplayAlignmentPane || Runtime.LayoutEditor.IsGamePreview) return; @@ -232,7 +232,7 @@ namespace LayoutBXLYT public static void DrawScissorPane(BasePane pane, byte effectiveAlpha, List SelectedPanes) { - if (!Runtime.LayoutEditor.DisplayScissorPane) + if (!Runtime.LayoutEditor.DisplayScissorPane || Runtime.LayoutEditor.IsGamePreview) return; Vector2[] TexCoords = new Vector2[] { @@ -677,21 +677,24 @@ namespace LayoutBXLYT private static void DrawQuad(float x, float y, float w, float h, Vector2[] texCoords, Color[] colors) { - GL.Disable(EnableCap.AlphaTest); - GL.Disable(EnableCap.Blend); + if (!Runtime.LayoutEditor.IsGamePreview) + { + GL.Disable(EnableCap.AlphaTest); + GL.Disable(EnableCap.Blend); - GL.LineWidth(0.5f); - GL.Begin(PrimitiveType.LineLoop); - GL.Color4(Color.Green); - GL.Vertex2(x, y); - GL.Vertex2(x + w, y); - GL.Vertex2(x + w, y - h); - GL.Vertex2(x, y - h); - GL.End(); - GL.LineWidth(1f); + GL.LineWidth(0.5f); + GL.Begin(PrimitiveType.LineLoop); + GL.Color4(Color.Green); + GL.Vertex2(x, y); + GL.Vertex2(x + w, y); + GL.Vertex2(x + w, y - h); + GL.Vertex2(x, y - h); + GL.End(); + GL.LineWidth(1f); - GL.Enable(EnableCap.AlphaTest); - GL.Enable(EnableCap.Blend); + GL.Enable(EnableCap.AlphaTest); + GL.Enable(EnableCap.Blend); + } GL.Begin(PrimitiveType.Quads); GL.Color4(colors[0]); @@ -928,21 +931,30 @@ namespace LayoutBXLYT } else { - GL.PolygonMode(MaterialFace.Front, PolygonMode.Line); - GL.Enable(EnableCap.LineSmooth); - GL.LineWidth(1f); - GL.PolygonOffset(1f, 1f); + if (!Runtime.LayoutEditor.IsGamePreview) + { + GL.Disable(EnableCap.Blend); + GL.Disable(EnableCap.AlphaTest); - GL.Begin(PrimitiveType.Quads); - GL.Color4(Color.Green); - GL.Vertex2(rect.LeftPoint, rect.BottomPoint); - GL.Vertex2(rect.RightPoint, rect.BottomPoint); - GL.Vertex2(rect.RightPoint, rect.TopPoint); - GL.Vertex2(rect.LeftPoint, rect.TopPoint); - GL.End(); + GL.PolygonMode(MaterialFace.Front, PolygonMode.Line); + GL.Enable(EnableCap.LineSmooth); + GL.LineWidth(1f); + GL.PolygonOffset(1f, 1f); - GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); - GL.PolygonOffset(0f, 0f); + GL.Begin(PrimitiveType.Quads); + GL.Color4(Color.Green); + GL.Vertex2(rect.LeftPoint, rect.BottomPoint); + GL.Vertex2(rect.RightPoint, rect.BottomPoint); + GL.Vertex2(rect.RightPoint, rect.TopPoint); + GL.Vertex2(rect.LeftPoint, rect.TopPoint); + GL.End(); + + GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); + GL.PolygonOffset(0f, 0f); + + GL.Enable(EnableCap.Blend); + GL.Enable(EnableCap.AlphaTest); + } GL.Begin(PrimitiveType.Quads); GL.Color4(colors[0]); diff --git a/File_Format_Library/GUI/BFLYT/LayoutEditor.Designer.cs b/File_Format_Library/GUI/BFLYT/LayoutEditor.Designer.cs index 5e063231..1838a259 100644 --- a/File_Format_Library/GUI/BFLYT/LayoutEditor.Designer.cs +++ b/File_Format_Library/GUI/BFLYT/LayoutEditor.Designer.cs @@ -46,6 +46,7 @@ this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.renderInGamePreviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.textureListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.textConverterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.orthographicViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -53,6 +54,7 @@ this.displayyBoundryPanesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.displayWindowPanesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.displayPicturePanesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.displayGridToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.backColorDisplay)).BeginInit(); this.stToolStrip1.SuspendLayout(); this.stMenuStrip1.SuspendLayout(); @@ -211,6 +213,8 @@ // viewToolStripMenuItem // this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.renderInGamePreviewToolStripMenuItem, + this.displayGridToolStripMenuItem, this.textureListToolStripMenuItem, this.textConverterToolStripMenuItem, this.orthographicViewToolStripMenuItem, @@ -222,17 +226,25 @@ this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20); this.viewToolStripMenuItem.Text = "View"; // + // renderInGamePreviewToolStripMenuItem + // + this.renderInGamePreviewToolStripMenuItem.CheckOnClick = true; + this.renderInGamePreviewToolStripMenuItem.Name = "renderInGamePreviewToolStripMenuItem"; + this.renderInGamePreviewToolStripMenuItem.Size = new System.Drawing.Size(202, 22); + this.renderInGamePreviewToolStripMenuItem.Text = "Render In Game Preview"; + this.renderInGamePreviewToolStripMenuItem.Click += new System.EventHandler(this.renderInGamePreviewToolStripMenuItem_Click); + // // textureListToolStripMenuItem // this.textureListToolStripMenuItem.Name = "textureListToolStripMenuItem"; - this.textureListToolStripMenuItem.Size = new System.Drawing.Size(194, 22); + this.textureListToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.textureListToolStripMenuItem.Text = "Texture List"; this.textureListToolStripMenuItem.Click += new System.EventHandler(this.textureListToolStripMenuItem_Click); // // textConverterToolStripMenuItem // this.textConverterToolStripMenuItem.Name = "textConverterToolStripMenuItem"; - this.textConverterToolStripMenuItem.Size = new System.Drawing.Size(194, 22); + this.textConverterToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.textConverterToolStripMenuItem.Text = "Text Converter"; this.textConverterToolStripMenuItem.Click += new System.EventHandler(this.textConverterToolStripMenuItem_Click); // @@ -242,7 +254,7 @@ this.orthographicViewToolStripMenuItem.CheckOnClick = true; this.orthographicViewToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.orthographicViewToolStripMenuItem.Name = "orthographicViewToolStripMenuItem"; - this.orthographicViewToolStripMenuItem.Size = new System.Drawing.Size(194, 22); + this.orthographicViewToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.orthographicViewToolStripMenuItem.Text = "Orthographic View"; this.orthographicViewToolStripMenuItem.Click += new System.EventHandler(this.orthographicViewToolStripMenuItem_Click); // @@ -252,7 +264,7 @@ this.displayNullPanesToolStripMenuItem.CheckOnClick = true; this.displayNullPanesToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.displayNullPanesToolStripMenuItem.Name = "displayNullPanesToolStripMenuItem"; - this.displayNullPanesToolStripMenuItem.Size = new System.Drawing.Size(194, 22); + this.displayNullPanesToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.displayNullPanesToolStripMenuItem.Text = "Display Null Panes"; this.displayNullPanesToolStripMenuItem.Click += new System.EventHandler(this.displayPanesToolStripMenuItem_Click); // @@ -262,7 +274,7 @@ this.displayyBoundryPanesToolStripMenuItem.CheckOnClick = true; this.displayyBoundryPanesToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.displayyBoundryPanesToolStripMenuItem.Name = "displayyBoundryPanesToolStripMenuItem"; - this.displayyBoundryPanesToolStripMenuItem.Size = new System.Drawing.Size(194, 22); + this.displayyBoundryPanesToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.displayyBoundryPanesToolStripMenuItem.Text = "Display Boundry Panes"; this.displayyBoundryPanesToolStripMenuItem.Click += new System.EventHandler(this.displayPanesToolStripMenuItem_Click); // @@ -272,7 +284,7 @@ this.displayWindowPanesToolStripMenuItem.CheckOnClick = true; this.displayWindowPanesToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.displayWindowPanesToolStripMenuItem.Name = "displayWindowPanesToolStripMenuItem"; - this.displayWindowPanesToolStripMenuItem.Size = new System.Drawing.Size(194, 22); + this.displayWindowPanesToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.displayWindowPanesToolStripMenuItem.Text = "Display Window Panes"; this.displayWindowPanesToolStripMenuItem.Click += new System.EventHandler(this.displayPanesToolStripMenuItem_Click); // @@ -282,10 +294,18 @@ this.displayPicturePanesToolStripMenuItem.CheckOnClick = true; this.displayPicturePanesToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.displayPicturePanesToolStripMenuItem.Name = "displayPicturePanesToolStripMenuItem"; - this.displayPicturePanesToolStripMenuItem.Size = new System.Drawing.Size(194, 22); + this.displayPicturePanesToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.displayPicturePanesToolStripMenuItem.Text = "Display Picture Panes"; this.displayPicturePanesToolStripMenuItem.Click += new System.EventHandler(this.displayPanesToolStripMenuItem_Click); // + // displayGridToolStripMenuItem + // + this.displayGridToolStripMenuItem.CheckOnClick = true; + this.displayGridToolStripMenuItem.Name = "displayGridToolStripMenuItem"; + this.displayGridToolStripMenuItem.Size = new System.Drawing.Size(202, 22); + this.displayGridToolStripMenuItem.Text = "Display Grid"; + this.displayGridToolStripMenuItem.Click += new System.EventHandler(this.displayGridToolStripMenuItem_Click); + // // LayoutEditor // this.AllowDrop = true; @@ -341,5 +361,7 @@ private System.Windows.Forms.ToolStripMenuItem displayyBoundryPanesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem displayWindowPanesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem displayPicturePanesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem renderInGamePreviewToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem displayGridToolStripMenuItem; } } diff --git a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs index 9870a9dc..69490e08 100644 --- a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs +++ b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs @@ -65,6 +65,8 @@ namespace LayoutBXLYT displayyBoundryPanesToolStripMenuItem.Checked = Runtime.LayoutEditor.DisplayBoundryPane; displayPicturePanesToolStripMenuItem.Checked = Runtime.LayoutEditor.DisplayPicturePane; displayWindowPanesToolStripMenuItem.Checked = Runtime.LayoutEditor.DisplayWindowPane; + renderInGamePreviewToolStripMenuItem.Checked = Runtime.LayoutEditor.IsGamePreview; + displayGridToolStripMenuItem.Checked = Runtime.LayoutEditor.DisplayGrid; ObjectSelected += OnObjectSelected; ObjectChanged += OnObjectChanged; @@ -634,8 +636,19 @@ namespace LayoutBXLYT Runtime.LayoutEditor.DisplayPicturePane = displayPicturePanesToolStripMenuItem.Checked; Runtime.LayoutEditor.DisplayWindowPane = displayWindowPanesToolStripMenuItem.Checked; - if (ActiveViewport != null) - ActiveViewport.UpdateViewport(); + ActiveViewport?.UpdateViewport(); + } + + private void renderInGamePreviewToolStripMenuItem_Click(object sender, EventArgs e) + { + Runtime.LayoutEditor.IsGamePreview = renderInGamePreviewToolStripMenuItem.Checked; + ActiveViewport?.UpdateViewport(); + } + + private void displayGridToolStripMenuItem_Click(object sender, EventArgs e) + { + Runtime.LayoutEditor.DisplayGrid = displayGridToolStripMenuItem.Checked; + ActiveViewport?.UpdateViewport(); } } } diff --git a/File_Format_Library/GUI/BFLYT/LayoutViewer.cs b/File_Format_Library/GUI/BFLYT/LayoutViewer.cs index c68ed847..5ed28fb1 100644 --- a/File_Format_Library/GUI/BFLYT/LayoutViewer.cs +++ b/File_Format_Library/GUI/BFLYT/LayoutViewer.cs @@ -264,7 +264,7 @@ namespace LayoutBXLYT private void DrawDefaultPane(BasePane pane) { - if (!Runtime.LayoutEditor.DisplayNullPane) + if (!Runtime.LayoutEditor.DisplayNullPane || Runtime.LayoutEditor.IsGamePreview) return; Vector2[] TexCoords = new Vector2[] { @@ -376,6 +376,9 @@ namespace LayoutBXLYT private void DrawXyLines() { + if (Runtime.LayoutEditor.IsGamePreview) + return; + int lineLength = 20; GL.Color3(Color.Green); @@ -393,6 +396,9 @@ namespace LayoutBXLYT private void DrawGrid() { + if (!Runtime.LayoutEditor.DisplayGrid) + return; + var size = 40; var amount = 300; diff --git a/Switch_Toolbox_Library/Config.cs b/Switch_Toolbox_Library/Config.cs index 54cfcc08..cc87167d 100644 --- a/Switch_Toolbox_Library/Config.cs +++ b/Switch_Toolbox_Library/Config.cs @@ -270,6 +270,9 @@ namespace Toolbox.Library case "DisplayWindowPane": bool.TryParse(node.InnerText, out Runtime.LayoutEditor.DisplayWindowPane); break; + case "LayoutDisplayGrid": + bool.TryParse(node.InnerText, out Runtime.LayoutEditor.DisplayGrid); + break; } } @@ -389,6 +392,7 @@ namespace Toolbox.Library layoutSettingsNode.AppendChild(createNode(doc, "LayoutShadingMode", Runtime.LayoutEditor.Shading.ToString())); layoutSettingsNode.AppendChild(createNode(doc, "LayoutBackgroundColor", ColorTranslator.ToHtml(Runtime.LayoutEditor.BackgroundColor))); layoutSettingsNode.AppendChild(createNode(doc, "IsGamePreview", Runtime.LayoutEditor.IsGamePreview.ToString())); + layoutSettingsNode.AppendChild(createNode(doc, "LayoutDisplayGrid", Runtime.LayoutEditor.DisplayGrid.ToString())); layoutSettingsNode.AppendChild(createNode(doc, "DisplayNullPane", Runtime.LayoutEditor.DisplayNullPane.ToString())); layoutSettingsNode.AppendChild(createNode(doc, "DisplayBoundryPane", Runtime.LayoutEditor.DisplayBoundryPane.ToString())); layoutSettingsNode.AppendChild(createNode(doc, "DisplayPicturePane", Runtime.LayoutEditor.DisplayPicturePane.ToString())); diff --git a/Switch_Toolbox_Library/Runtime.cs b/Switch_Toolbox_Library/Runtime.cs index ef4c0050..b3e87557 100644 --- a/Switch_Toolbox_Library/Runtime.cs +++ b/Switch_Toolbox_Library/Runtime.cs @@ -47,6 +47,8 @@ namespace Toolbox.Library public static bool DisplayAlignmentPane = true; public static bool DisplayScissorPane = true; + public static bool DisplayGrid = true; + public static Color BackgroundColor = Color.FromArgb(130, 130, 130); public static DebugShading Shading = DebugShading.Default;