Tag Range plugin: custom increment can now be set.

Tag Range plugin: tags can be set in relative mode (when this mode is enabled, generated values are added to existing tags instead of replacing them).
Updated documentation.
This commit is contained in:
MaxED 2014-08-12 08:13:46 +00:00
parent 2a880920d9
commit 9802b653d8
4 changed files with 195 additions and 57 deletions

View file

@ -151,6 +151,8 @@
</li>
<li>Line angle and front side direction are displayed when a line is drawn in Draw Geometry mode.</li>
<li><span class="style1"><strong>[new]</strong></span> <strong>[UDMF]</strong> Floor/ceiling texture offsets can be pinned using this button in the toolbar: <img src="general/pin_textures.jpg"/>. When pinned, textures will be aligned to a sector while it is dragged.</li>
<li><span class="style1"><strong>[new]</strong></span> <strong>Tag Range plugin</strong>: custom increment can now be set.</li>
<li><span class="style1"><strong>[new]</strong></span> <strong>Tag Range plugin:</strong> tags can be set in relative mode (when this mode is enabled, generated values are added to existing tags instead of replacing them).</li>
<li><span class="style1"><strong>[new]</strong></span> You can clear selection groups (default shortcuts are Ctrl-Shift-1 ... 0).</li>
<li><span class="style1"><strong>[new]</strong></span> You can add selection to groups, select and clear groups using <strong>Edit</strong> menu.
<input class="spoilerbutton" type="button" onclick="ToggleSpoiler(this);" href="javascript:void(0);" value="Show image"/>
@ -184,7 +186,7 @@
<li><span class="style1"><strong>[new]</strong></span> <strong>[UDMF]</strong> New actions: &quot;<strong>Align Ceiling Texture to Back Side</strong>&quot;, &quot;<strong>Align Ceiling Texture to Front Side</strong>&quot;, &quot;<strong>Align Floor Texture to Back Side</strong>&quot; and &quot;<strong>Align Floor Texture to Front Side</strong>&quot; (available in <strong>Linedefs -&gt; Align Textures</strong> menu).</li>
<li><span class="style1"><strong>[new]</strong></span> <strong>[UDMF]</strong> &quot;<strong>Make brightness gradient</strong>&quot; command is available in Linedefs mode.</li>
<li><strong>[UDMF]</strong> Linedef info panel: relative UDMF light values are shown like this: <span class="style7">16</span> (<span class="style9">128</span>), which means &quot;<span class="style7">UDMF light value</span>&quot; (&quot;<span class="style9">total surface brightness</span>&quot;). Total surface brightness is UDMF light value + sector brightness.</li>
<li><span class="style1"><strong>[new]</strong></span> When a linedef is within Split Linedefs range, it is highlighted using Info line color.</li>
<li><span class="style1"><strong>[new]</strong></span> Split Linedefs preview (a rectangle, colored using Info line color) is shown in this mode.</li>
<li><span class="style1"><strong>[new]</strong></span> &quot;<strong>Flip Linedefs</strong>&quot; action will try to align linedefs, so their front (or back) point towards the same sector.</li>
</ul>
</li>
@ -208,7 +210,7 @@
<h3><a name="vertices" id="vertices"></a>Vertices mode:</h3>
<ul>
<li><strong>[UDMF]</strong> Vertical offsets of a vertex can be edited in Vertex Edit form and are shown in Vertex Info panel.</li>
<li> When a linedef is within Split Linedefs range, it is highlighted using Info line color.</li>
<li><span class="style1"><strong>[new]</strong></span> Split Linedefs preview (a rectangle, colored using Info line color) is shown in this mode.</li>
</ul>
</li>
<li>

View file

@ -81,7 +81,7 @@ namespace CodeImp.DoomBuilder.TagRange
if(f.SelectionCount > 0)
f.ShowDialog(Form.ActiveForm);
else
General.Interface.MessageBeep(MessageBeepType.Default);
General.Interface.DisplayStatus(StatusType.Warning, "This action requires a selection!"); //mxd
f.Dispose();
}
}

View file

