mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
- prevented showing editing dialog when EndEdit was the result of a BeginEdit action started from another mode (which is normal behavior and desired in some cases, such as dragging)
- implemented Accept action and corresponding OnAccept event for all editing modes
This commit is contained in:
parent
0d35ce0536
commit
8c777ca780
10 changed files with 134 additions and 76 deletions
|
@ -110,7 +110,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.OnEngage();
|
||||
|
||||
// Show toolbox window
|
||||
BuilderPlug.Me.CurveLinedefsForm.Show((Form)General.Interface, this);
|
||||
BuilderPlug.Me.CurveLinedefsForm.Show((Form)General.Interface);
|
||||
}
|
||||
|
||||
// Disenagaging
|
||||
|
@ -123,7 +123,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// This applies the curves and returns to the base mode
|
||||
public void Apply()
|
||||
public override void OnAccept()
|
||||
{
|
||||
// Create undo
|
||||
General.Map.UndoRedo.CreateUndo("Curve linedefs", UndoGroup.None, 0);
|
||||
|
|
|
@ -135,8 +135,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Map.ChangeMode(basemode);
|
||||
}
|
||||
|
||||
// Disenagaging
|
||||
public override void OnDisengage()
|
||||
// Accepted
|
||||
public override void OnAccept()
|
||||
{
|
||||
List<Vertex> newverts = new List<Vertex>();
|
||||
List<Vertex> intersectverts = new List<Vertex>();
|
||||
|
@ -145,17 +145,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
List<Sidedef> insidesides = new List<Sidedef>();
|
||||
List<Vertex> mergeverts = new List<Vertex>();
|
||||
List<Vertex> nonmergeverts = new List<Vertex>(General.Map.Map.Vertices);
|
||||
|
||||
MapSet map = General.Map.Map;
|
||||
|
||||
base.OnDisengage();
|
||||
|
||||
Cursor.Current = Cursors.AppStarting;
|
||||
|
||||
General.Settings.FindDefaultDrawSettings();
|
||||
|
||||
// When not cancelled and points have been drawn
|
||||
if(!cancelled && (points.Count > 0))
|
||||
// When points have been drawn
|
||||
if(points.Count > 0)
|
||||
{
|
||||
// Make undo for the draw
|
||||
General.Map.UndoRedo.CreateUndo("line draw", UndoGroup.None, 0);
|
||||
|
@ -523,6 +520,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Done
|
||||
Cursor.Current = Cursors.Default;
|
||||
|
||||
// Return to original mode
|
||||
Type t = basemode.GetType();
|
||||
basemode = (EditMode)Activator.CreateInstance(t);
|
||||
General.Map.ChangeMode(basemode);
|
||||
}
|
||||
|
||||
// This checks if the view offset/zoom changed and updates the check
|
||||
|
@ -781,8 +783,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("finishdraw")]
|
||||
public void FinishDraw()
|
||||
{
|
||||
// Just return to base mode, Disengage will be called automatically.
|
||||
General.Map.ChangeMode(basemode);
|
||||
// Accept the changes
|
||||
General.Map.AcceptMode();
|
||||
}
|
||||
|
||||
// When a key is released
|
||||
|
|
|
@ -54,6 +54,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Highlighted item
|
||||
private Linedef highlighted;
|
||||
|
||||
// Interface
|
||||
private bool editpressed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -256,6 +259,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Item highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
{
|
||||
// Edit pressed in this mode
|
||||
editpressed = true;
|
||||
|
||||
// Highlighted item not selected?
|
||||
if(!highlighted.Selected)
|
||||
{
|
||||
|
@ -282,6 +288,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Done editing
|
||||
protected override void OnEndEdit()
|
||||
{
|
||||
// Edit pressed in this mode?
|
||||
if(editpressed)
|
||||
{
|
||||
// Anything selected?
|
||||
ICollection<Linedef> selected = General.Map.Map.GetSelectedLinedefs(true);
|
||||
|
@ -296,7 +305,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Update entire display
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
editpressed = false;
|
||||
base.OnEndEdit();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Highlighted item
|
||||
private Sector highlighted;
|
||||
|
||||
// Interface
|
||||
private bool editpressed;
|
||||
|
||||
// The methods GetSelected* and MarkSelected* on the MapSet do not
|
||||
// retain the order in which items were selected.
|
||||
// This list keeps in order while sectors are selected/deselected.
|
||||
|
@ -319,6 +322,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Item highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
{
|
||||
// Edit pressed in this mode
|
||||
editpressed = true;
|
||||
|
||||
// Highlighted item not selected?
|
||||
if(!highlighted.Selected)
|
||||
{
|
||||
|
@ -344,6 +350,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Done editing
|
||||
protected override void OnEndEdit()
|
||||
{
|
||||
// Edit pressed in this mode?
|
||||
if(editpressed)
|
||||
{
|
||||
// Anything selected?
|
||||
ICollection<Sector> selected = General.Map.Map.GetSelectedSectors(true);
|
||||
|
@ -362,7 +371,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Update entire display
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
editpressed = false;
|
||||
base.OnEndEdit();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Highlighted item
|
||||
private Thing highlighted;
|
||||
|
||||
// Interface
|
||||
private bool editpressed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -227,6 +230,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Item highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
{
|
||||
// Edit pressed in this mode
|
||||
editpressed = true;
|
||||
|
||||
// Highlighted item not selected?
|
||||
if(!highlighted.Selected)
|
||||
{
|
||||
|
@ -251,6 +257,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Done editing
|
||||
protected override void OnEndEdit()
|
||||
{
|
||||
// Edit pressed in this mode?
|
||||
if(editpressed)
|
||||
{
|
||||
// Anything selected?
|
||||
ICollection<Thing> selected = General.Map.Map.GetSelectedThings(true);
|
||||
|
@ -265,7 +274,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Update entire display
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
editpressed = false;
|
||||
base.OnEndEdit();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Highlighted item
|
||||
protected Vertex highlighted;
|
||||
|
||||
// Interface
|
||||
private bool editpressed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -238,12 +241,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Start editing
|
||||
protected override void OnEdit()
|
||||
{
|
||||
// Edit pressed in this mode
|
||||
editpressed = true;
|
||||
|
||||
base.OnEdit();
|
||||
}
|
||||
|
||||
// Done editing
|
||||
protected override void OnEndEdit()
|
||||
{
|
||||
editpressed = false;
|
||||
base.OnEndEdit();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
#region ================== Variables
|
||||
|
||||
private CurveLinedefsMode mode;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -80,11 +78,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// This shows the window
|
||||
public void Show(Form owner, CurveLinedefsMode mode)
|
||||
public void Show(Form owner)
|
||||
{
|
||||
// Keep reference to mode
|
||||
this.mode = mode;
|
||||
|
||||
// First time showing?
|
||||
//if((this.Location.X == 0) && (this.Location.Y == 0))
|
||||
{
|
||||
|
@ -183,7 +178,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private void apply_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Apply now
|
||||
mode.Apply();
|
||||
General.Map.AcceptMode();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -163,6 +163,8 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// This forces the mode to cancel and return to the "parent" mode
|
||||
public virtual void OnCancel() { }
|
||||
|
||||
public virtual void OnAccept() { }
|
||||
|
||||
// Interface events
|
||||
public virtual void OnMouseClick(MouseEventArgs e) { }
|
||||
public virtual void OnMouseDoubleClick(MouseEventArgs e) { }
|
||||
|
|
|
@ -833,6 +833,16 @@ namespace CodeImp.DoomBuilder
|
|||
mode.OnCancel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This accepts the changes in the current mode.
|
||||
/// </summary>
|
||||
[BeginAction("acceptmode")]
|
||||
public void AcceptMode()
|
||||
{
|
||||
// Let the mode know
|
||||
mode.OnAccept();
|
||||
}
|
||||
|
||||
//
|
||||
// This changes the editing mode.
|
||||
// Order in which events occur for the old and new modes:
|
||||
|
|
|
@ -126,6 +126,15 @@ cancelmode
|
|||
allowscroll = true;
|
||||
}
|
||||
|
||||
acceptmode
|
||||
{
|
||||
title = "Edit: Accept Action";
|
||||
description = "Accepts the changes in the current action and switches back to normal editing mode.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
||||
classicselect
|
||||
{
|
||||
title = "2D: Select";
|
||||
|
|
Loading…
Reference in a new issue