Add proper null checks

This commit is contained in:
KillzXGaming 2019-04-07 17:54:37 -04:00
parent 08b4f3296e
commit aecd4a0d7b
14 changed files with 92 additions and 47 deletions

Binary file not shown.

View file

@ -53,7 +53,15 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
[Category("Transform")]
public Vector3 Rotate
{
get { return new Vector3(this[N_Rotate]["X"], this[N_Rotate]["Y"], this[N_Rotate]["Z"]); ; }
get {
if (this[N_Rotate] == null)
return new Vector3(0, 0, 0);
return new Vector3(
this[N_Rotate]["X"] != null ? this[N_Rotate]["X"] : 0,
this[N_Rotate]["Y"] != null ? this[N_Rotate]["Y"] : 0,
this[N_Rotate]["Z"] != null ? this[N_Rotate]["Z"] : 0);
}
set
{
this[N_Rotate]["X"] = value.X;
@ -65,7 +73,16 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
[Category("Transform")]
public Vector3 Scale
{
get { return new Vector3(this[N_Scale]["X"], this[N_Scale]["Y"], this[N_Scale]["Z"]); ; }
get
{
if (this[N_Scale] == null)
return new Vector3(1, 1, 1);
return new Vector3(
this[N_Scale]["X"] != null ? this[N_Scale]["X"] : 1,
this[N_Scale]["Y"] != null ? this[N_Scale]["Y"] : 1,
this[N_Scale]["Z"] != null ? this[N_Scale]["Z"] : 1);
}
set
{
if (this[N_Scale] != null)
@ -80,7 +97,16 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
[Category("Transform")]
public Vector3 Translate
{
get { return new Vector3(this[N_Translate]["X"], this[N_Translate]["Y"], this[N_Translate]["Z"]); ; }
get
{
if (this[N_Translate] == null)
return new Vector3(0, 0, 0);
return new Vector3(
this[N_Translate]["X"] != null ? this[N_Translate]["X"] : 0,
this[N_Translate]["Y"] != null ? this[N_Translate]["Y"] : 0,
this[N_Translate]["Z"] != null ? this[N_Translate]["Z"] : 0);
}
set
{
this[N_Translate]["X"] = value.X;

View file

@ -32,13 +32,13 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
public int EnemyPathGroupId
{
get { return this[N_EnemyPathGroup]; }
get { return this[N_EnemyPathGroup] != null ? this[N_EnemyPathGroup] : -1; }
set { this[N_EnemyPathGroup] = value; }
}
public int UnitIdNum
{
get { return this[N_UnitIdNum]; }
get { return this[N_UnitIdNum] != null ? this[N_UnitIdNum] : -1; }
set { this[N_UnitIdNum] = value; }
}
@ -75,14 +75,14 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
[Category("Properties")]
public int BattleFlag
{
get { return this["BattleFlag"]; }
get { return this["BattleFlag"] != null ? this["BattleFlag"] : -1; }
set { this["BattleFlag"] = value; }
}
[Category("Properties")]
public int Priority
{
get { return this["Priority"]; }
get { return this["Priority"] != null ? this["Priority"] : -1; }
set { this["Priority"] = value; }
}

View file

@ -24,7 +24,7 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
foreach (var point in this["PathPt"])
{
PathPoints.Add(new EnemyPathPoint(point));
PathPoints.Add(new GlidePathPoint(point));
}
ConnectGroups = false;
@ -78,28 +78,28 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
[Category("Properties")]
public int GlideType
{
get { return this["GlideType"]; }
get { return (this["GlideType"] != null) ? this["GlideType"] : -1; }
set { this["GlideType"] = value; }
}
[Category("Properties")]
public bool IsUp
{
get { return this["IsUp"]; }
get { return (this["IsUp"] != null) ? this["IsUp"] : false; }
set { this["IsUp"] = value; }
}
[Category("Properties")]
public int Ascend
{
get { return this["Ascend"]; }
get { return (this["Ascend"] != null) ? this["Ascend"] : -1; }
set { this["Ascend"] = value; }
}
[Category("Properties")]
public bool Cannon
{
get { return this["Cannon"]; }
get { return (this["Cannon"] != null) ? this["Cannon"] : false; }
set { this["Cannon"] = value; }
}

View file

@ -23,7 +23,7 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
foreach (var point in this["PathPt"])
{
PathPoints.Add(new EnemyPathPoint(point));
PathPoints.Add(new ItemPathPoint(point));
}
}

View file

@ -23,7 +23,7 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
foreach (var point in this["PathPt"])
{
PathPoints.Add(new EnemyPathPoint(point));
PathPoints.Add(new SteerAssistPathPoint(point));
}
}

View file

@ -29,19 +29,20 @@
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitter1 = new System.Windows.Forms.Splitter();
this.stPanel2 = new Switch_Toolbox.Library.Forms.STPanel();
this.stPropertyGrid1 = new Switch_Toolbox.Library.Forms.STPropertyGrid();
this.splitter1 = new System.Windows.Forms.Splitter();
this.stPanel1 = new Switch_Toolbox.Library.Forms.STPanel();
this.treeView1 = new System.Windows.Forms.TreeView();
this.stButton2 = new Switch_Toolbox.Library.Forms.STButton();
this.stButton1 = new Switch_Toolbox.Library.Forms.STButton();
this.stTabControl1 = new Switch_Toolbox.Library.Forms.STTabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.stPanel4 = new Switch_Toolbox.Library.Forms.STPanel();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.stMenuStrip1 = new Switch_Toolbox.Library.Forms.STMenuStrip();
this.viewIntroCameraToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.stPanel4 = new Switch_Toolbox.Library.Forms.STPanel();
this.treeView1 = new System.Windows.Forms.TreeView();
this.stPanel3 = new Switch_Toolbox.Library.Forms.STPanel();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -50,6 +51,7 @@
this.stPanel1.SuspendLayout();
this.stTabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.stMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
@ -73,15 +75,6 @@
this.splitContainer1.SplitterDistance = 209;
this.splitContainer1.TabIndex = 1;
//
// splitter1
//
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter1.Location = new System.Drawing.Point(0, 419);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(209, 3);
this.splitter1.TabIndex = 1;
this.splitter1.TabStop = false;
//
// stPanel2
//
this.stPanel2.Controls.Add(this.stPropertyGrid1);
@ -101,6 +94,15 @@
this.stPropertyGrid1.Size = new System.Drawing.Size(209, 296);
this.stPropertyGrid1.TabIndex = 0;
//
// splitter1
//
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter1.Location = new System.Drawing.Point(0, 419);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(209, 3);
this.splitter1.TabIndex = 1;
this.splitter1.TabStop = false;
//
// stPanel1
//
this.stPanel1.Controls.Add(this.treeView1);
@ -112,6 +114,20 @@
this.stPanel1.Size = new System.Drawing.Size(209, 419);
this.stPanel1.TabIndex = 0;
//
// treeView1
//
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.treeView1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.treeView1.CheckBoxes = true;
this.treeView1.Location = new System.Drawing.Point(3, 3);
this.treeView1.Name = "treeView1";
this.treeView1.Size = new System.Drawing.Size(203, 381);
this.treeView1.TabIndex = 3;
this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck);
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
//
// stButton2
//
this.stButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@ -159,12 +175,21 @@
this.tabPage1.Text = "3D View";
this.tabPage1.UseVisualStyleBackColor = true;
//
// stPanel4
//
this.stPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.stPanel4.Location = new System.Drawing.Point(3, 3);
this.stPanel4.Name = "stPanel4";
this.stPanel4.Size = new System.Drawing.Size(726, 653);
this.stPanel4.TabIndex = 0;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.stPanel3);
this.tabPage2.Location = new System.Drawing.Point(4, 25);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(592, 433);
this.tabPage2.Size = new System.Drawing.Size(732, 659);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "2D View";
this.tabPage2.UseVisualStyleBackColor = true;
@ -186,27 +211,13 @@
this.viewIntroCameraToolStripMenuItem.Text = "View Intro Camera";
this.viewIntroCameraToolStripMenuItem.Click += new System.EventHandler(this.viewIntroCameraToolStripMenuItem_Click);
//
// stPanel4
// stPanel3
//
this.stPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.stPanel4.Location = new System.Drawing.Point(3, 3);
this.stPanel4.Name = "stPanel4";
this.stPanel4.Size = new System.Drawing.Size(726, 653);
this.stPanel4.TabIndex = 0;
//
// treeView1
//
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.treeView1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.treeView1.CheckBoxes = true;
this.treeView1.Location = new System.Drawing.Point(3, 3);
this.treeView1.Name = "treeView1";
this.treeView1.Size = new System.Drawing.Size(203, 381);
this.treeView1.TabIndex = 3;
this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck);
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
this.stPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.stPanel3.Location = new System.Drawing.Point(3, 3);
this.stPanel3.Name = "stPanel3";
this.stPanel3.Size = new System.Drawing.Size(726, 653);
this.stPanel3.TabIndex = 0;
//
// TurboMunntEditor
//
@ -224,6 +235,7 @@
this.stPanel1.ResumeLayout(false);
this.stTabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.stMenuStrip1.ResumeLayout(false);
this.stMenuStrip1.PerformLayout();
this.ResumeLayout(false);
@ -246,5 +258,6 @@
private System.Windows.Forms.TabPage tabPage2;
private Switch_Toolbox.Library.Forms.STPanel stPanel4;
private System.Windows.Forms.TreeView treeView1;
private Switch_Toolbox.Library.Forms.STPanel stPanel3;
}
}

View file

@ -16,6 +16,8 @@ namespace FirstPlugin.Forms
public partial class TurboMunntEditor : UserControl, IViewportContainer
{
Viewport viewport;
GLControl2D viewport2D;
bool IsLoaded = false;
public TurboMunntEditor()
@ -31,6 +33,10 @@ namespace FirstPlugin.Forms
viewport.Dock = DockStyle.Fill;
viewport.scene.SelectionChanged += Scene_SelectionChanged;
stPanel4.Controls.Add(viewport);
// viewport2D = new GLControl2D();
// viewport2D.Dock = DockStyle.Fill;
// stPanel3.Controls.Add(viewport2D);
}