diff --git a/Build/Builder.cfg b/Build/Builder.cfg
index 8bc5ccb1..eb2a0cac 100644
--- a/Build/Builder.cfg
+++ b/Build/Builder.cfg
@@ -1,16 +1,34 @@
shortcuts
{
- closemap = 0;
- configuration = 116;
- newmap = 131150;
- openmap = 131151;
- scrolleast = 39;
- scrollnorth = 38;
- scrollsouth = 40;
- scrollwest = 37;
- zoomin = 65530;
- zoomout = 65531;
+ builder_closemap = 0;
+ builder_configuration = 117;
+ builder_newmap = 131150;
+ builder_openmap = 131151;
+ builder_scrolleast = 39;
+ builder_scrollnorth = 38;
+ builder_scrollsouth = 40;
+ builder_scrollwest = 37;
+ builder_zoomin = 65530;
+ builder_zoomout = 65531;
+ builder_preferences = 116;
+ builder_savemap = 0;
+ builder_savemapas = 0;
+ builder_savemapinto = 0;
+ builder_mapoptions = 113;
+ builder_reloadresources = 119;
+ builder_testaction = 123;
+ builder_cancelmode = 27;
+ builder_gridsetup = 71;
+ builder_undo = 131162;
+ builder_redo = 131161;
+ builder_togglesnap = 0;
+ builder_clearselection = 67;
+ builder_toggleautomerge = 0;
+ buildermodes_thingsmode = 84;
+ buildermodes_linedefsmode = 76;
+ buildermodes_verticesmode = 86;
+ buildermodes_sectorsmode = 83;
}
diff --git a/Builder.sln b/Builder.sln
index c9c09102..00da3f6a 100644
--- a/Builder.sln
+++ b/Builder.sln
@@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Source\Builder.csproj", "{818B3D10-F791-4C3F-9AF5-BB2D0079B63C}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuilderModes", "Source\BuilderModes\BuilderModes.csproj", "{B42D5AA0-F9A6-4234-9C4B-A05B11A64851}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -13,6 +15,10 @@ Global
{818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Resources/Icons/WAuthor.png b/Resources/Icons/WAuthor.png
new file mode 100644
index 00000000..b98bed40
Binary files /dev/null and b/Resources/Icons/WAuthor.png differ
diff --git a/Source/Builder.csproj b/Source/Builder.csproj
index 269c3c19..7f451676 100644
--- a/Source/Builder.csproj
+++ b/Source/Builder.csproj
@@ -69,16 +69,13 @@
-
+
+
-
-
-
-
@@ -169,6 +166,7 @@
ImageSelectorControl.cs
+
Form
@@ -278,6 +276,8 @@
+
+
True
@@ -292,6 +292,8 @@
+
+
@@ -349,13 +351,9 @@
-
-
-
-
diff --git a/Source/BuilderModes/BuilderModes.csproj b/Source/BuilderModes/BuilderModes.csproj
new file mode 100644
index 00000000..f1578f2e
--- /dev/null
+++ b/Source/BuilderModes/BuilderModes.csproj
@@ -0,0 +1,80 @@
+
+
+ Debug
+ AnyCPU
+ 8.0.50727
+ 2.0
+ {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}
+ Library
+ Properties
+ CodeImp.DoomBuilder.BuilderModes
+ BuilderModes
+
+
+ true
+ full
+ false
+ ..\..\Build\Plugins\
+ DEBUG;TRACE
+ prompt
+ 4
+ true
+
+
+ pdbonly
+ true
+ ..\..\Build\Plugins\
+
+
+ prompt
+ 4
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}
+ Builder
+ False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Source/Editing/DragVerticesMode.cs b/Source/BuilderModes/Editing/DragVerticesMode.cs
similarity index 87%
rename from Source/Editing/DragVerticesMode.cs
rename to Source/BuilderModes/Editing/DragVerticesMode.cs
index d3cbc685..0ba326af 100644
--- a/Source/Editing/DragVerticesMode.cs
+++ b/Source/BuilderModes/Editing/DragVerticesMode.cs
@@ -30,6 +30,7 @@ using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
+using CodeImp.DoomBuilder.Editing;
#endregion
@@ -37,8 +38,9 @@ using System.Drawing;
// 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
+namespace CodeImp.DoomBuilder.BuilderModes.Editing
{
+ [EditMode]
public class DragVerticesMode : ClassicMode
{
#region ================== Constants
@@ -77,6 +79,9 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Properties
+ // Just keep the vertices mode button checked
+ public override string EditModeButtonName { get { return typeof(VerticesMode).Name; } }
+
#endregion
#region ================== Constructor / Disposer
@@ -116,7 +121,7 @@ namespace CodeImp.DoomBuilder.Editing
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public override void Dispose()
{
// Not already disposed?
@@ -219,9 +224,6 @@ namespace CodeImp.DoomBuilder.Editing
public override void Engage()
{
base.Engage();
-
- // Check vertices button on main window
- General.MainWindow.SetVerticesChecked(true);
}
// Disenagaging
@@ -256,10 +258,9 @@ namespace CodeImp.DoomBuilder.Editing
}
// Hide highlight info
- General.MainWindow.HideInfo();
+ General.Interface.HideInfo();
- // Uncheck vertices button on main window
- General.MainWindow.SetVerticesChecked(false);
+ // Done
Cursor.Current = Cursors.Default;
}
@@ -287,8 +288,8 @@ namespace CodeImp.DoomBuilder.Editing
// This updates the dragging
private void Update()
{
- snaptogrid = General.MainWindow.ShiftState ^ General.MainWindow.SnapToGrid;
- snaptonearest = General.MainWindow.CtrlState;
+ snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
+ snaptonearest = General.Interface.CtrlState;
// Move selected geometry
if(MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest))
@@ -297,7 +298,7 @@ namespace CodeImp.DoomBuilder.Editing
General.Map.Map.Update();
// Redraw
- General.MainWindow.RedrawDisplay();
+ General.Interface.RedrawDisplay();
}
}
@@ -325,16 +326,16 @@ namespace CodeImp.DoomBuilder.Editing
public override void KeyUp(KeyEventArgs e)
{
base.KeyUp(e);
- if(snaptogrid != General.MainWindow.ShiftState ^ General.MainWindow.SnapToGrid) Update();
- if(snaptonearest != General.MainWindow.CtrlState) Update();
+ if(snaptogrid != General.Interface.ShiftState ^ General.Interface.SnapToGrid) Update();
+ if(snaptonearest != General.Interface.CtrlState) Update();
}
// When a key is pressed
public override void KeyDown(KeyEventArgs e)
{
base.KeyDown(e);
- if(snaptogrid != General.MainWindow.ShiftState ^ General.MainWindow.SnapToGrid) Update();
- if(snaptonearest != General.MainWindow.CtrlState) Update();
+ if(snaptogrid != General.Interface.ShiftState ^ General.Interface.SnapToGrid) Update();
+ if(snaptonearest != General.Interface.CtrlState) Update();
}
#endregion
diff --git a/Source/Editing/LinedefsMode.cs b/Source/BuilderModes/Editing/LinedefsMode.cs
similarity index 89%
rename from Source/Editing/LinedefsMode.cs
rename to Source/BuilderModes/Editing/LinedefsMode.cs
index b01857c7..e0a875b7 100644
--- a/Source/Editing/LinedefsMode.cs
+++ b/Source/BuilderModes/Editing/LinedefsMode.cs
@@ -29,11 +29,16 @@ using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
+using CodeImp.DoomBuilder.Editing;
#endregion
-namespace CodeImp.DoomBuilder.Editing
+namespace CodeImp.DoomBuilder.BuilderModes.Editing
{
+ [EditMode(SwitchAction = "linedefsmode",
+ ButtonDesc = "Linedefs Mode",
+ ButtonImage = "LinesMode.png",
+ ButtonOrder = int.MinValue + 1)]
public class LinedefsMode : ClassicMode
{
#region ================== Constants
@@ -60,7 +65,7 @@ namespace CodeImp.DoomBuilder.Editing
{
}
- // Diposer
+ // Disposer
public override void Dispose()
{
// Not already disposed?
@@ -90,9 +95,6 @@ namespace CodeImp.DoomBuilder.Editing
public override void Engage()
{
base.Engage();
-
- // Check linedefs button on main window
- General.MainWindow.SetLinedefsChecked(true);
}
// Mode disengages
@@ -117,10 +119,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// Hide highlight info
- General.MainWindow.HideInfo();
-
- // Uncheck linedefs button on main window
- General.MainWindow.SetLinedefsChecked(false);
+ General.Interface.HideInfo();
}
// This redraws the display
@@ -179,9 +178,9 @@ namespace CodeImp.DoomBuilder.Editing
// Show highlight info
if((highlighted != null) && !highlighted.IsDisposed)
- General.MainWindow.ShowLinedefInfo(highlighted);
+ General.Interface.ShowLinedefInfo(highlighted);
else
- General.MainWindow.HideInfo();
+ General.Interface.HideInfo();
}
// Mouse moves
@@ -242,7 +241,7 @@ namespace CodeImp.DoomBuilder.Editing
// Make this the only selection
General.Map.Map.ClearSelectedLinedefs();
highlighted.Selected = true;
- General.MainWindow.RedrawDisplay();
+ General.Interface.RedrawDisplay();
}
// Update display
@@ -286,13 +285,13 @@ namespace CodeImp.DoomBuilder.Editing
if(selected.Count > 0)
{
// Show line edit dialog
- LinedefEditForm.EditLinedefs(General.MainWindow, selected);
+ General.Interface.ShowEditLinedefs(selected);
// When a single line was selected, deselect it now
if(selected.Count == 1) General.Map.Map.ClearSelectedLinedefs();
// Update entire display
- General.MainWindow.RedrawDisplay();
+ General.Interface.RedrawDisplay();
}
}
}
diff --git a/Source/Editing/SectorsMode.cs b/Source/BuilderModes/Editing/SectorsMode.cs
similarity index 90%
rename from Source/Editing/SectorsMode.cs
rename to Source/BuilderModes/Editing/SectorsMode.cs
index 77e6a4d5..b65fb72d 100644
--- a/Source/Editing/SectorsMode.cs
+++ b/Source/BuilderModes/Editing/SectorsMode.cs
@@ -29,11 +29,16 @@ using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
+using CodeImp.DoomBuilder.Editing;
#endregion
-namespace CodeImp.DoomBuilder.Editing
+namespace CodeImp.DoomBuilder.BuilderModes.Editing
{
+ [EditMode(SwitchAction = "sectorsmode",
+ ButtonDesc = "Sectors Mode",
+ ButtonImage = "SectorsMode.png",
+ ButtonOrder = int.MinValue + 2)]
public class SectorsMode : ClassicMode
{
#region ================== Constants
@@ -58,7 +63,7 @@ namespace CodeImp.DoomBuilder.Editing
{
}
- // Diposer
+ // Disposer
public override void Dispose()
{
// Not already disposed?
@@ -88,9 +93,6 @@ namespace CodeImp.DoomBuilder.Editing
public override void Engage()
{
base.Engage();
-
- // Check sectors button on main window
- General.MainWindow.SetSectorsChecked(true);
}
// Mode disengages
@@ -115,10 +117,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// Hide highlight info
- General.MainWindow.HideInfo();
-
- // Uncheck sectors button on main window
- General.MainWindow.SetSectorsChecked(false);
+ General.Interface.HideInfo();
}
// This redraws the display
@@ -181,9 +180,9 @@ namespace CodeImp.DoomBuilder.Editing
// Show highlight info
if((highlighted != null) && !highlighted.IsDisposed)
- General.MainWindow.ShowSectorInfo(highlighted);
+ General.Interface.ShowSectorInfo(highlighted);
else
- General.MainWindow.HideInfo();
+ General.Interface.HideInfo();
}
// Mouse moves
diff --git a/Source/Editing/ThingsMode.cs b/Source/BuilderModes/Editing/ThingsMode.cs
similarity index 88%
rename from Source/Editing/ThingsMode.cs
rename to Source/BuilderModes/Editing/ThingsMode.cs
index 9b3e8074..4b2917e3 100644
--- a/Source/Editing/ThingsMode.cs
+++ b/Source/BuilderModes/Editing/ThingsMode.cs
@@ -29,11 +29,16 @@ using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
+using CodeImp.DoomBuilder.Editing;
#endregion
-namespace CodeImp.DoomBuilder.Editing
+namespace CodeImp.DoomBuilder.BuilderModes.Editing
{
+ [EditMode(SwitchAction = "thingsmode",
+ ButtonDesc = "Things Mode",
+ ButtonImage = "ThingsMode.png",
+ ButtonOrder = int.MinValue + 3)]
public class ThingsMode : ClassicMode
{
#region ================== Constants
@@ -60,7 +65,7 @@ namespace CodeImp.DoomBuilder.Editing
{
}
- // Diposer
+ // Disposer
public override void Dispose()
{
// Not already disposed?
@@ -90,9 +95,6 @@ namespace CodeImp.DoomBuilder.Editing
public override void Engage()
{
base.Engage();
-
- // Check things button on main window
- General.MainWindow.SetThingsChecked(true);
}
// Mode disengages
@@ -101,10 +103,7 @@ namespace CodeImp.DoomBuilder.Editing
base.Disengage();
// Hide highlight info
- General.MainWindow.HideInfo();
-
- // Uncheck things button on main window
- General.MainWindow.SetThingsChecked(false);
+ General.Interface.HideInfo();
}
// This redraws the display
@@ -153,9 +152,9 @@ namespace CodeImp.DoomBuilder.Editing
// Show highlight info
if((highlighted != null) && !highlighted.IsDisposed)
- General.MainWindow.ShowThingInfo(highlighted);
+ General.Interface.ShowThingInfo(highlighted);
else
- General.MainWindow.HideInfo();
+ General.Interface.HideInfo();
}
// Mouse moves
@@ -214,7 +213,7 @@ namespace CodeImp.DoomBuilder.Editing
// Make this the only selection
General.Map.Map.ClearSelectedThings();
highlighted.Selected = true;
- General.MainWindow.RedrawDisplay();
+ General.Interface.RedrawDisplay();
}
// Update display
@@ -259,7 +258,7 @@ namespace CodeImp.DoomBuilder.Editing
if(selected.Count == 1) General.Map.Map.ClearSelectedThings();
// Update entire display
- General.MainWindow.RedrawDisplay();
+ General.Interface.RedrawDisplay();
}
}
}
diff --git a/Source/Editing/VerticesMode.cs b/Source/BuilderModes/Editing/VerticesMode.cs
similarity index 89%
rename from Source/Editing/VerticesMode.cs
rename to Source/BuilderModes/Editing/VerticesMode.cs
index 38f2aa12..7816b93a 100644
--- a/Source/Editing/VerticesMode.cs
+++ b/Source/BuilderModes/Editing/VerticesMode.cs
@@ -29,11 +29,16 @@ using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
+using CodeImp.DoomBuilder.Editing;
#endregion
-namespace CodeImp.DoomBuilder.Editing
+namespace CodeImp.DoomBuilder.BuilderModes.Editing
{
+ [EditMode(SwitchAction = "verticesmode",
+ ButtonDesc = "Vertices Mode",
+ ButtonImage = "VerticesMode.png",
+ ButtonOrder = int.MinValue + 0)]
public class VerticesMode : ClassicMode
{
#region ================== Constants
@@ -60,7 +65,7 @@ namespace CodeImp.DoomBuilder.Editing
{
}
- // Diposer
+ // Disposer
public override void Dispose()
{
// Not already disposed?
@@ -90,9 +95,6 @@ namespace CodeImp.DoomBuilder.Editing
public override void Engage()
{
base.Engage();
-
- // Check vertices button on main window
- General.MainWindow.SetVerticesChecked(true);
}
// Mode disengages
@@ -117,10 +119,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// Hide highlight info
- General.MainWindow.HideInfo();
-
- // Uncheck vertices button on main window
- General.MainWindow.SetVerticesChecked(false);
+ General.Interface.HideInfo();
}
// This redraws the display
@@ -169,9 +168,9 @@ namespace CodeImp.DoomBuilder.Editing
// Show highlight info
if((highlighted != null) && !highlighted.IsDisposed)
- General.MainWindow.ShowVertexInfo(highlighted);
+ General.Interface.ShowVertexInfo(highlighted);
else
- General.MainWindow.HideInfo();
+ General.Interface.HideInfo();
}
// Mouse moves
diff --git a/Source/BuilderModes/Editing/WAuthorMode.cs b/Source/BuilderModes/Editing/WAuthorMode.cs
new file mode 100644
index 00000000..b7e2f586
--- /dev/null
+++ b/Source/BuilderModes/Editing/WAuthorMode.cs
@@ -0,0 +1,353 @@
+
+#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 CodeImp.DoomBuilder.Editing;
+
+#endregion
+
+namespace CodeImp.DoomBuilder.BuilderModes.Editing
+{
+ [EditMode(SwitchAction = "wauthormode",
+ ButtonDesc = "WadAuthor Mode",
+ ButtonImage = "WAuthor.png",
+ ButtonOrder = int.MinValue + 4,
+ ConfigSpecific = true)]
+ public class WAuthorMode : ClassicMode
+ {
+ #region ================== Constants
+
+ protected const float LINEDEF_HIGHLIGHT_RANGE = 10f;
+ protected const float VERTEX_HIGHLIGHT_RANGE = 8f;
+ protected const float THING_HIGHLIGHT_RANGE = 2f;
+
+ #endregion
+
+ #region ================== Variables
+
+ // Highlighted item
+ protected object highlighted;
+
+ #endregion
+
+ #region ================== Properties
+
+ #endregion
+
+ #region ================== Constructor / Disposer
+
+ // Constructor
+ public WAuthorMode()
+ {
+ // Initialize
+
+ // We have no destructor
+ GC.SuppressFinalize(this);
+ }
+
+ // Disposer
+ public override void Dispose()
+ {
+ // Not already disposed?
+ if(!isdisposed)
+ {
+ // Clean up
+
+ // Dispose base
+ base.Dispose();
+ }
+ }
+
+ #endregion
+
+ #region ================== Methods
+
+ // Cancel mode
+ public override void Cancel()
+ {
+ base.Cancel();
+
+ // Return to this mode
+ General.Map.ChangeMode(new WAuthorMode());
+ }
+
+ // Mode engages
+ public override void Engage()
+ {
+ base.Engage();
+ }
+
+ // Mode disengages
+ public override void Disengage()
+ {
+ base.Disengage();
+
+ // Clear selected vertices
+ General.Map.Map.ClearAllSelected();
+
+ // Hide highlight info
+ General.Interface.HideInfo();
+ }
+
+ // This redraws the display
+ public unsafe override void RedrawDisplay()
+ {
+ // Start with a clear display
+ if(renderer.Start(true, true))
+ {
+ // Render things
+ renderer.SetThingsRenderOrder(true);
+ renderer.RenderThingSet(General.Map.Map.Things);
+
+ // Render lines and vertices
+ renderer.RenderLinedefSet(General.Map.Map.Linedefs);
+ renderer.RenderVerticesSet(General.Map.Map.Vertices);
+
+ // Render highlighted item
+ if(highlighted != null) DrawHighlight(true);
+
+ // Done
+ renderer.Finish();
+ }
+ }
+
+ // This draws the highlighted item
+ protected void DrawHighlight(bool highlightcolor)
+ {
+ // With highlight color
+ if(highlightcolor)
+ {
+ // Vertex
+ if(highlighted is Vertex)
+ {
+ if((highlighted as Vertex).IsDisposed) return;
+ renderer.RenderVertex(highlighted as Vertex, ColorCollection.HIGHLIGHT);
+ }
+ // Linedef
+ else if(highlighted is Linedef)
+ {
+ if((highlighted as Linedef).IsDisposed) return;
+ renderer.RenderLinedef((highlighted as Linedef), General.Colors.Highlight);
+ renderer.RenderVertex((highlighted as Linedef).Start, renderer.DetermineVertexColor((highlighted as Linedef).Start));
+ renderer.RenderVertex((highlighted as Linedef).End, renderer.DetermineVertexColor((highlighted as Linedef).End));
+ }
+ // Sector
+ else if(highlighted is Sector)
+ {
+ if((highlighted as Sector).IsDisposed) return;
+ renderer.RenderSector((highlighted as Sector), General.Colors.Highlight);
+ }
+ // Thing
+ else if(highlighted is Thing)
+ {
+ if((highlighted as Thing).IsDisposed) return;
+ renderer.RenderThing((highlighted as Thing), General.Colors.Highlight);
+ }
+ }
+ // With original color
+ else
+ {
+ // Vertex
+ if(highlighted is Vertex)
+ {
+ if((highlighted as Vertex).IsDisposed) return;
+ renderer.RenderVertex(highlighted as Vertex, renderer.DetermineVertexColor(highlighted as Vertex));
+ }
+ // Linedef
+ else if(highlighted is Linedef)
+ {
+ if((highlighted as Linedef).IsDisposed) return;
+ renderer.RenderLinedef((highlighted as Linedef), renderer.DetermineLinedefColor((highlighted as Linedef)));
+ renderer.RenderVertex((highlighted as Linedef).Start, renderer.DetermineVertexColor((highlighted as Linedef).Start));
+ renderer.RenderVertex((highlighted as Linedef).End, renderer.DetermineVertexColor((highlighted as Linedef).End));
+ }
+ // Sector
+ else if(highlighted is Sector)
+ {
+ if((highlighted as Sector).IsDisposed) return;
+ renderer.RenderSector((highlighted as Sector));
+ }
+ // Thing
+ else if(highlighted is Thing)
+ {
+ if((highlighted as Thing).IsDisposed) return;
+ renderer.RenderThing((highlighted as Thing), renderer.DetermineThingColor((highlighted as Thing)));
+ }
+ }
+ }
+
+ // This highlights a new item
+ protected void Highlight(object h)
+ {
+ // Changes?
+ if(highlighted != h)
+ {
+ // Update display
+ if(renderer.Start(false, false))
+ {
+ // Undraw previous highlight
+ if(highlighted != null) DrawHighlight(false);
+
+ // Set new highlight
+ highlighted = h;
+
+ // Render highlighted item
+ if(highlighted != null) DrawHighlight(true);
+
+ // Done
+ renderer.Finish();
+ }
+
+ // Hide info
+ General.Interface.HideInfo();
+
+ // Anything highlighted?
+ if(highlighted != null)
+ {
+ // Show highlight info
+ if(highlighted is Vertex)
+ General.Interface.ShowVertexInfo(highlighted as Vertex);
+ else if(highlighted is Linedef)
+ General.Interface.ShowLinedefInfo(highlighted as Linedef);
+ else if(highlighted is Sector)
+ General.Interface.ShowSectorInfo(highlighted as Sector);
+ else if(highlighted is Thing)
+ General.Interface.ShowThingInfo(highlighted as Thing);
+ }
+ }
+ }
+
+ // Mouse moves
+ public override void MouseMove(MouseEventArgs e)
+ {
+ base.MouseMove(e);
+
+ // Not holding any buttons?
+ if(e.Button == MouseButtons.None)
+ {
+ // Find the nearest items within highlight range
+ Vertex v = General.Map.Map.NearestVertexSquareRange(mousemappos, VERTEX_HIGHLIGHT_RANGE / renderer.Scale);
+ Thing t = General.Map.Map.NearestThingSquareRange(mousemappos, THING_HIGHLIGHT_RANGE / renderer.Scale);
+ Linedef l = General.Map.Map.NearestLinedef(mousemappos);
+ Sector s;
+
+ // Check on which side of the linedef the mouse is
+ float side = l.SideOfLine(mousemappos);
+ if(side > 0)
+ {
+ // Is there a sidedef here?
+ if(l.Back != null) s = l.Back.Sector;
+ else s = null;
+ }
+ else
+ {
+ // Is there a sidedef here?
+ if(l.Front != null) s = l.Front.Sector;
+ else s = null;
+ }
+
+ // Both a vertex and thing in range?
+ if((v != null) && (t != null))
+ {
+ // Highlight closest
+ float vd = v.DistanceToSq(mousemappos);
+ float td = t.DistanceToSq(mousemappos);
+ if(vd < td) Highlight(v); else Highlight(t);
+ }
+ // Vertex in range?
+ else if(v != null)
+ {
+ // Highlight vertex
+ Highlight(v);
+ }
+ // Thing in range?
+ else if(t != null)
+ {
+ // Highlight thing
+ Highlight(t);
+ }
+ else
+ {
+ // Linedef within in range?
+ float ld = l.DistanceTo(mousemappos, true);
+ if(ld < (LINEDEF_HIGHLIGHT_RANGE / renderer.Scale))
+ {
+ // Highlight line
+ Highlight(l);
+ }
+ // Mouse inside a sector?
+ else if(s != null)
+ {
+ // Highlight sector
+ Highlight(s);
+ }
+ else
+ {
+ // Highlight nothing
+ Highlight(null);
+ }
+ }
+ }
+ }
+
+ // Maybe i'll finish this later, or not even include this mode at all, not sure yet.
+
+ /*
+ // Mouse leaves
+ public override void MouseLeave(EventArgs e)
+ {
+ base.MouseLeave(e);
+
+ // Highlight nothing
+ Highlight(null);
+ }
+
+ // Mouse button pressed
+ public override void MouseDown(MouseEventArgs e)
+ {
+ base.MouseDown(e);
+ }
+
+ // Mouse released
+ public override void MouseUp(MouseEventArgs e)
+ {
+ base.MouseUp(e);
+ }
+
+ // Mouse wants to drag
+ protected override void DragStart(MouseEventArgs e)
+ {
+ base.DragStart(e);
+ }
+ */
+
+ #endregion
+ }
+}
diff --git a/Source/BuilderModes/Properties/AssemblyInfo.cs b/Source/BuilderModes/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..dcb32819
--- /dev/null
+++ b/Source/BuilderModes/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Builder Modes")]
+[assembly: AssemblyDescription("Doom Builder Editing Modes")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("CodeImp")]
+[assembly: AssemblyProduct("Doom Builder")]
+[assembly: AssemblyCopyright("Copyright © 2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("30d96659-77e7-4921-a52f-a854c1a36b7d")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyFileVersion("1.0.*")]
diff --git a/Source/BuilderModes/Resources/Actions.cfg b/Source/BuilderModes/Resources/Actions.cfg
new file mode 100644
index 00000000..105e55c0
--- /dev/null
+++ b/Source/BuilderModes/Resources/Actions.cfg
@@ -0,0 +1,51 @@
+/******************************************\
+ Doom Builder Actions Configuration
+\******************************************/
+
+// This just defines which actions there are and what description they have
+// The source code will bind to these actions with delegates (function pointers)
+
+verticesmode
+{
+ title = "Edit: Vertices Mode";
+ description = "Switches to vertices editing mode.";
+ allowkeys = true;
+ allowmouse = true;
+ allowscroll = true;
+}
+
+linedefsmode
+{
+ title = "Edit: Linedefs Mode";
+ description = "Switches to linedefs editing mode.";
+ allowkeys = true;
+ allowmouse = true;
+ allowscroll = true;
+}
+
+sectorsmode
+{
+ title = "Edit: Sectors Mode";
+ description = "Switches to sectors editing mode.";
+ allowkeys = true;
+ allowmouse = true;
+ allowscroll = true;
+}
+
+thingsmode
+{
+ title = "Edit: Things Mode";
+ description = "Switches to things editing mode.";
+ allowkeys = true;
+ allowmouse = true;
+ allowscroll = true;
+}
+
+wauthormode
+{
+ title = "Edit: WadAuthor Mode";
+ description = "Switches to Wad Author editing mode.";
+ allowkeys = true;
+ allowmouse = true;
+ allowscroll = true;
+}
diff --git a/Source/Resources/LinesMode.png b/Source/BuilderModes/Resources/LinesMode.png
similarity index 100%
rename from Source/Resources/LinesMode.png
rename to Source/BuilderModes/Resources/LinesMode.png
diff --git a/Source/Resources/SectorsMode.png b/Source/BuilderModes/Resources/SectorsMode.png
similarity index 100%
rename from Source/Resources/SectorsMode.png
rename to Source/BuilderModes/Resources/SectorsMode.png
diff --git a/Source/BuilderModes/Resources/ThingsMode.png b/Source/BuilderModes/Resources/ThingsMode.png
new file mode 100644
index 00000000..2bfc8a8f
Binary files /dev/null and b/Source/BuilderModes/Resources/ThingsMode.png differ
diff --git a/Source/Resources/VerticesMode.png b/Source/BuilderModes/Resources/VerticesMode.png
similarity index 100%
rename from Source/Resources/VerticesMode.png
rename to Source/BuilderModes/Resources/VerticesMode.png
diff --git a/Source/BuilderModes/Resources/WAuthor.png b/Source/BuilderModes/Resources/WAuthor.png
new file mode 100644
index 00000000..b98bed40
Binary files /dev/null and b/Source/BuilderModes/Resources/WAuthor.png differ
diff --git a/Source/Config/CompilerInfo.cs b/Source/Config/CompilerInfo.cs
index 1d1bf61e..7ab633f5 100644
--- a/Source/Config/CompilerInfo.cs
+++ b/Source/Config/CompilerInfo.cs
@@ -30,7 +30,7 @@ using System.Diagnostics;
namespace CodeImp.DoomBuilder.Config
{
- public class CompilerInfo
+ internal class CompilerInfo
{
#region ================== Constants
diff --git a/Source/Config/ConfigurationInfo.cs b/Source/Config/ConfigurationInfo.cs
index 32ad8d80..893eca3d 100644
--- a/Source/Config/ConfigurationInfo.cs
+++ b/Source/Config/ConfigurationInfo.cs
@@ -29,7 +29,7 @@ using System.IO;
namespace CodeImp.DoomBuilder.Config
{
- public class ConfigurationInfo : IComparable
+ internal class ConfigurationInfo : IComparable
{
#region ================== Variables
diff --git a/Source/Config/GameConfiguration.cs b/Source/Config/GameConfiguration.cs
index 233a7f46..a1d30eeb 100644
--- a/Source/Config/GameConfiguration.cs
+++ b/Source/Config/GameConfiguration.cs
@@ -113,7 +113,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Constructor / Disposer
// Constructor
- public GameConfiguration(Configuration cfg)
+ internal GameConfiguration(Configuration cfg)
{
// Initialize
this.cfg = cfg;
@@ -393,6 +393,12 @@ namespace CodeImp.DoomBuilder.Config
return null;
}
+ // This checks if a specific edit mode class is listed
+ public bool IsEditModeSpecified(string classname)
+ {
+ return cfg.SettingExists("additionalmodes." + classname.ToString(CultureInfo.InvariantCulture));
+ }
+
#endregion
}
}
diff --git a/Source/Config/GeneralActionBit.cs b/Source/Config/GeneralActionBit.cs
index 42f37bd4..dd160435 100644
--- a/Source/Config/GeneralActionBit.cs
+++ b/Source/Config/GeneralActionBit.cs
@@ -30,7 +30,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Constructor / Disposer
// Constructor
- public GeneralActionBit(int index, string title)
+ internal GeneralActionBit(int index, string title)
{
// Initialize
this.index = index;
diff --git a/Source/Config/GeneralActionCategory.cs b/Source/Config/GeneralActionCategory.cs
index d3b7f92e..2ec018cd 100644
--- a/Source/Config/GeneralActionCategory.cs
+++ b/Source/Config/GeneralActionCategory.cs
@@ -7,7 +7,7 @@ using CodeImp.DoomBuilder.IO;
namespace CodeImp.DoomBuilder.Config
{
- public class GeneralActionCategory : IDisposable
+ public class GeneralActionCategory
{
#region ================== Constants
@@ -39,7 +39,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Constructor / Disposer
// Constructor
- public GeneralActionCategory(string name, Configuration cfg)
+ internal GeneralActionCategory(string name, Configuration cfg)
{
IDictionary opts;
@@ -67,8 +67,8 @@ namespace CodeImp.DoomBuilder.Config
GC.SuppressFinalize(this);
}
- // Diposer
- public void Dispose()
+ // Disposer
+ internal void Dispose()
{
// Not already disposed?
if(!isdisposed)
diff --git a/Source/Config/GeneralActionOption.cs b/Source/Config/GeneralActionOption.cs
index d12f134c..1e3ed1d0 100644
--- a/Source/Config/GeneralActionOption.cs
+++ b/Source/Config/GeneralActionOption.cs
@@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Constructor / Disposer
// Constructor
- public GeneralActionOption(string cat, string name, IDictionary bitslist)
+ internal GeneralActionOption(string cat, string name, IDictionary bitslist)
{
int index;
diff --git a/Source/Config/LinedefActionCategory.cs b/Source/Config/LinedefActionCategory.cs
index 37320cca..1a36215b 100644
--- a/Source/Config/LinedefActionCategory.cs
+++ b/Source/Config/LinedefActionCategory.cs
@@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Rendering;
namespace CodeImp.DoomBuilder.Config
{
- public class LinedefActionCategory : IDisposable, IComparable
+ public class LinedefActionCategory : IComparable
{
#region ================== Constants
@@ -62,7 +62,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Constructor / Disposer
// Constructor
- public LinedefActionCategory(string name)
+ internal LinedefActionCategory(string name)
{
// Initialize
this.name = name;
@@ -72,8 +72,8 @@ namespace CodeImp.DoomBuilder.Config
GC.SuppressFinalize(this);
}
- // Diposer
- public void Dispose()
+ // Disposer
+ internal void Dispose()
{
// Not already disposed?
if(!isdisposed)
@@ -91,7 +91,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Methods
// This adds an action to this category
- public void Add(LinedefActionInfo a)
+ internal void Add(LinedefActionInfo a)
{
// Make it so.
actions.Add(a);
diff --git a/Source/Config/LinedefActionInfo.cs b/Source/Config/LinedefActionInfo.cs
index c014f3d3..299d79bf 100644
--- a/Source/Config/LinedefActionInfo.cs
+++ b/Source/Config/LinedefActionInfo.cs
@@ -68,7 +68,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Constructor / Disposer
// Constructor
- public LinedefActionInfo(int index, string desc)
+ internal LinedefActionInfo(int index, string desc)
{
string[] parts;
int p = 0;
@@ -103,7 +103,7 @@ namespace CodeImp.DoomBuilder.Config
}
// Constructor
- public LinedefActionInfo(int index, Configuration cfg)
+ internal LinedefActionInfo(int index, Configuration cfg)
{
string actionsetting = "linedeftypes." + index.ToString(CultureInfo.InvariantCulture);
string desc;
diff --git a/Source/Config/LinedefActivateInfo.cs b/Source/Config/LinedefActivateInfo.cs
index e442a16d..81a08704 100644
--- a/Source/Config/LinedefActivateInfo.cs
+++ b/Source/Config/LinedefActivateInfo.cs
@@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Constructor / Disposer
// Constructor
- public LinedefActivateInfo(int index, string title)
+ internal LinedefActivateInfo(int index, string title)
{
// Initialize
this.index = index;
diff --git a/Source/Config/NodebuilderInfo.cs b/Source/Config/NodebuilderInfo.cs
index 6fdeceaf..c8094b46 100644
--- a/Source/Config/NodebuilderInfo.cs
+++ b/Source/Config/NodebuilderInfo.cs
@@ -31,7 +31,7 @@ using System.Windows.Forms;
namespace CodeImp.DoomBuilder.Config
{
- public class NodebuilderInfo : IComparable
+ internal class NodebuilderInfo : IComparable
{
#region ================== Constants
diff --git a/Source/Config/ProgramConfiguration.cs b/Source/Config/ProgramConfiguration.cs
index eb9cff57..9f4317c0 100644
--- a/Source/Config/ProgramConfiguration.cs
+++ b/Source/Config/ProgramConfiguration.cs
@@ -51,17 +51,17 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Properties
- public Configuration Config { get { return cfg; } }
- public int UndoLevels { get { return undolevels; } set { undolevels = value; } }
- public bool BlackBrowsers { get { return blackbrowsers; } set { blackbrowsers = value; } }
- public float StitchDistance { get { return stitchdistance; } set { stitchdistance = value; } }
+ internal Configuration Config { get { return cfg; } }
+ public int UndoLevels { get { return undolevels; } internal set { undolevels = value; } }
+ public bool BlackBrowsers { get { return blackbrowsers; } internal set { blackbrowsers = value; } }
+ public float StitchDistance { get { return stitchdistance; } internal set { stitchdistance = value; } }
#endregion
#region ================== Constructor / Disposer
// Constructor
- public ProgramConfiguration()
+ internal ProgramConfiguration()
{
// We have no destructor
GC.SuppressFinalize(this);
@@ -72,7 +72,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Loading / Saving
// This loads the program configuration
- public bool Load(string cfgfilepathname, string defaultfilepathname)
+ internal bool Load(string cfgfilepathname, string defaultfilepathname)
{
// First parse it
if(Read(cfgfilepathname, defaultfilepathname))
@@ -93,7 +93,7 @@ namespace CodeImp.DoomBuilder.Config
}
// This saves the program configuration
- public void Save(string filepathname)
+ internal void Save(string filepathname)
{
// Write the cache variables
cfg.WriteSetting("blackbrowsers", blackbrowsers);
@@ -171,8 +171,8 @@ namespace CodeImp.DoomBuilder.Config
public IDictionary ReadSetting(string setting, IDictionary defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
// WriteSetting
- public bool WriteSetting(string setting, object settingvalue) { return cfg.WriteSetting(setting, settingvalue); }
- public bool WriteSetting(string setting, object settingvalue, string pathseperator) { return cfg.WriteSetting(setting, settingvalue, pathseperator); }
+ internal bool WriteSetting(string setting, object settingvalue) { return cfg.WriteSetting(setting, settingvalue); }
+ internal bool WriteSetting(string setting, object settingvalue, string pathseperator) { return cfg.WriteSetting(setting, settingvalue, pathseperator); }
#endregion
}
diff --git a/Source/Config/ThingCategory.cs b/Source/Config/ThingCategory.cs
index b9b213e0..94b139ce 100644
--- a/Source/Config/ThingCategory.cs
+++ b/Source/Config/ThingCategory.cs
@@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Rendering;
namespace CodeImp.DoomBuilder.Config
{
- public class ThingCategory : IDisposable
+ public class ThingCategory
{
#region ================== Constants
@@ -84,7 +84,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Constructor / Disposer
// Constructor
- public ThingCategory(Configuration cfg, string name)
+ internal ThingCategory(Configuration cfg, string name)
{
IDictionary dic;
int index;
@@ -136,7 +136,7 @@ namespace CodeImp.DoomBuilder.Config
}
// Disposer
- public void Dispose()
+ internal void Dispose()
{
// Not already disposed?
if(!isdisposed)
@@ -154,7 +154,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Methods
// This adds a thing to the category
- public void AddThing(ThingTypeInfo t)
+ internal void AddThing(ThingTypeInfo t)
{
// Add
things.Add(t);
diff --git a/Source/Config/ThingTypeInfo.cs b/Source/Config/ThingTypeInfo.cs
index 5e94d8ca..75f0789f 100644
--- a/Source/Config/ThingTypeInfo.cs
+++ b/Source/Config/ThingTypeInfo.cs
@@ -75,7 +75,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Constructor / Disposer
// Constructor
- public ThingTypeInfo(int index)
+ internal ThingTypeInfo(int index)
{
// Initialize
this.index = index;
@@ -98,7 +98,7 @@ namespace CodeImp.DoomBuilder.Config
}
// Constructor
- public ThingTypeInfo(ThingCategory cat, int index, Configuration cfg)
+ internal ThingTypeInfo(ThingCategory cat, int index, Configuration cfg)
{
string key = index.ToString(CultureInfo.InvariantCulture);
diff --git a/Source/Controls/Action.cs b/Source/Controls/Action.cs
index 17827a94..ca1a31b7 100644
--- a/Source/Controls/Action.cs
+++ b/Source/Controls/Action.cs
@@ -27,7 +27,7 @@ using System.Windows.Forms;
namespace CodeImp.DoomBuilder.Controls
{
- public class Action
+ internal class Action
{
#region ================== Variables
diff --git a/Source/Controls/ActionAttribute.cs b/Source/Controls/ActionAttribute.cs
index eef98dce..619bde85 100644
--- a/Source/Controls/ActionAttribute.cs
+++ b/Source/Controls/ActionAttribute.cs
@@ -34,9 +34,16 @@ namespace CodeImp.DoomBuilder.Controls
// The action to bind to
private string action;
+ private bool baseaction;
#endregion
+ #region ================== Properties
+
+ public bool BaseAction { get { return baseaction; } set { baseaction = value; } }
+
+ #endregion
+
#region ================== Constructor / Disposer
// Constructor
@@ -44,21 +51,52 @@ namespace CodeImp.DoomBuilder.Controls
{
// Initialize
this.action = action;
+ this.baseaction = false;
}
#endregion
+ #region ================== Methods
+
+ // This makes the proper name
+ public string GetFullActionName(Assembly asm)
+ {
+ string asmname;
+
+ if(baseaction)
+ asmname = General.ThisAssembly.GetName().Name.ToLowerInvariant();
+ else
+ asmname = asm.GetName().Name.ToLowerInvariant();
+
+ return asmname + "_" + action;
+ }
+
+ #endregion
+
#region ================== Static Methods
+ // This makes the proper name
+ public string GetFullActionName(Assembly asm, bool baseaction, string actionname)
+ {
+ string asmname;
+
+ if(baseaction)
+ asmname = General.ThisAssembly.GetName().Name.ToLowerInvariant();
+ else
+ asmname = asm.GetName().Name.ToLowerInvariant();
+
+ return asmname + "_" + actionname;
+ }
+
// This binds all methods marked with this attribute
- public static void BindMethods(Type type)
+ internal static void BindMethods(Type type)
{
// Bind static methods
BindMethods(null, type);
}
// This binds all methods marked with this attribute
- public static void BindMethods(object obj)
+ internal static void BindMethods(object obj)
{
// Bind instance methods
BindMethods(obj, obj.GetType());
@@ -70,14 +108,15 @@ namespace CodeImp.DoomBuilder.Controls
MethodInfo[] methods;
ActionAttribute[] attrs;
ActionDelegate del;
-
+ string actionname;
+
if(obj == null)
General.WriteLogLine("Binding static action methods for class " + type.Name + "...");
else
General.WriteLogLine("Binding action methods for " + type.Name + " object...");
// Go for all methods on obj
- methods = type.GetMethods();
+ methods = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
foreach(MethodInfo m in methods)
{
// Check if the method has this attribute
@@ -89,24 +128,42 @@ namespace CodeImp.DoomBuilder.Controls
// Create a delegate for this method
del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
+ // Make proper name
+ actionname = a.GetFullActionName(type.Assembly);
+
// Bind method to action
- if(General.Actions.Exists(a.action))
- General.Actions[a.action].Bind(del);
+ if(General.Actions.Exists(actionname))
+ General.Actions[actionname].Bind(del);
else
- throw new ArgumentException("Could not bind " + m.ReflectedType.Name + "." + m.Name + " to action \"" + a.action + "\", that action does not exist! Refer to, or edit Actions.cfg for all available application actions.");
+ throw new ArgumentException("Could not bind " + m.ReflectedType.Name + "." + m.Name + " to action \"" + actionname + "\", that action does not exist! Refer to, or edit Actions.cfg for all available application actions.");
}
}
}
-
+
+ // This binds a delegate manually
+ internal static void BindDelegate(Assembly asm, ActionDelegate d, ActionAttribute a)
+ {
+ string actionname;
+
+ // Make proper name
+ actionname = a.GetFullActionName(asm);
+
+ // Bind delegate to action
+ if(General.Actions.Exists(actionname))
+ General.Actions[actionname].Bind(d);
+ else
+ throw new ArgumentException("Could not bind delegate for " + d.Method.Name + " to action \"" + actionname + "\", that action does not exist! Refer to, or edit Actions.cfg for all available application actions.");
+ }
+
// This unbinds all methods marked with this attribute
- public static void UnbindMethods(Type type)
+ internal static void UnbindMethods(Type type)
{
// Unbind static methods
UnbindMethods(null, type);
}
// This unbinds all methods marked with this attribute
- public static void UnbindMethods(object obj)
+ internal static void UnbindMethods(object obj)
{
// Unbind instance methods
UnbindMethods(obj, obj.GetType());
@@ -118,6 +175,7 @@ namespace CodeImp.DoomBuilder.Controls
MethodInfo[] methods;
ActionAttribute[] attrs;
ActionDelegate del;
+ string actionname;
if(obj == null)
General.WriteLogLine("Unbinding static action methods for class " + type.Name + "...");
@@ -137,11 +195,26 @@ namespace CodeImp.DoomBuilder.Controls
// Create a delegate for this method
del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
+ // Make proper name
+ actionname = a.GetFullActionName(type.Assembly);
+
// Unbind method from action
- General.Actions[a.action].Unbind(del);
+ General.Actions[actionname].Unbind(del);
}
}
}
+
+ // This unbinds a delegate manually
+ internal static void UnbindDelegate(Assembly asm, ActionDelegate d, ActionAttribute a)
+ {
+ string actionname;
+
+ // Make proper name
+ actionname = a.GetFullActionName(asm);
+
+ // Unbind delegate to action
+ General.Actions[actionname].Unbind(d);
+ }
#endregion
}
diff --git a/Source/Controls/ActionDelegate.cs b/Source/Controls/ActionDelegate.cs
index 61041a04..577692a6 100644
--- a/Source/Controls/ActionDelegate.cs
+++ b/Source/Controls/ActionDelegate.cs
@@ -26,5 +26,5 @@ using System.Text;
namespace CodeImp.DoomBuilder.Controls
{
- public delegate void ActionDelegate();
+ internal delegate void ActionDelegate();
}
diff --git a/Source/Controls/ActionManager.cs b/Source/Controls/ActionManager.cs
index ffe71447..f147b2ab 100644
--- a/Source/Controls/ActionManager.cs
+++ b/Source/Controls/ActionManager.cs
@@ -25,15 +25,18 @@ using CodeImp.DoomBuilder.Properties;
using System.IO;
using CodeImp.DoomBuilder.IO;
using System.Collections;
+using System.Reflection;
#endregion
namespace CodeImp.DoomBuilder.Controls
{
- public class ActionManager : IDisposable
+ internal class ActionManager
{
#region ================== Constants
+ private const string ACTIONS_RESOURCE = "Actions.cfg";
+
#endregion
#region ================== Variables
@@ -62,14 +65,14 @@ namespace CodeImp.DoomBuilder.Controls
General.WriteLogLine("Starting action manager...");
actions = new Dictionary();
- // Load all actions
- LoadActions();
+ // Load all actions in this assembly
+ LoadActions(General.ThisAssembly);
// We have no destructor
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public void Dispose()
{
// Not already disposed?
@@ -86,45 +89,73 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Actions
- // This loads all actions
- private void LoadActions()
+ // This loads all actions from an assembly
+ public void LoadActions(Assembly asm)
{
Stream actionsdata;
StreamReader actionsreader;
Configuration cfg;
string name, title, desc;
bool amouse, akeys, ascroll;
- int key;
-
- // Get a stream from the resource
- actionsdata = General.ThisAssembly.GetManifestResourceStream("CodeImp.DoomBuilder.Resources.Actions.cfg");
- actionsreader = new StreamReader(actionsdata, Encoding.ASCII);
-
- // Load configuration from stream
- cfg = new Configuration();
- cfg.InputConfiguration(actionsreader.ReadToEnd());
+ string[] resnames;
+ AssemblyName asmname = asm.GetName();
- // Done with the resource
- actionsreader.Dispose();
- actionsdata.Dispose();
-
- // Go for all objects in the configuration
- foreach(DictionaryEntry a in cfg.Root)
+ // Find a resource named Actions.cfg
+ resnames = asm.GetManifestResourceNames();
+ foreach(string rn in resnames)
{
- // Get action properties
- name = a.Key.ToString();
- title = cfg.ReadSetting(name + ".title", "[" + name + "]");
- desc = cfg.ReadSetting(name + ".description", "");
- key = General.Settings.ReadSetting("shortcuts." + name, 0);
- akeys = cfg.ReadSetting(name + ".allowkeys", false);
- amouse = cfg.ReadSetting(name + ".allowmouse", false);
- ascroll = cfg.ReadSetting(name + ".allowscroll", false);
-
- // Create an action
- actions.Add(name, new Action(name, title, desc, key, akeys, amouse, ascroll));
+ // Found one?
+ if(rn.EndsWith(ACTIONS_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
+ {
+ // Get a stream from the resource
+ actionsdata = asm.GetManifestResourceStream(rn);
+ actionsreader = new StreamReader(actionsdata, Encoding.ASCII);
+
+ // Load configuration from stream
+ cfg = new Configuration();
+ cfg.InputConfiguration(actionsreader.ReadToEnd());
+
+ // Done with the resource
+ actionsreader.Dispose();
+ actionsdata.Dispose();
+
+ // Go for all objects in the configuration
+ foreach(DictionaryEntry a in cfg.Root)
+ {
+ // Get action properties
+ name = asmname.Name.ToLowerInvariant() + "_" + a.Key.ToString();
+ title = cfg.ReadSetting(a.Key + ".title", "[" + name + "]");
+ desc = cfg.ReadSetting(a.Key + ".description", "");
+ akeys = cfg.ReadSetting(a.Key + ".allowkeys", false);
+ amouse = cfg.ReadSetting(a.Key + ".allowmouse", false);
+ ascroll = cfg.ReadSetting(a.Key + ".allowscroll", false);
+
+ // Create an action
+ CreateAction(name, title, desc, akeys, amouse, ascroll);
+ }
+ }
}
}
+ // This manually creates an action
+ private void CreateAction(string name, string title, string desc, bool allowkeys, bool allowmouse, bool allowscroll)
+ {
+ // Action does not exist yet?
+ if(!actions.ContainsKey(name))
+ {
+ // Read the key from configuration
+ int key = General.Settings.ReadSetting("shortcuts." + name, 0);
+
+ // Create an action
+ actions.Add(name, new Action(name, title, desc, key, allowkeys, allowmouse, allowscroll));
+ }
+ else
+ {
+ // Action already exists!
+ General.WriteLogLine("WARNING: Action '" + name + "' already exists. Action names must be unique!");
+ }
+ }
+
// This checks if a given action exists
public bool Exists(string action)
{
diff --git a/Source/Controls/KeyControl.cs b/Source/Controls/KeyControl.cs
index a0956264..f38e2a7a 100644
--- a/Source/Controls/KeyControl.cs
+++ b/Source/Controls/KeyControl.cs
@@ -1,13 +1,37 @@
+
+#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.ComponentModel;
+using System.Drawing;
using System.Text;
+using CodeImp.DoomBuilder.Properties;
+using System.IO;
+using CodeImp.DoomBuilder.IO;
+using System.Collections;
using System.Windows.Forms;
+#endregion
+
namespace CodeImp.DoomBuilder.Controls
{
- public struct KeyControl
+ internal struct KeyControl
{
#region ================== Variables
diff --git a/Source/Data/DataLocation.cs b/Source/Data/DataLocation.cs
index 536ff88e..72c346b6 100644
--- a/Source/Data/DataLocation.cs
+++ b/Source/Data/DataLocation.cs
@@ -26,7 +26,7 @@ using System.Text;
namespace CodeImp.DoomBuilder.Data
{
- public struct DataLocation : IComparable, IComparable, IEquatable
+ internal struct DataLocation : IComparable, IComparable, IEquatable
{
// Constants
public const int RESOURCE_WAD = 0;
diff --git a/Source/Data/DataLocationList.cs b/Source/Data/DataLocationList.cs
index c464188b..1386a3fe 100644
--- a/Source/Data/DataLocationList.cs
+++ b/Source/Data/DataLocationList.cs
@@ -1,3 +1,21 @@
+
+#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;
@@ -6,9 +24,11 @@ using System.Text;
using CodeImp.DoomBuilder.IO;
using System.Collections.Specialized;
+#endregion
+
namespace CodeImp.DoomBuilder.Data
{
- public sealed class DataLocationList : List
+ internal sealed class DataLocationList : List
{
#region ================== Constructors
diff --git a/Source/Data/DataManager.cs b/Source/Data/DataManager.cs
index 2a4affe7..a23c154a 100644
--- a/Source/Data/DataManager.cs
+++ b/Source/Data/DataManager.cs
@@ -34,7 +34,7 @@ using System.Threading;
namespace CodeImp.DoomBuilder.Data
{
- public sealed class DataManager : IDisposable
+ public sealed class DataManager
{
#region ================== Constants
@@ -82,14 +82,14 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Constructor / Disposer
// Constructor
- public DataManager()
+ internal DataManager()
{
// We have no destructor
GC.SuppressFinalize(this);
}
// Disposer
- public void Dispose()
+ internal void Dispose()
{
// Not already disposed?
if(!isdisposed)
@@ -107,7 +107,7 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Loading / Unloading
// This loads all data resources
- public void Load(DataLocationList configlist, DataLocationList maplist, DataLocation maplocation)
+ internal void Load(DataLocationList configlist, DataLocationList maplist, DataLocation maplocation)
{
DataLocationList all = DataLocationList.Combined(configlist, maplist);
all.Add(maplocation);
@@ -115,14 +115,14 @@ namespace CodeImp.DoomBuilder.Data
}
// This loads all data resources
- public void Load(DataLocationList configlist, DataLocationList maplist)
+ internal void Load(DataLocationList configlist, DataLocationList maplist)
{
DataLocationList all = DataLocationList.Combined(configlist, maplist);
Load(all);
}
// This loads all data resources
- public void Load(DataLocationList locations)
+ internal void Load(DataLocationList locations)
{
DataReader c;
@@ -191,7 +191,7 @@ namespace CodeImp.DoomBuilder.Data
}
// This unloads all data
- public void Unload()
+ internal void Unload()
{
// Stop background loader
StopBackgroundLoader();
@@ -212,7 +212,7 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Suspend / Resume
// This suspends data resources
- public void Suspend()
+ internal void Suspend()
{
// Stop background loader
StopBackgroundLoader();
@@ -227,7 +227,7 @@ namespace CodeImp.DoomBuilder.Data
}
// This resumes data resources
- public void Resume()
+ internal void Resume()
{
// Go for all containers
foreach(DataReader d in containers)
@@ -425,7 +425,7 @@ namespace CodeImp.DoomBuilder.Data
}
// This returns a specific patch stream
- public Stream GetPatchData(string pname)
+ internal Stream GetPatchData(string pname)
{
Stream patch;
@@ -539,7 +539,7 @@ namespace CodeImp.DoomBuilder.Data
}
// This returns a specific flat stream
- public Stream GetFlatData(string pname)
+ internal Stream GetFlatData(string pname)
{
Stream flat;
diff --git a/Source/Data/DataReader.cs b/Source/Data/DataReader.cs
index 2db3ac71..a72433f4 100644
--- a/Source/Data/DataReader.cs
+++ b/Source/Data/DataReader.cs
@@ -31,7 +31,7 @@ using CodeImp.DoomBuilder.Rendering;
namespace CodeImp.DoomBuilder.Data
{
- public abstract class DataReader : IDisposable
+ internal abstract class DataReader
{
#region ================== Variables
diff --git a/Source/Data/DirectoryReader.cs b/Source/Data/DirectoryReader.cs
index 7540a82e..cfbc2cc4 100644
--- a/Source/Data/DirectoryReader.cs
+++ b/Source/Data/DirectoryReader.cs
@@ -30,7 +30,7 @@ using CodeImp.DoomBuilder.IO;
namespace CodeImp.DoomBuilder.Data
{
- public sealed class DirectoryReader : DataReader
+ internal sealed class DirectoryReader : DataReader
{
#region ================== Constants
diff --git a/Source/Data/FlatImage.cs b/Source/Data/FlatImage.cs
index 68ac8a54..4b77ca0d 100644
--- a/Source/Data/FlatImage.cs
+++ b/Source/Data/FlatImage.cs
@@ -1,14 +1,36 @@
+
+#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.Drawing;
+using System.Drawing.Imaging;
using System.IO;
using CodeImp.DoomBuilder.IO;
+#endregion
+
namespace CodeImp.DoomBuilder.Data
{
- public sealed class FlatImage : ImageData
+ internal sealed class FlatImage : ImageData
{
#region ================== Constructor / Disposer
diff --git a/Source/Data/ImageData.cs b/Source/Data/ImageData.cs
index 595f1408..554a94fb 100644
--- a/Source/Data/ImageData.cs
+++ b/Source/Data/ImageData.cs
@@ -33,7 +33,7 @@ using System.Windows.Forms;
namespace CodeImp.DoomBuilder.Data
{
- public abstract unsafe class ImageData : IDisposable
+ public abstract unsafe class ImageData
{
#region ================== Constants
@@ -124,7 +124,7 @@ namespace CodeImp.DoomBuilder.Data
}
// This creates the 2D pixel data
- public virtual void CreatePixelData()
+ internal virtual void CreatePixelData()
{
BitmapData bmpdata;
@@ -143,7 +143,7 @@ namespace CodeImp.DoomBuilder.Data
}
// This creates the Direct3D texture
- public virtual void CreateTexture()
+ internal virtual void CreateTexture()
{
MemoryStream memstream;
@@ -164,7 +164,7 @@ namespace CodeImp.DoomBuilder.Data
}
// This destroys the Direct3D texture
- public void ReleaseTexture()
+ internal void ReleaseTexture()
{
lock(this)
{
diff --git a/Source/Data/ImageDataFormat.cs b/Source/Data/ImageDataFormat.cs
index a8ee1f91..86f4443c 100644
--- a/Source/Data/ImageDataFormat.cs
+++ b/Source/Data/ImageDataFormat.cs
@@ -29,7 +29,7 @@ using CodeImp.DoomBuilder.IO;
namespace CodeImp.DoomBuilder.Data
{
- public static class ImageDataFormat
+ internal static class ImageDataFormat
{
// Input guess formats
public const int UNKNOWN = 0; // No clue.
diff --git a/Source/Data/NullImage.cs b/Source/Data/NullImage.cs
index ab828dcf..6bc30921 100644
--- a/Source/Data/NullImage.cs
+++ b/Source/Data/NullImage.cs
@@ -53,8 +53,8 @@ namespace CodeImp.DoomBuilder.Data
// Dont do anything
public override void LoadImage() { bitmap = CodeImp.DoomBuilder.Properties.Resources.UnknownImage; }
- public override void CreatePixelData() { }
- public override void CreateTexture() { }
+ internal override void CreatePixelData() { }
+ internal override void CreateTexture() { }
#endregion
}
diff --git a/Source/Data/PK3Reader.cs b/Source/Data/PK3Reader.cs
index 7cc03169..0e0dc517 100644
--- a/Source/Data/PK3Reader.cs
+++ b/Source/Data/PK3Reader.cs
@@ -31,7 +31,7 @@ using ICSharpCode.SharpZipLib.Zip;
namespace CodeImp.DoomBuilder.Data
{
- public sealed class PK3Reader : DataReader
+ internal sealed class PK3Reader : DataReader
{
#region ================== Constants
diff --git a/Source/Data/PatchNames.cs b/Source/Data/PatchNames.cs
index 350029cb..a90b3cff 100644
--- a/Source/Data/PatchNames.cs
+++ b/Source/Data/PatchNames.cs
@@ -28,7 +28,7 @@ using CodeImp.DoomBuilder.IO;
namespace CodeImp.DoomBuilder.Data
{
- public sealed class PatchNames
+ internal sealed class PatchNames
{
#region ================== Constants
diff --git a/Source/Data/SpriteImage.cs b/Source/Data/SpriteImage.cs
index 2d80c568..82f0523c 100644
--- a/Source/Data/SpriteImage.cs
+++ b/Source/Data/SpriteImage.cs
@@ -1,14 +1,37 @@
+
+#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.IO;
+using System.Drawing;
+using System.Drawing.Imaging;
+using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.IO;
+using System.IO;
+
+#endregion
namespace CodeImp.DoomBuilder.Data
{
- public sealed class SpriteImage : ImageData
+ internal sealed class SpriteImage : ImageData
{
#region ================== Constructor / Disposer
diff --git a/Source/Data/TextureImage.cs b/Source/Data/TextureImage.cs
index 8dbf0067..862ba0fa 100644
--- a/Source/Data/TextureImage.cs
+++ b/Source/Data/TextureImage.cs
@@ -31,7 +31,7 @@ using System.IO;
namespace CodeImp.DoomBuilder.Data
{
- public sealed unsafe class TextureImage : ImageData
+ internal sealed unsafe class TextureImage : ImageData
{
#region ================== Variables
diff --git a/Source/Data/TexturePatch.cs b/Source/Data/TexturePatch.cs
index a0668ca7..6c61bc74 100644
--- a/Source/Data/TexturePatch.cs
+++ b/Source/Data/TexturePatch.cs
@@ -30,7 +30,7 @@ using CodeImp.DoomBuilder.IO;
namespace CodeImp.DoomBuilder.Data
{
- public struct TexturePatch
+ internal struct TexturePatch
{
public string lumpname;
public int x;
diff --git a/Source/Data/WADReader.cs b/Source/Data/WADReader.cs
index ae090f03..57ef2d74 100644
--- a/Source/Data/WADReader.cs
+++ b/Source/Data/WADReader.cs
@@ -30,7 +30,7 @@ using CodeImp.DoomBuilder.IO;
namespace CodeImp.DoomBuilder.Data
{
- public sealed class WADReader : DataReader
+ internal sealed class WADReader : DataReader
{
#region ================== Constants
@@ -61,7 +61,7 @@ namespace CodeImp.DoomBuilder.Data
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public override void Dispose()
{
// Not already disposed?
diff --git a/Source/Editing/ClassicMode.cs b/Source/Editing/ClassicMode.cs
index f56911f6..a159d36f 100644
--- a/Source/Editing/ClassicMode.cs
+++ b/Source/Editing/ClassicMode.cs
@@ -51,7 +51,8 @@ namespace CodeImp.DoomBuilder.Editing
protected bool cancelled;
// Graphics
- protected Renderer2D renderer;
+ protected IRenderer2D renderer;
+ private Renderer2D renderer2d;
// Mouse status
protected Vector2D mousepos;
@@ -75,9 +76,10 @@ namespace CodeImp.DoomBuilder.Editing
{
// Initialize
this.renderer = General.Map.Renderer2D;
+ this.renderer2d = (Renderer2D)General.Map.Renderer2D;
}
- // Diposer
+ // Disposer
public override void Dispose()
{
// Not already disposed?
@@ -95,39 +97,39 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Scroll / Zoom
// This scrolls the view north
- [Action("scrollnorth")]
+ [Action("scrollnorth", BaseAction = true)]
public virtual void ScrollNorth()
{
// Scroll
- ScrollBy(0f, 100f / renderer.Scale);
+ ScrollBy(0f, 100f / renderer2d.Scale);
}
// This scrolls the view south
- [Action("scrollsouth")]
+ [Action("scrollsouth", BaseAction = true)]
public virtual void ScrollSouth()
{
// Scroll
- ScrollBy(0f, -100f / renderer.Scale);
+ ScrollBy(0f, -100f / renderer2d.Scale);
}
// This scrolls the view west
- [Action("scrollwest")]
+ [Action("scrollwest", BaseAction = true)]
public virtual void ScrollWest()
{
// Scroll
- ScrollBy(-100f / renderer.Scale, 0f);
+ ScrollBy(-100f / renderer2d.Scale, 0f);
}
// This scrolls the view east
- [Action("scrolleast")]
+ [Action("scrolleast", BaseAction = true)]
public virtual void ScrollEast()
{
// Scroll
- ScrollBy(100f / renderer.Scale, 0f);
+ ScrollBy(100f / renderer2d.Scale, 0f);
}
// This zooms in
- [Action("zoomin")]
+ [Action("zoomin", BaseAction = true)]
public virtual void ZoomIn()
{
// Zoom
@@ -135,7 +137,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// This zooms out
- [Action("zoomout")]
+ [Action("zoomout", BaseAction = true)]
public virtual void ZoomOut()
{
// Zoom
@@ -146,14 +148,14 @@ namespace CodeImp.DoomBuilder.Editing
private void ScrollBy(float deltax, float deltay)
{
// Scroll now
- renderer.PositionView(renderer.OffsetX + deltax, renderer.OffsetY + deltay);
+ renderer2d.PositionView(renderer2d.OffsetX + deltax, renderer2d.OffsetY + deltay);
this.ViewChanged();
// Redraw
General.MainWindow.RedrawDisplay();
// Determine new unprojected mouse coordinates
- mousemappos = renderer.GetMapCoordinates(mousepos);
+ mousemappos = renderer2d.GetMapCoordinates(mousepos);
General.MainWindow.UpdateCoordinates(mousemappos);
}
@@ -164,7 +166,7 @@ namespace CodeImp.DoomBuilder.Editing
float newscale;
// This will be the new zoom scale
- newscale = renderer.Scale * deltaz;
+ newscale = renderer2d.Scale * deltaz;
// Limit scale
if(newscale > SCALE_MAX) newscale = SCALE_MAX;
@@ -187,11 +189,11 @@ namespace CodeImp.DoomBuilder.Editing
}
// Calculate view position difference
- diff = ((clientsize / newscale) - (clientsize / renderer.Scale)) * zoompos;
+ diff = ((clientsize / newscale) - (clientsize / renderer2d.Scale)) * zoompos;
// Zoom now
- renderer.PositionView(renderer.OffsetX - diff.x, renderer.OffsetY + diff.y);
- renderer.ScaleView(newscale);
+ renderer2d.PositionView(renderer2d.OffsetX - diff.x, renderer2d.OffsetY + diff.y);
+ renderer2d.ScaleView(newscale);
this.ViewChanged();
// Redraw
@@ -206,7 +208,7 @@ namespace CodeImp.DoomBuilder.Editing
public void SetZoom(float newscale)
{
// Zoom now
- renderer.ScaleView(newscale);
+ renderer2d.ScaleView(newscale);
this.ViewChanged();
// Redraw
@@ -251,8 +253,8 @@ namespace CodeImp.DoomBuilder.Editing
if(scalew < scaleh) scale = scalew; else scale = scaleh;
// Change the view to see the whole map
- renderer.ScaleView(scale);
- renderer.PositionView(left + (right - left) * 0.5f, top + (bottom - top) * 0.5f);
+ renderer2d.ScaleView(scale);
+ renderer2d.PositionView(left + (right - left) * 0.5f, top + (bottom - top) * 0.5f);
this.ViewChanged();
// Redraw
@@ -296,7 +298,7 @@ namespace CodeImp.DoomBuilder.Editing
// Record last position
mouseinside = true;
mousepos = new Vector2D(e.X, e.Y);
- mousemappos = renderer.GetMapCoordinates(mousepos);
+ mousemappos = renderer2d.GetMapCoordinates(mousepos);
mousebuttons = e.Button;
// Update labels in main window
@@ -370,7 +372,7 @@ namespace CodeImp.DoomBuilder.Editing
// This just refreshes the display
public override void RefreshDisplay()
{
- renderer.Present();
+ renderer2d.Present();
}
#endregion
@@ -378,7 +380,7 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Methods
// Override cancel method to bind it with its action
- [Action("cancelmode")]
+ [Action("cancelmode", BaseAction = true)]
public override void Cancel()
{
cancelled = true;
diff --git a/Source/Editing/EditMode.cs b/Source/Editing/EditMode.cs
index bb37d33f..6bf413d7 100644
--- a/Source/Editing/EditMode.cs
+++ b/Source/Editing/EditMode.cs
@@ -35,7 +35,7 @@ using CodeImp.DoomBuilder.Controls;
namespace CodeImp.DoomBuilder.Editing
{
- public abstract class EditMode : IDisposable
+ public abstract class EditMode
{
#region ================== Constants
@@ -56,6 +56,10 @@ namespace CodeImp.DoomBuilder.Editing
public bool IsDisposed { get { return isdisposed; } }
+ // Unless overriden, this returns the name of this mode
+ // for checking the appropriate button on the toolbar.
+ public virtual string EditModeButtonName { get { return GetType().Name; } }
+
#endregion
#region ================== Constructor / Disposer
@@ -67,7 +71,7 @@ namespace CodeImp.DoomBuilder.Editing
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public virtual void Dispose()
{
// Not already disposed?
diff --git a/Source/Editing/EditModeAttribute.cs b/Source/Editing/EditModeAttribute.cs
new file mode 100644
index 00000000..4beefca3
--- /dev/null
+++ b/Source/Editing/EditModeAttribute.cs
@@ -0,0 +1,68 @@
+
+#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.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+#endregion
+
+namespace CodeImp.DoomBuilder.Editing
+{
+ [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
+ public class EditModeAttribute : Attribute
+ {
+ #region ================== Variables
+
+ // Properties
+ private string switchaction;
+ private string buttonimage;
+ private string buttondesc;
+ private int buttonorder;
+ private bool configspecific;
+
+ #endregion
+
+ #region ================== Properties
+
+ public string SwitchAction { get { return switchaction; } set { switchaction = value; } }
+ public string ButtonImage { get { return buttonimage; } set { buttonimage = value; } }
+ public string ButtonDesc { get { return buttondesc; } set { buttondesc = value; } }
+ public int ButtonOrder { get { return buttonorder; } set { buttonorder = value; } }
+ public bool ConfigSpecific { get { return configspecific; } set { configspecific = value; } }
+
+ #endregion
+
+ #region ================== Constructor / Disposer
+
+ // Constructor
+ public EditModeAttribute()
+ {
+ // Initialize
+ }
+
+ #endregion
+
+ #region ================== Methods
+
+ #endregion
+ }
+}
diff --git a/Source/Editing/EditModeInfo.cs b/Source/Editing/EditModeInfo.cs
new file mode 100644
index 00000000..184cf95d
--- /dev/null
+++ b/Source/Editing/EditModeInfo.cs
@@ -0,0 +1,171 @@
+
+#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.Controls;
+using CodeImp.DoomBuilder.Plugins;
+using System.Drawing;
+
+#endregion
+
+namespace CodeImp.DoomBuilder.Editing
+{
+ internal class EditModeInfo : IComparable
+ {
+ #region ================== Constants
+
+ #endregion
+
+ #region ================== Variables
+
+ // Mode type
+ private Plugin plugin;
+ private Type type;
+ private bool configspecific;
+
+ // Mode switching
+ private ActionAttribute switchactionattr = null;
+ private ActionDelegate switchactiondel = null;
+
+ // Mode button
+ private Stream buttonimagestream = null;
+ private Image buttonimage = null;
+ private string buttondesc = null;
+ private int buttonorder = int.MaxValue;
+
+ #endregion
+
+ #region ================== Properties
+
+ public Plugin Plugin { get { return plugin; } }
+ public Type Type { get { return type; } }
+ public ActionAttribute SwitchAction { get { return switchactionattr; } }
+ public Image ButtonImage { get { return buttonimage; } }
+ public string ButtonDesc { get { return buttondesc; } }
+ public bool ConfigSpecific { get { return configspecific; } }
+
+ #endregion
+
+ #region ================== Constructor / Disposer
+
+ // Constructor
+ public EditModeInfo(Plugin plugin, Type type, EditModeAttribute attr)
+ {
+ // Initialize
+ this.plugin = plugin;
+ this.type = type;
+ this.configspecific = attr.ConfigSpecific;
+
+ // Make switch action info
+ if((attr.SwitchAction != null) && (attr.SwitchAction.Length > 0))
+ {
+ switchactionattr = new ActionAttribute(attr.SwitchAction);
+ switchactiondel = new ActionDelegate(SwitchToMode);
+
+ // Bind switch action
+ ActionAttribute.BindDelegate(plugin.Assembly, switchactiondel, switchactionattr);
+ }
+
+ // Make button info
+ if((attr.ButtonImage != null) && (attr.ButtonDesc != null))
+ {
+ buttonimagestream = plugin.FindResource(attr.ButtonImage);
+ if(buttonimagestream != null)
+ {
+ buttonimage = Image.FromStream(buttonimagestream);
+ buttondesc = attr.ButtonDesc;
+ buttonorder = attr.ButtonOrder;
+ }
+ }
+
+ // We have no destructor
+ GC.SuppressFinalize(this);
+ }
+
+ // Disposer
+ public void Dispose()
+ {
+ // Unbind switch action
+ if(switchactiondel != null) ActionAttribute.UnbindDelegate(plugin.Assembly, switchactiondel, switchactionattr);
+ buttonimage.Dispose();
+ buttonimagestream.Dispose();
+
+ // Clean up
+ plugin = null;
+ }
+
+ #endregion
+
+ #region ================== Methods
+
+ // This switches to the mode
+ public void SwitchToMode()
+ {
+ EditMode newmode;
+
+ // Only when a map is opened
+ if(General.Map != null)
+ {
+ // Create instance
+ newmode = plugin.CreateObject(type);
+
+ // Switch mode
+ General.Map.ChangeMode(newmode);
+ }
+ }
+
+ // This switches to the mode with arguments
+ public void SwitchToMode(object[] args)
+ {
+ EditMode newmode;
+
+ // Only when a map is opened
+ if(General.Map != null)
+ {
+ // Create instance
+ newmode = plugin.CreateObjectA(type, args);
+
+ // Switch mode
+ General.Map.ChangeMode(newmode);
+ }
+ }
+
+ // String representation
+ public override string ToString()
+ {
+ return type.Name;
+ }
+
+ // Compare by button order
+ public int CompareTo(EditModeInfo other)
+ {
+ if(this.buttonorder > other.buttonorder) return 1;
+ else if(this.buttonorder < other.buttonorder) return -1;
+ else return 0;
+ }
+
+ #endregion
+ }
+}
diff --git a/Source/Editing/GridSetup.cs b/Source/Editing/GridSetup.cs
index 40c9cca3..c2aca2b9 100644
--- a/Source/Editing/GridSetup.cs
+++ b/Source/Editing/GridSetup.cs
@@ -1,12 +1,40 @@
+
+#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 System.Diagnostics;
+using CodeImp.DoomBuilder.Controls;
using CodeImp.DoomBuilder.Data;
-using SlimDX.Direct3D9;
using CodeImp.DoomBuilder.Geometry;
+#endregion
+
namespace CodeImp.DoomBuilder.Editing
{
public class GridSetup
@@ -39,18 +67,18 @@ namespace CodeImp.DoomBuilder.Editing
public int GridSize { get { return gridsize; } }
public float GridSizeF { get { return gridsizef; } }
- public string BackgroundName { get { return background; } }
- public int BackgroundSource { get { return backsource; } }
- public ImageData Background { get { return backimage; } }
- public int BackgroundX { get { return backoffsetx; } }
- public int BackgroundY { get { return backoffsety; } }
+ internal string BackgroundName { get { return background; } }
+ internal int BackgroundSource { get { return backsource; } }
+ internal ImageData Background { get { return backimage; } }
+ internal int BackgroundX { get { return backoffsetx; } }
+ internal int BackgroundY { get { return backoffsety; } }
#endregion
#region ================== Constructor / Disposer
// Constructor
- public GridSetup()
+ internal GridSetup()
{
// Initialize
SetGridSize(DEFAULT_GRID_SIZE);
@@ -64,7 +92,7 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Methods
// This sets the grid size
- public void SetGridSize(int size)
+ internal void SetGridSize(int size)
{
// Change grid
this.gridsize = size;
@@ -76,7 +104,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// This sets the background
- public void SetBackground(string name, int source)
+ internal void SetBackground(string name, int source)
{
// Set background
if(name == null) name = "";
@@ -88,7 +116,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// This sets the background offset
- public void SetBackgroundOffset(int offsetx, int offsety)
+ internal void SetBackgroundOffset(int offsetx, int offsety)
{
// Set background offset
this.backoffsetx = offsetx;
@@ -96,7 +124,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// This finds and links the background image
- public void LinkBackground()
+ internal void LinkBackground()
{
// From textures?
if(backsource == SOURCE_TEXTURES)
diff --git a/Source/Editing/UndoManager.cs b/Source/Editing/UndoManager.cs
index 5972fed0..fee8b128 100644
--- a/Source/Editing/UndoManager.cs
+++ b/Source/Editing/UndoManager.cs
@@ -35,7 +35,7 @@ using CodeImp.DoomBuilder.Controls;
namespace CodeImp.DoomBuilder.Editing
{
- public class UndoManager : IDisposable
+ public class UndoManager
{
#region ================== Constants
@@ -61,8 +61,8 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Properties
- public UndoSnapshot NextUndo { get { if(undos.Count > 0) return undos[0]; else return null; } }
- public UndoSnapshot NextRedo { get { if(redos.Count > 0) return redos[0]; else return null; } }
+ internal UndoSnapshot NextUndo { get { if(undos.Count > 0) return undos[0]; else return null; } }
+ internal UndoSnapshot NextRedo { get { if(redos.Count > 0) return redos[0]; else return null; } }
public bool IsDisposed { get { return isdisposed; } }
#endregion
@@ -70,7 +70,7 @@ namespace CodeImp.DoomBuilder.Editing
#region ================== Constructor / Disposer
// Constructor
- public UndoManager()
+ internal UndoManager()
{
// Initialize
ticketid = 1;
@@ -84,8 +84,8 @@ namespace CodeImp.DoomBuilder.Editing
GC.SuppressFinalize(this);
}
- // Diposer
- public void Dispose()
+ // Disposer
+ internal void Dispose()
{
// Not already disposed?
if(!isdisposed)
diff --git a/Source/Editing/UndoSnapshot.cs b/Source/Editing/UndoSnapshot.cs
index f9b2291d..8e3c87e4 100644
--- a/Source/Editing/UndoSnapshot.cs
+++ b/Source/Editing/UndoSnapshot.cs
@@ -35,7 +35,7 @@ using CodeImp.DoomBuilder.Controls;
namespace CodeImp.DoomBuilder.Editing
{
- public class UndoSnapshot
+ internal class UndoSnapshot
{
public MapSet map;
public string description;
diff --git a/Source/General/Clock.cs b/Source/General/Clock.cs
index c2b75243..01030705 100644
--- a/Source/General/Clock.cs
+++ b/Source/General/Clock.cs
@@ -28,7 +28,7 @@ using System.Diagnostics;
namespace CodeImp.DoomBuilder
{
- public class Clock : IDisposable
+ public class Clock
{
#region ================== Declarations
@@ -104,7 +104,7 @@ namespace CodeImp.DoomBuilder
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public void Dispose()
{
// Not already disposed?
diff --git a/Source/General/General.cs b/Source/General/General.cs
index 0134aabb..e773264d 100644
--- a/Source/General/General.cs
+++ b/Source/General/General.cs
@@ -35,6 +35,7 @@ using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Config;
using SlimDX.Direct3D9;
using System.Drawing;
+using CodeImp.DoomBuilder.Plugins;
#endregion
@@ -45,37 +46,37 @@ namespace CodeImp.DoomBuilder
#region ================== API Declarations
//[DllImport("user32.dll")]
- //public static extern bool LockWindowUpdate(IntPtr hwnd);
+ //internal static extern bool LockWindowUpdate(IntPtr hwnd);
[DllImport("kernel32.dll", EntryPoint="RtlZeroMemory", SetLastError=false)]
- public static extern void ZeroMemory(IntPtr dest, int size);
+ internal static extern void ZeroMemory(IntPtr dest, int size);
[DllImport("kernel32.dll", EntryPoint = "RtlMoveMemory", SetLastError = false)]
- public static extern unsafe void CopyMemory(void* dst, void* src, UIntPtr length);
+ internal static extern unsafe void CopyMemory(void* dst, void* src, UIntPtr length);
#endregion
#region ================== Constants
// Memory APIs
- public const uint MEM_COMMIT = 0x1000;
- public const uint MEM_RESERVE = 0x2000;
- public const uint MEM_DECOMMIT = 0x4000;
- public const uint MEM_RELEASE = 0x8000;
- public const uint MEM_RESET = 0x80000;
- public const uint MEM_TOP_DOWN = 0x100000;
- public const uint MEM_PHYSICAL = 0x400000;
- public const uint PAGE_NOACCESS = 0x01;
- public const uint PAGE_READONLY = 0x02;
- public const uint PAGE_READWRITE = 0x04;
- public const uint PAGE_WRITECOPY = 0x08;
- public const uint PAGE_EXECUTE = 0x10;
- public const uint PAGE_EXECUTE_READ = 0x20;
- public const uint PAGE_EXECUTE_READWRITE = 0x40;
- public const uint PAGE_EXECUTE_WRITECOPY = 0x80;
- public const uint PAGE_GUARD = 0x100;
- public const uint PAGE_NOCACHE = 0x200;
- public const uint PAGE_WRITECOMBINE = 0x400;
+ internal const uint MEM_COMMIT = 0x1000;
+ internal const uint MEM_RESERVE = 0x2000;
+ internal const uint MEM_DECOMMIT = 0x4000;
+ internal const uint MEM_RELEASE = 0x8000;
+ internal const uint MEM_RESET = 0x80000;
+ internal const uint MEM_TOP_DOWN = 0x100000;
+ internal const uint MEM_PHYSICAL = 0x400000;
+ internal const uint PAGE_NOACCESS = 0x01;
+ internal const uint PAGE_READONLY = 0x02;
+ internal const uint PAGE_READWRITE = 0x04;
+ internal const uint PAGE_WRITECOPY = 0x08;
+ internal const uint PAGE_EXECUTE = 0x10;
+ internal const uint PAGE_EXECUTE_READ = 0x20;
+ internal const uint PAGE_EXECUTE_READWRITE = 0x40;
+ internal const uint PAGE_EXECUTE_WRITECOPY = 0x80;
+ internal const uint PAGE_GUARD = 0x100;
+ internal const uint PAGE_NOCACHE = 0x200;
+ internal const uint PAGE_WRITECOMBINE = 0x400;
// Files and Folders
private const string SETTINGS_FILE = "Builder.cfg";
@@ -83,6 +84,7 @@ namespace CodeImp.DoomBuilder
private const string LOG_FILE = "Builder.log";
private const string GAME_CONFIGS_DIR = "Configurations";
private const string COMPILERS_DIR = "Compilers";
+ private const string PLUGINS_DIR = "Plugins";
#endregion
@@ -95,6 +97,7 @@ namespace CodeImp.DoomBuilder
private static string temppath;
private static string configspath;
private static string compilerspath;
+ private static string pluginspath;
// Main objects
private static Assembly thisasm;
@@ -102,6 +105,7 @@ namespace CodeImp.DoomBuilder
private static ProgramConfiguration settings;
private static MapManager map;
private static ActionManager actions;
+ private static PluginManager plugins;
private static ColorCollection colors;
private static Clock clock;
@@ -114,19 +118,22 @@ namespace CodeImp.DoomBuilder
#region ================== Properties
- public static Assembly ThisAssembly { get { return thisasm; } }
+ internal static Assembly ThisAssembly { get { return thisasm; } }
public static string AppPath { get { return apppath; } }
public static string TempPath { get { return temppath; } }
public static string ConfigsPath { get { return configspath; } }
public static string CompilersPath { get { return compilerspath; } }
- public static MainForm MainWindow { get { return mainwindow; } }
+ public static string PluginsPath { get { return pluginspath; } }
+ internal static MainForm MainWindow { get { return mainwindow; } }
+ public static IMainForm Interface { get { return mainwindow; } }
public static ProgramConfiguration Settings { get { return settings; } }
public static ColorCollection Colors { get { return colors; } }
- public static List Configs { get { return configs; } }
- public static List Nodebuilders { get { return nodebuilders; } }
- public static List Compilers { get { return compilers; } }
+ internal static List Configs { get { return configs; } }
+ internal static List Nodebuilders { get { return nodebuilders; } }
+ internal static List Compilers { get { return compilers; } }
public static MapManager Map { get { return map; } }
- public static ActionManager Actions { get { return actions; } }
+ internal static ActionManager Actions { get { return actions; } }
+ internal static PluginManager Plugins { get { return plugins; } }
public static Clock Clock { get { return clock; } }
#endregion
@@ -134,7 +141,7 @@ namespace CodeImp.DoomBuilder
#region ================== Configurations
// This returns the game configuration info by filename
- public static ConfigurationInfo GetConfigurationInfo(string filename)
+ internal static ConfigurationInfo GetConfigurationInfo(string filename)
{
// Go for all config infos
foreach(ConfigurationInfo ci in configs)
@@ -153,7 +160,7 @@ namespace CodeImp.DoomBuilder
}
// This loads and returns a game configuration
- public static Configuration LoadGameConfiguration(string filename)
+ internal static Configuration LoadGameConfiguration(string filename)
{
Configuration cfg;
@@ -347,7 +354,7 @@ namespace CodeImp.DoomBuilder
}
// This returns a nodebuilder by name
- public static NodebuilderInfo GetNodebuilderByName(string name)
+ internal static NodebuilderInfo GetNodebuilderByName(string name)
{
// Go for all nodebuilders
foreach(NodebuilderInfo n in nodebuilders)
@@ -366,7 +373,7 @@ namespace CodeImp.DoomBuilder
// Main program entry
[STAThread]
- public static void Main(string[] args)
+ internal static void Main(string[] args)
{
Uri localpath;
Version thisversion;
@@ -388,6 +395,7 @@ namespace CodeImp.DoomBuilder
settingspath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), SETTINGS_DIR);
configspath = Path.Combine(apppath, GAME_CONFIGS_DIR);
compilerspath = Path.Combine(apppath, COMPILERS_DIR);
+ pluginspath = Path.Combine(apppath, PLUGINS_DIR);
logfile = Path.Combine(settingspath, LOG_FILE);
// Make program settings directory if missing
@@ -401,6 +409,7 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Local settings path: " + settingspath);
General.WriteLogLine("Configurations path: " + configspath);
General.WriteLogLine("Compilers path: " + compilerspath);
+ General.WriteLogLine("Plugins path: " + pluginspath);
// Load configuration
General.WriteLogLine("Loading program configuration...");
@@ -428,6 +437,10 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Starting Direct3D graphics driver...");
Direct3D.Initialize();
+ // Load plugin manager
+ General.WriteLogLine("Loading plugins...");
+ plugins = new PluginManager();
+
// Load game configurations
General.WriteLogLine("Loading game configurations...");
LoadAllGameConfigurations();
@@ -465,7 +478,7 @@ namespace CodeImp.DoomBuilder
#region ================== Terminate
// This terminates the program
- public static void Terminate(bool properexit)
+ internal static void Terminate(bool properexit)
{
// Terminate properly?
if(properexit)
@@ -481,6 +494,7 @@ namespace CodeImp.DoomBuilder
mainwindow.Dispose();
actions.Dispose();
clock.Dispose();
+ plugins.Dispose();
Direct3D.Terminate();
// Save colors
@@ -514,7 +528,7 @@ namespace CodeImp.DoomBuilder
// This creates a new map
[Action("newmap")]
- public static void NewMap()
+ internal static void NewMap()
{
MapOptions newoptions = new MapOptions();
MapOptionsForm optionswindow;
@@ -562,7 +576,7 @@ namespace CodeImp.DoomBuilder
// This closes the current map
[Action("closemap")]
- public static void CloseMap()
+ internal static void CloseMap()
{
// Ask the user to save changes (if any)
if(General.AskSaveMap())
@@ -589,7 +603,7 @@ namespace CodeImp.DoomBuilder
// This loads a map from file
[Action("openmap")]
- public static void OpenMap()
+ internal static void OpenMap()
{
OpenFileDialog openfile;
@@ -612,7 +626,7 @@ namespace CodeImp.DoomBuilder
}
// This opens the specified file
- public static void OpenMapFile(string filename)
+ internal static void OpenMapFile(string filename)
{
OpenMapOptionsForm openmapwindow;
@@ -660,7 +674,7 @@ namespace CodeImp.DoomBuilder
// This saves the current map
[Action("savemap")]
- public static void SaveMap()
+ internal static void SaveMap()
{
// Check if a wad file is known
if(map.FilePathName == "")
@@ -690,7 +704,7 @@ namespace CodeImp.DoomBuilder
// This saves the current map as a different file
[Action("savemapas")]
- public static void SaveMapAs()
+ internal static void SaveMapAs()
{
SaveFileDialog savefile;
@@ -724,7 +738,7 @@ namespace CodeImp.DoomBuilder
// This asks to save the map if needed
// Returns false when action was cancelled
- public static bool AskSaveMap()
+ internal static bool AskSaveMap()
{
DialogResult result;
@@ -800,13 +814,13 @@ namespace CodeImp.DoomBuilder
}
// Convert bool to integer
- public static int Bool2Int(bool v)
+ internal static int Bool2Int(bool v)
{
if(v) return 1; else return 0;
}
// Convert integer to bool
- public static bool Int2Bool(int v)
+ internal static bool Int2Bool(int v)
{
return (v != 0);
}
@@ -864,7 +878,7 @@ namespace CodeImp.DoomBuilder
}
// This returns a unique temp filename
- public static string MakeTempFilename(string tempdir)
+ internal static string MakeTempFilename(string tempdir)
{
string filename;
string chars = "abcdefghijklmnopqrstuvwxyz1234567890";
@@ -886,7 +900,7 @@ namespace CodeImp.DoomBuilder
}
// This returns a unique temp directory name
- public static string MakeTempDirname()
+ internal static string MakeTempDirname()
{
string dirname;
string chars = "abcdefghijklmnopqrstuvwxyz1234567890";
@@ -977,7 +991,7 @@ namespace CodeImp.DoomBuilder
#endregion
[Action("testaction")]
- public static void TestAction()
+ internal static void TestAction()
{
TextureBrowserForm t = new TextureBrowserForm();
t.ShowDialog(mainwindow);
diff --git a/Source/General/MapManager.cs b/Source/General/MapManager.cs
index 3da823ec..02467701 100644
--- a/Source/General/MapManager.cs
+++ b/Source/General/MapManager.cs
@@ -24,21 +24,22 @@ using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
+using System.Diagnostics;
using CodeImp.DoomBuilder.Interface;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Editing;
-using System.Diagnostics;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Controls;
using CodeImp.DoomBuilder.Config;
+using CodeImp.DoomBuilder.Plugins;
#endregion
namespace CodeImp.DoomBuilder
{
- public class MapManager : IDisposable
+ public class MapManager
{
#region ================== Constants
@@ -89,16 +90,16 @@ namespace CodeImp.DoomBuilder
public string FilePathName { get { return filepathname; } }
public string FileTitle { get { return filetitle; } }
public string TempPath { get { return temppath; } }
- public MapOptions Options { get { return options; } }
+ internal MapOptions Options { get { return options; } }
public MapSet Map { get { return map; } }
public EditMode Mode { get { return mode; } }
public EditMode NewMode { get { return newmode; } }
public DataManager Data { get { return data; } }
public bool IsChanged { get { return changed; } set { changed |= value; } }
public bool IsDisposed { get { return isdisposed; } }
- public D3DDevice Graphics { get { return graphics; } }
- public Renderer2D Renderer2D { get { return renderer2d; } }
- public Renderer3D Renderer3D { get { return renderer3d; } }
+ internal D3DDevice Graphics { get { return graphics; } }
+ public IRenderer2D Renderer2D { get { return renderer2d; } }
+ public IRenderer3D Renderer3D { get { return renderer3d; } }
public GameConfiguration Config { get { return config; } }
public GridSetup Grid { get { return grid; } }
public UndoManager UndoRedo { get { return undoredo; } }
@@ -109,7 +110,7 @@ namespace CodeImp.DoomBuilder
#region ================== Constructor / Disposer
// Constructor
- public MapManager()
+ internal MapManager()
{
// We have no destructor
GC.SuppressFinalize(this);
@@ -117,17 +118,16 @@ namespace CodeImp.DoomBuilder
// Basic objects
grid = new GridSetup();
undoredo = new UndoManager();
-
}
- // Diposer
- public void Dispose()
+ // Disposer
+ internal void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
// Change to no mode
- ChangeMode(null);
+ ChangeMode((EditMode)null);
// Unbind any methods
ActionAttribute.UnbindMethods(this);
@@ -168,7 +168,7 @@ namespace CodeImp.DoomBuilder
#region ================== New / Open
// Initializes for a new map
- public bool InitializeNewMap(MapOptions options)
+ internal bool InitializeNewMap(MapOptions options)
{
string tempfile;
@@ -198,6 +198,7 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Loading game configuration...");
configinfo = General.GetConfigurationInfo(options.ConfigFile);
config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
+ General.Plugins.GameConfigurationChanged();
// Create map data
map = new MapSet();
@@ -226,7 +227,7 @@ namespace CodeImp.DoomBuilder
ActionAttribute.BindMethods(this);
// Set default mode
- ChangeMode(new VerticesMode());
+ ChangeMode("VerticesMode");
// Success
General.WriteLogLine("Map creation done");
@@ -234,7 +235,7 @@ namespace CodeImp.DoomBuilder
}
// Initializes for an existing map
- public bool InitializeOpenMap(string filepathname, MapOptions options)
+ internal bool InitializeOpenMap(string filepathname, MapOptions options)
{
WAD mapwad;
string tempfile;
@@ -261,12 +262,13 @@ namespace CodeImp.DoomBuilder
// Create renderers
renderer2d = new Renderer2D(graphics);
renderer3d = new Renderer3D(graphics);
-
+
// Load game configuration
General.WriteLogLine("Loading game configuration...");
configinfo = General.GetConfigurationInfo(options.ConfigFile);
config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
-
+ General.Plugins.GameConfigurationChanged();
+
// Create map data
map = new MapSet();
@@ -312,7 +314,7 @@ namespace CodeImp.DoomBuilder
ActionAttribute.BindMethods(this);
// Set default mode
- ChangeMode(new VerticesMode());
+ ChangeMode("VerticesMode");
// Center map in screen
(General.Map.Mode as ClassicMode).CenterInScreen();
@@ -327,7 +329,7 @@ namespace CodeImp.DoomBuilder
#region ================== Save
// Initializes for an existing map
- public bool SaveMap(string newfilepathname, int savemode)
+ internal bool SaveMap(string newfilepathname, int savemode)
{
MapSet outputset;
string nodebuildername, oldstatus, settingsfile;
@@ -757,7 +759,7 @@ namespace CodeImp.DoomBuilder
// This finds a lump within the range of known lump names
// Returns -1 when the lump cannot be found
- public static int FindSpecificLump(WAD source, string lumpname, int mapheaderindex, string mapheadername, IDictionary maplumps)
+ internal static int FindSpecificLump(WAD source, string lumpname, int mapheaderindex, string mapheadername, IDictionary maplumps)
{
// Use the configured map lump names to find the specific lump within range,
// because when an unknown lump is met, this search must stop.
@@ -793,7 +795,7 @@ namespace CodeImp.DoomBuilder
// This removes a specific lump and returns the position where the lump was removed
// Returns -1 when the lump could not be found
- public static int RemoveSpecificLump(WAD source, string lumpname, int mapheaderindex, string mapheadername, IDictionary maplumps)
+ internal static int RemoveSpecificLump(WAD source, string lumpname, int mapheaderindex, string mapheadername, IDictionary maplumps)
{
int lumpindex;
@@ -846,6 +848,12 @@ namespace CodeImp.DoomBuilder
// Apply new mode
mode = newmode;
+ // Check appropriate button on interface
+ if(newmode != null)
+ General.MainWindow.CheckEditModeButton(newmode.EditModeButtonName);
+ else
+ General.MainWindow.CheckEditModeButton("");
+
// Engage new mode
if(newmode != null) newmode.Engage();
@@ -858,37 +866,12 @@ namespace CodeImp.DoomBuilder
// Redraw the display
General.MainWindow.RedrawDisplay();
}
-
- // This switches to vertices mode
- [Action("verticesmode")]
- public void SwitchVerticesMode()
+
+ // This changes mode by class name and optionally with arguments
+ public void ChangeMode(string classname, params object[] args)
{
- // Change to vertices mode
- ChangeMode(new VerticesMode());
- }
-
- // This switches to linedefs mode
- [Action("linedefsmode")]
- public void SwitchLinedefsMode()
- {
- // Change to linedefs mode
- ChangeMode(new LinedefsMode());
- }
-
- // This switches to sectors mode
- [Action("sectorsmode")]
- public void SwitchSectorsMode()
- {
- // Change to sectors mode
- ChangeMode(new SectorsMode());
- }
-
- // This switches to things mode
- [Action("thingsmode")]
- public void SwitchThingsMode()
- {
- // Change to things mode
- ChangeMode(new ThingsMode());
+ EditModeInfo emi = General.Plugins.GetEditModeInfo(classname);
+ if(emi != null) emi.SwitchToMode(args);
}
#endregion
@@ -907,7 +890,7 @@ namespace CodeImp.DoomBuilder
}
// This sets a new mapset for editing
- public void ChangeMapSet(MapSet newmap)
+ internal void ChangeMapSet(MapSet newmap)
{
// Can't have a selection in an old map set
map.ClearAllSelected();
@@ -920,7 +903,7 @@ namespace CodeImp.DoomBuilder
// This reloads resources
[Action("reloadresources")]
- public void ReloadResources()
+ internal void ReloadResources()
{
DataLocation maplocation;
string oldstatus;
@@ -945,6 +928,7 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Reloading game configuration...");
configinfo = General.GetConfigurationInfo(options.ConfigFile);
config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
+ General.Plugins.GameConfigurationChanged();
// Reload data resources
General.WriteLogLine("Reloading data resources...");
@@ -965,7 +949,7 @@ namespace CodeImp.DoomBuilder
// Game Configuration action
[Action("mapoptions")]
- public void ShowMapOptions()
+ internal void ShowMapOptions()
{
// Show map options dialog
MapOptionsForm optionsform = new MapOptionsForm(options);
diff --git a/Source/IO/ClippedStream.cs b/Source/IO/ClippedStream.cs
index c8363457..8ce26767 100644
--- a/Source/IO/ClippedStream.cs
+++ b/Source/IO/ClippedStream.cs
@@ -27,7 +27,7 @@ using System.IO;
namespace CodeImp.DoomBuilder.IO
{
- public class ClippedStream : Stream
+ internal class ClippedStream : Stream
{
#region ================== Variables
@@ -73,7 +73,7 @@ namespace CodeImp.DoomBuilder.IO
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public new void Dispose()
{
// Not already disposed?
diff --git a/Source/IO/DoomFlatReader.cs b/Source/IO/DoomFlatReader.cs
index cde02161..d0e9ff51 100644
--- a/Source/IO/DoomFlatReader.cs
+++ b/Source/IO/DoomFlatReader.cs
@@ -33,7 +33,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.IO
{
- public unsafe class DoomFlatReader : IImageReader
+ internal unsafe class DoomFlatReader : IImageReader
{
#region ================== Variables
diff --git a/Source/IO/DoomMapSetIO.cs b/Source/IO/DoomMapSetIO.cs
index 3967801d..21e14698 100644
--- a/Source/IO/DoomMapSetIO.cs
+++ b/Source/IO/DoomMapSetIO.cs
@@ -29,7 +29,7 @@ using CodeImp.DoomBuilder.Geometry;
namespace CodeImp.DoomBuilder.IO
{
- public class DoomMapSetIO : MapSetIO
+ internal class DoomMapSetIO : MapSetIO
{
#region ================== Constants
diff --git a/Source/IO/DoomPictureReader.cs b/Source/IO/DoomPictureReader.cs
index b57283f2..1b77985f 100644
--- a/Source/IO/DoomPictureReader.cs
+++ b/Source/IO/DoomPictureReader.cs
@@ -33,7 +33,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.IO
{
- public unsafe class DoomPictureReader : IImageReader
+ internal unsafe class DoomPictureReader : IImageReader
{
#region ================== Variables
diff --git a/Source/IO/FileImageReader.cs b/Source/IO/FileImageReader.cs
index 6d9d667a..679b677e 100644
--- a/Source/IO/FileImageReader.cs
+++ b/Source/IO/FileImageReader.cs
@@ -33,7 +33,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.IO
{
- public unsafe class FileImageReader : IImageReader
+ internal unsafe class FileImageReader : IImageReader
{
#region ================== Constructor / Disposer
diff --git a/Source/IO/HexenMapSetIO.cs b/Source/IO/HexenMapSetIO.cs
index 1d6a39f9..42ba2a23 100644
--- a/Source/IO/HexenMapSetIO.cs
+++ b/Source/IO/HexenMapSetIO.cs
@@ -29,7 +29,7 @@ using CodeImp.DoomBuilder.Geometry;
namespace CodeImp.DoomBuilder.IO
{
- public class HexenMapSetIO : MapSetIO
+ internal class HexenMapSetIO : MapSetIO
{
#region ================== Constants
diff --git a/Source/IO/IImageReader.cs b/Source/IO/IImageReader.cs
index 81cb7d9a..e6a3ea8f 100644
--- a/Source/IO/IImageReader.cs
+++ b/Source/IO/IImageReader.cs
@@ -33,7 +33,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.IO
{
- public unsafe interface IImageReader
+ internal unsafe interface IImageReader
{
// Methods
Bitmap ReadAsBitmap(Stream stream);
diff --git a/Source/IO/Lump.cs b/Source/IO/Lump.cs
index 0a36ee31..1e7ee869 100644
--- a/Source/IO/Lump.cs
+++ b/Source/IO/Lump.cs
@@ -27,7 +27,7 @@ using System.IO;
namespace CodeImp.DoomBuilder.IO
{
- public class Lump : IDisposable
+ internal class Lump
{
#region ================== Variables
@@ -83,7 +83,7 @@ namespace CodeImp.DoomBuilder.IO
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public void Dispose()
{
// Not already disposed?
diff --git a/Source/IO/MapSetIO.cs b/Source/IO/MapSetIO.cs
index e26a2fd0..b03238b6 100644
--- a/Source/IO/MapSetIO.cs
+++ b/Source/IO/MapSetIO.cs
@@ -30,7 +30,7 @@ using System.Diagnostics;
namespace CodeImp.DoomBuilder.IO
{
- public abstract class MapSetIO
+ internal abstract class MapSetIO
{
#region ================== Constants
diff --git a/Source/IO/UnknownImageReader.cs b/Source/IO/UnknownImageReader.cs
index 0e5f9278..020b7260 100644
--- a/Source/IO/UnknownImageReader.cs
+++ b/Source/IO/UnknownImageReader.cs
@@ -33,7 +33,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.IO
{
- public unsafe class UnknownImageReader : IImageReader
+ internal unsafe class UnknownImageReader : IImageReader
{
#region ================== Constructor / Disposer
diff --git a/Source/IO/WAD.cs b/Source/IO/WAD.cs
index 7f75e2df..b602dc44 100644
--- a/Source/IO/WAD.cs
+++ b/Source/IO/WAD.cs
@@ -27,7 +27,7 @@ using System.IO;
namespace CodeImp.DoomBuilder.IO
{
- public class WAD : IDisposable
+ internal class WAD
{
#region ================== Constants
@@ -98,7 +98,7 @@ namespace CodeImp.DoomBuilder.IO
this.Dispose();
}
- // Diposer
+ // Disposer
public void Dispose()
{
// Not already disposed?
diff --git a/Source/Interface/AboutForm.cs b/Source/Interface/AboutForm.cs
index d57958b1..b41ac798 100644
--- a/Source/Interface/AboutForm.cs
+++ b/Source/Interface/AboutForm.cs
@@ -29,7 +29,7 @@ using System.Diagnostics;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class AboutForm : DelayedForm
+ internal partial class AboutForm : DelayedForm
{
// Constructor
public AboutForm()
diff --git a/Source/Interface/ActionBrowserForm.cs b/Source/Interface/ActionBrowserForm.cs
index cf7910fb..9b0e7c42 100644
--- a/Source/Interface/ActionBrowserForm.cs
+++ b/Source/Interface/ActionBrowserForm.cs
@@ -34,7 +34,7 @@ using CodeImp.DoomBuilder.IO;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class ActionBrowserForm : DelayedForm
+ internal partial class ActionBrowserForm : DelayedForm
{
// Constants
private const int MAX_OPTIONS = 8;
diff --git a/Source/Interface/ActionSelectorControl.cs b/Source/Interface/ActionSelectorControl.cs
index ae0297f4..351b172e 100644
--- a/Source/Interface/ActionSelectorControl.cs
+++ b/Source/Interface/ActionSelectorControl.cs
@@ -30,7 +30,7 @@ using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class ActionSelectorControl : UserControl
+ internal partial class ActionSelectorControl : UserControl
{
// Events
public event EventHandler ValueChanges;
diff --git a/Source/Interface/AutoSelectTextbox.cs b/Source/Interface/AutoSelectTextbox.cs
index 0af73f47..3c40c945 100644
--- a/Source/Interface/AutoSelectTextbox.cs
+++ b/Source/Interface/AutoSelectTextbox.cs
@@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Editing;
namespace CodeImp.DoomBuilder.Interface
{
- public class AutoSelectTextbox : TextBox
+ internal class AutoSelectTextbox : TextBox
{
#region ================== Constants
diff --git a/Source/Interface/CheckboxArrayControl.cs b/Source/Interface/CheckboxArrayControl.cs
index 8bb04f21..bd8f1b21 100644
--- a/Source/Interface/CheckboxArrayControl.cs
+++ b/Source/Interface/CheckboxArrayControl.cs
@@ -29,7 +29,7 @@ using System.Drawing.Drawing2D;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class CheckboxArrayControl : UserControl
+ internal partial class CheckboxArrayControl : UserControl
{
// Constants
private const int SPACING_Y = 1;
diff --git a/Source/Interface/ColorControl.cs b/Source/Interface/ColorControl.cs
index 093bdce3..cbf0181e 100644
--- a/Source/Interface/ColorControl.cs
+++ b/Source/Interface/ColorControl.cs
@@ -30,7 +30,7 @@ using CodeImp.DoomBuilder.Rendering;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class ColorControl : UserControl
+ internal partial class ColorControl : UserControl
{
// Constructor
public ColorControl()
diff --git a/Source/Interface/ConfigForm.cs b/Source/Interface/ConfigForm.cs
index 251958ba..9fb7c4f4 100644
--- a/Source/Interface/ConfigForm.cs
+++ b/Source/Interface/ConfigForm.cs
@@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class ConfigForm : DelayedForm
+ internal partial class ConfigForm : DelayedForm
{
// Constructor
public ConfigForm()
diff --git a/Source/Interface/FlatBrowserForm.cs b/Source/Interface/FlatBrowserForm.cs
index f7f7a98e..7f30801b 100644
--- a/Source/Interface/FlatBrowserForm.cs
+++ b/Source/Interface/FlatBrowserForm.cs
@@ -33,7 +33,7 @@ using CodeImp.DoomBuilder.Map;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class FlatBrowserForm : DelayedForm
+ internal partial class FlatBrowserForm : DelayedForm
{
// Variables
private string selectedname;
diff --git a/Source/Interface/FlatSelectorControl.cs b/Source/Interface/FlatSelectorControl.cs
index a68b82db..ba38e850 100644
--- a/Source/Interface/FlatSelectorControl.cs
+++ b/Source/Interface/FlatSelectorControl.cs
@@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.Map;
namespace CodeImp.DoomBuilder.Interface
{
- public class FlatSelectorControl : ImageSelectorControl
+ internal class FlatSelectorControl : ImageSelectorControl
{
// Setup
public void Initialize()
diff --git a/Source/Interface/GridSetupForm.cs b/Source/Interface/GridSetupForm.cs
index e8514946..b4effd81 100644
--- a/Source/Interface/GridSetupForm.cs
+++ b/Source/Interface/GridSetupForm.cs
@@ -33,7 +33,7 @@ using CodeImp.DoomBuilder.Editing;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class GridSetupForm : DelayedForm
+ internal partial class GridSetupForm : DelayedForm
{
// Variables
private string backgroundname;
diff --git a/Source/Interface/IMainForm.cs b/Source/Interface/IMainForm.cs
new file mode 100644
index 00000000..91f04964
--- /dev/null
+++ b/Source/Interface/IMainForm.cs
@@ -0,0 +1,63 @@
+
+#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 System.Drawing;
+using System.ComponentModel;
+using CodeImp.DoomBuilder.Map;
+using SlimDX.Direct3D;
+using SlimDX.Direct3D9;
+using SlimDX;
+using CodeImp.DoomBuilder.Geometry;
+using System.Drawing.Imaging;
+using CodeImp.DoomBuilder.Data;
+using CodeImp.DoomBuilder.Editing;
+
+#endregion
+
+namespace CodeImp.DoomBuilder.Interface
+{
+ public interface IMainForm
+ {
+ // Properties
+ bool AltState { get; }
+ bool CtrlState { get; }
+ bool ShiftState { get; }
+ bool MouseInDisplay { get; }
+ bool AutoMerge { get; }
+ bool SnapToGrid { get; }
+
+ // Methods
+ void DisplayReady();
+ void DisplayStatus(string status);
+ void RedrawDisplay();
+ void ShowEditLinedefs(ICollection lines);
+ void ShowLinedefInfo(Linedef l);
+ void ShowSectorInfo(Sector s);
+ void ShowThingInfo(Thing t);
+ void ShowVertexInfo(Vertex v);
+ void HideInfo();
+ }
+}
diff --git a/Source/Interface/ImageBrowserControl.cs b/Source/Interface/ImageBrowserControl.cs
index 3570b6fd..2816d09f 100644
--- a/Source/Interface/ImageBrowserControl.cs
+++ b/Source/Interface/ImageBrowserControl.cs
@@ -36,7 +36,7 @@ using System.Drawing.Drawing2D;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class ImageBrowserControl : UserControl
+ internal partial class ImageBrowserControl : UserControl
{
#region ================== Delegates / Events
diff --git a/Source/Interface/ImageSelectorControl.cs b/Source/Interface/ImageSelectorControl.cs
index 06c38da0..2ee495bd 100644
--- a/Source/Interface/ImageSelectorControl.cs
+++ b/Source/Interface/ImageSelectorControl.cs
@@ -36,7 +36,7 @@ using System.Drawing.Drawing2D;
namespace CodeImp.DoomBuilder.Interface
{
- public abstract partial class ImageSelectorControl : UserControl
+ internal abstract partial class ImageSelectorControl : UserControl
{
// Properties
public string TextureName { get { return name.Text; } set { name.Text = value; } }
diff --git a/Source/Interface/LinedefEditForm.cs b/Source/Interface/LinedefEditForm.cs
index a5af214a..5268c2eb 100644
--- a/Source/Interface/LinedefEditForm.cs
+++ b/Source/Interface/LinedefEditForm.cs
@@ -33,7 +33,7 @@ using CodeImp.DoomBuilder.Editing;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class LinedefEditForm : DelayedForm
+ internal partial class LinedefEditForm : DelayedForm
{
// Variables
private ICollection lines;
@@ -200,16 +200,6 @@ namespace CodeImp.DoomBuilder.Interface
}
}
}
-
- // This shows the dialog to edit lines
- public static void EditLinedefs(IWin32Window owner, ICollection lines)
- {
- // Show line edit dialog
- LinedefEditForm f = new LinedefEditForm();
- f.Setup(lines);
- f.ShowDialog(owner);
- f.Dispose();
- }
// Front side (un)checked
private void frontside_CheckStateChanged(object sender, EventArgs e)
diff --git a/Source/Interface/LinedefInfoPanel.cs b/Source/Interface/LinedefInfoPanel.cs
index 0ad4275c..e18f913b 100644
--- a/Source/Interface/LinedefInfoPanel.cs
+++ b/Source/Interface/LinedefInfoPanel.cs
@@ -31,7 +31,7 @@ using CodeImp.DoomBuilder.Map;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class LinedefInfoPanel : UserControl
+ internal partial class LinedefInfoPanel : UserControl
{
// Constructor
public LinedefInfoPanel()
diff --git a/Source/Interface/MainForm.Designer.cs b/Source/Interface/MainForm.Designer.cs
index 240ff9f1..a0ad685f 100644
--- a/Source/Interface/MainForm.Designer.cs
+++ b/Source/Interface/MainForm.Designer.cs
@@ -35,16 +35,16 @@ namespace CodeImp.DoomBuilder.Interface
System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
System.Windows.Forms.ToolStripSeparator toolStripSeparator9;
- System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
- System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
- System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
- System.Windows.Forms.ToolStripSeparator toolStripMenuItem5;
System.Windows.Forms.ToolStripSeparator toolStripSeparator10;
System.Windows.Forms.ToolStripSeparator toolStripMenuItem4;
System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
System.Windows.Forms.ToolStripSeparator toolStripSeparator11;
+ System.Windows.Forms.ToolStripSeparator toolstripSeperator1;
+ System.Windows.Forms.ToolStripSeparator toolstripSeperator6;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
+ this.itemeditmodesseperator = new System.Windows.Forms.ToolStripSeparator();
+ this.buttoneditmodesseperator = new System.Windows.Forms.ToolStripSeparator();
this.poscommalabel = new System.Windows.Forms.ToolStripStatusLabel();
this.menumain = new System.Windows.Forms.MenuStrip();
this.menufile = new System.Windows.Forms.ToolStripMenuItem();
@@ -59,11 +59,8 @@ namespace CodeImp.DoomBuilder.Interface
this.menuedit = new System.Windows.Forms.ToolStripMenuItem();
this.itemundo = new System.Windows.Forms.ToolStripMenuItem();
this.itemredo = new System.Windows.Forms.ToolStripMenuItem();
- this.itemverticesmode = new System.Windows.Forms.ToolStripMenuItem();
- this.itemlinedefsmode = new System.Windows.Forms.ToolStripMenuItem();
- this.itemsectorsmode = new System.Windows.Forms.ToolStripMenuItem();
- this.itemthingsmode = new System.Windows.Forms.ToolStripMenuItem();
this.itemsnaptogrid = new System.Windows.Forms.ToolStripMenuItem();
+ this.itemautomerge = new System.Windows.Forms.ToolStripMenuItem();
this.itemmapoptions = new System.Windows.Forms.ToolStripMenuItem();
this.menutools = new System.Windows.Forms.ToolStripMenuItem();
this.itemreloadresources = new System.Windows.Forms.ToolStripMenuItem();
@@ -78,10 +75,6 @@ namespace CodeImp.DoomBuilder.Interface
this.buttonmapoptions = new System.Windows.Forms.ToolStripButton();
this.buttonundo = new System.Windows.Forms.ToolStripButton();
this.buttonredo = new System.Windows.Forms.ToolStripButton();
- this.buttonverticesmode = new System.Windows.Forms.ToolStripButton();
- this.buttonlinedefsmode = new System.Windows.Forms.ToolStripButton();
- this.buttonsectorsmode = new System.Windows.Forms.ToolStripButton();
- this.buttonthingsmode = new System.Windows.Forms.ToolStripButton();
this.buttonthingsfilter = new System.Windows.Forms.ToolStripButton();
this.thingfilters = new System.Windows.Forms.ToolStripComboBox();
this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
@@ -119,22 +112,19 @@ namespace CodeImp.DoomBuilder.Interface
this.linedefinfo = new CodeImp.DoomBuilder.Interface.LinedefInfoPanel();
this.redrawtimer = new System.Windows.Forms.Timer(this.components);
this.display = new CodeImp.DoomBuilder.Interface.RenderTargetControl();
- this.itemautomerge = new System.Windows.Forms.ToolStripMenuItem();
toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
- toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
- toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
- toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
- toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator();
toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator();
+ toolstripSeperator1 = new System.Windows.Forms.ToolStripSeparator();
+ toolstripSeperator6 = new System.Windows.Forms.ToolStripSeparator();
this.menumain.SuspendLayout();
this.toolbar.SuspendLayout();
this.statusbar.SuspendLayout();
@@ -173,10 +163,10 @@ namespace CodeImp.DoomBuilder.Interface
toolStripSeparator9.Name = "toolStripSeparator9";
toolStripSeparator9.Size = new System.Drawing.Size(6, 23);
//
- // toolStripSeparator6
+ // itemeditmodesseperator
//
- toolStripSeparator6.Name = "toolStripSeparator6";
- toolStripSeparator6.Size = new System.Drawing.Size(162, 6);
+ this.itemeditmodesseperator.Name = "itemeditmodesseperator";
+ this.itemeditmodesseperator.Size = new System.Drawing.Size(162, 6);
//
// toolStripSeparator3
//
@@ -184,22 +174,11 @@ namespace CodeImp.DoomBuilder.Interface
toolStripSeparator3.Name = "toolStripSeparator3";
toolStripSeparator3.Size = new System.Drawing.Size(6, 25);
//
- // toolStripSeparator5
+ // buttoneditmodesseperator
//
- toolStripSeparator5.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
- toolStripSeparator5.Name = "toolStripSeparator5";
- toolStripSeparator5.Size = new System.Drawing.Size(6, 25);
- //
- // toolStripSeparator7
- //
- toolStripSeparator7.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
- toolStripSeparator7.Name = "toolStripSeparator7";
- toolStripSeparator7.Size = new System.Drawing.Size(6, 25);
- //
- // toolStripMenuItem5
- //
- toolStripMenuItem5.Name = "toolStripMenuItem5";
- toolStripMenuItem5.Size = new System.Drawing.Size(162, 6);
+ this.buttoneditmodesseperator.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
+ this.buttoneditmodesseperator.Name = "buttoneditmodesseperator";
+ this.buttoneditmodesseperator.Size = new System.Drawing.Size(6, 25);
//
// toolStripSeparator10
//
@@ -222,6 +201,17 @@ namespace CodeImp.DoomBuilder.Interface
toolStripSeparator11.Name = "toolStripSeparator11";
toolStripSeparator11.Size = new System.Drawing.Size(162, 6);
//
+ // toolstripSeperator1
+ //
+ toolstripSeperator1.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
+ toolstripSeperator1.Name = "toolstripSeperator1";
+ toolstripSeperator1.Size = new System.Drawing.Size(6, 25);
+ //
+ // toolstripSeperator6
+ //
+ toolstripSeperator6.Name = "toolstripSeperator6";
+ toolstripSeperator6.Size = new System.Drawing.Size(162, 6);
+ //
// poscommalabel
//
this.poscommalabel.Name = "poscommalabel";
@@ -329,12 +319,8 @@ namespace CodeImp.DoomBuilder.Interface
this.menuedit.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.itemundo,
this.itemredo,
- toolStripMenuItem5,
- this.itemverticesmode,
- this.itemlinedefsmode,
- this.itemsectorsmode,
- this.itemthingsmode,
- toolStripSeparator6,
+ toolstripSeperator6,
+ this.itemeditmodesseperator,
this.itemsnaptogrid,
this.itemautomerge,
toolStripSeparator11,
@@ -361,42 +347,6 @@ namespace CodeImp.DoomBuilder.Interface
this.itemredo.Text = "Redo";
this.itemredo.Click += new System.EventHandler(this.InvokeTaggedAction);
//
- // itemverticesmode
- //
- this.itemverticesmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.VerticesMode;
- this.itemverticesmode.Name = "itemverticesmode";
- this.itemverticesmode.Size = new System.Drawing.Size(165, 22);
- this.itemverticesmode.Tag = "verticesmode";
- this.itemverticesmode.Text = "Vertices Mode";
- this.itemverticesmode.Click += new System.EventHandler(this.InvokeTaggedAction);
- //
- // itemlinedefsmode
- //
- this.itemlinedefsmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.LinesMode;
- this.itemlinedefsmode.Name = "itemlinedefsmode";
- this.itemlinedefsmode.Size = new System.Drawing.Size(165, 22);
- this.itemlinedefsmode.Tag = "linedefsmode";
- this.itemlinedefsmode.Text = "Linedefs Mode";
- this.itemlinedefsmode.Click += new System.EventHandler(this.InvokeTaggedAction);
- //
- // itemsectorsmode
- //
- this.itemsectorsmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.SectorsMode;
- this.itemsectorsmode.Name = "itemsectorsmode";
- this.itemsectorsmode.Size = new System.Drawing.Size(165, 22);
- this.itemsectorsmode.Tag = "sectorsmode";
- this.itemsectorsmode.Text = "Sectors Mode";
- this.itemsectorsmode.Click += new System.EventHandler(this.InvokeTaggedAction);
- //
- // itemthingsmode
- //
- this.itemthingsmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.ThingsMode;
- this.itemthingsmode.Name = "itemthingsmode";
- this.itemthingsmode.Size = new System.Drawing.Size(165, 22);
- this.itemthingsmode.Tag = "thingsmode";
- this.itemthingsmode.Text = "Things Mode";
- this.itemthingsmode.Click += new System.EventHandler(this.InvokeTaggedAction);
- //
// itemsnaptogrid
//
this.itemsnaptogrid.Checked = true;
@@ -408,6 +358,17 @@ namespace CodeImp.DoomBuilder.Interface
this.itemsnaptogrid.Text = "Snap to Grid";
this.itemsnaptogrid.Click += new System.EventHandler(this.InvokeTaggedAction);
//
+ // itemautomerge
+ //
+ this.itemautomerge.Checked = true;
+ this.itemautomerge.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.itemautomerge.Image = global::CodeImp.DoomBuilder.Properties.Resources.mergegeometry2;
+ this.itemautomerge.Name = "itemautomerge";
+ this.itemautomerge.Size = new System.Drawing.Size(165, 22);
+ this.itemautomerge.Tag = "toggleautomerge";
+ this.itemautomerge.Text = "Merge Geometry";
+ this.itemautomerge.Click += new System.EventHandler(this.InvokeTaggedAction);
+ //
// itemmapoptions
//
this.itemmapoptions.Image = global::CodeImp.DoomBuilder.Properties.Resources.Properties;
@@ -479,12 +440,8 @@ namespace CodeImp.DoomBuilder.Interface
toolStripSeparator10,
this.buttonundo,
this.buttonredo,
- toolStripSeparator5,
- this.buttonverticesmode,
- this.buttonlinedefsmode,
- this.buttonsectorsmode,
- this.buttonthingsmode,
- toolStripSeparator7,
+ toolstripSeperator1,
+ this.buttoneditmodesseperator,
this.buttonthingsfilter,
this.thingfilters,
this.toolStripSeparator8,
@@ -561,50 +518,6 @@ namespace CodeImp.DoomBuilder.Interface
this.buttonredo.Text = "Redo";
this.buttonredo.Click += new System.EventHandler(this.InvokeTaggedAction);
//
- // buttonverticesmode
- //
- this.buttonverticesmode.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
- this.buttonverticesmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.VerticesMode;
- this.buttonverticesmode.ImageTransparentColor = System.Drawing.Color.Magenta;
- this.buttonverticesmode.Name = "buttonverticesmode";
- this.buttonverticesmode.Size = new System.Drawing.Size(23, 22);
- this.buttonverticesmode.Tag = "verticesmode";
- this.buttonverticesmode.Text = "Vertices Mode";
- this.buttonverticesmode.Click += new System.EventHandler(this.InvokeTaggedAction);
- //
- // buttonlinedefsmode
- //
- this.buttonlinedefsmode.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
- this.buttonlinedefsmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.LinesMode;
- this.buttonlinedefsmode.ImageTransparentColor = System.Drawing.Color.Magenta;
- this.buttonlinedefsmode.Name = "buttonlinedefsmode";
- this.buttonlinedefsmode.Size = new System.Drawing.Size(23, 22);
- this.buttonlinedefsmode.Tag = "linedefsmode";
- this.buttonlinedefsmode.Text = "Linedefs Mode";
- this.buttonlinedefsmode.Click += new System.EventHandler(this.InvokeTaggedAction);
- //
- // buttonsectorsmode
- //
- this.buttonsectorsmode.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
- this.buttonsectorsmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.SectorsMode;
- this.buttonsectorsmode.ImageTransparentColor = System.Drawing.Color.Magenta;
- this.buttonsectorsmode.Name = "buttonsectorsmode";
- this.buttonsectorsmode.Size = new System.Drawing.Size(23, 22);
- this.buttonsectorsmode.Tag = "sectorsmode";
- this.buttonsectorsmode.Text = "Sectors Mode";
- this.buttonsectorsmode.Click += new System.EventHandler(this.InvokeTaggedAction);
- //
- // buttonthingsmode
- //
- this.buttonthingsmode.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
- this.buttonthingsmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.ThingsMode;
- this.buttonthingsmode.ImageTransparentColor = System.Drawing.Color.Magenta;
- this.buttonthingsmode.Name = "buttonthingsmode";
- this.buttonthingsmode.Size = new System.Drawing.Size(23, 22);
- this.buttonthingsmode.Tag = "thingsmode";
- this.buttonthingsmode.Text = "Things Mode";
- this.buttonthingsmode.Click += new System.EventHandler(this.InvokeTaggedAction);
- //
// buttonthingsfilter
//
this.buttonthingsfilter.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
@@ -987,17 +900,6 @@ namespace CodeImp.DoomBuilder.Interface
this.display.Paint += new System.Windows.Forms.PaintEventHandler(this.display_Paint);
this.display.MouseUp += new System.Windows.Forms.MouseEventHandler(this.display_MouseUp);
//
- // itemautomerge
- //
- this.itemautomerge.Checked = true;
- this.itemautomerge.CheckState = System.Windows.Forms.CheckState.Checked;
- this.itemautomerge.Image = global::CodeImp.DoomBuilder.Properties.Resources.mergegeometry2;
- this.itemautomerge.Name = "itemautomerge";
- this.itemautomerge.Size = new System.Drawing.Size(165, 22);
- this.itemautomerge.Tag = "toggleautomerge";
- this.itemautomerge.Text = "Merge Geometry";
- this.itemautomerge.Click += new System.EventHandler(this.InvokeTaggedAction);
- //
// MainForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -1074,14 +976,6 @@ namespace CodeImp.DoomBuilder.Interface
private System.Windows.Forms.ToolStripMenuItem itemmapoptions;
private System.Windows.Forms.ToolStripButton buttonmapoptions;
private System.Windows.Forms.ToolStripMenuItem itemreloadresources;
- private System.Windows.Forms.ToolStripButton buttonverticesmode;
- private System.Windows.Forms.ToolStripButton buttonlinedefsmode;
- private System.Windows.Forms.ToolStripButton buttonsectorsmode;
- private System.Windows.Forms.ToolStripMenuItem itemverticesmode;
- private System.Windows.Forms.ToolStripMenuItem itemlinedefsmode;
- private System.Windows.Forms.ToolStripMenuItem itemsectorsmode;
- private System.Windows.Forms.ToolStripButton buttonthingsmode;
- private System.Windows.Forms.ToolStripMenuItem itemthingsmode;
private LinedefInfoPanel linedefinfo;
private VertexInfoPanel vertexinfo;
private SectorInfoPanel sectorinfo;
@@ -1110,5 +1004,7 @@ namespace CodeImp.DoomBuilder.Interface
private System.Windows.Forms.ToolStripMenuItem itemsnaptogrid;
private System.Windows.Forms.ToolStripButton buttonautomerge;
private System.Windows.Forms.ToolStripMenuItem itemautomerge;
+ private System.Windows.Forms.ToolStripSeparator buttoneditmodesseperator;
+ private System.Windows.Forms.ToolStripSeparator itemeditmodesseperator;
}
}
\ No newline at end of file
diff --git a/Source/Interface/MainForm.cs b/Source/Interface/MainForm.cs
index 237f6b6c..db6a4d0d 100644
--- a/Source/Interface/MainForm.cs
+++ b/Source/Interface/MainForm.cs
@@ -35,7 +35,7 @@ using CodeImp.DoomBuilder.Map;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class MainForm : DelayedForm
+ public partial class MainForm : DelayedForm, IMainForm
{
#region ================== Constants
@@ -67,6 +67,9 @@ namespace CodeImp.DoomBuilder.Interface
// Recent files
private ToolStripMenuItem[] recentitems;
+ // Edit modes
+ private List editmodeitems;
+
#endregion
#region ================== Properties
@@ -75,7 +78,7 @@ namespace CodeImp.DoomBuilder.Interface
public bool CtrlState { get { return ctrl; } }
public bool AltState { get { return alt; } }
public bool MouseInDisplay { get { return mouseinside; } }
- public RenderTargetControl Display { get { return display; } }
+ internal RenderTargetControl Display { get { return display; } }
public bool SnapToGrid { get { return buttonsnaptogrid.Checked; } }
public bool AutoMerge { get { return buttonautomerge.Checked; } }
@@ -84,11 +87,12 @@ namespace CodeImp.DoomBuilder.Interface
#region ================== Constructor / Disposer
// Constructor
- public MainForm()
+ internal MainForm()
{
// Setup controls
InitializeComponent();
-
+ editmodeitems = new List();
+
// Visual Studio IDE doesn't let me set these in the designer :(
buttonzoom.Font = menufile.Font;
buttonzoom.DropDownDirection = ToolStripDropDownDirection.AboveLeft;
@@ -117,7 +121,7 @@ namespace CodeImp.DoomBuilder.Interface
#region ================== General
// This updates all menus for the current status
- public void UpdateInterface()
+ internal void UpdateInterface()
{
// Map opened?
if(General.Map != null)
@@ -138,13 +142,17 @@ namespace CodeImp.DoomBuilder.Interface
UpdateFileMenu();
UpdateEditMenu();
UpdateToolsMenu();
+ UpdateEditModeItems();
}
// Generic event that invokes the tagged action
private void InvokeTaggedAction(object sender, EventArgs e)
{
+ string asmname;
+
this.Update();
- General.Actions[(sender as ToolStripItem).Tag.ToString()].Invoke();
+ asmname = General.ThisAssembly.GetName().Name.ToLowerInvariant();
+ General.Actions[asmname + "_" + (sender as ToolStripItem).Tag.ToString()].Invoke();
this.Update();
}
@@ -270,7 +278,7 @@ namespace CodeImp.DoomBuilder.Interface
}
// This returns the current status text
- public string GetCurrentSatus()
+ internal string GetCurrentSatus()
{
return statuslabel.Text;
}
@@ -298,7 +306,7 @@ namespace CodeImp.DoomBuilder.Interface
}
// This updates the status icon
- public void UpdateStatusIcon()
+ internal void UpdateStatusIcon()
{
// From another thread?
if(statusbar.InvokeRequired)
@@ -342,7 +350,7 @@ namespace CodeImp.DoomBuilder.Interface
}
// This changes coordinates display
- public void UpdateCoordinates(Vector2D coords)
+ internal void UpdateCoordinates(Vector2D coords)
{
// X position
if(float.IsNaN(coords.x))
@@ -361,7 +369,7 @@ namespace CodeImp.DoomBuilder.Interface
}
// This changes zoom display
- public void UpdateZoom(float scale)
+ internal void UpdateZoom(float scale)
{
// Update scale label
if(float.IsNaN(scale))
@@ -409,7 +417,7 @@ namespace CodeImp.DoomBuilder.Interface
}
// This changes grid display
- public void UpdateGrid(int gridsize)
+ internal void UpdateGrid(int gridsize)
{
// Update grid label
if(gridsize == 0)
@@ -454,7 +462,7 @@ namespace CodeImp.DoomBuilder.Interface
// This shows the grid setup dialog
[Action("gridsetup")]
- public void ShowGridSetup()
+ internal void ShowGridSetup()
{
// Only when a map is open
if(General.Map == null) return;
@@ -473,10 +481,102 @@ namespace CodeImp.DoomBuilder.Interface
#endregion
+ #region ================== Toolbar
+
+ // This enables or disables all editing mode items
+ private void UpdateEditModeItems()
+ {
+ // Enable/disable all items
+ foreach(ToolStripItem i in editmodeitems) i.Enabled = (General.Map != null);
+ }
+
+ // This checks one of the edit mode items (and unchecks all others)
+ internal void CheckEditModeButton(string modeclassname)
+ {
+ // Go for all items
+ foreach(ToolStripItem i in editmodeitems)
+ {
+ // Check what type it is
+ if(i is ToolStripMenuItem)
+ {
+ // Check if mode type matches with given name
+ (i as ToolStripMenuItem).Checked = ((i.Tag as EditModeInfo).Type.Name == modeclassname);
+ }
+ else if(i is ToolStripButton)
+ {
+ // Check if mode type matches with given name
+ (i as ToolStripButton).Checked = ((i.Tag as EditModeInfo).Type.Name == modeclassname);
+ }
+ }
+ }
+
+ // This removes the config-specific editing mode buttons
+ internal void RemoveSpecificEditModeButtons()
+ {
+ bool removed;
+
+ do
+ {
+ // Go for all items
+ removed = false;
+ foreach(ToolStripItem i in editmodeitems)
+ {
+ // Only remove the button if it is for a config-specific editing mode
+ if((i.Tag as EditModeInfo).ConfigSpecific)
+ {
+ // Remove it and restart
+ editmodeitems.Remove(i);
+ toolbar.Items.Remove(i);
+ menuedit.DropDownItems.Remove(i);
+ removed = true;
+ break;
+ }
+ }
+ }
+ while(removed);
+ }
+
+ // This adds an editing mode button to the toolbar and edit menu
+ internal void AddEditModeButton(EditModeInfo modeinfo)
+ {
+ ToolStripItem item;
+ int index;
+
+ // Create a button
+ index = toolbar.Items.IndexOf(buttoneditmodesseperator);
+ item = new ToolStripButton(modeinfo.ButtonDesc, modeinfo.ButtonImage, new EventHandler(EditModeButtonHandler));
+ item.DisplayStyle = ToolStripItemDisplayStyle.Image;
+ item.Tag = modeinfo;
+ item.Enabled = (General.Map != null);
+ toolbar.Items.Insert(index, item);
+ editmodeitems.Add(item);
+
+ // Create menu item
+ index = menuedit.DropDownItems.IndexOf(itemeditmodesseperator);
+ item = new ToolStripMenuItem(modeinfo.ButtonDesc, modeinfo.ButtonImage, new EventHandler(EditModeButtonHandler));
+ item.Tag = modeinfo;
+ item.Enabled = (General.Map != null);
+ menuedit.DropDownItems.Insert(index, item);
+ editmodeitems.Add(item);
+ }
+
+ // This handles edit mode button clicks
+ private void EditModeButtonHandler(object sender, EventArgs e)
+ {
+ EditModeInfo modeinfo;
+
+ this.Update();
+ modeinfo = (EditModeInfo)((sender as ToolStripItem).Tag);
+ General.Actions[modeinfo.SwitchAction.GetFullActionName(modeinfo.Plugin.Assembly)].Invoke();
+ this.Update();
+ }
+
+ #endregion
+
#region ================== Display
// This shows the splash screen on display
- public void ShowSplashDisplay()
+ internal void ShowSplashDisplay()
{
// Change display to show splash logo
display.SetSplashLogoDisplay();
@@ -484,7 +584,7 @@ namespace CodeImp.DoomBuilder.Interface
}
// This clears the display
- public void ClearDisplay()
+ internal void ClearDisplay()
{
// Clear the display
display.SetManualRendering();
@@ -636,7 +736,7 @@ namespace CodeImp.DoomBuilder.Interface
#region ================== Menus
// Public method to apply shortcut keys
- public void ApplyShortcutKeys()
+ internal void ApplyShortcutKeys()
{
// Apply shortcut keys to menus
ApplyShortcutKeys(menumain.Items);
@@ -753,7 +853,7 @@ namespace CodeImp.DoomBuilder.Interface
}
// This adds a recent file to the list
- public void AddRecentFile(string filename)
+ internal void AddRecentFile(string filename)
{
int movedownto = MAX_RECENT_FILES - 1;
@@ -838,34 +938,6 @@ namespace CodeImp.DoomBuilder.Interface
#region ================== Edit Menu
- // This sets the status of the vertices button
- public void SetVerticesChecked(bool value)
- {
- itemverticesmode.Checked = value;
- buttonverticesmode.Checked = value;
- }
-
- // This sets the status of the linedefs button
- public void SetLinedefsChecked(bool value)
- {
- itemlinedefsmode.Checked = value;
- buttonlinedefsmode.Checked = value;
- }
-
- // This sets the status of the sectors button
- public void SetSectorsChecked(bool value)
- {
- itemsectorsmode.Checked = value;
- buttonsectorsmode.Checked = value;
- }
-
- // This sets the status of the things button
- public void SetThingsChecked(bool value)
- {
- itemthingsmode.Checked = value;
- buttonthingsmode.Checked = value;
- }
-
// This sets up the edit menu
private void UpdateEditMenu()
{
@@ -876,10 +948,6 @@ namespace CodeImp.DoomBuilder.Interface
itemundo.Enabled = (General.Map != null) && (General.Map.UndoRedo.NextUndo != null);
itemredo.Enabled = (General.Map != null) && (General.Map.UndoRedo.NextRedo != null);
itemmapoptions.Enabled = (General.Map != null);
- itemverticesmode.Enabled = (General.Map != null);
- itemlinedefsmode.Enabled = (General.Map != null);
- itemsectorsmode.Enabled = (General.Map != null);
- itemthingsmode.Enabled = (General.Map != null);
itemsnaptogrid.Enabled = (General.Map != null);
itemautomerge.Enabled = (General.Map != null);
@@ -897,10 +965,6 @@ namespace CodeImp.DoomBuilder.Interface
// Toolbar icons
buttonmapoptions.Enabled = (General.Map != null);
- buttonverticesmode.Enabled = (General.Map != null);
- buttonlinedefsmode.Enabled = (General.Map != null);
- buttonsectorsmode.Enabled = (General.Map != null);
- buttonthingsmode.Enabled = (General.Map != null);
buttonundo.Enabled = itemundo.Enabled;
buttonredo.Enabled = itemredo.Enabled;
buttonundo.ToolTipText = itemundo.Text;
@@ -911,7 +975,7 @@ namespace CodeImp.DoomBuilder.Interface
// Action to toggle snap to grid
[Action("togglesnap")]
- public void ToggleSnapToGrid()
+ internal void ToggleSnapToGrid()
{
buttonsnaptogrid.Checked = !buttonsnaptogrid.Checked;
itemsnaptogrid.Checked = buttonsnaptogrid.Checked;
@@ -919,7 +983,7 @@ namespace CodeImp.DoomBuilder.Interface
// Action to toggle auto merge
[Action("toggleautomerge")]
- public void ToggleAutoMerge()
+ internal void ToggleAutoMerge()
{
buttonautomerge.Checked = !buttonautomerge.Checked;
itemautomerge.Checked = buttonautomerge.Checked;
@@ -954,7 +1018,7 @@ namespace CodeImp.DoomBuilder.Interface
// Game Configuration action
[Action("configuration")]
- public void ShowConfiguration()
+ internal void ShowConfiguration()
{
// Show configuration dialog
ConfigForm cfgform = new ConfigForm();
@@ -976,7 +1040,7 @@ namespace CodeImp.DoomBuilder.Interface
// Preferences action
[Action("preferences")]
- public void ShowPreferences()
+ internal void ShowPreferences()
{
// Show preferences dialog
PreferencesForm prefform = new PreferencesForm();
@@ -1023,5 +1087,19 @@ namespace CodeImp.DoomBuilder.Interface
public void ShowThingInfo(Thing t) { thinginfo.ShowInfo(t); }
#endregion
+
+ #region ================== Dialogs
+
+ // This shows the dialog to edit lines
+ public void ShowEditLinedefs(ICollection lines)
+ {
+ // Show line edit dialog
+ LinedefEditForm f = new LinedefEditForm();
+ f.Setup(lines);
+ f.ShowDialog(this);
+ f.Dispose();
+ }
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/Source/Interface/MainForm.resx b/Source/Interface/MainForm.resx
index 14f07729..91bd2c69 100644
--- a/Source/Interface/MainForm.resx
+++ b/Source/Interface/MainForm.resx
@@ -135,21 +135,9 @@
False
-
- False
-
False
-
- False
-
-
- False
-
-
- False
-
False
@@ -162,6 +150,12 @@
False
+
+ False
+
+
+ False
+
True
diff --git a/Source/Interface/MapOptionsForm.cs b/Source/Interface/MapOptionsForm.cs
index 24fff510..29d71b06 100644
--- a/Source/Interface/MapOptionsForm.cs
+++ b/Source/Interface/MapOptionsForm.cs
@@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class MapOptionsForm : DelayedForm
+ internal partial class MapOptionsForm : DelayedForm
{
// Variables
private MapOptions options;
diff --git a/Source/Interface/OpenMapOptionsForm.cs b/Source/Interface/OpenMapOptionsForm.cs
index aaa71022..119c7f50 100644
--- a/Source/Interface/OpenMapOptionsForm.cs
+++ b/Source/Interface/OpenMapOptionsForm.cs
@@ -34,7 +34,7 @@ using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class OpenMapOptionsForm : DelayedForm
+ internal partial class OpenMapOptionsForm : DelayedForm
{
// Variables
private Configuration mapsettings;
diff --git a/Source/Interface/PreferencesForm.cs b/Source/Interface/PreferencesForm.cs
index 8b935819..728cbc62 100644
--- a/Source/Interface/PreferencesForm.cs
+++ b/Source/Interface/PreferencesForm.cs
@@ -30,7 +30,7 @@ using CodeImp.DoomBuilder.Controls;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class PreferencesForm : DelayedForm
+ internal partial class PreferencesForm : DelayedForm
{
#region ================== Variables
diff --git a/Source/Interface/RenderTargetControl.cs b/Source/Interface/RenderTargetControl.cs
index 662cc1f8..41e29b27 100644
--- a/Source/Interface/RenderTargetControl.cs
+++ b/Source/Interface/RenderTargetControl.cs
@@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Editing;
namespace CodeImp.DoomBuilder.Interface
{
- public class RenderTargetControl : Panel
+ internal class RenderTargetControl : Panel
{
#region ================== Constants
@@ -59,7 +59,7 @@ namespace CodeImp.DoomBuilder.Interface
this.SetStyle(ControlStyles.FixedHeight, true);
}
- // Diposer
+ // Disposer
protected override void Dispose(bool disposing)
{
// Clean up
diff --git a/Source/Interface/ResourceListEditor.Designer.cs b/Source/Interface/ResourceListEditor.Designer.cs
index ccec6a0a..f4a9e5b6 100644
--- a/Source/Interface/ResourceListEditor.Designer.cs
+++ b/Source/Interface/ResourceListEditor.Designer.cs
@@ -1,6 +1,6 @@
namespace CodeImp.DoomBuilder.Interface
{
- public partial class ResourceListEditor
+ partial class ResourceListEditor
{
///
/// Required designer variable.
diff --git a/Source/Interface/ResourceListEditor.cs b/Source/Interface/ResourceListEditor.cs
index 099135ea..d16ff29f 100644
--- a/Source/Interface/ResourceListEditor.cs
+++ b/Source/Interface/ResourceListEditor.cs
@@ -29,7 +29,7 @@ using CodeImp.DoomBuilder.Data;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class ResourceListEditor : UserControl
+ internal partial class ResourceListEditor : UserControl
{
#region ================== Delegates / Events
diff --git a/Source/Interface/ResourceListView.cs b/Source/Interface/ResourceListView.cs
index 11e07f91..8e692902 100644
--- a/Source/Interface/ResourceListView.cs
+++ b/Source/Interface/ResourceListView.cs
@@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Editing;
namespace CodeImp.DoomBuilder.Interface
{
- public class ResourceListView : ListView
+ internal class ResourceListView : ListView
{
#region ================== Constants
diff --git a/Source/Interface/ResourceOptionsForm.cs b/Source/Interface/ResourceOptionsForm.cs
index 7edf56e1..6dc21252 100644
--- a/Source/Interface/ResourceOptionsForm.cs
+++ b/Source/Interface/ResourceOptionsForm.cs
@@ -30,7 +30,7 @@ using CodeImp.DoomBuilder.Data;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class ResourceOptionsForm : DelayedForm
+ internal partial class ResourceOptionsForm : DelayedForm
{
// Variables
private DataLocation res;
diff --git a/Source/Interface/SectorInfoPanel.cs b/Source/Interface/SectorInfoPanel.cs
index c87e3821..72d0f336 100644
--- a/Source/Interface/SectorInfoPanel.cs
+++ b/Source/Interface/SectorInfoPanel.cs
@@ -31,7 +31,7 @@ using CodeImp.DoomBuilder.Map;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class SectorInfoPanel : UserControl
+ internal partial class SectorInfoPanel : UserControl
{
// Constructor
public SectorInfoPanel()
diff --git a/Source/Interface/TextureBrowserForm.cs b/Source/Interface/TextureBrowserForm.cs
index 3200df63..eddb58ae 100644
--- a/Source/Interface/TextureBrowserForm.cs
+++ b/Source/Interface/TextureBrowserForm.cs
@@ -33,7 +33,7 @@ using CodeImp.DoomBuilder.Map;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class TextureBrowserForm : DelayedForm
+ internal partial class TextureBrowserForm : DelayedForm
{
// Variables
private string selectedname;
diff --git a/Source/Interface/TextureSelectorControl.cs b/Source/Interface/TextureSelectorControl.cs
index 27279230..3e0c4588 100644
--- a/Source/Interface/TextureSelectorControl.cs
+++ b/Source/Interface/TextureSelectorControl.cs
@@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.Map;
namespace CodeImp.DoomBuilder.Interface
{
- public class TextureSelectorControl : ImageSelectorControl
+ internal class TextureSelectorControl : ImageSelectorControl
{
// Variables
private bool required;
diff --git a/Source/Interface/ThingInfoPanel.cs b/Source/Interface/ThingInfoPanel.cs
index 8d5b94fb..5b563ef0 100644
--- a/Source/Interface/ThingInfoPanel.cs
+++ b/Source/Interface/ThingInfoPanel.cs
@@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class ThingInfoPanel : UserControl
+ internal partial class ThingInfoPanel : UserControl
{
// Constructor
public ThingInfoPanel()
diff --git a/Source/Interface/VertexInfoPanel.cs b/Source/Interface/VertexInfoPanel.cs
index a7d44e0b..7619809f 100644
--- a/Source/Interface/VertexInfoPanel.cs
+++ b/Source/Interface/VertexInfoPanel.cs
@@ -31,7 +31,7 @@ using CodeImp.DoomBuilder.Map;
namespace CodeImp.DoomBuilder.Interface
{
- public partial class VertexInfoPanel : UserControl
+ internal partial class VertexInfoPanel : UserControl
{
// Constructor
public VertexInfoPanel()
diff --git a/Source/Map/Linedef.cs b/Source/Map/Linedef.cs
index a26b3f60..95993c54 100644
--- a/Source/Map/Linedef.cs
+++ b/Source/Map/Linedef.cs
@@ -30,7 +30,7 @@ using System.Drawing;
namespace CodeImp.DoomBuilder.Map
{
- public sealed class Linedef : IDisposable
+ public sealed class Linedef
{
#region ================== Constants
@@ -121,7 +121,7 @@ namespace CodeImp.DoomBuilder.Map
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public void Dispose()
{
// Not already disposed?
diff --git a/Source/Map/MapOptions.cs b/Source/Map/MapOptions.cs
index 868d0e30..25d440bf 100644
--- a/Source/Map/MapOptions.cs
+++ b/Source/Map/MapOptions.cs
@@ -29,7 +29,7 @@ using CodeImp.DoomBuilder.Data;
namespace CodeImp.DoomBuilder.Map
{
- public sealed class MapOptions
+ internal sealed class MapOptions
{
#region ================== Constants
diff --git a/Source/Map/MapSet.cs b/Source/Map/MapSet.cs
index 0b27bf4e..89c613f2 100644
--- a/Source/Map/MapSet.cs
+++ b/Source/Map/MapSet.cs
@@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Editing;
namespace CodeImp.DoomBuilder.Map
{
- public sealed class MapSet : IDisposable
+ public sealed class MapSet
{
#region ================== Constants
@@ -88,7 +88,7 @@ namespace CodeImp.DoomBuilder.Map
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public void Dispose()
{
ArrayList list;
diff --git a/Source/Map/Sector.cs b/Source/Map/Sector.cs
index 97f36721..ab2b24f2 100644
--- a/Source/Map/Sector.cs
+++ b/Source/Map/Sector.cs
@@ -27,7 +27,7 @@ using CodeImp.DoomBuilder.IO;
namespace CodeImp.DoomBuilder.Map
{
- public sealed class Sector : IDisposable
+ public sealed class Sector
{
#region ================== Constants
@@ -109,7 +109,7 @@ namespace CodeImp.DoomBuilder.Map
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public void Dispose()
{
// Not already disposed?
diff --git a/Source/Map/Sidedef.cs b/Source/Map/Sidedef.cs
index c08e3165..201e3442 100644
--- a/Source/Map/Sidedef.cs
+++ b/Source/Map/Sidedef.cs
@@ -27,7 +27,7 @@ using CodeImp.DoomBuilder.IO;
namespace CodeImp.DoomBuilder.Map
{
- public sealed class Sidedef : IDisposable
+ public sealed class Sidedef
{
#region ================== Constants
@@ -106,7 +106,7 @@ namespace CodeImp.DoomBuilder.Map
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public void Dispose()
{
// Not already disposed?
diff --git a/Source/Map/Thing.cs b/Source/Map/Thing.cs
index 7053f29d..609ff855 100644
--- a/Source/Map/Thing.cs
+++ b/Source/Map/Thing.cs
@@ -30,7 +30,7 @@ using System.Drawing;
namespace CodeImp.DoomBuilder.Map
{
- public sealed class Thing : IDisposable
+ public sealed class Thing
{
#region ================== Constants
@@ -110,7 +110,7 @@ namespace CodeImp.DoomBuilder.Map
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public void Dispose()
{
// Not already disposed?
@@ -264,5 +264,23 @@ namespace CodeImp.DoomBuilder.Map
}
#endregion
+
+ #region ================== Methods
+
+ // This returns the distance from given coordinates
+ public float DistanceToSq(Vector2D p)
+ {
+ Vector2D delta = p - (Vector2D)pos;
+ return delta.GetLengthSq();
+ }
+
+ // This returns the distance from given coordinates
+ public float DistanceTo(Vector2D p)
+ {
+ Vector2D delta = p - (Vector2D)pos;
+ return delta.GetLength();
+ }
+
+ #endregion
}
}
diff --git a/Source/Map/Vertex.cs b/Source/Map/Vertex.cs
index add15612..2dea7e3d 100644
--- a/Source/Map/Vertex.cs
+++ b/Source/Map/Vertex.cs
@@ -30,7 +30,7 @@ using System.Drawing;
namespace CodeImp.DoomBuilder.Map
{
- public sealed class Vertex : IDisposable
+ public sealed class Vertex
{
#region ================== Constants
@@ -95,7 +95,7 @@ namespace CodeImp.DoomBuilder.Map
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public void Dispose()
{
// Not already disposed?
diff --git a/Source/Plugins/Plugin.cs b/Source/Plugins/Plugin.cs
new file mode 100644
index 00000000..2a5af648
--- /dev/null
+++ b/Source/Plugins/Plugin.cs
@@ -0,0 +1,175 @@
+
+#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.IO;
+using System.Reflection;
+using CodeImp.DoomBuilder.Controls;
+
+#endregion
+
+namespace CodeImp.DoomBuilder.Plugins
+{
+ internal class Plugin
+ {
+ #region ================== Constants
+
+ #endregion
+
+ #region ================== Variables
+
+ // The plugin assembly
+ private Assembly asm;
+
+ // Unique name used to refer to this assembly
+ private string name;
+
+ // Disposing
+ private bool isdisposed = false;
+
+ #endregion
+
+ #region ================== Properties
+
+ public Assembly Assembly { get { return asm; } }
+ public string Name { get { return name; } }
+ public bool IsDisposed { get { return isdisposed; } }
+
+ #endregion
+
+ #region ================== Constructor / Disposer
+
+ // Constructor
+ public Plugin(string filename)
+ {
+ // Initialize
+ name = Path.GetFileNameWithoutExtension(filename);
+ General.WriteLogLine("Loading plugin '" + name + "' from '" + Path.GetFileName(filename) + "'...");
+
+ // Load assembly
+ asm = Assembly.LoadFile(filename);
+
+ // Load actions
+ General.Actions.LoadActions(asm);
+
+ // We have no destructor
+ GC.SuppressFinalize(this);
+ }
+
+ // Disposer
+ public void Dispose()
+ {
+ // Not already disposed?
+ if(!isdisposed)
+ {
+ // Clean up
+ asm = null;
+
+ // Done
+ isdisposed = true;
+ }
+ }
+
+ #endregion
+
+ #region ================== Methods
+
+ // This creates a stream to read a resource or returns null when not found
+ public Stream FindResource(string resourcename)
+ {
+ string[] resnames;
+
+ // Find a resource
+ resnames = asm.GetManifestResourceNames();
+ foreach(string rn in resnames)
+ {
+ // Found it?
+ if(rn.EndsWith(resourcename, StringComparison.InvariantCultureIgnoreCase))
+ {
+ // Get a stream from the resource
+ return asm.GetManifestResourceStream(rn);
+ }
+ }
+
+ // Nothing found
+ return null;
+ }
+
+ // This finds all class types that inherits from the given type
+ public Type[] FindClasses(Type t)
+ {
+ List found = new List();
+ Type[] types;
+
+ // Get all exported types
+ types = asm.GetExportedTypes();
+ foreach(Type it in types)
+ {
+ // Compare types
+ if(t.IsAssignableFrom(it)) found.Add(it);
+ }
+
+ // Return list
+ return found.ToArray();
+ }
+
+ // This finds a single class type that inherits from the given type
+ // Returns null when no valid type was found
+ public Type FindSingleClass(Type t)
+ {
+ Type[] types = FindClasses(t);
+ if(types.Length > 0) return types[0]; else return null;
+ }
+
+ // This creates an instance of a class
+ public T CreateObject(Type t, params object[] args)
+ {
+ return CreateObjectA(t, args);
+ }
+
+ // This creates an instance of a class
+ public T CreateObjectA(Type t, object[] args)
+ {
+ try
+ {
+ // Create instance
+ return (T)asm.CreateInstance(t.FullName, false, BindingFlags.Default, null, args, CultureInfo.CurrentCulture, new object[0]);
+ }
+ catch(TargetInvocationException e)
+ {
+ // Error!
+ General.WriteLogLine("ERROR: Failed to create class instance '" + t.Name + "' from plugin '" + name + "'!");
+ General.WriteLogLine(e.InnerException.GetType().Name + ": " + e.InnerException.Message);
+ return default(T);
+ }
+ catch(Exception e)
+ {
+ // Error!
+ General.WriteLogLine("ERROR: Failed to create class instance '" + t.Name + "' from plugin '" + name + "'!");
+ General.WriteLogLine(e.GetType().Name + ": " + e.Message);
+ return default(T);
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/Source/Plugins/PluginManager.cs b/Source/Plugins/PluginManager.cs
new file mode 100644
index 00000000..83f617e8
--- /dev/null
+++ b/Source/Plugins/PluginManager.cs
@@ -0,0 +1,164 @@
+
+#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.IO;
+using CodeImp.DoomBuilder.Editing;
+
+#endregion
+
+namespace CodeImp.DoomBuilder.Plugins
+{
+ internal class PluginManager
+ {
+ #region ================== Constants
+
+ #endregion
+
+ #region ================== Variables
+
+ // Plugins
+ private List plugins;
+
+ // Modes
+ private List editmodes;
+
+ // Disposing
+ private bool isdisposed = false;
+
+ #endregion
+
+ #region ================== Properties
+
+ public ICollection EditModes { get { return editmodes; } }
+ public bool IsDisposed { get { return isdisposed; } }
+
+ #endregion
+
+ #region ================== Constructor / Disposer
+
+ // Constructor
+ public PluginManager()
+ {
+ string[] filenames;
+ Type[] editclasses;
+ EditModeAttribute[] emattrs;
+ EditModeInfo editmodeinfo;
+ Plugin p;
+
+ // Make lists
+ this.plugins = new List();
+ this.editmodes = new List();
+
+ // Find all .dll files
+ filenames = Directory.GetFiles(General.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly);
+ foreach(string fn in filenames)
+ {
+ // Load plugin from this file
+ General.MainWindow.DisplayStatus("Loading plugin '" + Path.GetFileName(fn) + "'...");
+ p = new Plugin(fn);
+ if(!p.IsDisposed) this.plugins.Add(p);
+
+ // For all classes that inherit from EditMode
+ editclasses = p.FindClasses(typeof(EditMode));
+ foreach(Type t in editclasses)
+ {
+ // For all defined EditMode attributes
+ emattrs = (EditModeAttribute[])t.GetCustomAttributes(typeof(EditModeAttribute), true);
+ foreach(EditModeAttribute a in emattrs)
+ {
+ // Make edit mode information
+ editmodeinfo = new EditModeInfo(p, t, a);
+ editmodes.Add(editmodeinfo);
+ }
+ }
+ }
+
+ // Sort the list in order for buttons
+ editmodes.Sort();
+
+ // Go for all edit modes to add buttons
+ foreach(EditModeInfo emi in editmodes)
+ {
+ // Add all non-config-specific buttons to interface
+ if((emi.ButtonImage != null) && (emi.ButtonDesc != null) && !emi.ConfigSpecific)
+ General.MainWindow.AddEditModeButton(emi);
+ }
+
+ // We have no destructor
+ GC.SuppressFinalize(this);
+ }
+
+ // Disposer
+ public void Dispose()
+ {
+ // Not already disposed?
+ if(!isdisposed)
+ {
+ // Clean up
+ foreach(Plugin p in plugins) p.Dispose();
+
+ // Done
+ isdisposed = true;
+ }
+ }
+
+ #endregion
+
+ #region ================== Methods
+
+ // This returns specific editing mode info by name
+ public EditModeInfo GetEditModeInfo(string editmodename)
+ {
+ // Find the edit mode
+ foreach(EditModeInfo emi in editmodes)
+ {
+ // Mode matches class name?
+ if(emi.ToString() == editmodename) return emi;
+ }
+
+ // No such mode found
+ return null;
+ }
+
+ // This is called when the game canfiguration is set or changed
+ public void GameConfigurationChanged()
+ {
+ // Remove all config-specific editing mode buttons from toolbar
+ General.MainWindow.RemoveSpecificEditModeButtons();
+
+ // Go for all edit modes to add buttons
+ foreach(EditModeInfo emi in editmodes)
+ {
+ // Add only non-config-specific buttons to interface
+ if((emi.ButtonImage != null) && (emi.ButtonDesc != null) && emi.ConfigSpecific)
+ {
+ // Add if this button is specified by the game config
+ if(General.Map.Config.IsEditModeSpecified(emi.Type.Name))
+ General.MainWindow.AddEditModeButton(emi);
+ }
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs
index 760b29bc..23f07213 100644
--- a/Source/Properties/AssemblyInfo.cs
+++ b/Source/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("2.0")]
-[assembly: AssemblyFileVersion("2.0")]
+[assembly: AssemblyVersion("2.0.*")]
+[assembly: AssemblyFileVersion("2.0.*")]
diff --git a/Source/Properties/Resources.Designer.cs b/Source/Properties/Resources.Designer.cs
index d7f7e828..12ec26da 100644
--- a/Source/Properties/Resources.Designer.cs
+++ b/Source/Properties/Resources.Designer.cs
@@ -109,13 +109,6 @@ namespace CodeImp.DoomBuilder.Properties {
}
}
- internal static System.Drawing.Bitmap LinesMode {
- get {
- object obj = ResourceManager.GetObject("LinesMode", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
internal static System.Drawing.Bitmap mergegeometry {
get {
object obj = ResourceManager.GetObject("mergegeometry", resourceCulture);
@@ -172,13 +165,6 @@ namespace CodeImp.DoomBuilder.Properties {
}
}
- internal static System.Drawing.Bitmap SectorsMode {
- get {
- object obj = ResourceManager.GetObject("SectorsMode", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
internal static System.Drawing.Bitmap Splash2 {
get {
object obj = ResourceManager.GetObject("Splash2", resourceCulture);
@@ -214,13 +200,6 @@ namespace CodeImp.DoomBuilder.Properties {
}
}
- internal static System.Drawing.Bitmap ThingsMode {
- get {
- object obj = ResourceManager.GetObject("ThingsMode", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
internal static System.Drawing.Bitmap treeview {
get {
object obj = ResourceManager.GetObject("treeview", resourceCulture);
@@ -242,13 +221,6 @@ namespace CodeImp.DoomBuilder.Properties {
}
}
- internal static System.Drawing.Bitmap VerticesMode {
- get {
- object obj = ResourceManager.GetObject("VerticesMode", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
internal static System.Drawing.Bitmap Zoom {
get {
object obj = ResourceManager.GetObject("Zoom", resourceCulture);
diff --git a/Source/Properties/Resources.resx b/Source/Properties/Resources.resx
index b5ff007f..de801898 100644
--- a/Source/Properties/Resources.resx
+++ b/Source/Properties/Resources.resx
@@ -130,9 +130,6 @@
..\Resources\Properties.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\Resources\LinesMode.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
..\Resources\Splash2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -157,9 +154,6 @@
..\Resources\ColorPick.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\Resources\SectorsMode.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
..\Resources\Grid2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -175,12 +169,6 @@
..\Resources\Status2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\Resources\VerticesMode.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- ..\Resources\ThingsMode.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
..\Resources\Status1.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
diff --git a/Source/Rendering/ColorCollection.cs b/Source/Rendering/ColorCollection.cs
index 3dc68513..17164a31 100644
--- a/Source/Rendering/ColorCollection.cs
+++ b/Source/Rendering/ColorCollection.cs
@@ -104,35 +104,35 @@ namespace CodeImp.DoomBuilder.Rendering
public PixelColor[] BrightColors { get { return brightcolors; } }
public PixelColor[] DarkColors { get { return darkcolors; } }
- public PixelColor Background { get { return colors[BACKGROUND]; } set { colors[BACKGROUND] = value; } }
- public PixelColor Vertices { get { return colors[VERTICES]; } set { colors[VERTICES] = value; } }
- public PixelColor Linedefs { get { return colors[LINEDEFS]; } set { colors[LINEDEFS] = value; } }
- public PixelColor Actions { get { return colors[ACTIONS]; } set { colors[ACTIONS] = value; } }
- public PixelColor Sounds { get { return colors[SOUNDS]; } set { colors[SOUNDS] = value; } }
- public PixelColor Highlight { get { return colors[HIGHLIGHT]; } set { colors[HIGHLIGHT] = value; } }
- public PixelColor Selection { get { return colors[SELECTION]; } set { colors[SELECTION] = value; } }
- public PixelColor Association { get { return colors[ASSOCIATION]; } set { colors[ASSOCIATION] = value; } }
- public PixelColor Grid { get { return colors[GRID]; } set { colors[GRID] = value; } }
- public PixelColor Grid64 { get { return colors[GRID64]; } set { colors[GRID64] = value; } }
+ public PixelColor Background { get { return colors[BACKGROUND]; } internal set { colors[BACKGROUND] = value; } }
+ public PixelColor Vertices { get { return colors[VERTICES]; } internal set { colors[VERTICES] = value; } }
+ public PixelColor Linedefs { get { return colors[LINEDEFS]; } internal set { colors[LINEDEFS] = value; } }
+ public PixelColor Actions { get { return colors[ACTIONS]; } internal set { colors[ACTIONS] = value; } }
+ public PixelColor Sounds { get { return colors[SOUNDS]; } internal set { colors[SOUNDS] = value; } }
+ public PixelColor Highlight { get { return colors[HIGHLIGHT]; } internal set { colors[HIGHLIGHT] = value; } }
+ public PixelColor Selection { get { return colors[SELECTION]; } internal set { colors[SELECTION] = value; } }
+ public PixelColor Association { get { return colors[ASSOCIATION]; } internal set { colors[ASSOCIATION] = value; } }
+ public PixelColor Grid { get { return colors[GRID]; } internal set { colors[GRID] = value; } }
+ public PixelColor Grid64 { get { return colors[GRID64]; } internal set { colors[GRID64] = value; } }
- public PixelColor Crosshair3D { get { return colors[CROSSHAIR3D]; } set { colors[CROSSHAIR3D] = value; } }
- public PixelColor Highlight3D { get { return colors[HIGHLIGHT3D]; } set { colors[HIGHLIGHT3D] = value; } }
- public PixelColor Selection3D { get { return colors[SELECTION3D]; } set { colors[SELECTION3D] = value; } }
+ public PixelColor Crosshair3D { get { return colors[CROSSHAIR3D]; } internal set { colors[CROSSHAIR3D] = value; } }
+ public PixelColor Highlight3D { get { return colors[HIGHLIGHT3D]; } internal set { colors[HIGHLIGHT3D] = value; } }
+ public PixelColor Selection3D { get { return colors[SELECTION3D]; } internal set { colors[SELECTION3D] = value; } }
- public PixelColor ScriptBackground { get { return colors[SCRIPTBACKGROUND]; } set { colors[SCRIPTBACKGROUND] = value; } }
- public PixelColor LineNumbers { get { return colors[LINENUMBERS]; } set { colors[LINENUMBERS] = value; } }
- public PixelColor PlainText { get { return colors[PLAINTEXT]; } set { colors[PLAINTEXT] = value; } }
- public PixelColor Comments { get { return colors[COMMENTS]; } set { colors[COMMENTS] = value; } }
- public PixelColor Keywords { get { return colors[KEYWORDS]; } set { colors[KEYWORDS] = value; } }
- public PixelColor Literals { get { return colors[LITERALS]; } set { colors[LITERALS] = value; } }
- public PixelColor Constants { get { return colors[CONSTANTS]; } set { colors[CONSTANTS] = value; } }
+ public PixelColor ScriptBackground { get { return colors[SCRIPTBACKGROUND]; } internal set { colors[SCRIPTBACKGROUND] = value; } }
+ public PixelColor LineNumbers { get { return colors[LINENUMBERS]; } internal set { colors[LINENUMBERS] = value; } }
+ public PixelColor PlainText { get { return colors[PLAINTEXT]; } internal set { colors[PLAINTEXT] = value; } }
+ public PixelColor Comments { get { return colors[COMMENTS]; } internal set { colors[COMMENTS] = value; } }
+ public PixelColor Keywords { get { return colors[KEYWORDS]; } internal set { colors[KEYWORDS] = value; } }
+ public PixelColor Literals { get { return colors[LITERALS]; } internal set { colors[LITERALS] = value; } }
+ public PixelColor Constants { get { return colors[CONSTANTS]; } internal set { colors[CONSTANTS] = value; } }
#endregion
#region ================== Constructor / Disposer
// Constructor for settings from configuration
- public ColorCollection(Configuration cfg)
+ internal ColorCollection(Configuration cfg)
{
// Initialize
colors = new PixelColor[NUM_COLORS];
@@ -176,7 +176,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Copy constructor
- public ColorCollection(ColorCollection collection)
+ internal ColorCollection(ColorCollection collection)
{
// Initialize
colors = new PixelColor[NUM_COLORS];
@@ -205,7 +205,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// This creates assist colors
- public void CreateAssistColors()
+ internal void CreateAssistColors()
{
ColorValue o;
ColorValue c = new ColorValue(1f, 0f, 0f, 0f);
@@ -231,7 +231,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// This applies colors to this collection
- public void Apply(ColorCollection collection)
+ internal void Apply(ColorCollection collection)
{
// Copy all colors
for(int i = 0; i < NUM_COLORS; i++)
@@ -242,7 +242,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// This saves colors to configuration
- public void SaveColors(Configuration cfg)
+ internal void SaveColors(Configuration cfg)
{
// Write all colors to config
for(int i = 0; i < NUM_COLORS; i++)
diff --git a/Source/Rendering/ColorSetting.cs b/Source/Rendering/ColorSetting.cs
index bb82ab94..02ba90b7 100644
--- a/Source/Rendering/ColorSetting.cs
+++ b/Source/Rendering/ColorSetting.cs
@@ -28,7 +28,7 @@ using System.Drawing;
namespace CodeImp.DoomBuilder.Rendering
{
- public sealed class ColorSetting : IEquatable
+ internal sealed class ColorSetting : IEquatable
{
#region ================== Constants
diff --git a/Source/Rendering/D3DDevice.cs b/Source/Rendering/D3DDevice.cs
index a7497fa7..29a6ba12 100644
--- a/Source/Rendering/D3DDevice.cs
+++ b/Source/Rendering/D3DDevice.cs
@@ -36,7 +36,7 @@ using CodeImp.DoomBuilder.Interface;
namespace CodeImp.DoomBuilder.Rendering
{
- public class D3DDevice : IDisposable
+ internal class D3DDevice
{
#region ================== Constants
@@ -67,20 +67,20 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Properties
- public Device Device { get { return device; } }
+ internal Device Device { get { return device; } }
public bool IsDisposed { get { return isdisposed; } }
- public RenderTargetControl RenderTarget { get { return rendertarget; } }
- public Viewport Viewport { get { return viewport; } }
- public ShaderManager Shaders { get { return shaders; } }
- public Surface BackBuffer { get { return backbuffer; } }
- public Surface DepthBuffer { get { return depthbuffer; } }
+ internal RenderTargetControl RenderTarget { get { return rendertarget; } }
+ internal Viewport Viewport { get { return viewport; } }
+ internal ShaderManager Shaders { get { return shaders; } }
+ internal Surface BackBuffer { get { return backbuffer; } }
+ internal Surface DepthBuffer { get { return depthbuffer; } }
#endregion
#region ================== Constructor / Disposer
// Constructor
- public D3DDevice(RenderTargetControl rendertarget)
+ internal D3DDevice(RenderTargetControl rendertarget)
{
// Set render target
this.rendertarget = rendertarget;
@@ -92,8 +92,8 @@ namespace CodeImp.DoomBuilder.Rendering
GC.SuppressFinalize(this);
}
- // Diposer
- public void Dispose()
+ // Disposer
+ internal void Dispose()
{
// Not already disposed?
if(!isdisposed)
@@ -283,21 +283,21 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Resetting
// This registers a resource
- public void RegisterResource(ID3DResource res)
+ internal void RegisterResource(ID3DResource res)
{
// Add resource
resources.Add(res);
}
// This unregisters a resource
- public void UnregisterResource(ID3DResource res)
+ internal void UnregisterResource(ID3DResource res)
{
// Remove resource
resources.Remove(res);
}
// This resets the device and returns true on success
- public bool Reset()
+ internal bool Reset()
{
PresentParameters displaypp;
diff --git a/Source/Rendering/D3DShader.cs b/Source/Rendering/D3DShader.cs
index 5d9556df..ef8c4ddf 100644
--- a/Source/Rendering/D3DShader.cs
+++ b/Source/Rendering/D3DShader.cs
@@ -37,7 +37,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.Rendering
{
- public abstract class D3DShader : IDisposable
+ internal abstract class D3DShader
{
#region ================== Constants
@@ -78,7 +78,7 @@ namespace CodeImp.DoomBuilder.Rendering
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public virtual void Dispose()
{
// Not already disposed?
diff --git a/Source/Rendering/Display2DShader.cs b/Source/Rendering/Display2DShader.cs
index 5e61b304..8f9df73d 100644
--- a/Source/Rendering/Display2DShader.cs
+++ b/Source/Rendering/Display2DShader.cs
@@ -37,7 +37,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.Rendering
{
- public sealed class Display2DShader : D3DShader
+ internal sealed class Display2DShader : D3DShader
{
#region ================== Variables
@@ -82,7 +82,7 @@ namespace CodeImp.DoomBuilder.Rendering
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public override void Dispose()
{
// Not already disposed?
diff --git a/Source/Rendering/FlatVertex.cs b/Source/Rendering/FlatVertex.cs
index f9d32e01..090cc77a 100644
--- a/Source/Rendering/FlatVertex.cs
+++ b/Source/Rendering/FlatVertex.cs
@@ -1,14 +1,44 @@
+
+#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 System.Drawing;
+using System.ComponentModel;
+using CodeImp.DoomBuilder.Map;
+using SlimDX.Direct3D;
using SlimDX.Direct3D9;
+using SlimDX;
+using CodeImp.DoomBuilder.Geometry;
+using System.Drawing.Imaging;
+
+#endregion
namespace CodeImp.DoomBuilder.Rendering
{
// FlatVertex
- public struct FlatVertex
+ internal struct FlatVertex
{
// Vertex format
public static readonly int Stride = 7 * 4;
diff --git a/Source/Rendering/ID3DResource.cs b/Source/Rendering/ID3DResource.cs
index df71254c..bcfecae5 100644
--- a/Source/Rendering/ID3DResource.cs
+++ b/Source/Rendering/ID3DResource.cs
@@ -34,7 +34,7 @@ using SlimDX;
namespace CodeImp.DoomBuilder.Rendering
{
- public interface ID3DResource : IDisposable
+ internal interface ID3DResource
{
// This is used to unload the resouce
void UnloadResource();
diff --git a/Source/Rendering/IRenderer2D.cs b/Source/Rendering/IRenderer2D.cs
new file mode 100644
index 00000000..b8610a92
--- /dev/null
+++ b/Source/Rendering/IRenderer2D.cs
@@ -0,0 +1,70 @@
+
+#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 System.Drawing;
+using System.ComponentModel;
+using CodeImp.DoomBuilder.Map;
+using SlimDX.Direct3D;
+using SlimDX.Direct3D9;
+using SlimDX;
+using CodeImp.DoomBuilder.Geometry;
+using System.Drawing.Imaging;
+using CodeImp.DoomBuilder.Data;
+using CodeImp.DoomBuilder.Editing;
+
+#endregion
+
+namespace CodeImp.DoomBuilder.Rendering
+{
+ public interface IRenderer2D
+ {
+ // Properties
+ float OffsetX { get; }
+ float OffsetY { get; }
+ float Scale { get; }
+
+ // Color methods
+ PixelColor DetermineLinedefColor(Linedef l);
+ PixelColor DetermineThingColor(Thing t);
+ int DetermineVertexColor(Vertex v);
+
+ // Rendering management methods
+ bool Start(bool clearstructs, bool clearthings);
+ void Finish();
+ void SetThingsRenderOrder(bool front);
+
+ // Drawing methods
+ void RenderLine(Vector2D start, Vector2D end, PixelColor c);
+ void RenderLinedef(Linedef l, PixelColor c);
+ void RenderLinedefSet(ICollection linedefs);
+ void RenderSector(Sector s);
+ void RenderSector(Sector s, PixelColor c);
+ void RenderThing(Thing t, PixelColor c);
+ void RenderThingSet(ICollection things);
+ void RenderVertex(Vertex v, int colorindex);
+ void RenderVerticesSet(ICollection vertices);
+ }
+}
diff --git a/Source/Rendering/IRenderer3D.cs b/Source/Rendering/IRenderer3D.cs
new file mode 100644
index 00000000..4a05876a
--- /dev/null
+++ b/Source/Rendering/IRenderer3D.cs
@@ -0,0 +1,47 @@
+
+#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 System.Drawing;
+using System.ComponentModel;
+using CodeImp.DoomBuilder.Map;
+using SlimDX.Direct3D;
+using SlimDX.Direct3D9;
+using SlimDX;
+using CodeImp.DoomBuilder.Geometry;
+using System.Drawing.Imaging;
+using CodeImp.DoomBuilder.Data;
+using CodeImp.DoomBuilder.Editing;
+
+#endregion
+
+namespace CodeImp.DoomBuilder.Rendering
+{
+ public interface IRenderer3D
+ {
+ //void Finish();
+ //bool Start();
+ }
+}
diff --git a/Source/Rendering/PixelColor.cs b/Source/Rendering/PixelColor.cs
index 0b641b7f..f5c74fdf 100644
--- a/Source/Rendering/PixelColor.cs
+++ b/Source/Rendering/PixelColor.cs
@@ -31,6 +31,12 @@ namespace CodeImp.DoomBuilder.Rendering
{
public struct PixelColor
{
+ #region ================== Statics
+
+ public static readonly PixelColor Transparent = new PixelColor(0, 0, 0, 0);
+
+ #endregion
+
#region ================== Variables
// Members
diff --git a/Source/Rendering/Plotter.cs b/Source/Rendering/Plotter.cs
index 207dad5d..67c04564 100644
--- a/Source/Rendering/Plotter.cs
+++ b/Source/Rendering/Plotter.cs
@@ -37,7 +37,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.Rendering
{
- public unsafe sealed class Plotter
+ internal unsafe sealed class Plotter
{
#region ================== Constants
diff --git a/Source/Rendering/Renderer.cs b/Source/Rendering/Renderer.cs
index 2ed5c2fe..eddfa976 100644
--- a/Source/Rendering/Renderer.cs
+++ b/Source/Rendering/Renderer.cs
@@ -26,7 +26,7 @@ using System.Text;
namespace CodeImp.DoomBuilder.Rendering
{
- public abstract class Renderer : IDisposable, ID3DResource
+ internal abstract class Renderer : ID3DResource
{
#region ================== Constants
@@ -52,7 +52,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Constructor / Disposer
// Constructor
- public Renderer(D3DDevice g)
+ internal Renderer(D3DDevice g)
{
// Initialize
this.graphics = g;
@@ -64,8 +64,8 @@ namespace CodeImp.DoomBuilder.Rendering
GC.SuppressFinalize(this);
}
- // Diposer
- public virtual void Dispose()
+ // Disposer
+ internal virtual void Dispose()
{
// Not already disposed?
if(!isdisposed)
diff --git a/Source/Rendering/Renderer2D.cs b/Source/Rendering/Renderer2D.cs
index 51986b3f..330b3ee3 100644
--- a/Source/Rendering/Renderer2D.cs
+++ b/Source/Rendering/Renderer2D.cs
@@ -39,7 +39,7 @@ using CodeImp.DoomBuilder.Editing;
namespace CodeImp.DoomBuilder.Rendering
{
- public unsafe class Renderer2D : Renderer
+ internal unsafe sealed class Renderer2D : Renderer, IRenderer2D
{
#region ================== Constants
@@ -114,7 +114,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Constructor / Disposer
// Constructor
- public Renderer2D(D3DDevice graphics) : base(graphics)
+ internal Renderer2D(D3DDevice graphics) : base(graphics)
{
// Initialize
thingtexture = new ResourceImage("Thing2D.png");
@@ -128,8 +128,8 @@ namespace CodeImp.DoomBuilder.Rendering
GC.SuppressFinalize(this);
}
- // Diposer
- public override void Dispose()
+ // Disposer
+ internal override void Dispose()
{
// Not already disposed?
if(!isdisposed)
@@ -270,7 +270,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// This destroys the rendertargets
- private void DestroyRendertargets()
+ public void DestroyRendertargets()
{
// Trash rendertargets
if(structtex != null) structtex.Dispose();
@@ -826,7 +826,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Present new image
Present();
}
-
+
// This adds a thing in the things buffer for rendering
public void RenderThing(Thing t, PixelColor c)
{
@@ -913,6 +913,17 @@ namespace CodeImp.DoomBuilder.Rendering
}
}
+ // This renders a simple line
+ public void RenderLine(Vector2D start, Vector2D end, PixelColor c)
+ {
+ // Transform coordinates
+ Vector2D v1 = start.GetTransformed(translatex, translatey, scale, -scale);
+ Vector2D v2 = end.GetTransformed(translatex, translatey, scale, -scale);
+
+ // Draw line
+ plotter.DrawLineSolid((int)v1.x, (int)v1.y, (int)v2.x, (int)v2.y, c);
+ }
+
// This renders a single linedef
public void RenderLinedef(Linedef l, PixelColor c)
{
diff --git a/Source/Rendering/Renderer3D.cs b/Source/Rendering/Renderer3D.cs
index df6ca437..024ace76 100644
--- a/Source/Rendering/Renderer3D.cs
+++ b/Source/Rendering/Renderer3D.cs
@@ -32,7 +32,7 @@ using System.ComponentModel;
namespace CodeImp.DoomBuilder.Rendering
{
- public class Renderer3D : Renderer
+ internal sealed class Renderer3D : Renderer, IRenderer3D
{
#region ================== Constants
@@ -49,7 +49,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Constructor / Disposer
// Constructor
- public Renderer3D(D3DDevice graphics) : base(graphics)
+ internal Renderer3D(D3DDevice graphics) : base(graphics)
{
// Initialize
@@ -57,8 +57,8 @@ namespace CodeImp.DoomBuilder.Rendering
GC.SuppressFinalize(this);
}
- // Diposer
- public override void Dispose()
+ // Disposer
+ internal override void Dispose()
{
// Not already disposed?
if(!isdisposed)
diff --git a/Source/Rendering/ShaderManager.cs b/Source/Rendering/ShaderManager.cs
index d9c22697..6194a81e 100644
--- a/Source/Rendering/ShaderManager.cs
+++ b/Source/Rendering/ShaderManager.cs
@@ -37,7 +37,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.Rendering
{
- public class ShaderManager : IDisposable, ID3DResource
+ internal class ShaderManager : ID3DResource
{
#region ================== Constants
@@ -89,7 +89,7 @@ namespace CodeImp.DoomBuilder.Rendering
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public void Dispose()
{
// Not already disposed?
diff --git a/Source/Rendering/Things2DShader.cs b/Source/Rendering/Things2DShader.cs
index 20325ed0..37b4aa0e 100644
--- a/Source/Rendering/Things2DShader.cs
+++ b/Source/Rendering/Things2DShader.cs
@@ -37,7 +37,7 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.Rendering
{
- public sealed class Things2DShader : D3DShader
+ internal sealed class Things2DShader : D3DShader
{
#region ================== Variables
@@ -80,7 +80,7 @@ namespace CodeImp.DoomBuilder.Rendering
GC.SuppressFinalize(this);
}
- // Diposer
+ // Disposer
public override void Dispose()
{
// Not already disposed?
diff --git a/Source/Resources/Actions.cfg b/Source/Resources/Actions.cfg
index a446d997..9a101b45 100644
--- a/Source/Resources/Actions.cfg
+++ b/Source/Resources/Actions.cfg
@@ -77,6 +77,42 @@ mapoptions
allowscroll = false;
}
+configuration
+{
+ title = "Tools: Game Configurations";
+ description = "Shows the Game Configurations dialog which allows you to configure settings such as nodebuilder, testing program and resources.";
+ allowkeys = true;
+ allowmouse = false;
+ allowscroll = false;
+}
+
+preferences
+{
+ title = "Tools: Preferences";
+ description = "Shows this Preferences dialog.";
+ allowkeys = true;
+ allowmouse = false;
+ allowscroll = false;
+}
+
+reloadresources
+{
+ title = "Tools: Reload Resources";
+ description = "Reloads all data resources such as game configuration, textures and flats. Usefull when resource files have been changed outside of Doom Builder.";
+ allowkeys = true;
+ allowmouse = false;
+ allowscroll = false;
+}
+
+cancelmode
+{
+ title = "Edit: Cancel Action";
+ description = "Cancels the current action and switches back to normal editing mode.";
+ allowkeys = true;
+ allowmouse = true;
+ allowscroll = true;
+}
+
scrollwest
{
title = "2D: Scroll West";
@@ -131,78 +167,6 @@ zoomout
allowscroll = true;
}
-configuration
-{
- title = "Tools: Game Configurations";
- description = "Shows the Game Configurations dialog which allows you to configure settings such as nodebuilder, testing program and resources.";
- allowkeys = true;
- allowmouse = false;
- allowscroll = false;
-}
-
-preferences
-{
- title = "Tools: Preferences";
- description = "Shows this Preferences dialog.";
- allowkeys = true;
- allowmouse = false;
- allowscroll = false;
-}
-
-reloadresources
-{
- title = "Tools: Reload Resources";
- description = "Reloads all data resources such as game configuration, textures and flats. Usefull when resource files have been changed outside of Doom Builder.";
- allowkeys = true;
- allowmouse = false;
- allowscroll = false;
-}
-
-verticesmode
-{
- title = "Edit: Vertices Mode";
- description = "Switches to vertices editing mode.";
- allowkeys = true;
- allowmouse = true;
- allowscroll = true;
-}
-
-linedefsmode
-{
- title = "Edit: Linedefs Mode";
- description = "Switches to linedefs editing mode.";
- allowkeys = true;
- allowmouse = true;
- allowscroll = true;
-}
-
-sectorsmode
-{
- title = "Edit: Sectors Mode";
- description = "Switches to sectors editing mode.";
- allowkeys = true;
- allowmouse = true;
- allowscroll = true;
-}
-
-thingsmode
-{
- title = "Edit: Things Mode";
- description = "Switches to things editing mode.";
- allowkeys = true;
- allowmouse = true;
- allowscroll = true;
-}
-
-cancelmode
-{
- title = "Edit: Cancel Action";
- description = "Cancels the current action and switches back to normal editing mode.";
- allowkeys = true;
- allowmouse = true;
- allowscroll = true;
-}
-
gridsetup
{
title = "View: Grid Setup";
diff --git a/Source/Resources/ThingsMode.png b/Source/Resources/ThingsMode.png
deleted file mode 100644
index 70773256..00000000
Binary files a/Source/Resources/ThingsMode.png and /dev/null differ