Add action for deselecting things, tweak other new actions

This commit is contained in:
spherallic 2023-04-27 02:23:27 +02:00
parent 9191c30126
commit 94887efa9a
6 changed files with 86 additions and 9 deletions

View file

@ -388,6 +388,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
BuilderPlug.Me.MenusForm.SyncronizeThingEditSectorsItem.Checked = BuilderPlug.Me.SyncronizeThingEdit;
}
// This keeps only the single-sided lines selected
[BeginAction("deselectthings")]
public void DeselectThings()
{
int counter = 0;
ICollection<Thing> selected = General.Map.Map.GetSelectedThings(true);
foreach (Thing t in selected)
{
t.Selected = false;
counter++;
}
UpdateSelectionInfo();
General.Interface.DisplayStatus(StatusType.Action, "Deselected things (" + counter + ")");
General.Interface.RedrawDisplay();
}
#endregion
}
}

View file

@ -2446,7 +2446,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
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)
{
@ -2454,6 +2453,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
l.UpdateCache();
}
if (selected.Count > 1)
General.Interface.DisplayStatus(StatusType.Action, "Incremented tags of " + selected.Count + " linedefs by 1.");
else
General.Interface.DisplayStatus(StatusType.Action, "Incremented tag of one linedef to " + selected.First().Tag + ".");
// Update
General.Map.Map.Update();
General.Interface.RedrawDisplay();
@ -2476,7 +2480,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
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)
{
@ -2484,6 +2487,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
l.UpdateCache();
}
if (selected.Count > 1)
General.Interface.DisplayStatus(StatusType.Action, "Decremented tags of " + selected.Count + " linedefs by 1.");
else
General.Interface.DisplayStatus(StatusType.Action, "Decremented tag of one linedef to " + selected.First().Tag + ".");
// Update
General.Map.Map.Update();
General.Interface.RedrawDisplay();

View file

@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Actions;
using CodeImp.DoomBuilder.BuilderModes.Interface;
@ -2623,7 +2624,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
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)
{
@ -2632,7 +2632,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
s.UpdateCache();
}
if (selected.Count > 1)
General.Interface.DisplayStatus(StatusType.Action, "Incremented tags of " + selected.Count + " sectors by 1.");
else
General.Interface.DisplayStatus(StatusType.Action, "Incremented tag of one sector to " + selected.First().Tag + ".");
// Update
UpdateSelectionInfo();
UpdateEffectLabels();
General.Map.Map.Update();
General.Interface.RedrawDisplay();
General.Interface.RefreshInfo();
@ -2654,7 +2661,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
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)
{
@ -2663,7 +2669,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
s.UpdateCache();
}
if (selected.Count > 1)
General.Interface.DisplayStatus(StatusType.Action, "Decremented tags of " + selected.Count + " sectors by 1.");
else
General.Interface.DisplayStatus(StatusType.Action, "Decremented tag of one sector to " + selected.First().Tag + ".");
// Update
UpdateSelectionInfo();
UpdateEffectLabels();
General.Map.Map.Update();
General.Interface.RedrawDisplay();
General.Interface.RefreshInfo();

View file

@ -1386,6 +1386,16 @@ deselectfofplanes
allowscroll = true;
}
deselectthings
{
title = "Deselect things";
category = "visual";
description = "Deselects all things from your selection in Visual Mode.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
placevisualstart
{
title = "Place Visual Mode Camera";

View file

@ -1058,7 +1058,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
public void OnRemoveFOFSelection()
public bool OnRemoveFOFSelection()
{
if (level != null)
{
@ -1068,8 +1068,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
selected = false;
mode.RemoveSelectedObject(this);
return true;
}
}
return false;
}
#endregion

View file

@ -33,6 +33,7 @@ using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.GZBuilder.Data;
using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.Data;
using System.Diagnostics;
#endregion
@ -4467,23 +4468,49 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
PreAction(UndoGroup.None);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, false, false, false);
int counter = 0;
foreach (IVisualEventReceiver i in objs)
{
if (i is VisualFloor)
{
VisualFloor vf = i as VisualFloor;
vf.OnRemoveFOFSelection();
if (vf.OnRemoveFOFSelection())
counter++;
}
if (i is VisualCeiling)
{
VisualCeiling vc = i as VisualCeiling;
vc.OnRemoveFOFSelection();
if (vc.OnRemoveFOFSelection())
counter++;
}
}
General.Interface.DisplayStatus(StatusType.Action, "Deselected FOF planes.");
General.Interface.DisplayStatus(StatusType.Action, "Deselected FOF planes (" + counter + ")");
General.Interface.RedrawDisplay();
UpdateSelectionInfo();
UpdateChangedObjects();
}
[BeginAction("deselectthings")]
public void DeselectThings()
{
PreAction(UndoGroup.None);
List<IVisualEventReceiver> objs = GetSelectedObjects(false, false, true, false);
int counter = 0;
foreach (IVisualEventReceiver i in objs)
{
if (i is VisualThing)
{
BaseVisualThing vt = i as BaseVisualThing;
vt.OnSelectEnd();
counter++;
}
}
General.Interface.DisplayStatus(StatusType.Action, "Deselected things (" + counter + ")");
General.Interface.RedrawDisplay();
UpdateSelectionInfo();
UpdateChangedObjects();