oops, the EditingManager should be a general manager, not depending on the loaded map

This commit is contained in:
codeimp 2008-11-27 11:59:17 +00:00
parent ae8daa2924
commit 580fe3f181
30 changed files with 152 additions and 121 deletions

View file

@ -101,7 +101,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Switch to EditSelectionMode
EditSelectionMode editmode = new EditSelectionMode();
editmode.Pasting = true;
General.Map.Editing.ChangeMode(editmode);
General.Editing.ChangeMode(editmode);
}
#endregion

View file

@ -407,7 +407,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MakeGradientBrightness);
// Going to EditSelectionMode?
if(General.Map.Editing.NewMode is EditSelectionMode)
if(General.Editing.NewMode is EditSelectionMode)
{
// No selection made? But we have a highlight!
if((General.Map.Map.GetSelectedSectors(true).Count == 0) && (highlighted != null))

View file

@ -57,7 +57,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Properties
// Just keep the base mode button checked
public override string EditModeButtonName { get { return General.Map.Editing.PreviousStableMode.Name; } }
public override string EditModeButtonName { get { return General.Editing.PreviousStableMode.Name; } }
#endregion
@ -162,7 +162,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnCancel();
// Return to base mode
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
// Mode engages
@ -221,7 +221,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Map.IsChanged = true;
// Return to base mode
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
// Redrawing display

View file

@ -83,7 +83,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Properties
// Just keep the base mode button checked
public override string EditModeButtonName { get { return General.Map.Editing.PreviousStableMode.Name; } }
public override string EditModeButtonName { get { return General.Editing.PreviousStableMode.Name; } }
#endregion
@ -283,7 +283,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnCancel();
// Return to vertices mode
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
// Mode engages
@ -367,7 +367,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected override void OnEditEnd()
{
// Just return to base mode, Disengage will be called automatically.
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
base.OnEditEnd();
}

View file

@ -268,7 +268,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnCancel();
// Return to vertices mode
General.Map.Editing.ChangeMode(basemode);
General.Editing.ChangeMode(basemode);
}
// Mode engages
@ -354,7 +354,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected override void OnEditEnd()
{
// Just return to vertices mode, geometry will be merged on disengage.
General.Map.Editing.ChangeMode(basemode);
General.Editing.ChangeMode(basemode);
base.OnEditEnd();
}

View file

@ -69,7 +69,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Properties
// Just keep the base mode button checked
public override string EditModeButtonName { get { return General.Map.Editing.PreviousStableMode.Name; } }
public override string EditModeButtonName { get { return General.Editing.PreviousStableMode.Name; } }
#endregion
@ -335,7 +335,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnCancel();
// Return to original mode
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
// Accepted
@ -369,7 +369,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
Cursor.Current = Cursors.Default;
// Return to original mode
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
// This redraws the display
@ -454,7 +454,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void FinishDraw()
{
// Accept the changes
General.Map.Editing.AcceptMode();
General.Editing.AcceptMode();
}
#endregion

View file

@ -133,7 +133,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Properties
// Just keep the base mode button checked
public override string EditModeButtonName { get { return General.Map.Editing.PreviousStableMode.Name; } }
public override string EditModeButtonName { get { return General.Editing.PreviousStableMode.Name; } }
public bool Pasting { get { return pasting; } set { pasting = value; } }
@ -690,7 +690,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.DisplayWarning("Please make a selection first!");
// Cancel now
General.Map.Editing.CancelMode();
General.Editing.CancelMode();
}
}
@ -711,7 +711,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Map.Map.Update(true, true);
// Return to previous stable mode
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
// When accepted
@ -848,7 +848,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(!modealreadyswitching)
{
// Return to previous stable mode
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
}
@ -1084,7 +1084,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Outside the selection?
default:
// Accept and be done with it
General.Map.Editing.AcceptMode();
General.Editing.AcceptMode();
break;
}
}
@ -1131,7 +1131,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void ClearSelection()
{
// Accept changes
General.Map.Editing.AcceptMode();
General.Editing.AcceptMode();
General.Map.Map.ClearAllSelected();
}

View file

@ -67,7 +67,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnCancel();
// Return to base mode
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
// Mode engages
@ -112,7 +112,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Map.IsChanged = true;
// Return to base mode
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
// Redrawing display

View file

@ -67,7 +67,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnCancel();
// Return to base mode
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
// Mode engages
@ -103,7 +103,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Map.IsChanged = true;
// Return to base mode
General.Map.Editing.ChangeMode(General.Map.Editing.PreviousStableMode.Name);
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
// Redrawing display

View file

@ -178,7 +178,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnCancel();
// Return to this mode
General.Map.Editing.ChangeMode(new LinedefsMode());
General.Editing.ChangeMode(new LinedefsMode());
}
// Mode engages
@ -202,7 +202,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnDisengage();
// Going to EditSelectionMode?
if(General.Map.Editing.NewMode is EditSelectionMode)
if(General.Editing.NewMode is EditSelectionMode)
{
// No selection made? But we have a highlight!
if((General.Map.Map.GetSelectedLinedefs(true).Count == 0) && (highlighted != null))
@ -343,7 +343,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Start drawing mode
DrawGeometryMode drawmode = new DrawGeometryMode();
drawmode.DrawPointAt(mousemappos, true);
General.Map.Editing.ChangeMode(drawmode);
General.Editing.ChangeMode(drawmode);
}
base.OnEditBegin();
@ -419,7 +419,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
General.Map.Editing.ChangeMode(new DragLinedefsMode(mousedownmappos));
General.Editing.ChangeMode(new DragLinedefsMode(mousedownmappos));
}
}
}
@ -633,7 +633,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(selected.Count > 0)
{
// Go into curve linedefs mode
General.Map.Editing.ChangeMode(new CurveLinedefsMode(new LinedefsMode()));
General.Editing.ChangeMode(new CurveLinedefsMode(new LinedefsMode()));
}
}

View file

@ -246,7 +246,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnCancel();
// Return to base mode
General.Map.Editing.ChangeMode(new SectorsMode());
General.Editing.ChangeMode(new SectorsMode());
}
// Mode engages
@ -271,14 +271,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnDisengage();
// Check which mode we are switching to
if(General.Map.Editing.NewMode is VerticesMode)
if(General.Editing.NewMode is VerticesMode)
{
// Convert selection to vertices
// Clear selected sectors
General.Map.Map.ClearSelectedSectors();
}
else if(General.Map.Editing.NewMode is LinedefsMode)
else if(General.Editing.NewMode is LinedefsMode)
{
// Convert selection to linedefs

View file

@ -251,7 +251,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnCancel();
// Return to this mode
General.Map.Editing.ChangeMode(new SectorsMode());
General.Editing.ChangeMode(new SectorsMode());
}
// Mode engages
@ -295,7 +295,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnDisengage();
// Going to EditSelectionMode?
if(General.Map.Editing.NewMode is EditSelectionMode)
if(General.Editing.NewMode is EditSelectionMode)
{
// No selection made? But we have a highlight!
if((General.Map.Map.GetSelectedSectors(true).Count == 0) && (highlighted != null))
@ -429,7 +429,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Start drawing mode
DrawGeometryMode drawmode = new DrawGeometryMode();
drawmode.DrawPointAt(mousemappos, true);
General.Map.Editing.ChangeMode(drawmode);
General.Editing.ChangeMode(drawmode);
}
base.OnEditBegin();
@ -545,7 +545,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
General.Map.Editing.ChangeMode(new DragSectorsMode(mousedownmappos));
General.Editing.ChangeMode(new DragSectorsMode(mousedownmappos));
}
}
}

View file

@ -80,7 +80,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnCancel();
// Return to this mode
General.Map.Editing.ChangeMode(new ThingsMode());
General.Editing.ChangeMode(new ThingsMode());
}
// Mode engages
@ -104,7 +104,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnDisengage();
// Going to EditSelectionMode?
if(General.Map.Editing.NewMode is EditSelectionMode)
if(General.Editing.NewMode is EditSelectionMode)
{
// No selection made? But we have a highlight!
if((General.Map.Map.GetSelectedThings(true).Count == 0) && (highlighted != null))
@ -417,7 +417,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
General.Map.Editing.ChangeMode(new DragThingsMode(new ThingsMode(), mousedownmappos));
General.Editing.ChangeMode(new DragThingsMode(new ThingsMode(), mousedownmappos));
}
}
}

View file

@ -77,7 +77,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnCancel();
// Return to this mode
General.Map.Editing.ChangeMode(new VerticesMode());
General.Editing.ChangeMode(new VerticesMode());
}
// Mode engages
@ -106,7 +106,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnDisengage();
// Going to EditSelectionMode?
if(General.Map.Editing.NewMode is EditSelectionMode)
if(General.Editing.NewMode is EditSelectionMode)
{
// No selection made? But we have a highlight!
if((General.Map.Map.GetSelectedVertices(true).Count == 0) && (highlighted != null))
@ -275,7 +275,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Start drawing mode
DrawGeometryMode drawmode = new DrawGeometryMode();
drawmode.DrawPointAt(mousemappos, true);
General.Map.Editing.ChangeMode(drawmode);
General.Editing.ChangeMode(drawmode);
}
}
@ -334,7 +334,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
General.Map.Editing.ChangeMode(new DragVerticesMode(highlighted, mousedownmappos));
General.Editing.ChangeMode(new DragVerticesMode(highlighted, mousedownmappos));
}
}
}

View file

@ -88,7 +88,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(e.CloseReason == CloseReason.UserClosing)
{
// Just cancel
General.Map.Editing.CancelMode();
General.Editing.CancelMode();
e.Cancel = true;
}
}
@ -193,14 +193,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
private void cancel_Click(object sender, EventArgs e)
{
// Cancel now
General.Map.Editing.CancelMode();
General.Editing.CancelMode();
}
// Apply clicked
private void apply_Click(object sender, EventArgs e)
{
// Apply now
General.Map.Editing.AcceptMode();
General.Editing.AcceptMode();
}
#endregion

View file

@ -331,7 +331,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
General.Map.Editing.CancelMode();
General.Editing.CancelMode();
}
}

View file

@ -213,14 +213,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
General.Map.Editing.CancelMode();
General.Editing.CancelMode();
}
}
// Close button clicked
private void closebutton_Click(object sender, EventArgs e)
{
General.Map.Editing.CancelMode();
General.Editing.CancelMode();
}
#endregion

View file

@ -124,7 +124,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// When these modes are active, then test against the base mode they will return to
if((mode is DragGeometryMode) || (mode is DragThingsMode) ||
(mode is DrawGeometryMode) || (mode is CurveLinedefsMode))
sourcemode = General.Map.Editing.PreviousStableMode;
sourcemode = General.Editing.PreviousStableMode;
// Final decision
if(sourcemode == typeof(LinedefsMode)) HideAllMenusExcept(linedefsmenu);

View file

@ -94,7 +94,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
base.OnCancel();
// Return to this mode
General.Map.Editing.ChangeMode(new SectorsMode());
General.Editing.ChangeMode(new SectorsMode());
}
// Mode engages
@ -109,14 +109,14 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
base.OnDisengage();
// Check which mode we are switching to
if(General.Map.Editing.NewMode is VerticesMode)
if(General.Editing.NewMode is VerticesMode)
{
// Convert selection to vertices
// Clear selected sectors
General.Map.Map.ClearSelectedSectors();
}
else if(General.Map.Editing.NewMode is LinedefsMode)
else if(General.Editing.NewMode is LinedefsMode)
{
// Convert selection to linedefs

View file

@ -105,7 +105,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
base.OnCancel();
// Return to this mode
General.Map.Editing.ChangeMode(new WAuthorMode());
General.Editing.ChangeMode(new WAuthorMode());
}
// Mode engages

View file

@ -47,6 +47,7 @@ namespace CodeImp.DoomBuilder.Config
private int testskill;
private List<ThingsFilter> thingsfilters;
private List<DefinedTextureSet> texturesets;
private List<string> editmodes;
#endregion
@ -64,7 +65,8 @@ namespace CodeImp.DoomBuilder.Config
public bool CustomParameters { get { return customparameters; } set { customparameters = value; } }
internal ICollection<ThingsFilter> ThingsFilters { get { return thingsfilters; } }
public List<DefinedTextureSet> TextureSets { get { return texturesets; } }
internal List<string> EditModes { get { return editmodes; } }
#endregion
#region ================== Constructor / Disposer
@ -104,8 +106,16 @@ namespace CodeImp.DoomBuilder.Config
{
texturesets.Add(new DefinedTextureSet(General.Settings.Config, "configurations." + settingskey + ".texturesets." + de.Key));
}
// Make list of edit modes
this.editmodes = new List<string>();
IDictionary modes = General.Settings.ReadSetting("configurations." + settingskey + ".editmodes", new Hashtable());
foreach(DictionaryEntry de in modes)
{
editmodes.Add(de.Value.ToString());
}
}
// Constructor
private ConfigurationInfo()
{
@ -133,7 +143,7 @@ namespace CodeImp.DoomBuilder.Config
General.Settings.WriteSetting("configurations." + settingskey + ".customparameters", customparameters);
General.Settings.WriteSetting("configurations." + settingskey + ".testskill", testskill);
resources.WriteToConfig(General.Settings.Config, "configurations." + settingskey + ".resources");
// Write filters to configuration
for(int i = 0; i < thingsfilters.Count; i++)
{
@ -147,6 +157,12 @@ namespace CodeImp.DoomBuilder.Config
texturesets[i].WriteToConfig(General.Settings.Config,
"configurations." + settingskey + ".texturesets.set" + i.ToString(CultureInfo.InvariantCulture));
}
// Write filters to configuration
for(int i = 0; i < editmodes.Count; i++)
{
General.Settings.WriteSetting("configurations." + settingskey + ".editmodes.mode" + i.ToString(CultureInfo.InvariantCulture), editmodes[i]);
}
}
// String representation
@ -172,6 +188,7 @@ namespace CodeImp.DoomBuilder.Config
ci.testskill = this.testskill;
ci.texturesets = new List<DefinedTextureSet>();
foreach(DefinedTextureSet s in this.texturesets) ci.texturesets.Add(s.Copy());
ci.editmodes = new List<string>(this.editmodes);
return ci;
}
@ -191,6 +208,7 @@ namespace CodeImp.DoomBuilder.Config
this.testskill = ci.testskill;
this.texturesets = new List<DefinedTextureSet>();
foreach(DefinedTextureSet s in ci.texturesets) this.texturesets.Add(s.Copy());
this.editmodes = new List<string>(ci.editmodes);
}
// This applies the defaults

View file

@ -95,9 +95,9 @@ namespace CodeImp.DoomBuilder.Editing
this.renderer2d = (Renderer2D)General.Map.Renderer2D;
// If the current mode is a ClassicMode, copy mouse properties
if(General.Map.Editing.Mode is ClassicMode)
if(General.Editing.Mode is ClassicMode)
{
ClassicMode oldmode = General.Map.Editing.Mode as ClassicMode;
ClassicMode oldmode = General.Editing.Mode as ClassicMode;
// Copy mouse properties
mousepos = oldmode.mousepos;

View file

@ -97,7 +97,7 @@ namespace CodeImp.DoomBuilder.Editing
// Ask the editing mode to prepare selection for copying.
// The edit mode should mark all vertices, lines and sectors
// that need to be copied.
if(General.Map.Editing.Mode.OnCopyBegin())
if(General.Editing.Mode.OnCopyBegin())
{
// Copy the marked geometry
// This links sidedefs that are not linked to a marked sector to a virtual sector
@ -114,7 +114,7 @@ namespace CodeImp.DoomBuilder.Editing
// Done
memstream.Dispose();
General.Map.Editing.Mode.OnCopyEnd();
General.Editing.Mode.OnCopyEnd();
General.Plugins.OnCopyEnd();
return true;
}
@ -137,7 +137,7 @@ namespace CodeImp.DoomBuilder.Editing
if(General.Plugins.OnPasteBegin())
{
// Ask the editing mode to prepare selection for pasting.
if(General.Map.Editing.Mode.OnPasteBegin())
if(General.Editing.Mode.OnPasteBegin())
{
// Read from clipboard
Stream memstream = (Stream)Clipboard.GetData(CLIPBOARD_DATA_FORMAT);
@ -156,7 +156,7 @@ namespace CodeImp.DoomBuilder.Editing
// Done
memstream.Dispose();
General.Map.Editing.Mode.OnPasteEnd();
General.Editing.Mode.OnPasteEnd();
General.Plugins.OnPasteEnd();
return true;
}

View file

@ -130,13 +130,13 @@ namespace CodeImp.DoomBuilder.Editing
if(General.Map != null)
{
// Not switching from volatile mode to volatile mode?
if((General.Map.Editing.Mode == null) || !General.Map.Editing.Mode.Attributes.Volatile || !this.attribs.Volatile)
if((General.Editing.Mode == null) || !General.Editing.Mode.Attributes.Volatile || !this.attribs.Volatile)
{
// Create instance
newmode = plugin.CreateObject<EditMode>(type);
// Switch mode
General.Map.Editing.ChangeMode(newmode);
General.Editing.ChangeMode(newmode);
}
}
}
@ -153,7 +153,7 @@ namespace CodeImp.DoomBuilder.Editing
newmode = plugin.CreateObject<EditMode>(type);
// Switch mode
General.Map.Editing.ChangeMode(newmode);
General.Editing.ChangeMode(newmode);
}
}
@ -169,7 +169,7 @@ namespace CodeImp.DoomBuilder.Editing
newmode = plugin.CreateObjectA<EditMode>(type, args);
// Switch mode
if(!General.Map.Editing.ChangeMode(newmode))
if(!General.Editing.ChangeMode(newmode))
{
// When cancelled, dispose mode
newmode.Dispose();

View file

@ -64,6 +64,7 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Properties
internal List<EditModeInfo> ModesInfo { get { return allmodes; } }
public EditMode Mode { get { return mode; } }
public EditMode NewMode { get { return newmode; } }
public Type PreviousMode { get { return prevmode; } }
@ -101,6 +102,9 @@ namespace CodeImp.DoomBuilder.Editing
// Sort the modes in order for buttons
allmodes.Sort();
// Update modes
UpdateCurrentEditModes();
// We have no destructor
GC.SuppressFinalize(this);
}

View file

@ -222,7 +222,7 @@ namespace CodeImp.DoomBuilder.Editing
if(General.Plugins.OnUndoBegin())
{
// Call UndoBegin event
if(General.Map.Editing.Mode.OnUndoBegin())
if(General.Editing.Mode.OnUndoBegin())
{
// Cancel volatile mode, if any
// This returns false when mode was not volatile
@ -255,7 +255,7 @@ namespace CodeImp.DoomBuilder.Editing
General.Map.ChangeMapSet(u.map);
// Done
General.Map.Editing.Mode.OnUndoEnd();
General.Editing.Mode.OnUndoEnd();
General.Plugins.OnUndoEnd();
// Update
@ -281,7 +281,7 @@ namespace CodeImp.DoomBuilder.Editing
if(General.Plugins.OnRedoBegin())
{
// Call RedoBegin event
if(General.Map.Editing.Mode.OnRedoBegin())
if(General.Editing.Mode.OnRedoBegin())
{
// Cancel volatile mode, if any
General.CancelVolatileMode();
@ -313,7 +313,7 @@ namespace CodeImp.DoomBuilder.Editing
General.Map.ChangeMapSet(r.map);
// Done
General.Map.Editing.Mode.OnRedoEnd();
General.Editing.Mode.OnRedoEnd();
General.Plugins.OnRedoEnd();
// Update

View file

@ -39,6 +39,7 @@ using CodeImp.DoomBuilder.Plugins;
using CodeImp.DoomBuilder.Types;
using System.Collections.ObjectModel;
using System.Threading;
using CodeImp.DoomBuilder.Editing;
#endregion
@ -120,6 +121,7 @@ namespace CodeImp.DoomBuilder
private static MainForm mainwindow;
private static ProgramConfiguration settings;
private static MapManager map;
private static EditingManager editing;
private static ActionManager actions;
private static PluginManager plugins;
private static ColorCollection colors;
@ -171,6 +173,7 @@ namespace CodeImp.DoomBuilder
public static string AutoLoadMap { get { return autoloadmap; } }
public static string AutoLoadConfig { get { return autoloadconfig; } }
public static bool DelayMainWindow { get { return delaymainwindow; } }
public static EditingManager Editing { get { return editing; } }
#endregion
@ -620,7 +623,7 @@ namespace CodeImp.DoomBuilder
// Load color settings
General.WriteLogLine("Loading color settings...");
colors = new ColorCollection(settings.Config);
// Create application clock
General.WriteLogLine("Creating application clock...");
clock = new Clock();
@ -629,6 +632,10 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Creating types manager...");
types = new TypesManager();
// Create editing modes
General.WriteLogLine("Creating editing modes manager...");
editing = new EditingManager();
// Do auto map loading when window is delayed
if(delaymainwindow)
mainwindow.PerformAutoMapLoading();
@ -783,6 +790,7 @@ namespace CodeImp.DoomBuilder
// Clean up
if(map != null) map.Dispose(); map = null;
if(editing != null) editing.Dispose(); editing = null;
if(mainwindow != null) mainwindow.Dispose();
if(actions != null) actions.Dispose();
if(clock != null) clock.Dispose();
@ -813,10 +821,10 @@ namespace CodeImp.DoomBuilder
public static bool CancelVolatileMode()
{
// Volatile mode?
if((map != null) & (map.Editing.Mode != null) && map.Editing.Mode.Attributes.Volatile)
if((map != null) & (editing.Mode != null) && editing.Mode.Attributes.Volatile)
{
// Cancel
map.Editing.Mode.OnCancel();
editing.Mode.OnCancel();
return true;
}
else
@ -830,10 +838,10 @@ namespace CodeImp.DoomBuilder
public static bool DisengageVolatileMode()
{
// Volatile mode?
if((map != null) && (map.Editing.Mode != null) && map.Editing.Mode.Attributes.Volatile)
if((map != null) && (editing.Mode != null) && editing.Mode.Attributes.Volatile)
{
// Change back to normal mode
map.Editing.ChangeMode(map.Editing.PreviousStableMode.Name);
editing.ChangeMode(editing.PreviousStableMode.Name);
return true;
}
else

View file

@ -75,7 +75,6 @@ namespace CodeImp.DoomBuilder
private ConfigurationInfo configinfo;
private GameConfiguration config;
private DataManager data;
private EditingManager editing;
private D3DDevice graphics;
private Renderer2D renderer2d;
private Renderer3D renderer3d;
@ -100,7 +99,6 @@ namespace CodeImp.DoomBuilder
public string TempPath { get { return temppath; } }
internal MapOptions Options { get { return options; } }
public MapSet Map { get { return map; } }
public EditingManager Editing { get { return editing; } }
public DataManager Data { get { return data; } }
public bool IsChanged { get { return changed | CheckScriptChanged(); } set { changed |= value; } }
public bool IsDisposed { get { return isdisposed; } }
@ -141,7 +139,6 @@ namespace CodeImp.DoomBuilder
copypaste = new CopyPasteManager();
launcher = new Launcher(this);
thingsfilter = new NullThingsFilter();
editing = new EditingManager();
}
// Disposer
@ -154,7 +151,7 @@ namespace CodeImp.DoomBuilder
CloseScriptEditor(false);
// Change to no mode
editing.ChangeMode((EditMode)null);
General.Editing.ChangeMode((EditMode)null);
// Unbind any methods
General.Actions.UnbindMethods(this);
@ -164,7 +161,6 @@ namespace CodeImp.DoomBuilder
if(launcher != null) launcher.Dispose();
if(copypaste != null) copypaste.Dispose();
if(undoredo != null) undoredo.Dispose();
if(editing != null) editing.Dispose();
General.WriteLogLine("Unloading data resources...");
if(data != null) data.Dispose();
General.WriteLogLine("Closing temporary file...");
@ -179,7 +175,6 @@ namespace CodeImp.DoomBuilder
launcher = null;
copypaste = null;
undoredo = null;
editing = null;
data = null;
tempwad = null;
map = null;
@ -240,7 +235,7 @@ namespace CodeImp.DoomBuilder
configinfo = General.GetConfigurationInfo(options.ConfigFile);
config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
configinfo.ApplyDefaults();
editing.UpdateCurrentEditModes();
General.Editing.UpdateCurrentEditModes();
// Create map data
map = new MapSet();
@ -273,8 +268,8 @@ namespace CodeImp.DoomBuilder
General.Actions.BindMethods(this);
// Set default mode
editing.ChangeMode("VerticesMode");
ClassicMode cmode = (editing.Mode as ClassicMode);
General.Editing.ChangeMode("VerticesMode");
ClassicMode cmode = (General.Editing.Mode as ClassicMode);
cmode.SetZoom(0.5f);
renderer2d.SetViewMode((ViewMode)General.Settings.DefaultViewMode);
@ -312,7 +307,7 @@ namespace CodeImp.DoomBuilder
configinfo = General.GetConfigurationInfo(options.ConfigFile);
config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
configinfo.ApplyDefaults();
editing.UpdateCurrentEditModes();
General.Editing.UpdateCurrentEditModes();
// Create map data
map = new MapSet();
@ -360,11 +355,11 @@ namespace CodeImp.DoomBuilder
General.Actions.BindMethods(this);
// Set default mode
editing.ChangeMode("VerticesMode");
General.Editing.ChangeMode("VerticesMode");
renderer2d.SetViewMode((ViewMode)General.Settings.DefaultViewMode);
// Center map in screen
if(General.Map.Editing.Mode is ClassicMode) (General.Map.Editing.Mode as ClassicMode).CenterInScreen();
if(General.Editing.Mode is ClassicMode) (General.Editing.Mode as ClassicMode).CenterInScreen();
// Success
General.WriteLogLine("Map loading done");
@ -1273,7 +1268,7 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Reloading game configuration...");
configinfo = General.GetConfigurationInfo(options.ConfigFile);
config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
editing.UpdateCurrentEditModes();
General.Editing.UpdateCurrentEditModes();
// Reload data resources
General.WriteLogLine("Reloading data resources...");
@ -1320,7 +1315,7 @@ namespace CodeImp.DoomBuilder
configinfo = General.GetConfigurationInfo(options.ConfigFile);
config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
configinfo.ApplyDefaults();
editing.UpdateCurrentEditModes();
General.Editing.UpdateCurrentEditModes();
// Setup new map format IO
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");

View file

@ -29,6 +29,7 @@ using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Config;
using System.IO;
using CodeImp.DoomBuilder.Controls;
using CodeImp.DoomBuilder.Editing;
#endregion
@ -63,7 +64,7 @@ namespace CodeImp.DoomBuilder.Windows
if((General.Map != null) && (General.Map.ConfigSettings.Filename == ci.Filename))
lvi.Selected = true;
}
// No skill
skill.Value = 0;
@ -72,6 +73,11 @@ namespace CodeImp.DoomBuilder.Windows
// Fill comboboxes with nodebuilders
nodebuildersave.Items.AddRange(General.Nodebuilders.ToArray());
nodebuildertest.Items.AddRange(General.Nodebuilders.ToArray());
// Fill list of editing modes
foreach(EditModeInfo emi in General.Editing.ModesInfo)
{
}
}
// This shows a specific page

View file

@ -200,10 +200,10 @@ namespace CodeImp.DoomBuilder.Windows
{
// Check appropriate button on interface
// And show the mode name
if(General.Map.Editing.Mode != null)
if(General.Editing.Mode != null)
{
General.MainWindow.CheckEditModeButton(General.Map.Editing.Mode.EditModeButtonName);
General.MainWindow.DisplayModeName(General.Map.Editing.Mode.Attributes.DisplayName);
General.MainWindow.CheckEditModeButton(General.Editing.Mode.EditModeButtonName);
General.MainWindow.DisplayModeName(General.Editing.Mode.Attributes.DisplayName);
}
else
{
@ -214,8 +214,8 @@ namespace CodeImp.DoomBuilder.Windows
// View mode only matters in classic editing modes
for(int i = 0; i < Renderer2D.NUM_VIEW_MODES; i++)
{
viewmodesitems[i].Enabled = (General.Map.Editing.Mode is ClassicMode);
viewmodesbuttons[i].Enabled = (General.Map.Editing.Mode is ClassicMode);
viewmodesitems[i].Enabled = (General.Editing.Mode is ClassicMode);
viewmodesbuttons[i].Enabled = (General.Editing.Mode is ClassicMode);
}
}
@ -691,7 +691,7 @@ namespace CodeImp.DoomBuilder.Windows
if(General.Map == null) return;
// In classic mode?
if(General.Map.Editing.Mode is ClassicMode)
if(General.Editing.Mode is ClassicMode)
{
// Requested from menu?
if(sender is ToolStripMenuItem)
@ -700,7 +700,7 @@ namespace CodeImp.DoomBuilder.Windows
zoom = int.Parse((sender as ToolStripMenuItem).Tag.ToString(), CultureInfo.InvariantCulture);
// Zoom now
(General.Map.Editing.Mode as ClassicMode).SetZoom((float)zoom / 100f);
(General.Editing.Mode as ClassicMode).SetZoom((float)zoom / 100f);
}
}
}
@ -711,8 +711,8 @@ namespace CodeImp.DoomBuilder.Windows
if(General.Map == null) return;
// In classic mode?
if(General.Map.Editing.Mode is ClassicMode)
(General.Map.Editing.Mode as ClassicMode).CenterInScreen();
if(General.Editing.Mode is ClassicMode)
(General.Editing.Mode as ClassicMode).CenterInScreen();
}
// This changes grid display
@ -736,7 +736,7 @@ namespace CodeImp.DoomBuilder.Windows
if(General.Map == null) return;
// In classic mode?
if(General.Map.Editing.Mode is ClassicMode)
if(General.Editing.Mode is ClassicMode)
{
// Requested from menu?
if(sender is ToolStripMenuItem)
@ -792,9 +792,9 @@ namespace CodeImp.DoomBuilder.Windows
// This redraws the display on the next paint event
public void RedrawDisplay()
{
if((General.Map != null) && (General.Map.Editing.Mode != null))
if((General.Map != null) && (General.Editing.Mode != null))
{
General.Map.Editing.Mode.OnRedrawDisplay();
General.Editing.Mode.OnRedrawDisplay();
}
else
{
@ -807,9 +807,9 @@ namespace CodeImp.DoomBuilder.Windows
{
if(General.Map != null)
{
if(General.Map.Editing.Mode != null)
if(General.Editing.Mode != null)
{
if(!displayresized) General.Map.Editing.Mode.OnPresentDisplay();
if(!displayresized) General.Editing.Mode.OnPresentDisplay();
}
else
{
@ -867,10 +867,10 @@ namespace CodeImp.DoomBuilder.Windows
}
// Mouse click
private void display_MouseClick(object sender, MouseEventArgs e) { if((General.Map != null) && (General.Map.Editing.Mode != null)) General.Map.Editing.Mode.OnMouseClick(e); }
private void display_MouseClick(object sender, MouseEventArgs e) { if((General.Map != null) && (General.Editing.Mode != null)) General.Editing.Mode.OnMouseClick(e); }
// Mouse doubleclick
private void display_MouseDoubleClick(object sender, MouseEventArgs e) { if((General.Map != null) && (General.Map.Editing.Mode != null)) General.Map.Editing.Mode.OnMouseDoubleClick(e); }
private void display_MouseDoubleClick(object sender, MouseEventArgs e) { if((General.Map != null) && (General.Editing.Mode != null)) General.Editing.Mode.OnMouseDoubleClick(e); }
// Mouse down
private void display_MouseDown(object sender, MouseEventArgs e)
@ -891,27 +891,27 @@ namespace CodeImp.DoomBuilder.Windows
General.Actions.KeyPressed(key);
// Invoke on editing mode
if((General.Map != null) && (General.Map.Editing.Mode != null)) General.Map.Editing.Mode.OnMouseDown(e);
if((General.Map != null) && (General.Editing.Mode != null)) General.Editing.Mode.OnMouseDown(e);
}
// Mouse enters
private void display_MouseEnter(object sender, EventArgs e)
{
mouseinside = true;
if((General.Map != null) && (mouseinput == null) && (General.Map.Editing.Mode != null)) General.Map.Editing.Mode.OnMouseEnter(e);
if((General.Map != null) && (mouseinput == null) && (General.Editing.Mode != null)) General.Editing.Mode.OnMouseEnter(e);
}
// Mouse leaves
private void display_MouseLeave(object sender, EventArgs e)
{
mouseinside = false;
if((General.Map != null) && (mouseinput == null) && (General.Map.Editing.Mode != null)) General.Map.Editing.Mode.OnMouseLeave(e);
if((General.Map != null) && (mouseinput == null) && (General.Editing.Mode != null)) General.Editing.Mode.OnMouseLeave(e);
}
// Mouse moves
private void display_MouseMove(object sender, MouseEventArgs e)
{
if((General.Map != null) && (mouseinput == null) && (General.Map.Editing.Mode != null)) General.Map.Editing.Mode.OnMouseMove(e);
if((General.Map != null) && (mouseinput == null) && (General.Editing.Mode != null)) General.Editing.Mode.OnMouseMove(e);
}
// Mouse up
@ -933,7 +933,7 @@ namespace CodeImp.DoomBuilder.Windows
General.Actions.KeyReleased(key);
// Invoke on editing mode
if((General.Map != null) && (General.Map.Editing.Mode != null)) General.Map.Editing.Mode.OnMouseUp(e);
if((General.Map != null) && (General.Editing.Mode != null)) General.Editing.Mode.OnMouseUp(e);
}
#endregion
@ -1082,7 +1082,7 @@ namespace CodeImp.DoomBuilder.Windows
General.Actions.KeyPressed((int)e.KeyData);
// Invoke on editing mode
if((General.Map != null) && (General.Map.Editing.Mode != null)) General.Map.Editing.Mode.OnKeyDown(e);
if((General.Map != null) && (General.Editing.Mode != null)) General.Editing.Mode.OnKeyDown(e);
}
// When a key is released
@ -1103,7 +1103,7 @@ namespace CodeImp.DoomBuilder.Windows
General.Actions.KeyReleased((int)e.KeyData);
// Invoke on editing mode
if((General.Map != null) && (General.Map.Editing.Mode != null)) General.Map.Editing.Mode.OnKeyUp(e);
if((General.Map != null) && (General.Editing.Mode != null)) General.Editing.Mode.OnKeyUp(e);
}
#endregion
@ -1639,9 +1639,9 @@ namespace CodeImp.DoomBuilder.Windows
// Enable/disable items
itemundo.Enabled = (General.Map != null) && (General.Map.UndoRedo.NextUndo != null);
itemredo.Enabled = (General.Map != null) && (General.Map.UndoRedo.NextRedo != null);
itemcut.Enabled = (General.Map != null) && General.Map.Editing.Mode.Attributes.AllowCopyPaste;
itemcopy.Enabled = (General.Map != null) && General.Map.Editing.Mode.Attributes.AllowCopyPaste;
itempaste.Enabled = (General.Map != null) && General.Map.Editing.Mode.Attributes.AllowCopyPaste;
itemcut.Enabled = (General.Map != null) && General.Editing.Mode.Attributes.AllowCopyPaste;
itemcopy.Enabled = (General.Map != null) && General.Editing.Mode.Attributes.AllowCopyPaste;
itempaste.Enabled = (General.Map != null) && General.Editing.Mode.Attributes.AllowCopyPaste;
itemmapoptions.Enabled = (General.Map != null);
itemsnaptogrid.Enabled = (General.Map != null);
itemautomerge.Enabled = (General.Map != null);
@ -2041,13 +2041,13 @@ namespace CodeImp.DoomBuilder.Windows
{
// Process mouse input
deltamouse = mouseinput.Process();
if((General.Map != null) && (General.Map.Editing.Mode != null))
General.Map.Editing.Mode.OnMouseInput(deltamouse);
if((General.Map != null) && (General.Editing.Mode != null))
General.Editing.Mode.OnMouseInput(deltamouse);
}
// Process signal
if((General.Map != null) && (General.Map.Editing.Mode != null))
General.Map.Editing.Mode.OnProcess(deltatime);
if((General.Map != null) && (General.Editing.Mode != null))
General.Editing.Mode.OnProcess(deltatime);
}
#endregion