diff --git a/fTools.Designer.cs b/fTools.Designer.cs index 0728e0c..8568046 100644 --- a/fTools.Designer.cs +++ b/fTools.Designer.cs @@ -76,6 +76,7 @@ private void InitializeComponent() this.grpLineType = new System.Windows.Forms.GroupBox(); this.rLineTypeSpline = new System.Windows.Forms.RadioButton(); this.rLineTypeLinear = new System.Windows.Forms.RadioButton(); + this.chkUnusedOnly = new System.Windows.Forms.CheckBox(); this.groupBox2.SuspendLayout(); this.grpCreateThings.SuspendLayout(); this.panel3.SuspendLayout(); @@ -165,6 +166,7 @@ private void InitializeComponent() // // groupBox2 // + this.groupBox2.Controls.Add(this.chkUnusedOnly); this.groupBox2.Controls.Add(this.cmdRetag); this.groupBox2.Controls.Add(this.label12); this.groupBox2.Controls.Add(this.txtRetagStart); @@ -579,6 +581,16 @@ private void InitializeComponent() this.rLineTypeLinear.Text = "Linear"; this.rLineTypeLinear.UseVisualStyleBackColor = true; // + // chkUnusedOnly + // + this.chkUnusedOnly.AutoSize = true; + this.chkUnusedOnly.Location = new System.Drawing.Point(137, 12); + this.chkUnusedOnly.Name = "chkUnusedOnly"; + this.chkUnusedOnly.Size = new System.Drawing.Size(135, 17); + this.chkUnusedOnly.TabIndex = 3; + this.chkUnusedOnly.Text = "Use Only Unused TIDs"; + this.chkUnusedOnly.UseVisualStyleBackColor = true; + // // fTools // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -661,5 +673,6 @@ private void InitializeComponent() private System.Windows.Forms.GroupBox grpLineType; private System.Windows.Forms.RadioButton rLineTypeSpline; private System.Windows.Forms.RadioButton rLineTypeLinear; + private System.Windows.Forms.CheckBox chkUnusedOnly; } } \ No newline at end of file diff --git a/fTools.cs b/fTools.cs index b831a34..556b85a 100644 --- a/fTools.cs +++ b/fTools.cs @@ -20,6 +20,8 @@ public fTools(BuilderPlug p) { chkAdjustAngle.Checked = General.Settings.ReadPluginSetting("adjangle", true); chkAdjustPitch.Checked = General.Settings.ReadPluginSetting("adjpitch", true); + chkUnusedOnly.Checked = General.Settings.ReadPluginSetting("unusedonly", true); + txtUnitTime.Text = General.Settings.ReadPluginSetting("adjtics", 8).ToString(); txtUnitLength.Text = General.Settings.ReadPluginSetting("adjlen", 1024).ToString(); txtCreateType.Text = General.Settings.ReadPluginSetting("thingtype", 1).ToString(); @@ -572,27 +574,75 @@ private void cmdRetag_Click(object sender, EventArgs e) { return; } + if (!chkUnusedOnly.Checked && paths.Count > 1) { + MessageBox.Show("You may only have one path selected for retagging, when opting to clobber tids."); + return; + } + + General.Settings.WritePluginSetting("unusedonly", chkUnusedOnly.Checked); General.Map.UndoRedo.CreateUndo("Retag path"); - foreach (List path in paths) { - //filter interpolation points for faster lookup during path processing - List ip = new List(); - foreach(Thing t in General.Map.Map.Things) { - if (t.Type == 9070) - ip.Add(t); - } + //filter interpolation points for faster lookup during path processing + List ip = new List(); + List ip_specials = new List(); + List ip_movers = new List(); + foreach (Thing t in General.Map.Map.Things) { + if (t.Type == 9070) + ip.Add(t); + if (t.Type == 9075) + ip_specials.Add(t); + if (t.Type == 9071) //path follower + ip_movers.Add(t); + if (t.Type == 9072) //moving camera + ip_movers.Add(t); + if (t.Type == 9074) //actor mover + ip_movers.Add(t); + } + + void doretag(List path, int tid, bool unusedonly) + { //Retag each node in the path - foreach(PathNode node in path) { + int i = tid; + foreach (PathNode node in path) { int old = node.ID; - newtag = node.ID = GetNextUnusedTag(newtag); + if (unusedonly) { + tid = GetNextUnusedTag(tid); + } else { + tid = i; + } + node.ID = tid; //if any ip (anywhere) is pointing to this node, then update it if (old > 0) { - foreach(Thing t in ip) { - if (t.Args[3] == old) - t.Args[3] = newtag; + //Update any ip's pointing to this node + foreach (Thing t in ip) { + if (t.Args[3] == old) { + t.Args[3] = tid; + } + } + + //Update any assigned ip specials + foreach (Thing t in ip_specials) { + if (t.Tag == old) { + t.Tag = tid; + } + } + + //Update any assigned ip movers + foreach (Thing t in ip_movers) { + if (t.Args[0] == old) { + t.Args[0] = tid; + } } } + i++; + } + } + + foreach (List path in paths) { + doretag(path, newtag, true); + if (!chkUnusedOnly.Checked) { + doretag(path, newtag, false); } }