From d49b31dfc07957ac41bf2361aff843e900ae2507 Mon Sep 17 00:00:00 2001 From: codeimp Date: Thu, 27 Nov 2008 13:42:18 +0000 Subject: [PATCH] miauw --- Source/BuilderModes/BuilderModes.csproj | 4 +- .../VisualModes/BaseVisualMode.cs | 5 ++- .../VisualModes/BaseVisualSector.cs | 2 +- .../BuilderModes/VisualModes/VisualCeiling.cs | 2 +- .../BuilderModes/VisualModes/VisualFloor.cs | 2 +- .../BuilderModes/VisualModes/VisualLower.cs | 2 +- .../BuilderModes/VisualModes/VisualMiddle.cs | 2 +- .../BuilderModes/VisualModes/VisualUpper.cs | 2 +- Source/Editing/EditModeInfo.cs | 40 +++++++++++++------ Source/Editing/EditingManager.cs | 19 ++++++++- Source/General/General.cs | 7 ++-- Source/Windows/MainForm.cs | 6 +-- 12 files changed, 62 insertions(+), 31 deletions(-) diff --git a/Source/BuilderModes/BuilderModes.csproj b/Source/BuilderModes/BuilderModes.csproj index 353ae41b..c99e7931 100644 --- a/Source/BuilderModes/BuilderModes.csproj +++ b/Source/BuilderModes/BuilderModes.csproj @@ -99,7 +99,7 @@ True Resources.resx - + @@ -110,7 +110,7 @@ - + Form diff --git a/Source/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/BuilderModes/VisualModes/BaseVisualMode.cs index 70c63015..2e28e6cf 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualMode.cs @@ -35,9 +35,10 @@ using CodeImp.DoomBuilder.VisualModes; #endregion -namespace CodeImp.DoomBuilder.BuilderModes.Editing +namespace CodeImp.DoomBuilder.BuilderModes { - [EditMode(SwitchAction = "visualmode", // Action name used to switch to this mode + [EditMode(DisplayName = "Visual Mode", + SwitchAction = "visualmode", // Action name used to switch to this mode ButtonDesc = "Visual Mode", // Description on the button in toolbar/menu ButtonImage = "VisualMode.png", // Image resource name for the button ButtonOrder = 0)] // Position of the button (lower is more to the left) diff --git a/Source/BuilderModes/VisualModes/BaseVisualSector.cs b/Source/BuilderModes/VisualModes/BaseVisualSector.cs index 61c1f1fc..86622d19 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualSector.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualSector.cs @@ -34,7 +34,7 @@ using CodeImp.DoomBuilder.VisualModes; #endregion -namespace CodeImp.DoomBuilder.BuilderModes.Editing +namespace CodeImp.DoomBuilder.BuilderModes { internal class BaseVisualSector : VisualSector { diff --git a/Source/BuilderModes/VisualModes/VisualCeiling.cs b/Source/BuilderModes/VisualModes/VisualCeiling.cs index 9ef477b1..c764dc6c 100644 --- a/Source/BuilderModes/VisualModes/VisualCeiling.cs +++ b/Source/BuilderModes/VisualModes/VisualCeiling.cs @@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.VisualModes; #endregion -namespace CodeImp.DoomBuilder.BuilderModes.Editing +namespace CodeImp.DoomBuilder.BuilderModes { internal class VisualCeiling : VisualGeometry { diff --git a/Source/BuilderModes/VisualModes/VisualFloor.cs b/Source/BuilderModes/VisualModes/VisualFloor.cs index a4dc3043..ec285aeb 100644 --- a/Source/BuilderModes/VisualModes/VisualFloor.cs +++ b/Source/BuilderModes/VisualModes/VisualFloor.cs @@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.VisualModes; #endregion -namespace CodeImp.DoomBuilder.BuilderModes.Editing +namespace CodeImp.DoomBuilder.BuilderModes { internal class VisualFloor : VisualGeometry { diff --git a/Source/BuilderModes/VisualModes/VisualLower.cs b/Source/BuilderModes/VisualModes/VisualLower.cs index 4f682d50..e7f657b0 100644 --- a/Source/BuilderModes/VisualModes/VisualLower.cs +++ b/Source/BuilderModes/VisualModes/VisualLower.cs @@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.VisualModes; #endregion -namespace CodeImp.DoomBuilder.BuilderModes.Editing +namespace CodeImp.DoomBuilder.BuilderModes { internal class VisualLower : VisualGeometry { diff --git a/Source/BuilderModes/VisualModes/VisualMiddle.cs b/Source/BuilderModes/VisualModes/VisualMiddle.cs index f5846102..c8d7db77 100644 --- a/Source/BuilderModes/VisualModes/VisualMiddle.cs +++ b/Source/BuilderModes/VisualModes/VisualMiddle.cs @@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.VisualModes; #endregion -namespace CodeImp.DoomBuilder.BuilderModes.Editing +namespace CodeImp.DoomBuilder.BuilderModes { internal class VisualMiddle : VisualGeometry { diff --git a/Source/BuilderModes/VisualModes/VisualUpper.cs b/Source/BuilderModes/VisualModes/VisualUpper.cs index 393dfcec..fd35ea4f 100644 --- a/Source/BuilderModes/VisualModes/VisualUpper.cs +++ b/Source/BuilderModes/VisualModes/VisualUpper.cs @@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.VisualModes; #endregion -namespace CodeImp.DoomBuilder.BuilderModes.Editing +namespace CodeImp.DoomBuilder.BuilderModes { internal class VisualUpper : VisualGeometry { diff --git a/Source/Editing/EditModeInfo.cs b/Source/Editing/EditModeInfo.cs index 7d58b2da..41b9edf9 100644 --- a/Source/Editing/EditModeInfo.cs +++ b/Source/Editing/EditModeInfo.cs @@ -78,16 +78,6 @@ namespace CodeImp.DoomBuilder.Editing this.type = type; this.attribs = attr; - // Make switch action info - if((attr.SwitchAction != null) && (attr.SwitchAction.Length > 0)) - { - switchactionattr = new BeginActionAttribute(attr.SwitchAction); - switchactiondel = new ActionDelegate(UserSwitchToMode); - - // Bind switch action - General.Actions.BindBeginDelegate(plugin.Assembly, switchactiondel, switchactionattr); - } - // Make button info if((attr.ButtonImage != null) && (attr.ButtonDesc != null)) { @@ -107,8 +97,8 @@ namespace CodeImp.DoomBuilder.Editing // Disposer public void Dispose() { - // Unbind switch action - if(switchactiondel != null) General.Actions.UnbindBeginDelegate(plugin.Assembly, switchactiondel, switchactionattr); + // Dispose + UnbindSwitchAction(); buttonimage.Dispose(); buttonimagestream.Dispose(); @@ -119,7 +109,31 @@ namespace CodeImp.DoomBuilder.Editing #endregion #region ================== Methods - + + // This binds the action to switch to this editing mode + public void BindSwitchAction() + { + // Make switch action info + if((switchactiondel == null) && (attribs.SwitchAction != null) && (attribs.SwitchAction.Length > 0)) + { + switchactionattr = new BeginActionAttribute(attribs.SwitchAction); + switchactiondel = new ActionDelegate(UserSwitchToMode); + + // Bind switch action + General.Actions.BindBeginDelegate(plugin.Assembly, switchactiondel, switchactionattr); + } + } + + // This unbind the switch action + public void UnbindSwitchAction() + { + if(switchactiondel != null) + { + General.Actions.UnbindBeginDelegate(plugin.Assembly, switchactiondel, switchactionattr); + switchactiondel = null; + } + } + // This switches to the mode by user command // (when user presses shortcut key) public void UserSwitchToMode() diff --git a/Source/Editing/EditingManager.cs b/Source/Editing/EditingManager.cs index 0b87bc73..74139bab 100644 --- a/Source/Editing/EditingManager.cs +++ b/Source/Editing/EditingManager.cs @@ -143,9 +143,24 @@ namespace CodeImp.DoomBuilder.Editing // This is called when the editing modes must update internal void UpdateCurrentEditModes() { - // For now we use all the modes we can find + // Unbind editing mode switch actions + foreach(EditModeInfo emi in allmodes) + emi.UnbindSwitchAction(); + + // Rebuild list of used modes usedmodes.Clear(); - usedmodes.AddRange(allmodes); + if(General.Map != null) + { + foreach(EditModeInfo emi in allmodes) + { + if(General.Map.ConfigSettings.EditModes.Contains(emi.Type.FullName)) + { + // Add the mode to be used and bind switch action + usedmodes.Add(emi); + emi.BindSwitchAction(); + } + } + } // Remove editing mode buttons from interface General.MainWindow.RemoveEditModeButtons(); diff --git a/Source/General/General.cs b/Source/General/General.cs index 61b344da..2d5145bb 100644 --- a/Source/General/General.cs +++ b/Source/General/General.cs @@ -926,16 +926,17 @@ namespace CodeImp.DoomBuilder mainwindow.DisplayStatus("Closing map..."); General.WriteLogLine("Unloading map..."); Cursor.Current = Cursors.WaitCursor; - + // Trash the current map if(map != null) map.Dispose(); map = null; - + // Show splash logo on display mainwindow.ShowSplashDisplay(); - + // Done Cursor.Current = Cursors.Default; + editing.UpdateCurrentEditModes(); mainwindow.RedrawDisplay(); mainwindow.HideInfo(); mainwindow.UpdateInterface(); diff --git a/Source/Windows/MainForm.cs b/Source/Windows/MainForm.cs index 7280f2f2..4bfa4a74 100644 --- a/Source/Windows/MainForm.cs +++ b/Source/Windows/MainForm.cs @@ -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.Editing.Mode.Attributes.AllowCopyPaste; - itemcopy.Enabled = (General.Map != null) && General.Editing.Mode.Attributes.AllowCopyPaste; - itempaste.Enabled = (General.Map != null) && General.Editing.Mode.Attributes.AllowCopyPaste; + itemcut.Enabled = (General.Map != null) && (General.Editing.Mode != null) && General.Editing.Mode.Attributes.AllowCopyPaste; + itemcopy.Enabled = (General.Map != null) && (General.Editing.Mode != null) && General.Editing.Mode.Attributes.AllowCopyPaste; + itempaste.Enabled = (General.Map != null) && (General.Editing.Mode != null) && General.Editing.Mode.Attributes.AllowCopyPaste; itemmapoptions.Enabled = (General.Map != null); itemsnaptogrid.Enabled = (General.Map != null); itemautomerge.Enabled = (General.Map != null);