This commit is contained in:
codeimp 2007-11-10 01:58:08 +00:00
parent 713b522a6e
commit 8579667b82
7 changed files with 118 additions and 33 deletions

View file

@ -6,3 +6,7 @@
[15:50] <SoM> and it could easily be optional
[15:51] <SoM> I've been doing a lot of detailing that would be made a lot easier with a feature like this
[15:52] <CodeImp> i dont even think that should be an option, but normal behaviour
[20:55] <esselaptop> CodeImp_: i thought of another nice feature that i don't think DB has. in slade, you can middle-click (or bind it to something else) to select the nearest vertex. like, if you're drawing a line and you want to connect it to something that's off-grid, you can just put the mouse nearby the off-grid vertex and middle-click, and it'll snap to it.
Make Sector feature allows you to click somewhere and all surrounding lines will form a new sector. handy to split merged sectors.

View file

@ -47,6 +47,9 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Variables
// Cancelled?
protected bool cancelled;
// Graphics
protected Renderer2D renderer;
@ -335,6 +338,7 @@ namespace CodeImp.DoomBuilder.Editing
[Action(Action.CANCELMODE)]
public override void Cancel()
{
cancelled = true;
base.Cancel();
}

View file

@ -32,6 +32,10 @@ using CodeImp.DoomBuilder.Geometry;
#endregion
// This mode if for quickly dragging vertices without a layer.
// The geometry is merged and the mode returns to VerticesMode when the mouse is released.
namespace CodeImp.DoomBuilder.Editing
{
public class DragVerticesMode : VerticesMode
@ -42,6 +46,12 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Variables
// Mouse offset from dragitem
protected Vector2D dragoffset;
// Item used as reference for dragging
protected Vertex dragitem;
#endregion
#region ================== Properties
@ -50,19 +60,12 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Constructor / Disposer
// Constructor to start without dragging
public DragVerticesMode(Vertex highlighted)
{
// Initialize
// We have no destructor
GC.SuppressFinalize(this);
}
// Constructor to start dragging immediately
public DragVerticesMode()
public DragVerticesMode(Vertex dragitem, Vector2D dragoffset)
{
// Initialize
this.dragitem = dragitem;
this.dragoffset = dragoffset;
// We have no destructor
GC.SuppressFinalize(this);
@ -85,6 +88,64 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Methods
// Cancelled
public override void Cancel()
{
// Move geometry back to original position
// Continue cancelling
base.Cancel();
}
// Disenagaging
public override void Disengage()
{
// When not cancelled
if(!cancelled)
{
// TODO: Merge geometry
// Map is changed
General.Map.IsChanged = true;
}
// Continue disengage
base.Disengage();
}
// Mouse button pressed
public override void MouseDown(MouseEventArgs e)
{
// Do nothing.
}
// Mouse moving
public override void MouseMove(MouseEventArgs e)
{
// TODO: Move selected geometry and redraw
}
// Mosue button released
public override void MouseUp(MouseEventArgs e)
{
// Is the editing button released?
if(e.Button == EditMode.EDIT_BUTTON)
{
// Just return to vertices mode, geometry will be merged on disengage.
General.Map.ChangeMode(new VerticesMode());
}
}
// When dragging starts
protected override void DragStart(MouseEventArgs e)
{
// Do nothing. We're already dragging.
}
#endregion
}
}

View file

@ -109,6 +109,16 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Methods
//
// Order in which events occur for the old and new modes:
//
// - Constructor of new mode is called
// - Disengage of old mode is called
// ----- Mode switches -----
// - Engage of new mode is called
// - Dispose of old mode is called
//
// Mode engages
public virtual void Engage()
{

View file

@ -45,7 +45,7 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Variables
// Highlighted item
private Vertex highlighted;
protected Vertex highlighted;
#endregion
@ -258,7 +258,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// Start dragging the selection
General.Map.ChangeMode(new DragVerticesMode());
General.Map.ChangeMode(new DragVerticesMode(highlighted, mousedownmappos - highlighted.Position));
}
}
}

View file