@ -37,6 +37,10 @@ namespace CodeImp.DoomBuilder.TagRange
this.outoftagswarning = new System.Windows.Forms.Label();
this.endtaglabel = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.rangestep = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.relativemode = new System.Windows.Forms.CheckBox();
this.bglabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// rangestart
@ -55,18 +59,19 @@ namespace CodeImp.DoomBuilder.TagRange
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(10, 17);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 14);
this.label1.Size = new System.Drawing.Size(62, 14);
this.label1.TabIndex = 1;
this.label1.Text = "Start Tag:";
this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// doubletagwarning
//
this.doubletagwarning.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.doubletagwarning.BackColor = System.Drawing.SystemColors.Info;
this.doubletagwarning.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.doubletagwarning.Location = new System.Drawing.Point(12, 45);
this.doubletagwarning.Location = new System.Drawing.Point(12, 94);
this.doubletagwarning.Name = "doubletagwarning";
this.doubletagwarning.Padding = new System.Windows.Forms.Padding(3);
this.doubletagwarning.Size = new System.Drawing.Size(273, 50);
@ -76,9 +81,10 @@ namespace CodeImp.DoomBuilder.TagRange
//
// skipdoubletags
//
this.skipdoubletags.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.skipdoubletags.AutoSize = true;
this.skipdoubletags.BackColor = System.Drawing.SystemColors.Info;
this.skipdoubletags.Location = new System.Drawing.Point(63, 69);
this.skipdoubletags.Location = new System.Drawing.Point(63, 118);
this.skipdoubletags.Name = "skipdoubletags";
this.skipdoubletags.Size = new System.Drawing.Size(161, 18);
this.skipdoubletags.TabIndex = 5;
@ -90,7 +96,7 @@ namespace CodeImp.DoomBuilder.TagRange
// okbutton
//
this.okbutton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.okbutton.Location = new System.Drawing.Point(186, 102);
this.okbutton.Location = new System.Drawing.Point(186, 151);
this.okbutton.Name = "okbutton";
this.okbutton.Size = new System.Drawing.Size(99, 26);
this.okbutton.TabIndex = 6;
@ -102,7 +108,7 @@ namespace CodeImp.DoomBuilder.TagRange
//
this.cancelbutton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.cancelbutton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelbutton.Location = new System.Drawing.Point(81, 102);
this.cancelbutton.Location = new System.Drawing.Point(81, 151);
this.cancelbutton.Name = "cancelbutton";
this.cancelbutton.Size = new System.Drawing.Size(99, 26);
this.cancelbutton.TabIndex = 7;
@ -112,14 +118,16 @@ namespace CodeImp.DoomBuilder.TagRange
//
// outoftagswarning
//
this.outoftagswarning.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.outoftagswarning.BackColor = System.Drawing.SystemColors.Info;
this.outoftagswarning.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.outoftagswarning.Location = new System.Drawing.Point(12, 45);
this.outoftagswarning.Location = new System.Drawing.Point(12, 94);
this.outoftagswarning.Name = "outoftagswarning";
this.outoftagswarning.Padding = new System.Windows.Forms.Padding(3);
this.outoftagswarning.Size = new System.Drawing.Size(273, 50);
this.outoftagswarning.TabIndex = 8;
this.outoftagswarning.Text = "The range exceeds the maximum allowed tags and cannot be created.";
this.outoftagswarning.Text = "The range exceeds the maximum or minimum allowed tags and cannot be created.";
this.outoftagswarning.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.outoftagswarning.Visible = false;
//
// endtaglabel
@ -140,13 +148,62 @@ namespace CodeImp.DoomBuilder.TagRange
this.label4.TabIndex = 9;
this.label4.Text = "End Tag:";
//
// label2
//
this.label2.Location = new System.Drawing.Point(10, 47);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(62, 14);
this.label2.TabIndex = 11;
this.label2.Text = "Increment:";
this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// rangestep
//
this.rangestep.AllowDecimal = false;
this.rangestep.AllowNegative = true;
this.rangestep.AllowRelative = false;
this.rangestep.ButtonStep = 1;
this.rangestep.ButtonStepFloat = 1F;
this.rangestep.Location = new System.Drawing.Point(76, 42);
this.rangestep.Name = "rangestep";
this.rangestep.Size = new System.Drawing.Size(96, 24);
this.rangestep.StepValues = null;
this.rangestep.TabIndex = 12;
this.rangestep.WhenTextChanged += new System.EventHandler(this.rangestep_WhenTextChanged);
//
// relativemode
//
this.relativemode.AutoSize = true;
this.relativemode.Location = new System.Drawing.Point(76, 72);
this.relativemode.Name = "relativemode";
this.relativemode.Size = new System.Drawing.Size(140, 18);
this.relativemode.TabIndex = 13;
this.relativemode.Text = "Relative to existing tags";
this.relativemode.UseVisualStyleBackColor = false;
this.relativemode.CheckedChanged += new System.EventHandler(this.relativemode_CheckedChanged);
//
// bglabel
//
this.bglabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bglabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.bglabel.Enabled = false;
this.bglabel.Location = new System.Drawing.Point(12, 94);
this.bglabel.Name = "bglabel";
this.bglabel.Padding = new System.Windows.Forms.Padding(3);
this.bglabel.Size = new System.Drawing.Size(273, 50);
this.bglabel.TabIndex = 14;
this.bglabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// TagRangeForm
//
this.AcceptButton = this.okbutton;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.CancelButton = this.cancelbutton;
this.ClientSize = new System.Drawing.Size(298, 134);
this.ClientSize = new System.Drawing.Size(298, 183);
this.Controls.Add(this.relativemode);
this.Controls.Add(this.rangestep);
this.Controls.Add(this.label2);
this.Controls.Add(this.endtaglabel);
this.Controls.Add(this.label4);
this.Controls.Add(this.cancelbutton);
@ -156,6 +213,7 @@ namespace CodeImp.DoomBuilder.TagRange
this.Controls.Add(this.label1);
this.Controls.Add(this.rangestart);
this.Controls.Add(this.outoftagswarning);
this.Controls.Add(this.bglabel);
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
@ -182,5 +240,9 @@ namespace CodeImp.DoomBuilder.TagRange
private System.Windows.Forms.Label outoftagswarning;
private System.Windows.Forms.Label endtaglabel;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label2;
private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox rangestep;
private System.Windows.Forms.CheckBox relativemode;
private System.Windows.Forms.Label bglabel;
}
}

