mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +00:00
Add quick sector/linedef tag increment/decrement actions
This commit is contained in:
parent
b45861bb39
commit
dbdb8bc931
4 changed files with 179 additions and 8 deletions
|
@ -82,6 +82,27 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Methods
|
||||
|
||||
public int CreateSelectionCRC()
|
||||
{
|
||||
CRC crc = new CRC();
|
||||
ICollection<Linedef> orderedselection = General.Map.Map.GetSelectedLinedefs(true);
|
||||
crc.Add(orderedselection.Count);
|
||||
foreach (Linedef l in orderedselection)
|
||||
{
|
||||
crc.Add(l.Index);
|
||||
}
|
||||
return (int)(crc.Value & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
//mxd. This makes a CRC for given selection
|
||||
private static int CreateSelectionCRC(ICollection<Linedef> selection)
|
||||
{
|
||||
CRC crc = new CRC();
|
||||
crc.Add(selection.Count);
|
||||
foreach (Linedef l in selection) crc.Add(l.Index);
|
||||
return (int)(crc.Value & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
// This highlights a new item
|
||||
private void Highlight(Linedef l)
|
||||
{
|
||||
|
@ -1932,6 +1953,68 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.DisplayStatus(StatusType.Warning, "This action requires a selection!");
|
||||
}
|
||||
|
||||
[BeginAction("incrementtag")]
|
||||
public void IncrementTag()
|
||||
{
|
||||
// Get selection
|
||||
ICollection<Linedef> selected = General.Map.Map.GetSelectedLinedefs(true);
|
||||
if (selected.Count == 0 && highlighted != null && !highlighted.IsDisposed)
|
||||
selected.Add(highlighted);
|
||||
|
||||
if (selected.Count == 0)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "This action requires a selection!");
|
||||
return;
|
||||
}
|
||||
|
||||
General.Map.UndoRedo.CreateUndo("Decrement linedef tags by 1", this, UndoGroup.LinedefTagChange, CreateSelectionCRC(selected));
|
||||
General.Interface.DisplayStatus(StatusType.Action, "Incremented tag" + (selected.Count > 1 ? "s of" : " of") + selected.Count + (selected.Count > 1 ? " linedefs by 1." : " linedef by 1."));
|
||||
|
||||
foreach (Linedef l in selected)
|
||||
{
|
||||
l.Tag = Math.Min(l.Tag + 1, 65535);
|
||||
l.UpdateCache();
|
||||
}
|
||||
|
||||
// Update
|
||||
General.Interface.RefreshInfo();
|
||||
General.Map.IsChanged = true;
|
||||
|
||||
// Redraw
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
||||
[BeginAction("decrementtag")]
|
||||
public void DecrementTag()
|
||||
{
|
||||
// Get selection
|
||||
ICollection<Linedef> selected = General.Map.Map.GetSelectedLinedefs(true);
|
||||
if (selected.Count == 0 && highlighted != null && !highlighted.IsDisposed)
|
||||
selected.Add(highlighted);
|
||||
|
||||
if (selected.Count == 0)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "This action requires a selection!");
|
||||
return;
|
||||
}
|
||||
|
||||
General.Map.UndoRedo.CreateUndo("Decrement linedef tags by 1", this, UndoGroup.LinedefTagChange, CreateSelectionCRC(selected));
|
||||
General.Interface.DisplayStatus(StatusType.Action, "Decremented tag" + (selected.Count > 1 ? "s of" : " of") + selected.Count + (selected.Count > 1 ? " linedefs by 1." : " linedef by 1."));
|
||||
|
||||
foreach (Linedef l in selected)
|
||||
{
|
||||
l.Tag = Math.Max(l.Tag - 1, 0);
|
||||
l.UpdateCache();
|
||||
}
|
||||
|
||||
// Update
|
||||
General.Interface.RefreshInfo();
|
||||
General.Map.IsChanged = true;
|
||||
|
||||
// Redraw
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -637,7 +637,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.ViewSelectionEffects);
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorSectors1);
|
||||
if (!General.Map.SRB2) General.Interface.AddButton(BuilderPlug.Me.MenusForm.MakeDoor); //mxd
|
||||
if (!General.Map.SRB2) General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorSectors2); //mxd
|
||||
if (!General.Map.SRB2) General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorSectors2); //mxd
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.MakeGradientBrightness);
|
||||
if(General.Map.UDMF) General.Interface.AddButton(BuilderPlug.Me.MenusForm.GradientModeMenu); //mxd
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.GradientInterpolationMenu); //mxd
|
||||
|
@ -711,9 +711,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(General.Map.UDMF) General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.TextureOffsetLock); //mxd
|
||||
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PlaceThings); //JBR
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PerpendicularVertex); //JBR
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PerpendicularLinedef); //JBR
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.ParallelLinedef); //JBR
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PerpendicularVertex); //JBR
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PerpendicularLinedef); //JBR
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.ParallelLinedef); //JBR
|
||||
|
||||
// Keep only sectors selected
|
||||
General.Map.Map.ClearSelectedLinedefs();
|
||||
|
@ -764,8 +764,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
renderer.RenderThingSet(General.Map.ThingsFilter.HiddenThings, Presentation.THINGS_HIDDEN_ALPHA);
|
||||
renderer.RenderThingSet(General.Map.ThingsFilter.VisibleThings, Presentation.THINGS_ALPHA);
|
||||
renderer.RenderNiGHTSPath();
|
||||
renderer.Finish();
|
||||
renderer.RenderNiGHTSPath();
|
||||
renderer.Finish();
|
||||
}
|
||||
|
||||
// Render overlay
|
||||
|
@ -2114,8 +2114,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
s.Fields.BeforeFieldsChange();
|
||||
float u = index / (float) (orderedselection.Count - 1);
|
||||
Color c = Color.FromArgb(0, General.Clamp(InterpolationTools.Interpolate(startColor.R, endColor.R, u, interpolationmode), 0, 255),
|
||||
General.Clamp(InterpolationTools.Interpolate(startColor.G, endColor.G, u, interpolationmode), 0, 255),
|
||||
General.Clamp(InterpolationTools.Interpolate(startColor.B, endColor.B, u, interpolationmode), 0, 255));
|
||||
General.Clamp(InterpolationTools.Interpolate(startColor.G, endColor.G, u, interpolationmode), 0, 255),
|
||||
General.Clamp(InterpolationTools.Interpolate(startColor.B, endColor.B, u, interpolationmode), 0, 255));
|
||||
|
||||
UniFields.SetInteger(s.Fields, key, c.ToArgb(), defaultvalue);
|
||||
s.UpdateNeeded = true;
|
||||
|
@ -2377,6 +2377,70 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
||||
[BeginAction("incrementtag")]
|
||||
public void IncrementTag()
|
||||
{
|
||||
// Get selection
|
||||
ICollection<Sector> selected = General.Map.Map.GetSelectedSectors(true);
|
||||
if (selected.Count == 0 && highlighted != null && !highlighted.IsDisposed)
|
||||
selected.Add(highlighted);
|
||||
|
||||
if (selected.Count == 0)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "This action requires a selection!");
|
||||
return;
|
||||
}
|
||||
|
||||
General.Map.UndoRedo.CreateUndo("Decrement sector tags by 1", this, UndoGroup.SectorTagChange, CreateSelectionCRC(selected));
|
||||
General.Interface.DisplayStatus(StatusType.Action, "Incremented tag" + (selected.Count > 1 ? "s of" : " of") + selected.Count + (selected.Count > 1 ? " sectors by 1." : " sector by 1."));
|
||||
|
||||
foreach (Sector s in selected)
|
||||
{
|
||||
s.Tag = Math.Min(s.Tag + 1, 65535);
|
||||
s.UpdateNeeded = true;
|
||||
s.UpdateCache();
|
||||
}
|
||||
|
||||
// Update
|
||||
General.Interface.RefreshInfo();
|
||||
General.Map.IsChanged = true;
|
||||
|
||||
// Redraw
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
||||
[BeginAction("decrementtag")]
|
||||
public void DecrementTag()
|
||||
{
|
||||
// Get selection
|
||||
ICollection<Sector> selected = General.Map.Map.GetSelectedSectors(true);
|
||||
if (selected.Count == 0 && highlighted != null && !highlighted.IsDisposed)
|
||||
selected.Add(highlighted);
|
||||
|
||||
if (selected.Count == 0)
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "This action requires a selection!");
|
||||
return;
|
||||
}
|
||||
|
||||
General.Map.UndoRedo.CreateUndo("Decrement sector tags by 1", this, UndoGroup.SectorTagChange, CreateSelectionCRC(selected));
|
||||
General.Interface.DisplayStatus(StatusType.Action, "Decremented tag" + (selected.Count > 1 ? "s of" : " of") + selected.Count + (selected.Count > 1 ? " sectors by 1." : " sector by 1."));
|
||||
|
||||
foreach (Sector s in selected)
|
||||
{
|
||||
s.Tag = Math.Max(s.Tag - 1, 0);
|
||||
s.UpdateNeeded = true;
|
||||
s.UpdateCache();
|
||||
}
|
||||
|
||||
// Update
|
||||
General.Interface.RefreshInfo();
|
||||
General.Map.IsChanged = true;
|
||||
|
||||
// Redraw
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
||||
// This clears the selection
|
||||
[BeginAction("clearselection", BaseAction = true)]
|
||||
public void ClearSelection()
|
||||
|
|
|
@ -35,5 +35,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public const int ThingAngleChange = 10; //mxd
|
||||
public const int ThingPitchChange = 11; //mxd
|
||||
public const int ThingRollChange = 12; //mxd
|
||||
public const int SectorTagChange = 13;
|
||||
public const int LinedefTagChange = 14;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -763,6 +763,28 @@ raisesectorgridsize
|
|||
repeat = true;
|
||||
}
|
||||
|
||||
incrementtag
|
||||
{
|
||||
title = "Increment tag of sector/linedef";
|
||||
category = "classic";
|
||||
description = "Increments the tag of all selected sectors or linedefs by 1.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
repeat = true;
|
||||
}
|
||||
|
||||
decrementtag
|
||||
{
|
||||
title = "Increment tag of sector/linedef";
|
||||
category = "classic";
|
||||
description = "Increments the tag of all selected sectors or linedefs by 1.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
repeat = true;
|
||||
}
|
||||
|
||||
//mxd
|
||||
lowersectortonearest
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue