- added some new menus in the plugin

- volatile mode may not be started from a volatile mode by shortcut key!
- added ability to cancel an editing mode change
- added mipmap levels setting to images (this fixes blurred fonts in low-quality display)
This commit is contained in:
codeimp 2008-05-14 21:48:36 +00:00
parent 7c08847a5b
commit d7656f1f3b
23 changed files with 554 additions and 20 deletions

View file

@ -38,6 +38,12 @@
<Compile Include="ClassicModes\DragGeometryMode.cs" />
<Compile Include="ClassicModes\DrawGeometryMode.cs" />
<Compile Include="General\BuilderPlug.cs" />
<Compile Include="Interface\MenusForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Interface\MenusForm.Designer.cs">
<DependentUpon>MenusForm.cs</DependentUpon>
</Compile>
<Compile Include="Testing\TriangulatorMode.cs" />
<Compile Include="ClassicModes\DragThingsMode.cs" />
<Compile Include="General\LineLengthLabel.cs" />
@ -93,6 +99,10 @@
<EmbeddedResource Include="Resources\WAuthor.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Interface\MenusForm.resx">
<SubType>Designer</SubType>
<DependentUpon>MenusForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Resources\VisualMode.png" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

View file

@ -34,7 +34,7 @@ using CodeImp.DoomBuilder.Editing;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
public abstract class DragGeometryMode : ClassicMode
{
@ -87,6 +87,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// Just keep the base mode button checked
public override string EditModeButtonName { get { return basemode.GetType().Name; } }
internal EditMode BaseMode { get { return basemode; } }
#endregion
@ -300,11 +302,12 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
public override void Disengage()
{
base.Disengage();
Cursor.Current = Cursors.AppStarting;
// When not cancelled
if(!cancelled)
{
Cursor.Current = Cursors.AppStarting;
// Move geometry back to original position
MoveGeometryRelative(new Vector2D(0f, 0f), false, false);
@ -323,15 +326,13 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// Update cached values
General.Map.Map.Update();
// Map is changed
// Done
Cursor.Current = Cursors.Default;
General.Map.IsChanged = true;
}
// Hide highlight info
General.Interface.HideInfo();
// Done
Cursor.Current = Cursors.Default;
}
// This checks if the view offset/zoom changed and updates the check

View file

@ -34,7 +34,7 @@ using CodeImp.DoomBuilder.Editing;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
// No action or button for this mode, it is automatic.
// The EditMode attribute does not have to be specified unless the

View file

@ -34,7 +34,7 @@ using CodeImp.DoomBuilder.Editing;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
// No action or button for this mode, it is automatic.
// The EditMode attribute does not have to be specified unless the

View file

@ -34,7 +34,7 @@ using CodeImp.DoomBuilder.Editing;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
// No action or button for this mode, it is automatic.
// The EditMode attribute does not have to be specified unless the
@ -86,6 +86,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// Just keep the base mode button checked
public override string EditModeButtonName { get { return basemode.GetType().Name; } }
internal EditMode BaseMode { get { return basemode; } }
#endregion

View file

@ -34,7 +34,7 @@ using CodeImp.DoomBuilder.Editing;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
// No action or button for this mode, it is automatic.
// The EditMode attribute does not have to be specified unless the

View file

@ -35,7 +35,7 @@ using CodeImp.DoomBuilder.Controls;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
[EditMode(SwitchAction = "drawlinesmode", Volatile = true)]
@ -82,6 +82,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// Just keep the base mode button checked
public override string EditModeButtonName { get { return basemode.GetType().Name; } }
internal EditMode BaseMode { get { return basemode; } }
#endregion
#region ================== Constructor / Disposer

View file

@ -33,7 +33,7 @@ using CodeImp.DoomBuilder.Editing;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
[EditMode(SwitchAction = "linedefsmode", // Action name used to switch to this mode
ButtonDesc = "Linedefs Mode", // Description on the button in toolbar/menu

View file

@ -34,7 +34,7 @@ using System.Drawing;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
[EditMode(SwitchAction = "sectorsmode", // Action name used to switch to this mode
ButtonDesc = "Sectors Mode", // Description on the button in toolbar/menu

View file

@ -33,7 +33,7 @@ using CodeImp.DoomBuilder.Editing;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
[EditMode(SwitchAction = "thingsmode", // Action name used to switch to this mode
ButtonDesc = "Things Mode", // Description on the button in toolbar/menu

View file

@ -33,7 +33,7 @@ using CodeImp.DoomBuilder.Editing;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Editing
namespace CodeImp.DoomBuilder.BuilderModes
{
[EditMode(SwitchAction = "verticesmode", // Action name used to switch to this mode
ButtonDesc = "Vertices Mode", // Description on the button in toolbar/menu

View file

@ -0,0 +1,181 @@
namespace CodeImp.DoomBuilder.BuilderModes
{
partial class MenusForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if(disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.menustrip = new System.Windows.Forms.MenuStrip();
this.linedefsmenu = new System.Windows.Forms.ToolStripMenuItem();
this.sectorsmenu = new System.Windows.Forms.ToolStripMenuItem();
this.thingsmenu = new System.Windows.Forms.ToolStripMenuItem();
this.fliplinedefsitem = new System.Windows.Forms.ToolStripMenuItem();
this.flipsidedefsitem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.curvelinedefsitem = new System.Windows.Forms.ToolStripMenuItem();
this.joinsectorsitem = new System.Windows.Forms.ToolStripMenuItem();
this.mergesectorsitem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
this.rotatethingscwitem = new System.Windows.Forms.ToolStripMenuItem();
this.rotatethingsccwitem = new System.Windows.Forms.ToolStripMenuItem();
this.menustrip.SuspendLayout();
this.SuspendLayout();
//
// menustrip
//
this.menustrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.linedefsmenu,
this.sectorsmenu,
this.thingsmenu});
this.menustrip.Location = new System.Drawing.Point(0, 0);
this.menustrip.Name = "menustrip";
this.menustrip.Size = new System.Drawing.Size(423, 24);
this.menustrip.TabIndex = 0;
this.menustrip.Text = "menustrip";
//
// linedefsmenu
//
this.linedefsmenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fliplinedefsitem,
this.flipsidedefsitem,
this.toolStripMenuItem1,
this.curvelinedefsitem});
this.linedefsmenu.Name = "linedefsmenu";
this.linedefsmenu.Size = new System.Drawing.Size(59, 20);
this.linedefsmenu.Text = "Linedefs";
this.linedefsmenu.Visible = false;
//
// sectorsmenu
//
this.sectorsmenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.joinsectorsitem,
this.mergesectorsitem,
this.toolStripMenuItem2});
this.sectorsmenu.Name = "sectorsmenu";
this.sectorsmenu.Size = new System.Drawing.Size(55, 20);
this.sectorsmenu.Text = "Sectors";
this.sectorsmenu.Visible = false;
//
// thingsmenu
//
this.thingsmenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.rotatethingscwitem,
this.rotatethingsccwitem});
this.thingsmenu.Name = "thingsmenu";
this.thingsmenu.Size = new System.Drawing.Size(50, 20);
this.thingsmenu.Text = "Things";
this.thingsmenu.Visible = false;
//
// fliplinedefsitem
//
this.fliplinedefsitem.Name = "fliplinedefsitem";
this.fliplinedefsitem.Size = new System.Drawing.Size(169, 22);
this.fliplinedefsitem.Text = "Flip Linedefs";
//
// flipsidedefsitem
//
this.flipsidedefsitem.Name = "flipsidedefsitem";
this.flipsidedefsitem.Size = new System.Drawing.Size(169, 22);
this.flipsidedefsitem.Text = "Flip Sidedefs";
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(166, 6);
//
// curvelinedefsitem
//
this.curvelinedefsitem.Name = "curvelinedefsitem";
this.curvelinedefsitem.Size = new System.Drawing.Size(169, 22);
this.curvelinedefsitem.Text = "Curve Linedefs...";
//
// joinsectorsitem
//
this.joinsectorsitem.Name = "joinsectorsitem";
this.joinsectorsitem.Size = new System.Drawing.Size(154, 22);
this.joinsectorsitem.Text = "Join Sectors";
//
// mergesectorsitem
//
this.mergesectorsitem.Name = "mergesectorsitem";
this.mergesectorsitem.Size = new System.Drawing.Size(154, 22);
this.mergesectorsitem.Text = "Merge Sectors";
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(151, 6);
//
// rotatethingscwitem
//
this.rotatethingscwitem.Name = "rotatethingscwitem";
this.rotatethingscwitem.Size = new System.Drawing.Size(204, 22);
this.rotatethingscwitem.Text = "Rotate Clockwise";
//
// rotatethingsccwitem
//
this.rotatethingsccwitem.Name = "rotatethingsccwitem";
this.rotatethingsccwitem.Size = new System.Drawing.Size(204, 22);
this.rotatethingsccwitem.Text = "Rotate Counterclockwise";
//
// MenusForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(423, 248);
this.Controls.Add(this.menustrip);
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MainMenuStrip = this.menustrip;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MenusForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "MenusForm";
this.menustrip.ResumeLayout(false);
this.menustrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menustrip;
private System.Windows.Forms.ToolStripMenuItem linedefsmenu;
private System.Windows.Forms.ToolStripMenuItem sectorsmenu;
private System.Windows.Forms.ToolStripMenuItem thingsmenu;
private System.Windows.Forms.ToolStripMenuItem fliplinedefsitem;
private System.Windows.Forms.ToolStripMenuItem flipsidedefsitem;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem curvelinedefsitem;
private System.Windows.Forms.ToolStripMenuItem joinsectorsitem;
private System.Windows.Forms.ToolStripMenuItem mergesectorsitem;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
private System.Windows.Forms.ToolStripMenuItem rotatethingscwitem;
private System.Windows.Forms.ToolStripMenuItem rotatethingsccwitem;
}
}

View file

@ -0,0 +1,119 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Interface;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Editing;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
public partial class MenusForm : Form
{
#region ================== Variables
// Menus list
private ToolStripItem[] menus;
#endregion
#region ================== Properties
public ToolStripMenuItem LinedefsMenu { get { return linedefsmenu; } }
public ToolStripMenuItem SectorsMenu { get { return sectorsmenu; } }
public ToolStripMenuItem ThingsMenu { get { return thingsmenu; } }
#endregion
#region ================== Constructor / Disposer
// Constructor
public MenusForm()
{
// Initialize
InitializeComponent();
// List all menus
menus = new ToolStripItem[menustrip.Items.Count];
for(int i = 0; i < menustrip.Items.Count; i++) menus[i] = menustrip.Items[i];
}
#endregion
#region ================== Methods
// This registers with the core
public void Register()
{
// Add the menus to the core
foreach(ToolStripMenuItem m in menus)
General.Interface.AddMenu(m);
}
// This unregisters from the core
public void Unregister()
{
// Remove the menus from the core
foreach(ToolStripMenuItem m in menus)
General.Interface.RemoveMenu(m);
}
// This hides all menus
public void HideAllMenus()
{
foreach(ToolStripMenuItem m in menus) m.Visible = false;
}
// This hides all except one menu
public void HideAllMenusExcept(ToolStripMenuItem showthis)
{
HideAllMenus();
showthis.Visible = true;
}
// This shows the menu for the current editing mode
public void ShowEditingModeMenu(EditMode mode)
{
// When these modes are active, then test against the base mode they will return to
if(mode is DragGeometryMode) mode = (mode as DragGeometryMode).BaseMode;
if(mode is DragThingsMode) mode = (mode as DragThingsMode).BaseMode;
if(mode is DrawGeometryMode) mode = (mode as DrawGeometryMode).BaseMode;
// Final decision
if(mode is LinedefsMode) HideAllMenusExcept(linedefsmenu);
else if(mode is SectorsMode) HideAllMenusExcept(sectorsmenu);
else if(mode is ThingsMode) HideAllMenusExcept(thingsmenu);
else HideAllMenus();
}
#endregion
}
}

View file

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menustrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -66,6 +66,7 @@ namespace CodeImp.DoomBuilder.Data
private PixelColorBlock pixeldata;
// Direct3D texture
private int mipmaplevels = 0; // 0 creates the full chain
private Texture texture;
// Disposing
@ -86,6 +87,7 @@ namespace CodeImp.DoomBuilder.Data
internal bool Temporary { get { return temporary; } set { temporary = value; } }
internal int LoadState { get { return loadstate; } set { loadstate = value; } }
internal LinkedListNode<ImageData> LoadingTicket { get { return loadingticket; } set { loadingticket = value; } }
public int MipMapLevels { get { return mipmaplevels; } set { mipmaplevels = value; } }
public int Width { get { return width; } }
public int Height { get { return height; } }
public float ScaledWidth { get { return scaledwidth; } }
@ -214,7 +216,7 @@ namespace CodeImp.DoomBuilder.Data
memstream = new MemoryStream();
bitmap.Save(memstream, ImageFormat.Bmp);
memstream.Seek(0, SeekOrigin.Begin);
texture = Texture.FromStream(General.Map.Graphics.Device, memstream, (int)memstream.Length, bitmap.Size.Width, bitmap.Size.Height, 0,
texture = Texture.FromStream(General.Map.Graphics.Device, memstream, (int)memstream.Length, bitmap.Size.Width, bitmap.Size.Height, mipmaplevels,
Usage.None, Format.Unknown, Pool.Managed, Filter.Box, Filter.Box, 0);
memstream.Dispose();
}

View file

@ -44,6 +44,7 @@ namespace CodeImp.DoomBuilder.Editing
private Plugin plugin;
private Type type;
private bool configspecific;
private bool isvolatile;
// Mode switching
private BeginActionAttribute switchactionattr = null;
@ -65,7 +66,8 @@ namespace CodeImp.DoomBuilder.Editing
public Image ButtonImage { get { return buttonimage; } }
public string ButtonDesc { get { return buttondesc; } }
public bool ConfigSpecific { get { return configspecific; } }
public bool Volatile { get { return isvolatile; } }
#endregion
#region ================== Constructor / Disposer
@ -77,12 +79,13 @@ namespace CodeImp.DoomBuilder.Editing
this.plugin = plugin;
this.type = type;
this.configspecific = attr.ConfigSpecific;
this.isvolatile = attr.Volatile;
// Make switch action info
if((attr.SwitchAction != null) && (attr.SwitchAction.Length > 0))
{
switchactionattr = new BeginActionAttribute(attr.SwitchAction);
switchactiondel = new ActionDelegate(SwitchToMode);
switchactiondel = new ActionDelegate(UserSwitchToMode);
// Bind switch action
General.Actions.BindBeginDelegate(plugin.Assembly, switchactiondel, switchactionattr);
@ -120,6 +123,27 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Methods
// This switches to the mode by user command
// (when user presses shortcut key)
public void UserSwitchToMode()
{
EditMode newmode;
// Only when a map is opened
if(General.Map != null)
{
// Not switching from volatile mode to volatile mode?
if((General.Map.Mode == null) || !General.Map.Mode.Attributes.Volatile || !this.isvolatile)
{
// Create instance
newmode = plugin.CreateObject<EditMode>(type);
// Switch mode
General.Map.ChangeMode(newmode);
}
}
}
// This switches to the mode
public void SwitchToMode()
{

View file

@ -79,6 +79,7 @@ namespace CodeImp.DoomBuilder
private WAD tempwad;
private GridSetup grid;
private UndoManager undoredo;
private bool cancelmodechange;
// Disposing
private bool isdisposed = false;
@ -104,6 +105,7 @@ namespace CodeImp.DoomBuilder
public GridSetup Grid { get { return grid; } }
public UndoManager UndoRedo { get { return undoredo; } }
public IMapSetIO FormatInterface { get { return io; } }
public bool CancelModeChange { get { return cancelmodechange; } set { cancelmodechange |= value; } }
#endregion
@ -835,16 +837,34 @@ namespace CodeImp.DoomBuilder
{
EditMode oldmode = mode;
newmode = nextmode;
cancelmodechange = false;
// Log info
if(newmode != null)
General.WriteLogLine("Switching edit mode to " + newmode.GetType().Name + "...");
else
General.WriteLogLine("Stopping edit mode...");
// Let the plugins know beforehand
General.Plugins.ModeChanges(oldmode, newmode);
// Change cancelled?
if(cancelmodechange)
{
General.WriteLogLine("Edit mode change cancelled.");
return;
}
// Disenagage old mode
if(oldmode != null) oldmode.Disengage();
// Change cancelled?
if(cancelmodechange)
{
General.WriteLogLine("Edit mode change cancelled.");
return;
}
// Apply new mode
mode = newmode;
@ -942,6 +962,9 @@ namespace CodeImp.DoomBuilder
// Re-link the background image
grid.LinkBackground();
// Inform all plugins that the resource are reloaded
General.Plugins.ReloadResources();
// Reset status
General.MainWindow.DisplayStatus(oldstatus);
Cursor.Current = oldcursor;

View file

@ -68,5 +68,7 @@ namespace CodeImp.DoomBuilder.Interface
void BreakExclusiveMouseInput();
void ResumeExclusiveMouseInput();
bool CheckActionActive(Assembly assembly, string actionname);
void AddMenu(ToolStripMenuItem menu);
void RemoveMenu(ToolStripMenuItem menu);
}
}

View file

@ -933,6 +933,19 @@ namespace CodeImp.DoomBuilder.Interface
#region ================== Menus
// This adds a menu to the menus bar
public void AddMenu(ToolStripMenuItem menu)
{
// Insert the menu before the Tools menu
menumain.Items.Insert(menumain.Items.IndexOf(menutools), menu);
}
// This removes a menu to the menus bar
public void RemoveMenu(ToolStripMenuItem menu)
{
menumain.Items.Remove(menu);
}
// Public method to apply shortcut keys
internal void ApplyShortcutKeys()
{

View file

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using CodeImp.DoomBuilder.Editing;
#endregion
@ -100,6 +101,22 @@ namespace CodeImp.DoomBuilder.Plugins
{
return plugin.GetResourceStream(resourcename);
}
/// <summary>
/// This is called by the Doom Builder core when the user chose to reload the resources.
/// </summary>
public virtual void ReloadResources()
{
}
/// <summary>
/// This is called by the Doom Builder core when the editing mode changes.
/// </summary>
/// <param name="oldmode">The previous editing mode</param>
/// <param name="newmode">The new editing mode</param>
public virtual void ModeChanges(EditMode oldmode, EditMode newmode)
{
}
#endregion
}

View file

@ -92,7 +92,7 @@ namespace CodeImp.DoomBuilder.Plugins
{
// How can we plug something in without a plug?
General.WriteLogLine("ERROR: Could not load plugin '" + name + "', plugin is missing the plug!");
throw new Exception();
throw new InvalidProgramException();
}
// Load actions

View file

@ -80,7 +80,7 @@ namespace CodeImp.DoomBuilder.Plugins
{
p = new Plugin(fn);
}
catch(Exception)
catch(InvalidProgramException)
{
General.WriteLogLine("WARNING: Plugin file '" + Path.GetFileName(fn) + "' was not loaded.");
p = null;
@ -186,6 +186,20 @@ namespace CodeImp.DoomBuilder.Plugins
// Nothing found
return null;
}
// This calls ReloadResources on all plugins
public void ReloadResources()
{
foreach(Plugin p in plugins)
p.Plug.ReloadResources();
}
// This calls ModeChanges on all plugins
public void ModeChanges(EditMode oldmode, EditMode newmode)
{
foreach(Plugin p in plugins)
p.Plug.ModeChanges(oldmode, newmode);
}
#endregion
}

View file

@ -266,6 +266,7 @@ namespace CodeImp.DoomBuilder.Rendering
font = new TextFont();
fonttexture = new ResourceImage("Font.png");
fonttexture.LoadImage();
fonttexture.MipMapLevels = 2;
fonttexture.CreateTexture();
// Initialize settings