View file

@ -12,6 +12,11 @@ namespace CodeImp.DoomBuilder.TagRange
private UniversalType selectiontype;
private int selectioncount;
Dictionary<int, bool> usedtags;
private List<int> initialtags; //mxd
//mxd. Persistent settings
private static int storedstep = 1;
private static bool storedrelative;
public int SelectionCount { get { return selectioncount; } }
@ -31,6 +36,8 @@ namespace CodeImp.DoomBuilder.TagRange
{
selectiontype = UniversalType.SectorTag;
ICollection<Sector> list = General.Map.Map.GetSelectedSectors(true);
initialtags = new List<int>(list.Count); //mxd
foreach(Sector element in list) initialtags.Add(element.Tag); //mxd
selectioncount = list.Count;
this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " sectors" : " sector");
}
@ -38,6 +45,8 @@ namespace CodeImp.DoomBuilder.TagRange
{
selectiontype = UniversalType.LinedefTag;
ICollection<Linedef> list = General.Map.Map.GetSelectedLinedefs(true);
initialtags = new List<int>(list.Count); //mxd
foreach(Linedef element in list) initialtags.Add(element.Tag); //mxd
selectioncount = list.Count;
this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " linedefs" : " linedef");
}
@ -45,6 +54,8 @@ namespace CodeImp.DoomBuilder.TagRange
{
selectiontype = UniversalType.ThingTag;
ICollection<Thing> list = General.Map.Map.GetSelectedThings(true);
initialtags = new List<int>(list.Count); //mxd
foreach(Thing element in list) initialtags.Add(element.Tag); //mxd
selectioncount = list.Count;
this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " things" : " thing");
}
@ -56,6 +67,13 @@ namespace CodeImp.DoomBuilder.TagRange
// Find the first unused tag to use as range start
int starttag = General.Map.Map.GetNewTag();
rangestart.Text = starttag.ToString();
//mxd. Apply saved settings
rangestep.Text = storedstep.ToString();
relativemode.Checked = storedrelative;
//mxd. Do useless stuff
if(General.Random(0, 255) > 230) bglabel.Text = "Creating tag ranges is fun! ^_^";
}
// Handler for finding a new tag
@ -65,16 +83,57 @@ namespace CodeImp.DoomBuilder.TagRange
}
// This creates a range
private List<int> CreateRange(int starttag, bool skipusedtags, out bool tagsused, out bool outoftags)
private List<int> CreateRange(int starttag, int increment, bool relative, bool skipusedtags, out bool tagsused, out bool outoftags)
{
List<int> newtags = new List<int>(selectioncount);
outoftags = false;
tagsused = false;
//mxd. Get relative tag range
if (relative)
{
int newtag;
// Go for the number of tags we need
for(int i = 0; i < selectioncount; i++)
{
if(starttag > General.Map.FormatInterface.MaxTag)
newtag = initialtags[i] + starttag;
if(newtag > General.Map.FormatInterface.MaxTag || newtag < General.Map.FormatInterface.MinTag)
{
outoftags = true;
return newtags;
}
if(skipusedtags)
{
// Find next unused tag
while(usedtags.ContainsKey(newtag))
{
if(newtag >= General.Map.FormatInterface.MaxTag || newtag <= General.Map.FormatInterface.MinTag)
{
outoftags = true;
return newtags;
}
starttag += increment; //mxd
}
}
else
{
tagsused |= usedtags.ContainsKey(newtag);
}
newtags.Add(newtag);
starttag += increment;
}
}
else //mxd. Get absolute tag range
{
// Go for the number of tags we need
for (int i = 0; i < selectioncount; i++)
{
if (starttag > General.Map.FormatInterface.MaxTag || starttag < General.Map.FormatInterface.MinTag)
{
outoftags = true;
return newtags;
@ -85,13 +144,13 @@ namespace CodeImp.DoomBuilder.TagRange
// Find next unused tag
while (usedtags.ContainsKey(starttag))
{
if(starttag == General.Map.FormatInterface.MaxTag)
if (starttag >= General.Map.FormatInterface.MaxTag || starttag <= General.Map.FormatInterface.MinTag)
{
outoftags = true;
return newtags;
}
starttag++;
starttag += increment; //mxd
}
}
else
@ -100,9 +159,8 @@ namespace CodeImp.DoomBuilder.TagRange
}
newtags.Add(starttag);
if(starttag < General.Map.FormatInterface.MaxTag)
starttag++;
starttag += increment; //mxd
}
}
return newtags;
@ -113,18 +171,17 @@ namespace CodeImp.DoomBuilder.TagRange
{
bool outoftags, tagsused;
int starttag = rangestart.GetResult(0);
int step = rangestep.GetResult(1); //mxd
List<int> tags = CreateRange(starttag, false, out tagsused, out outoftags);
List<int> tags = CreateRange(starttag, step, relativemode.Checked, skipdoubletags.Checked, out tagsused, out outoftags); //mxd
outoftagswarning.Visible = outoftags;
okbutton.Enabled = !outoftags;
doubletagwarning.Visible = tagsused && !outoftags;
skipdoubletags.Visible = tagsused && !outoftags;
skipdoubletags.BringToFront();
tags = CreateRange(starttag, skipdoubletags.Checked, out tagsused, out outoftags);
if(tags.Count > 0)
endtaglabel.Text = tags[tags.Count - 1].ToString();
if(tags.Count > 0) endtaglabel.Text = tags[tags.Count - 1].ToString();
}
// Range start changes
@ -138,8 +195,10 @@ namespace CodeImp.DoomBuilder.TagRange
{
bool outoftags, tagsused;
int starttag = rangestart.GetResult(0);
int step = rangestep.GetResult(1);
List<int> tags = CreateRange(starttag, skipdoubletags.Checked, out tagsused, out outoftags);
//mxd
List<int> tags = CreateRange(starttag, step, relativemode.Checked, skipdoubletags.Checked, out tagsused, out outoftags);
if(outoftags)
{
@ -153,29 +212,31 @@ namespace CodeImp.DoomBuilder.TagRange
General.Map.UndoRedo.CreateUndo("Set " + selectioncount + " sector tags");
ICollection<Sector> list = General.Map.Map.GetSelectedSectors(true);
int index = 0;
foreach(Sector s in list)
s.Tag = tags[index++];
foreach(Sector s in list) s.Tag = tags[index++];
}
else if(selectiontype == UniversalType.LinedefTag)
{
General.Map.UndoRedo.CreateUndo("Set " + selectioncount + " linedef tags");
ICollection<Linedef> list = General.Map.Map.GetSelectedLinedefs(true);
int index = 0;
foreach(Linedef l in list)
l.Tag = tags[index++];
foreach(Linedef l in list) l.Tag = tags[index++];
}
else if(selectiontype == UniversalType.ThingTag)
{
General.Map.UndoRedo.CreateUndo("Set " + selectioncount + " thing tags");
ICollection<Thing> list = General.Map.Map.GetSelectedThings(true);
int index = 0;
foreach(Thing t in list)
t.Tag = tags[index++];
}
foreach(Thing t in list) t.Tag = tags[index++];
}
//mxd. Store settings
storedstep = rangestep.GetResult(1);
storedrelative = relativemode.Checked;
//We are done here.
this.Close();
}
}
// Cancel clicked
private void cancelbutton_Click(object sender, EventArgs e)
@ -188,6 +249,19 @@ namespace CodeImp.DoomBuilder.TagRange
{
UpdateChanges();
}
//mxd
private void rangestep_WhenTextChanged(object sender, EventArgs e)
{
UpdateChanges();
}
//mxd
private void relativemode_CheckedChanged(object sender, EventArgs e)
{
rangestart.AllowNegative = relativemode.Checked;
UpdateChanges();
}
}
}