mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +00:00
Added paint selecting to visual mode (PR#248 by biwa)
This commit is contained in:
parent
148f3d69ba
commit
9f597a271c
8 changed files with 247 additions and 9 deletions
|
@ -1422,4 +1422,19 @@ 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;
|
||||
}
|
||||
|
|
|
@ -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,37 @@ 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.AdditiveSelect)
|
||||
{
|
||||
this.selected = true;
|
||||
mode.AddSelectedObject(this);
|
||||
}
|
||||
else if (General.Interface.CtrlState)
|
||||
{
|
||||
this.selected = false;
|
||||
mode.RemoveSelectedObject(this);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.selected)
|
||||
mode.RemoveSelectedObject(this);
|
||||
else
|
||||
mode.AddSelectedObject(this);
|
||||
|
||||
this.selected = !this.selected;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(!General.Map.UDMF) return; //mxd. Cannot change texture offsets in other map formats...
|
||||
|
||||
// Dragging UV?
|
||||
|
@ -968,6 +1000,34 @@ 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.AdditiveSelect)
|
||||
{
|
||||
this.selected = true;
|
||||
mode.AddSelectedObject(this);
|
||||
}
|
||||
else if (General.Interface.CtrlState)
|
||||
{
|
||||
this.selected = false;
|
||||
mode.RemoveSelectedObject(this);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.selected)
|
||||
mode.RemoveSelectedObject(this);
|
||||
else
|
||||
mode.AddSelectedObject(this);
|
||||
|
||||
this.selected = !this.selected;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -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,35 @@ 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.AdditiveSelect)
|
||||
{
|
||||
this.selected = true;
|
||||
mode.AddSelectedObject(this);
|
||||
}
|
||||
else if (General.Interface.CtrlState)
|
||||
{
|
||||
this.selected = false;
|
||||
mode.RemoveSelectedObject(this);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.selected)
|
||||
mode.RemoveSelectedObject(this);
|
||||
else
|
||||
mode.AddSelectedObject(this);
|
||||
|
||||
this.selected = !this.selected;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select button pressed?
|
||||
|
@ -1542,6 +1572,33 @@ 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.AdditiveSelect)
|
||||
{
|
||||
this.selected = true;
|
||||
mode.AddSelectedObject(this);
|
||||
}
|
||||
else if (General.Interface.CtrlState)
|
||||
{
|
||||
this.selected = false;
|
||||
mode.RemoveSelectedObject(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.selected)
|
||||
mode.RemoveSelectedObject(this);
|
||||
else
|
||||
mode.AddSelectedObject(this);
|
||||
|
||||
this.selected = !this.selected;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,66 @@ 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.AdditiveSelect)
|
||||
{
|
||||
this.selected = true;
|
||||
mode.AddSelectedObject(this);
|
||||
}
|
||||
else if (General.Interface.CtrlState)
|
||||
{
|
||||
this.selected = false;
|
||||
mode.RemoveSelectedObject(this);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.selected)
|
||||
mode.RemoveSelectedObject(this);
|
||||
else
|
||||
mode.AddSelectedObject(this);
|
||||
|
||||
this.selected = !this.selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// biwa
|
||||
public virtual void OnPaintSelectBegin()
|
||||
{
|
||||
mode.PaintSelectType = this.GetType();
|
||||
|
||||
// toggle selected state
|
||||
if (General.Interface.ShiftState ^ BuilderPlug.Me.AdditiveSelect)
|
||||
{
|
||||
this.selected = true;
|
||||
mode.AddSelectedObject(this);
|
||||
}
|
||||
else if (General.Interface.CtrlState)
|
||||
{
|
||||
this.selected = false;
|
||||
mode.RemoveSelectedObject(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.selected)
|
||||
mode.RemoveSelectedObject(this);
|
||||
else
|
||||
mode.AddSelectedObject(this);
|
||||
|
||||
this.selected = !this.selected;
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
public void SetAngle(int newangle)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 ""; }
|
||||
|
|
Loading…
Reference in a new issue