@ -125,17 +125,20 @@ namespace CodeImp.DoomBuilder
// Unbind any methods
ActionAttribute.UnbindMethods(this);
// Basic objects
if(selection != null) selection.Dispose();
// Dispose
General.WriteLogLine("Unloading data resources...");
data.Dispose();
if(data != null) data.Dispose();
General.WriteLogLine("Closing temporary file...");
tempwad.Dispose();
if(tempwad != null) tempwad.Dispose();
General.WriteLogLine("Unloading map data...");
map.Dispose();
if(map != null) map.Dispose();
General.WriteLogLine("Stopping graphics device...");
renderer2d.Dispose();
renderer3d.Dispose();
graphics.Dispose();
if(renderer2d != null) renderer2d.Dispose();
if(renderer3d != null) renderer3d.Dispose();
if(graphics != null) graphics.Dispose();
// Remove temp file
General.WriteLogLine("Removing temporary directory...");
@ -145,9 +148,6 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Failed to remove temporary directory!");
}
// Basic objects
selection.Dispose();
// We may spend some time to clean things up here
GC.Collect();
@ -284,7 +284,12 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
io = MapSetIO.Create(config.FormatInterface, tempwad, this);
General.WriteLogLine("Reading map data structures from file...");
map = io.Read(map, TEMP_MAP_HEADER);
try { map = io.Read(map, TEMP_MAP_HEADER); }
catch(Exception)
{
General.ShowErrorMessage("Unable to read the map data structures with the specified configuration.", MessageBoxButtons.OK);
return false;
}
// Update structures
map.Update();
@ -806,6 +811,7 @@ namespace CodeImp.DoomBuilder
#region ================== Editing Modes
//
// This changes the editing mode.
// Order in which events occur for the old and new modes:
//

View file

@ -57,6 +57,7 @@ namespace CodeImp.DoomBuilder.Interface
this.actionkey = new System.Windows.Forms.TextBox();
this.actiondescription = new System.Windows.Forms.Label();
this.tabcolors = new System.Windows.Forms.TabPage();
this.blackbrowsers = new System.Windows.Forms.CheckBox();
this.colorsgroup3 = new System.Windows.Forms.GroupBox();
this.colorconstants = new CodeImp.DoomBuilder.Interface.ColorControl();
this.colorliterals = new CodeImp.DoomBuilder.Interface.ColorControl();
@ -69,7 +70,6 @@ namespace CodeImp.DoomBuilder.Interface
this.colorselection3d = new CodeImp.DoomBuilder.Interface.ColorControl();
this.colorhighlight3d = new CodeImp.DoomBuilder.Interface.ColorControl();
this.colorcrosshair3d = new CodeImp.DoomBuilder.Interface.ColorControl();
this.blackbrowsers = new System.Windows.Forms.CheckBox();
label7 = new System.Windows.Forms.Label();
label6 = new System.Windows.Forms.Label();
label5 = new System.Windows.Forms.Label();
@ -431,6 +431,16 @@ namespace CodeImp.DoomBuilder.Interface
this.tabcolors.Text = "Colors";
this.tabcolors.UseVisualStyleBackColor = true;
//
// blackbrowsers
//
this.blackbrowsers.AutoSize = true;
this.blackbrowsers.Location = new System.Drawing.Point(13, 345);
this.blackbrowsers.Name = "blackbrowsers";
this.blackbrowsers.Size = new System.Drawing.Size(241, 18);
this.blackbrowsers.TabIndex = 13;
this.blackbrowsers.Text = "Force black background for image browsers";
this.blackbrowsers.UseVisualStyleBackColor = true;
//
// colorsgroup3
//
this.colorsgroup3.Controls.Add(this.colorconstants);
@ -581,16 +591,6 @@ namespace CodeImp.DoomBuilder.Interface
this.colorcrosshair3d.Size = new System.Drawing.Size(150, 23);
this.colorcrosshair3d.TabIndex = 6;
//
// blackbrowsers
//
this.blackbrowsers.AutoSize = true;
this.blackbrowsers.Location = new System.Drawing.Point(13, 345);
this.blackbrowsers.Name = "blackbrowsers";
this.blackbrowsers.Size = new System.Drawing.Size(241, 18);
this.blackbrowsers.TabIndex = 13;
this.blackbrowsers.Text = "Force black background for image browsers";
this.blackbrowsers.UseVisualStyleBackColor = true;
//
// PreferencesForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;