mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-07 08:21:59 +00:00
- removed some unneeded code
- finished CurveLinedefsMode (except for Anders_A's code) - added public method to cancel editing modes
This commit is contained in:
parent
df4ad6d2e0
commit
d72ebc4330
7 changed files with 88 additions and 27 deletions
|
@ -100,7 +100,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
// Cancel base class
|
// Cancel base class
|
||||||
base.OnCancel();
|
base.OnCancel();
|
||||||
|
|
||||||
// Return to vertices mode
|
// Return to base mode
|
||||||
General.Map.ChangeMode(basemode);
|
General.Map.ChangeMode(basemode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,10 +110,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
base.OnEngage();
|
base.OnEngage();
|
||||||
|
|
||||||
// Show toolbox window
|
// Show toolbox window
|
||||||
BuilderPlug.Me.CurveLinedefsForm.Show(General.Interface);
|
BuilderPlug.Me.CurveLinedefsForm.Show((Form)General.Interface, this);
|
||||||
|
|
||||||
// Keep focus on main window
|
|
||||||
General.Interface.Focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disenagaging
|
// Disenagaging
|
||||||
|
@ -123,9 +120,45 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
|
|
||||||
// Hide toolbox window
|
// Hide toolbox window
|
||||||
BuilderPlug.Me.CurveLinedefsForm.Hide();
|
BuilderPlug.Me.CurveLinedefsForm.Hide();
|
||||||
|
}
|
||||||
|
|
||||||
// Hide highlight info
|
// This applies the curves and returns to the base mode
|
||||||
General.Interface.HideInfo();
|
public void Apply()
|
||||||
|
{
|
||||||
|
// Create undo
|
||||||
|
General.Map.UndoRedo.CreateUndo("Curve linedefs", UndoGroup.None, 0);
|
||||||
|
|
||||||
|
// Go for all selected lines
|
||||||
|
foreach(Linedef ld in selectedlines)
|
||||||
|
{
|
||||||
|
// Make curve for line
|
||||||
|
List<Vector2D> points = GenerateCurve(ld);
|
||||||
|
if(points.Count > 0)
|
||||||
|
{
|
||||||
|
// TODO: We may want some sector create/join code in here
|
||||||
|
// to allow curves that overlap lines and some geometry merging
|
||||||
|
|
||||||
|
// Go for all points to split the line
|
||||||
|
Linedef splitline = ld;
|
||||||
|
for(int i = 0; i < points.Count; i++)
|
||||||
|
{
|
||||||
|
// Make vertex
|
||||||
|
Vertex v = General.Map.Map.CreateVertex(points[i]);
|
||||||
|
|
||||||
|
// Split the line and move on with this line
|
||||||
|
splitline = splitline.Split(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Snap to map format accuracy
|
||||||
|
General.Map.Map.SnapAllToAccuracy();
|
||||||
|
|
||||||
|
// Update caches
|
||||||
|
General.Map.Map.Update();
|
||||||
|
|
||||||
|
// Return to base mode
|
||||||
|
General.Map.ChangeMode(basemode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This generates the vertices to split the line with, from start to end
|
// This generates the vertices to split the line with, from start to end
|
||||||
|
|
|
@ -330,9 +330,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
Cursor.Current = Cursors.Default;
|
Cursor.Current = Cursors.Default;
|
||||||
General.Map.IsChanged = true;
|
General.Map.IsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide highlight info
|
|
||||||
General.Interface.HideInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This checks if the view offset/zoom changed and updates the check
|
// This checks if the view offset/zoom changed and updates the check
|
||||||
|
|
|
@ -521,9 +521,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
General.Map.IsChanged = true;
|
General.Map.IsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide highlight info
|
|
||||||
General.Interface.HideInfo();
|
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
Cursor.Current = Cursors.Default;
|
Cursor.Current = Cursors.Default;
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
this.cancel.TabIndex = 22;
|
this.cancel.TabIndex = 22;
|
||||||
this.cancel.Text = "Cancel";
|
this.cancel.Text = "Cancel";
|
||||||
this.cancel.UseVisualStyleBackColor = true;
|
this.cancel.UseVisualStyleBackColor = true;
|
||||||
|
this.cancel.Click += new System.EventHandler(this.cancel_Click);
|
||||||
//
|
//
|
||||||
// apply
|
// apply
|
||||||
//
|
//
|
||||||
|
@ -161,6 +162,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
this.apply.TabIndex = 21;
|
this.apply.TabIndex = 21;
|
||||||
this.apply.Text = "OK";
|
this.apply.Text = "OK";
|
||||||
this.apply.UseVisualStyleBackColor = true;
|
this.apply.UseVisualStyleBackColor = true;
|
||||||
|
this.apply.Click += new System.EventHandler(this.apply_Click);
|
||||||
//
|
//
|
||||||
// circular
|
// circular
|
||||||
//
|
//
|
||||||
|
|
|
@ -38,6 +38,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
{
|
{
|
||||||
public partial class CurveLinedefsForm : DelayedForm
|
public partial class CurveLinedefsForm : DelayedForm
|
||||||
{
|
{
|
||||||
|
#region ================== Variables
|
||||||
|
|
||||||
|
private CurveLinedefsMode mode;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
|
||||||
public int Vertices { get { return verticesbar.Value; } }
|
public int Vertices { get { return verticesbar.Value; } }
|
||||||
|
@ -67,24 +73,27 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
// User closing the window?
|
// User closing the window?
|
||||||
if(e.CloseReason == CloseReason.UserClosing)
|
if(e.CloseReason == CloseReason.UserClosing)
|
||||||
{
|
{
|
||||||
// Just return to linedefs mode
|
// Just cancel
|
||||||
General.Map.ChangeMode(new LinedefsMode());
|
General.Map.CancelMode();
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Window is shown
|
// This shows the window
|
||||||
protected override void OnShown(EventArgs e)
|
public void Show(Form owner, CurveLinedefsMode mode)
|
||||||
{
|
{
|
||||||
|
// Keep reference to mode
|
||||||
|
this.mode = mode;
|
||||||
|
|
||||||
// First time showing?
|
// First time showing?
|
||||||
if((this.Location.X == 0) && (this.Location.Y == 0))
|
//if((this.Location.X == 0) && (this.Location.Y == 0))
|
||||||
{
|
{
|
||||||
// Position in left-top of owner
|
// Position at left-top of owner
|
||||||
this.Location = new Point(this.Owner.Location.X + 20, this.Owner.Location.Y + 80);
|
this.Location = new Point(owner.Location.X + 20, owner.Location.Y + 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Continue
|
// Show window
|
||||||
base.OnShown(e);
|
base.Show(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vertices bar changed
|
// Vertices bar changed
|
||||||
|
@ -163,6 +172,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
General.Interface.RedrawDisplay();
|
General.Interface.RedrawDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cancel clicked
|
||||||
|
private void cancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// Cancel now
|
||||||
|
General.Map.CancelMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply clicked
|
||||||
|
private void apply_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// Apply now
|
||||||
|
mode.Apply();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -161,7 +161,6 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
}
|
}
|
||||||
|
|
||||||
// This forces the mode to cancel and return to the "parent" mode
|
// This forces the mode to cancel and return to the "parent" mode
|
||||||
[BeginAction("cancelmode", BaseAction = true)]
|
|
||||||
public virtual void OnCancel() { }
|
public virtual void OnCancel() { }
|
||||||
|
|
||||||
// Interface events
|
// Interface events
|
||||||
|
|
|
@ -823,6 +823,16 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
#region ================== Editing Modes
|
#region ================== Editing Modes
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This cancels the current mode.
|
||||||
|
/// </summary>
|
||||||
|
[BeginAction("cancelmode")]
|
||||||
|
public void CancelMode()
|
||||||
|
{
|
||||||
|
// Let the mode know
|
||||||
|
mode.OnCancel();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// This changes the editing mode.
|
// This changes the editing mode.
|
||||||
// Order in which events occur for the old and new modes:
|
// Order in which events occur for the old and new modes:
|
||||||
|
|
Loading…
Reference in a new issue