mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-22 20:02:48 +00:00
Added paint selecting to visual mode (PR#248 by biwa)
This commit is contained in:
parent
5157dafd6a
commit
eaebf7ec1a
8 changed files with 242 additions and 5 deletions
|
@ -1390,4 +1390,18 @@ ceilingalignmode
|
|||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -449,6 +449,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public virtual void ApplyLowerUnpegged(bool set) { }
|
||||
protected abstract void MoveTextureOffset(int offsetx, int offsety);
|
||||
protected abstract Point GetTextureOffset();
|
||||
public virtual void OnPaintSelectEnd() { } // biwa
|
||||
|
||||
// Setup this plane
|
||||
public bool Setup() { return this.Setup(this.level, this.extrafloor); }
|
||||
|
@ -501,6 +502,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?
|
||||
|
@ -971,6 +1003,34 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
if(vs != null) vs.UpdateSectorGeometry(false);
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
|
|
@ -833,7 +833,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
protected abstract void MoveTextureOffset(int offsetx, int offsety);
|
||||
protected abstract Point GetTextureOffset();
|
||||
public virtual void OnTextureFit(FitTextureOptions options) { } //mxd
|
||||
|
||||
public virtual void OnPaintSelectEnd() { } // biwa
|
||||
|
||||
// Insert middle texture
|
||||
public virtual void OnInsert()
|
||||
{
|
||||
|
@ -1414,6 +1415,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?
|
||||
|
@ -1667,6 +1697,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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
#region ================== Constants
|
||||
// Object picking
|
||||
private const long PICK_INTERVAL = 80;
|
||||
private const long PICK_INTERVAL_PAINT_SELECT = 10; // biwa
|
||||
private const float PICK_RANGE = 0.98f;
|
||||
|
||||
// Gravity
|
||||
|
@ -94,6 +95,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private readonly List<ThingCopyData> copybuffer;
|
||||
private Type lasthighlighttype;
|
||||
|
||||
// biwa. Info for paint selection
|
||||
protected bool paintselectpressed;
|
||||
protected Type paintselecttype = null;
|
||||
protected IVisualPickable highlighted; // biwa
|
||||
|
||||
//mxd. Moved here from Tools
|
||||
private struct SidedefAlignJob
|
||||
{
|
||||
|
@ -159,6 +165,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public bool IsSingleSelection { get { return singleselection; } }
|
||||
public bool SelectionChanged { get { return selectionchanged; } set { selectionchanged |= value; } }
|
||||
|
||||
public bool PaintSelectPressed { get { return paintselectpressed; } } // biwa
|
||||
public Type PaintSelectType { get { return paintselecttype; } set { paintselecttype = value; } } // biwa
|
||||
public IVisualPickable Highlighted { get { return highlighted; } } // biwa
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
@ -1130,6 +1140,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Processing
|
||||
public override void OnProcess(long deltatime)
|
||||
{
|
||||
long pickinterval = PICK_INTERVAL; // biwa
|
||||
// Process things?
|
||||
base.ProcessThings = (BuilderPlug.Me.ShowVisualThings != 0);
|
||||
|
||||
|
@ -1203,9 +1214,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;
|
||||
|
@ -1443,6 +1458,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
|
||||
|
@ -3741,6 +3764,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.DisplayStatus(StatusType.Info, "Alpha-based textures highlighting is " + (BuilderPlug.Me.AlphaBasedTextureHighlighting ? "ENABLED" : "DISABLED"));
|
||||
}
|
||||
|
||||
// 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
|
||||
|
|
|
@ -646,7 +646,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() { }
|
||||
|
@ -665,7 +664,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void ApplyUpperUnpegged(bool set) { }
|
||||
public void ApplyLowerUnpegged(bool set) { }
|
||||
public void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd
|
||||
|
||||
public virtual void OnPaintSelectEnd() { } // biwa
|
||||
|
||||
// Return texture name
|
||||
public string GetTextureName() { return ""; }
|
||||
|
||||
|
@ -859,6 +859,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)
|
||||
{
|
||||
|
|
|
@ -262,6 +262,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void ApplyLowerUnpegged(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
|
||||
|
||||
|
|
|
@ -54,6 +54,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
void OnProcess(long 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(long deltatime) { }
|
||||
public void OnInsert() { }
|
||||
public void OnDelete() { }
|
||||
public void OnPaintSelectBegin() { } // biwa
|
||||
public void OnPaintSelectEnd() { } // biwa
|
||||
public void ApplyTexture(string texture) { }
|
||||
public void ApplyUpperUnpegged(bool set) { }
|
||||
public void ApplyLowerUnpegged(bool set) { }
|
||||
|
|
Loading…
Reference in a new issue