mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +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
|
||||
base.OnCancel();
|
||||
|
||||
// Return to vertices mode
|
||||
// Return to base mode
|
||||
General.Map.ChangeMode(basemode);
|
||||
}
|
||||
|
||||
|
@ -110,10 +110,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.OnEngage();
|
||||
|
||||
// Show toolbox window
|
||||
BuilderPlug.Me.CurveLinedefsForm.Show(General.Interface);
|
||||
|
||||
// Keep focus on main window
|
||||
General.Interface.Focus();
|
||||
BuilderPlug.Me.CurveLinedefsForm.Show((Form)General.Interface, this);
|
||||
}
|
||||
|
||||
// Disenagaging
|
||||
|
@ -123,11 +120,47 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Hide toolbox window
|
||||
BuilderPlug.Me.CurveLinedefsForm.Hide();
|
||||
|
||||
// Hide highlight info
|
||||
General.Interface.HideInfo();
|
||||
}
|
||||
|
||||
// This applies the curves and returns to the base mode
|
||||
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
|
||||
private List<Vector2D> GenerateCurve(Linedef line)
|
||||
{
|
||||
|
|
|
@ -330,9 +330,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Cursor.Current = Cursors.Default;
|
||||
General.Map.IsChanged = true;
|
||||
}
|
||||
|
||||
// Hide highlight info
|
||||
General.Interface.HideInfo();
|
||||
}
|
||||
|
||||
// This checks if the view offset/zoom changed and updates the check
|
||||
|
|
|
@ -521,9 +521,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Map.IsChanged = true;
|
||||
}
|
||||
|
||||
// Hide highlight info
|
||||
General.Interface.HideInfo();
|
||||
|
||||
// Done
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
|
|
|
@ -151,6 +151,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.cancel.TabIndex = 22;
|
||||
this.cancel.Text = "Cancel";
|
||||
this.cancel.UseVisualStyleBackColor = true;
|
||||
this.cancel.Click += new System.EventHandler(this.cancel_Click);
|
||||
//
|
||||
// apply
|
||||
//
|
||||
|
@ -161,6 +162,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.apply.TabIndex = 21;
|
||||
this.apply.Text = "OK";
|
||||
this.apply.UseVisualStyleBackColor = true;
|
||||
this.apply.Click += new System.EventHandler(this.apply_Click);
|
||||
//
|
||||
// circular
|
||||
//
|
||||
|
|
|
@ -38,6 +38,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
public partial class CurveLinedefsForm : DelayedForm
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private CurveLinedefsMode mode;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public int Vertices { get { return verticesbar.Value; } }
|
||||
|
@ -67,24 +73,27 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// User closing the window?
|
||||
if(e.CloseReason == CloseReason.UserClosing)
|
||||
{
|
||||
// Just return to linedefs mode
|
||||
General.Map.ChangeMode(new LinedefsMode());
|
||||
// Just cancel
|
||||
General.Map.CancelMode();
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Window is shown
|
||||
protected override void OnShown(EventArgs e)
|
||||
// This shows the window
|
||||
public void Show(Form owner, CurveLinedefsMode mode)
|
||||
{
|
||||
// First time showing?
|
||||
if((this.Location.X == 0) && (this.Location.Y == 0))
|
||||
{
|
||||
// Position in left-top of owner
|
||||
this.Location = new Point(this.Owner.Location.X + 20, this.Owner.Location.Y + 80);
|
||||
}
|
||||
// Keep reference to mode
|
||||
this.mode = mode;
|
||||
|
||||
// Continue
|
||||
base.OnShown(e);
|
||||
// First time showing?
|
||||
//if((this.Location.X == 0) && (this.Location.Y == 0))
|
||||
{
|
||||
// Position at left-top of owner
|
||||
this.Location = new Point(owner.Location.X + 20, owner.Location.Y + 90);
|
||||
}
|
||||
|
||||
// Show window
|
||||
base.Show(owner);
|
||||
}
|
||||
|
||||
// Vertices bar changed
|
||||
|
@ -162,7 +171,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
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
|
||||
}
|
||||
}
|
|
@ -161,7 +161,6 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
}
|
||||
|
||||
// This forces the mode to cancel and return to the "parent" mode
|
||||
[BeginAction("cancelmode", BaseAction = true)]
|
||||
public virtual void OnCancel() { }
|
||||
|
||||
// Interface events
|
||||
|
|
|
@ -823,6 +823,16 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
#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.
|
||||
// Order in which events occur for the old and new modes:
|
||||
|
|
Loading…
Reference in a new issue