mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2025-02-18 14:58:25 +00:00
Adjust how window panes load frame sizes to prevent divide zero errors.
This commit is contained in:
parent
f8d8d0ea30
commit
0a5b673d35
2 changed files with 103 additions and 38 deletions
File_Format_Library
|
@ -250,6 +250,16 @@ namespace LayoutBXLYT
|
|||
uint sizeY = (uint)pane.Height;
|
||||
|
||||
var window = (IWindowPane)pane;
|
||||
|
||||
ushort FrameRight = window.FrameElementRight;
|
||||
ushort FrameLeft = window.FrameElementLeft;
|
||||
ushort FrameBottom = window.FrameElementBottm;
|
||||
ushort FrameTop = window.FrameElementTop;
|
||||
if (FrameRight == 0) FrameRight = 1;
|
||||
if (FrameLeft == 0) FrameLeft = 1;
|
||||
if (FrameBottom == 0) FrameBottom = 1;
|
||||
if (FrameTop == 0) FrameTop = 1;
|
||||
|
||||
switch (window.WindowKind)
|
||||
{
|
||||
case WindowKind.Around:
|
||||
|
@ -270,8 +280,13 @@ namespace LayoutBXLYT
|
|||
|
||||
var image = Textures[texture];
|
||||
|
||||
uint contentWidth = sizeX - (uint)window.FrameElementRight - (uint)window.FrameElementLeft;
|
||||
uint contentHeight = sizeY - (uint)window.FrameElementTop - (uint)window.FrameElementBottm;
|
||||
FrameRight = (ushort)image.Width;
|
||||
FrameLeft = (ushort)image.Width;
|
||||
FrameTop = (ushort)image.Height;
|
||||
FrameBottom = (ushort)image.Height;
|
||||
|
||||
uint contentWidth = sizeX - (uint)FrameRight - (uint)FrameLeft;
|
||||
uint contentHeight = sizeY - (uint)FrameTop - (uint)FrameBottom;
|
||||
|
||||
RenderWindowContent(pane,
|
||||
contentWidth,
|
||||
|
@ -293,9 +308,9 @@ namespace LayoutBXLYT
|
|||
|
||||
GL.PushMatrix();
|
||||
{
|
||||
uint pieceWidth = sizeX - window.FrameElementRight;
|
||||
uint pieceHeight = window.FrameElementTop;
|
||||
int pieceX = (int)-(window.FrameElementRight / 2);
|
||||
uint pieceWidth = sizeX - FrameRight;
|
||||
uint pieceHeight = FrameTop;
|
||||
int pieceX = (int)-(FrameRight / 2);
|
||||
int pieceY = (int)((sizeY / 2) - (pieceHeight / 2));
|
||||
|
||||
GL.Translate(pieceX, pieceY, 0);
|
||||
|
@ -303,9 +318,9 @@ namespace LayoutBXLYT
|
|||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / window.FrameElementRight, 1);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / FrameRight, 1);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / window.FrameElementRight, 0);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / FrameRight, 0);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
|
@ -316,17 +331,17 @@ namespace LayoutBXLYT
|
|||
//Top Right
|
||||
GL.PushMatrix();
|
||||
{
|
||||
uint pieceWidth = window.FrameElementRight;
|
||||
uint pieceHeight = sizeY - window.FrameElementBottm;
|
||||
uint pieceWidth = FrameRight;
|
||||
uint pieceHeight = sizeY - FrameBottom;
|
||||
int pieceX = (int)((contentWidth / 2) + (pieceWidth / 2));
|
||||
int pieceY = (int)(window.FrameElementBottm / 2);
|
||||
int pieceY = (int)(FrameBottom / 2);
|
||||
|
||||
GL.Translate(pieceX, pieceY, 0);
|
||||
rect = pane.CreateRectangle(pieceWidth, pieceHeight);
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, pieceHeight / window.FrameElementBottm);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, pieceHeight / FrameBottom);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 1, pieceHeight / window.FrameElementBottm);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 1, pieceHeight / FrameBottom);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
|
@ -339,10 +354,10 @@ namespace LayoutBXLYT
|
|||
//Bottom Right
|
||||
GL.PushMatrix();
|
||||
{
|
||||
uint pieceWidth = window.FrameElementLeft;
|
||||
uint pieceHeight = sizeY - window.FrameElementTop;
|
||||
uint pieceWidth = FrameLeft;
|
||||
uint pieceHeight = sizeY - FrameTop;
|
||||
int pieceX = (int)-((contentWidth / 2) + (pieceWidth / 2));
|
||||
int pieceY = (int)-(window.FrameElementTop / 2);
|
||||
int pieceY = (int)-(FrameTop / 2);
|
||||
|
||||
GL.Translate(pieceX, pieceY, 0);
|
||||
rect = pane.CreateRectangle(pieceWidth, pieceHeight);
|
||||
|
@ -351,9 +366,9 @@ namespace LayoutBXLYT
|
|||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 1, 0);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 1, pieceHeight / window.FrameElementTop);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 1, pieceHeight / FrameTop);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, pieceHeight / window.FrameElementTop);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, pieceHeight / FrameTop);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.End();
|
||||
}
|
||||
|
@ -362,21 +377,21 @@ namespace LayoutBXLYT
|
|||
//Bottom Right
|
||||
GL.PushMatrix();
|
||||
{
|
||||
uint pieceWidth = sizeX - window.FrameElementLeft;
|
||||
uint pieceHeight = window.FrameElementBottm;
|
||||
int pieceX = (int)(window.FrameElementLeft / 2);
|
||||
uint pieceWidth = sizeX - FrameLeft;
|
||||
uint pieceHeight = FrameBottom;
|
||||
int pieceX = (int)(FrameLeft / 2);
|
||||
int pieceY = (int)(-(sizeY / 2) + (pieceHeight / 2));
|
||||
|
||||
GL.Translate(pieceX, pieceY, 0);
|
||||
rect = pane.CreateRectangle(pieceWidth, pieceHeight);
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / window.FrameElementLeft, 1);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / FrameLeft, 1);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / window.FrameElementLeft, 0);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / FrameLeft, 0);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.End();
|
||||
}
|
||||
|
@ -396,8 +411,8 @@ namespace LayoutBXLYT
|
|||
var frame3 = window.WindowFrames[0];
|
||||
var frame4 = window.WindowFrames[0];
|
||||
|
||||
uint contentWidth = sizeX - (uint)window.FrameElementRight - (uint)window.FrameElementLeft;
|
||||
uint contentHeight = sizeY - (uint)window.FrameElementTop - (uint)window.FrameElementBottm;
|
||||
uint contentWidth = sizeX - (uint)FrameRight - (uint)FrameLeft;
|
||||
uint contentHeight = sizeY - (uint)FrameTop - (uint)FrameBottom;
|
||||
|
||||
RenderWindowContent(pane,
|
||||
contentWidth,
|
||||
|
|
|
@ -42,13 +42,17 @@
|
|||
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.clearWorkspaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveAnimationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.viewToolStripMenuItem = 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();
|
||||
this.saveAnimationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.displayNullPanesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.displayWindowPanesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.displayyBoundryPanesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.displayPicturePanesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.backColorDisplay)).BeginInit();
|
||||
this.stToolStrip1.SuspendLayout();
|
||||
this.stMenuStrip1.SuspendLayout();
|
||||
|
@ -166,28 +170,35 @@
|
|||
// openToolStripMenuItem
|
||||
//
|
||||
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
|
||||
this.openToolStripMenuItem.Text = "Open";
|
||||
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
|
||||
//
|
||||
// clearWorkspaceToolStripMenuItem
|
||||
//
|
||||
this.clearWorkspaceToolStripMenuItem.Name = "clearWorkspaceToolStripMenuItem";
|
||||
this.clearWorkspaceToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.clearWorkspaceToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
|
||||
this.clearWorkspaceToolStripMenuItem.Text = "Clear Files";
|
||||
this.clearWorkspaceToolStripMenuItem.Click += new System.EventHandler(this.clearWorkspaceToolStripMenuItem_Click);
|
||||
//
|
||||
// saveToolStripMenuItem1
|
||||
//
|
||||
this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1";
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(157, 22);
|
||||
this.saveToolStripMenuItem1.Text = "Save Layout";
|
||||
this.saveToolStripMenuItem1.Click += new System.EventHandler(this.saveToolStripMenuItem1_Click);
|
||||
//
|
||||
// saveAnimationToolStripMenuItem
|
||||
//
|
||||
this.saveAnimationToolStripMenuItem.Name = "saveAnimationToolStripMenuItem";
|
||||
this.saveAnimationToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
|
||||
this.saveAnimationToolStripMenuItem.Text = "Save Animation";
|
||||
this.saveAnimationToolStripMenuItem.Click += new System.EventHandler(this.saveAnimationToolStripMenuItem_Click);
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(157, 22);
|
||||
this.saveToolStripMenuItem.Text = "Save As";
|
||||
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
|
||||
//
|
||||
|
@ -202,7 +213,11 @@
|
|||
this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.textureListToolStripMenuItem,
|
||||
this.textConverterToolStripMenuItem,
|
||||
this.orthographicViewToolStripMenuItem});
|
||||
this.orthographicViewToolStripMenuItem,
|
||||
this.displayNullPanesToolStripMenuItem,
|
||||
this.displayyBoundryPanesToolStripMenuItem,
|
||||
this.displayWindowPanesToolStripMenuItem,
|
||||
this.displayPicturePanesToolStripMenuItem});
|
||||
this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
|
||||
this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
|
||||
this.viewToolStripMenuItem.Text = "View";
|
||||
|
@ -210,31 +225,62 @@
|
|||
// textureListToolStripMenuItem
|
||||
//
|
||||
this.textureListToolStripMenuItem.Name = "textureListToolStripMenuItem";
|
||||
this.textureListToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
|
||||
this.textureListToolStripMenuItem.Size = new System.Drawing.Size(200, 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(173, 22);
|
||||
this.textConverterToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||
this.textConverterToolStripMenuItem.Text = "Text Converter";
|
||||
this.textConverterToolStripMenuItem.Click += new System.EventHandler(this.textConverterToolStripMenuItem_Click);
|
||||
//
|
||||
// orthographicViewToolStripMenuItem
|
||||
//
|
||||
this.orthographicViewToolStripMenuItem.Checked = true;
|
||||
this.orthographicViewToolStripMenuItem.CheckOnClick = true;
|
||||
this.orthographicViewToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.orthographicViewToolStripMenuItem.Name = "orthographicViewToolStripMenuItem";
|
||||
this.orthographicViewToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
|
||||
this.orthographicViewToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||
this.orthographicViewToolStripMenuItem.Text = "Orthographic View";
|
||||
this.orthographicViewToolStripMenuItem.Click += new System.EventHandler(this.orthographicViewToolStripMenuItem_Click);
|
||||
//
|
||||
// saveAnimationToolStripMenuItem
|
||||
// displayNullPanesToolStripMenuItem
|
||||
//
|
||||
this.saveAnimationToolStripMenuItem.Name = "saveAnimationToolStripMenuItem";
|
||||
this.saveAnimationToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveAnimationToolStripMenuItem.Text = "Save Animation";
|
||||
this.saveAnimationToolStripMenuItem.Click += new System.EventHandler(this.saveAnimationToolStripMenuItem_Click);
|
||||
this.displayNullPanesToolStripMenuItem.Checked = true;
|
||||
this.displayNullPanesToolStripMenuItem.CheckOnClick = true;
|
||||
this.displayNullPanesToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.displayNullPanesToolStripMenuItem.Name = "displayNullPanesToolStripMenuItem";
|
||||
this.displayNullPanesToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||
this.displayNullPanesToolStripMenuItem.Text = "Display Null Panes";
|
||||
//
|
||||
// displayWindowPanesToolStripMenuItem
|
||||
//
|
||||
this.displayWindowPanesToolStripMenuItem.Checked = true;
|
||||
this.displayWindowPanesToolStripMenuItem.CheckOnClick = true;
|
||||
this.displayWindowPanesToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.displayWindowPanesToolStripMenuItem.Name = "displayWindowPanesToolStripMenuItem";
|
||||
this.displayWindowPanesToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||
this.displayWindowPanesToolStripMenuItem.Text = "Display Window Panes";
|
||||
//
|
||||
// displayyBoundryPanesToolStripMenuItem
|
||||
//
|
||||
this.displayyBoundryPanesToolStripMenuItem.Checked = true;
|
||||
this.displayyBoundryPanesToolStripMenuItem.CheckOnClick = true;
|
||||
this.displayyBoundryPanesToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.displayyBoundryPanesToolStripMenuItem.Name = "displayyBoundryPanesToolStripMenuItem";
|
||||
this.displayyBoundryPanesToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||
this.displayyBoundryPanesToolStripMenuItem.Text = "Displayy Boundry Panes";
|
||||
//
|
||||
// displayPicturePanesToolStripMenuItem
|
||||
//
|
||||
this.displayPicturePanesToolStripMenuItem.Checked = true;
|
||||
this.displayPicturePanesToolStripMenuItem.CheckOnClick = true;
|
||||
this.displayPicturePanesToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.displayPicturePanesToolStripMenuItem.Name = "displayPicturePanesToolStripMenuItem";
|
||||
this.displayPicturePanesToolStripMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||
this.displayPicturePanesToolStripMenuItem.Text = "Display Picture Panes";
|
||||
//
|
||||
// LayoutEditor
|
||||
//
|
||||
|
@ -287,5 +333,9 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem orthographicViewToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripButton toolstripOrthoBtn;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveAnimationToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem displayNullPanesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem displayyBoundryPanesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem displayWindowPanesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem displayPicturePanesToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue