This commit is contained in:
codeimp 2008-11-27 13:42:18 +00:00
parent bc465effea
commit d49b31dfc0
12 changed files with 62 additions and 31 deletions

View file

@ -99,7 +99,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Testing\TriangulatorMode.cs" />
<None Include="Testing\TriangulatorMode.cs" />
<Compile Include="ClassicModes\DragThingsMode.cs" />
<Compile Include="General\LineLengthLabel.cs" />
<Compile Include="VisualModes\BaseVisualMode.cs" />
@ -110,7 +110,7 @@
<Compile Include="VisualModes\VisualFloor.cs" />
<Compile Include="VisualModes\VisualLower.cs" />
<Compile Include="VisualModes\VisualMiddle.cs" />
<Compile Include="Testing\WAuthorMode.cs" />
<None Include="Testing\WAuthorMode.cs" />
<Compile Include="Testing\WAuthorTools.cs">
<SubType>Form</SubType>
</Compile>

View file

@ -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)

View file

@ -34,7 +34,7 @@ using CodeImp.DoomBuilder.VisualModes;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class BaseVisualSector : VisualSector
{

View file

@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.VisualModes;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class VisualCeiling : VisualGeometry
{

View file

@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.VisualModes;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class VisualFloor : VisualGeometry
{

View file

@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.VisualModes;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class VisualLower : VisualGeometry
{

View file

@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.VisualModes;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class VisualMiddle : VisualGeometry
{

View file

@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.VisualModes;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class VisualUpper : VisualGeometry
{

View file

@ -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()

View file

@ -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();

View file

@ -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();

View file

@ -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);