From 7503df47e5ae1e176e6c7c1512632e1c09724939 Mon Sep 17 00:00:00 2001 From: Rytrak Date: Tue, 24 May 2022 01:37:16 +0200 Subject: [PATCH] Fixed issue on light editor form when clicking on delete light, treenode becomes empty --- CodeWalker/Forms/ModelLightForm.Designer.cs | 32 +++++++++++++++++++++ CodeWalker/Forms/ModelLightForm.cs | 12 +++++++- CodeWalker/Forms/ModelLightForm.resx | 3 ++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/CodeWalker/Forms/ModelLightForm.Designer.cs b/CodeWalker/Forms/ModelLightForm.Designer.cs index 4a04eb8..85e004a 100644 --- a/CodeWalker/Forms/ModelLightForm.Designer.cs +++ b/CodeWalker/Forms/ModelLightForm.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ModelLightForm)); this.MainSplitContainer = new System.Windows.Forms.SplitContainer(); this.DuplicateLightButton = new System.Windows.Forms.Button(); @@ -120,6 +121,9 @@ this.MoveMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.RotateMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ScaleMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.LightMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); + this.newLightToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteLightToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.MainSplitContainer)).BeginInit(); this.MainSplitContainer.Panel1.SuspendLayout(); this.MainSplitContainer.Panel2.SuspendLayout(); @@ -140,6 +144,7 @@ ((System.ComponentModel.ISupportInitialize)(this.ColourGUpDown)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ColourRUpDown)).BeginInit(); this.MainMenu.SuspendLayout(); + this.LightMenuStrip.SuspendLayout(); this.SuspendLayout(); // // MainSplitContainer @@ -202,6 +207,7 @@ this.LightsTreeView.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.LightsTreeView.ContextMenuStrip = this.LightMenuStrip; this.LightsTreeView.FullRowSelect = true; this.LightsTreeView.HideSelection = false; this.LightsTreeView.Location = new System.Drawing.Point(3, 3); @@ -1213,6 +1219,28 @@ this.ScaleMenuItem.ToolTipText = "Scale"; this.ScaleMenuItem.Click += new System.EventHandler(this.ScaleMenuItem_Click); // + // LightMenuStrip + // + this.LightMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.newLightToolStripMenuItem, + this.deleteLightToolStripMenuItem}); + this.LightMenuStrip.Name = "LightMenuStrip"; + this.LightMenuStrip.Size = new System.Drawing.Size(138, 48); + // + // newLightToolStripMenuItem + // + this.newLightToolStripMenuItem.Name = "newLightToolStripMenuItem"; + this.newLightToolStripMenuItem.Size = new System.Drawing.Size(137, 22); + this.newLightToolStripMenuItem.Text = "New Light"; + this.newLightToolStripMenuItem.Click += new System.EventHandler(this.newLightToolStripMenuItem_Click); + // + // deleteLightToolStripMenuItem + // + this.deleteLightToolStripMenuItem.Name = "deleteLightToolStripMenuItem"; + this.deleteLightToolStripMenuItem.Size = new System.Drawing.Size(137, 22); + this.deleteLightToolStripMenuItem.Text = "Delete Light"; + this.deleteLightToolStripMenuItem.Click += new System.EventHandler(this.deleteLightToolStripMenuItem_Click); + // // ModelLightForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1247,6 +1275,7 @@ ((System.ComponentModel.ISupportInitialize)(this.ColourRUpDown)).EndInit(); this.MainMenu.ResumeLayout(false); this.MainMenu.PerformLayout(); + this.LightMenuStrip.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -1345,5 +1374,8 @@ private System.Windows.Forms.Button DeleteLightButton; private System.Windows.Forms.Button NewLightButton; private System.Windows.Forms.Button DuplicateLightButton; + private System.Windows.Forms.ContextMenuStrip LightMenuStrip; + private System.Windows.Forms.ToolStripMenuItem newLightToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem deleteLightToolStripMenuItem; } } \ No newline at end of file diff --git a/CodeWalker/Forms/ModelLightForm.cs b/CodeWalker/Forms/ModelLightForm.cs index be0aa12..58b25e5 100644 --- a/CodeWalker/Forms/ModelLightForm.cs +++ b/CodeWalker/Forms/ModelLightForm.cs @@ -385,7 +385,7 @@ namespace CodeWalker.Forms lights.Remove(selectedLight); FragDrawable.OwnerFragment.LightAttributes.data_items = lights.ToArray(); UpdateLightParams(); - LoadModel(Drawable); + LoadModel(FragDrawable); } else { @@ -1081,5 +1081,15 @@ namespace CodeWalker.Forms { } + + private void newLightToolStripMenuItem_Click(object sender, EventArgs e) + { + CreateLight(); + } + + private void deleteLightToolStripMenuItem_Click(object sender, EventArgs e) + { + DeleteLight(); + } } } diff --git a/CodeWalker/Forms/ModelLightForm.resx b/CodeWalker/Forms/ModelLightForm.resx index 7b5727d..d282b87 100644 --- a/CodeWalker/Forms/ModelLightForm.resx +++ b/CodeWalker/Forms/ModelLightForm.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 127, 17 + 17, 17