Merge branch 'visualmode-paintselect' into 'master'

Paint selection in Visual Mode

See merge request STJr/ZoneBuilder!2
This commit is contained in:
sphere 2021-03-22 16:58:47 -04:00
commit f7234a36ef
15 changed files with 920 additions and 579 deletions

View file

@ -621,7 +621,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(l != highlighted)
{
//toggle selected state
if(General.Interface.ShiftState ^ BuilderPlug.Me.AdditiveSelect)
if(General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
l.Selected = true;
else if(General.Interface.CtrlState)
l.Selected = false;

View file

@ -1000,7 +1000,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
//toggle selected state
highlighted = s;
if(General.Interface.ShiftState ^ BuilderPlug.Me.AdditiveSelect)
if(General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
SelectSector(highlighted, true, true);
else if(General.Interface.CtrlState)
SelectSector(highlighted, false, true);
@ -1095,7 +1095,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
if(highlighted != null)
{
if(General.Interface.ShiftState ^ BuilderPlug.Me.AdditiveSelect)
if(General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
SelectSector(highlighted, true, true);
else if(General.Interface.CtrlState)
SelectSector(highlighted, false, true);

View file

@ -512,7 +512,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(t != highlighted)
{
//toggle selected state
if(General.Interface.ShiftState ^ BuilderPlug.Me.AdditiveSelect)
if(General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
t.Selected = true;
else if(General.Interface.CtrlState)
t.Selected = false;

View file

@ -437,7 +437,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(v != highlighted)
{
//toggle selected state
if(General.Interface.ShiftState ^ BuilderPlug.Me.AdditiveSelect)
if(General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
v.Selected = true;
else if(General.Interface.CtrlState)
v.Selected = false;

View file

@ -104,8 +104,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
private bool editnewthing;
private bool editnewsector;
private bool additiveselect;
private bool additivepaintselect;
private bool autoclearselection;
private bool dontusenodes;
private bool autoclearselection;
private bool visualmodeclearselection;
private string copiedtexture;
private string copiedflat;
@ -155,8 +156,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
public bool EditNewThing { get { return editnewthing; } }
public bool EditNewSector { get { return editnewsector; } }
public bool AdditiveSelect { get { return additiveselect; } }
public bool AdditivePaintSelect { get { return additivepaintselect; } }
public bool AutoClearSelection { get { return autoclearselection; } }
public bool DontUseNodes { get { return dontusenodes; } }
public bool AutoClearSelection { get { return autoclearselection; } }
public bool VisualModeClearSelection { get { return visualmodeclearselection; } }
public string CopiedTexture { get { return copiedtexture; } set { copiedtexture = value; } }
public string CopiedFlat { get { return copiedflat; } set { copiedflat = value; } }
@ -281,8 +283,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
editnewthing = General.Settings.ReadPluginSetting("editnewthing", true);
editnewsector = General.Settings.ReadPluginSetting("editnewsector", false);
additiveselect = General.Settings.ReadPluginSetting("additiveselect", false);
additivepaintselect = General.Settings.ReadPluginSetting("additivepaintselect", additiveselect); // use the same value as additiveselect by default
autoclearselection = General.Settings.ReadPluginSetting("autoclearselection", false);
dontusenodes = General.Settings.ReadPluginSetting("dontusenodes", false);
autoclearselection = General.Settings.ReadPluginSetting("autoclearselection", false);
visualmodeclearselection = General.Settings.ReadPluginSetting("visualmodeclearselection", false);
stitchrange = General.Settings.ReadPluginSetting("stitchrange", 20);
highlightrange = General.Settings.ReadPluginSetting("highlightrange", 20);

File diff suppressed because it is too large Load diff

View file

@ -46,8 +46,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
editnewthing.Checked = General.Settings.ReadPluginSetting("editnewthing", true);
editnewsector.Checked = General.Settings.ReadPluginSetting("editnewsector", false);
additiveselect.Checked = General.Settings.ReadPluginSetting("additiveselect", false);
additivepaintselect.Checked = General.Settings.ReadPluginSetting("additivepaintselect", additiveselect.Checked); // Use the same settign as additive select by default
stitchrange.Text = General.Settings.ReadPluginSetting("stitchrange", 20).ToString();
dontusenodes.Checked = General.Settings.ReadPluginSetting("dontusenodes", false);
stitchrange.Text = General.Settings.ReadPluginSetting("stitchrange", 20).ToString();
highlightrange.Text = General.Settings.ReadPluginSetting("highlightrange", 20).ToString();
highlightthingsrange.Text = General.Settings.ReadPluginSetting("highlightthingsrange", 10).ToString();
splitlinedefsrange.Text = General.Settings.ReadPluginSetting("splitlinedefsrange", 10).ToString();
@ -76,8 +77,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Settings.WritePluginSetting("editnewthing", editnewthing.Checked);
General.Settings.WritePluginSetting("editnewsector", editnewsector.Checked);
General.Settings.WritePluginSetting("additiveselect", additiveselect.Checked);
General.Settings.WritePluginSetting("additivepaintselect", additivepaintselect.Checked);
General.Settings.WritePluginSetting("stitchrange", stitchrange.GetResult(0));
General.Settings.WritePluginSetting("dontusenodes", dontusenodes.Checked);
General.Settings.WritePluginSetting("stitchrange", stitchrange.GetResult(0));
General.Settings.WritePluginSetting("highlightrange", highlightrange.GetResult(0));
General.Settings.WritePluginSetting("highlightthingsrange", highlightthingsrange.GetResult(0));
General.Settings.WritePluginSetting("splitlinedefsrange", splitlinedefsrange.GetResult(0));

View file

@ -1422,4 +1422,18 @@ togglecolormaps
allowmouse = true;
allowscroll = false;
default = 262211; //Alt+C
}
}
// biwa
visualpaintselect
{
title = "Paint Selection";
category = "visual";
description = "Selects or deselects items by dragging the mouse. Hold shift while dragging to toggle additive selection. Hold Ctrl while dragging to enable subtractive selection";
allowkeys = true;
allowmouse = true;
allowscroll = false;
disregardshift = true;
disregardcontrol = true;
disregardalt = true;
}

View file

@ -484,6 +484,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void ApplyLinedefFlag(string flag, bool set) { }
protected abstract void MoveTextureOffset(Point xy);
protected abstract Point GetTextureOffset();
public virtual void OnPaintSelectEnd() { } // biwa
// Setup this plane
public bool Setup() { return this.Setup(this.level, this.extrafloor); }
@ -536,6 +537,42 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Moving the mouse
public virtual void OnMouseMove(MouseEventArgs e)
{
// biwa. Paint selection going on?
if(mode.PaintSelectPressed)
{
// toggle selected state
if (mode.PaintSelectType == this.GetType().BaseType && mode.Highlighted != this) // using BaseType so that both floor and ceiling can be selected in one go
{
if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
{
if (!selected)
{
selected = true;
mode.AddSelectedObject(this);
}
}
else if (General.Interface.CtrlState)
{
if (selected)
{
selected = false;
mode.RemoveSelectedObject(this);
}
}
else
{
if (selected)
mode.RemoveSelectedObject(this);
else
mode.AddSelectedObject(this);
selected = !selected;
}
}
return;
}
if(!General.Map.UDMF) return; //mxd. Cannot change texture offsets in other map formats...
// Dragging UV?
@ -968,6 +1005,39 @@ namespace CodeImp.DoomBuilder.BuilderModes
ChangeTextureScale(incrementX, incrementY);
}
// biwa
public virtual void OnPaintSelectBegin()
{
mode.PaintSelectType = this.GetType().BaseType; // using BaseType so that both floor and ceiling can be selected in one go
// toggle selected state
if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
{
if (!selected)
{
selected = true;
mode.AddSelectedObject(this);
}
}
else if (General.Interface.CtrlState)
{
if (selected)
{
selected = false;
mode.RemoveSelectedObject(this);
}
}
else
{
if (selected)
mode.RemoveSelectedObject(this);
else
mode.AddSelectedObject(this);
selected = !selected;
}
}
#endregion
}

View file

@ -762,7 +762,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected abstract void MoveTextureOffset(Point xy);
protected abstract Point GetTextureOffset();
public virtual void OnTextureFit(FitTextureOptions options) { } //mxd
public virtual void OnPaintSelectEnd() { } // biwa
// Insert middle texture
public virtual void OnInsert()
{
@ -1282,6 +1283,40 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
UpdateDragUV();
}
else if (mode.PaintSelectPressed) // biwa. Paint selection going on?
{
if (mode.PaintSelectType == this.GetType().BaseType && mode.Highlighted != this) // using BaseType so that middle, upper, lower, etc can be selecting in one go
{
// toggle selected state
if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
{
if (!selected)
{
selected = true;
mode.AddSelectedObject(this);
}
}
else if (General.Interface.CtrlState)
{
if (selected)
{
selected = false;
mode.RemoveSelectedObject(this);
}
}
else
{
if (selected)
mode.RemoveSelectedObject(this);
else
mode.AddSelectedObject(this);
selected = !selected;
}
}
return;
}
else
{
// Select button pressed?
@ -1542,6 +1577,39 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode.SetActionResult("Wall scale changed to " + scaleX.ToString("F03", CultureInfo.InvariantCulture) + ", " + scaleY.ToString("F03", CultureInfo.InvariantCulture) + " (" + (int)Math.Round(Texture.Width / scaleX) + " x " + (int)Math.Round(Texture.Height / scaleY) + ").");
}
// biwa
public virtual void OnPaintSelectBegin()
{
mode.PaintSelectType = this.GetType().BaseType; // using BaseType so that middle, upper, lower, etc can be selecting in one go
// toggle selected state
if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
{
if (!selected)
{
selected = true;
mode.AddSelectedObject(this);
}
}
else if (General.Interface.CtrlState)
{
if (selected)
{
selected = false;
mode.RemoveSelectedObject(this);
}
}
else
{
if (selected)
mode.RemoveSelectedObject(this);
else
mode.AddSelectedObject(this);
selected = !selected;
}
}
#endregion
}
}

View file

@ -50,6 +50,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constants
// Object picking
private const float PICK_INTERVAL = 80.0f;
private const float PICK_INTERVAL_PAINT_SELECT = 10.0f; // biwa
private const float PICK_RANGE = 0.98f;
// Gravity
@ -99,8 +100,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
private BSP bsp;
private bool useblockmap;
//mxd. Moved here from Tools
private struct SidedefAlignJob
// biwa. Info for paint selection
protected bool paintselectpressed;
protected Type paintselecttype = null;
protected IVisualPickable highlighted; // biwa
//mxd. Moved here from Tools
private struct SidedefAlignJob
{
public Sidedef sidedef;
@ -170,9 +176,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
public BSP BSP { get { return bsp; } }
public bool UseBlockmap { get { return useblockmap; } }
#endregion
public bool PaintSelectPressed { get { return paintselectpressed; } } // biwa
public Type PaintSelectType { get { return paintselecttype; } set { paintselecttype = value; } } // biwa
public IVisualPickable Highlighted { get { return highlighted; } } // biwa
#region ================== Constructor / Disposer
#endregion
#region ================== Constructor / Disposer
// Constructor
public BaseVisualMode()
@ -1281,6 +1291,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Processing
public override void OnProcess(float deltatime)
{
float pickinterval = PICK_INTERVAL; // biwa
// Process things?
base.ProcessThings = (BuilderPlug.Me.ShowVisualThings != 0);
@ -1354,9 +1365,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
g.OnProcess(deltatime);
}
// biwa. Use a lower pick interval for paint selection, to make it more reliable
if (paintselectpressed)
pickinterval = PICK_INTERVAL_PAINT_SELECT;
// Time to pick a new target?
if(Clock.CurrentTime > (lastpicktime + PICK_INTERVAL))
if(Clock.CurrentTime > (lastpicktime + pickinterval))
{
PickTargetUnlocked();
lastpicktime = Clock.CurrentTime;
@ -1570,6 +1585,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
lasthighlighttype = o.GetType();
}
// biwa
if (o is NullVisualEventReceiver)
highlighted = null;
else if (o is VisualGeometry)
highlighted = (VisualGeometry)o;
else if (o is VisualThing)
highlighted = (VisualThing)o;
}
// Undo performed
@ -4058,6 +4081,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.DisplayStatus(StatusType.Action, "Toggled Slope for " + toUpdate.Count + (toUpdate.Count == 1 ? " surface." : " surfaces."));
}
// biwa
[BeginAction("visualpaintselect")]
protected virtual void OnPaintSelectBegin()
{
paintselectpressed = true;
GetTargetEventReceiver(true).OnPaintSelectBegin();
}
// biwa
[EndAction("visualpaintselect")]
protected virtual void OnPaintSelectEnd()
{
paintselectpressed = false;
paintselecttype = null;
GetTargetEventReceiver(true).OnPaintSelectEnd();
}
#endregion
#region ================== Texture Alignment

View file

@ -658,7 +658,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Unused
public void OnSelectBegin() { }
public void OnEditBegin() { }
public void OnMouseMove(MouseEventArgs e) { }
public void OnChangeTargetBrightness(bool up) { }
public void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { }
public void OnSelectTexture() { }
@ -678,7 +677,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void ApplyTexture(string texture) { }
public void ApplyLinedefFlag(string flag, bool set) { }
public void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd
public virtual void OnPaintSelectEnd() { } // biwa
// Return texture name
public string GetTextureName() { return ""; }
@ -890,6 +890,77 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.Changed = true;
}
// biwa. Moving the mouse
public virtual void OnMouseMove(MouseEventArgs e)
{
// biwa. Paint selection going on?
if (mode.PaintSelectPressed)
{
// toggle selected state
if (mode.PaintSelectType == this.GetType() && mode.Highlighted != this)
{
if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
{
if (!selected)
{
selected = true;
mode.AddSelectedObject(this);
}
}
else if (General.Interface.CtrlState)
{
if (selected)
{
selected = false;
mode.RemoveSelectedObject(this);
}
}
else
{
if (selected)
mode.RemoveSelectedObject(this);
else
mode.AddSelectedObject(this);
selected = !selected;
}
}
}
}
// biwa
public virtual void OnPaintSelectBegin()
{
mode.PaintSelectType = this.GetType();
// toggle selected state
if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditivePaintSelect)
{
if (!selected)
{
selected = true;
mode.AddSelectedObject(this);
}
}
else if (General.Interface.CtrlState)
{
if (selected)
{
selected = false;
mode.RemoveSelectedObject(this);
}
}
else
{
if (selected)
mode.RemoveSelectedObject(this);
else
mode.AddSelectedObject(this);
selected = !selected;
}
}
//mxd
public void SetAngle(int newangle)
{

View file

@ -263,6 +263,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void ApplyLinedefFlag(string flag, bool set) { }
public string GetTextureName() { return ""; }
public void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd
public virtual void OnPaintSelectBegin() { } // biwa
public virtual void OnPaintSelectEnd() { } // biwa
#endregion

View file

@ -53,6 +53,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
void OnProcess(float deltatime);
void OnInsert();
void OnDelete();
void OnPaintSelectBegin(); // biwa
void OnPaintSelectEnd(); // biwa
// Assist functions
void ApplyTexture(string texture);

View file

@ -53,6 +53,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void OnProcess(float deltatime) { }
public void OnInsert() { }
public void OnDelete() { }
public void OnPaintSelectBegin() { } // biwa
public void OnPaintSelectEnd() { } // biwa
public void ApplyTexture(string texture) { }
public void ApplyLinedefFlag(string flag, bool set) { }
public string GetTextureName() { return ""; }