diff --git a/Build/Configurations/Doom2.cfg b/Build/Configurations/Doom2.cfg index d9830dcc..59e619f8 100644 --- a/Build/Configurations/Doom2.cfg +++ b/Build/Configurations/Doom2.cfg @@ -38,11 +38,6 @@ start3dmode = 32000; // Default flags for first new thing defaulthingflags = 7; //1 + 2 + 4 -additionalmodes -{ - WAuthorMode; -} - /* TEXTURES AND FLAT SOURCES diff --git a/Source/BuilderModes/ClassicModes/BrightnessMode.cs b/Source/BuilderModes/ClassicModes/BrightnessMode.cs index d0383381..e922c73e 100644 --- a/Source/BuilderModes/ClassicModes/BrightnessMode.cs +++ b/Source/BuilderModes/ClassicModes/BrightnessMode.cs @@ -43,7 +43,7 @@ namespace CodeImp.DoomBuilder.BuilderModes ButtonImage = "BrightnessMode.png", ButtonOrder = int.MinValue + 3)] - public class BrightnessMode : ClassicMode + public class BrightnessMode : SectorsMode { #region ================== Constants @@ -51,17 +51,6 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Variables - // Highlighted item - private Sector highlighted; - - // Interface - private bool editpressed; - - // The methods GetSelected* and MarkSelected* on the MapSet do not - // retain the order in which items were selected. - // This list keeps in order while sectors are selected/deselected. - private List orderedselection; - #endregion #region ================== Properties @@ -73,12 +62,6 @@ namespace CodeImp.DoomBuilder.BuilderModes // Constructor public BrightnessMode() { - // Make lists - orderedselection = new List(); - - // Fill the list with selected sectors (these are not in order, but we have no other choice) - ICollection selectedsectors = General.Map.Map.GetSelectedSectors(true); - foreach(Sector s in selectedsectors) orderedselection.Add(s); } // Disposer @@ -87,9 +70,6 @@ namespace CodeImp.DoomBuilder.BuilderModes // Not already disposed? if(!isdisposed) { - // Clean up - orderedselection = null; - // Dispose base base.Dispose(); } @@ -99,65 +79,6 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Methods - // When undo is used - [EndAction("undo", BaseAction = true)] - public void Undo() - { - // Clear ordered selection - orderedselection.Clear(); - } - - // When redo is used - [EndAction("redo", BaseAction = true)] - public void Redo() - { - // Clear ordered selection - orderedselection.Clear(); - } - - // This selectes or deselects a sector - protected void SelectSector(Sector s, bool selectstate) - { - bool selectionchanged = false; - - // Select the sector? - if(selectstate && !s.Selected) - { - orderedselection.Add(s); - s.Selected = true; - selectionchanged = true; - } - // Deselect the sector? - else if(!selectstate && s.Selected) - { - orderedselection.Remove(s); - s.Selected = false; - selectionchanged = true; - } - - // Selection changed? - if(selectionchanged) - { - // Make update lines selection - foreach(Sidedef sd in s.Sidedefs) - { - bool front, back; - if(sd.Line.Front != null) front = sd.Line.Front.Sector.Selected; else front = false; - if(sd.Line.Back != null) back = sd.Line.Back.Sector.Selected; else back = false; - sd.Line.Selected = front | back; - } - } - } - - // Cancel mode - public override void OnCancel() - { - base.OnCancel(); - - // Return to this mode - General.Map.ChangeMode(new SectorsMode()); - } - // Mode engages public override void OnEngage() { @@ -173,31 +94,6 @@ namespace CodeImp.DoomBuilder.BuilderModes renderer.SetPresentation(p); } - // Mode disengages - public override void OnDisengage() - { - base.OnDisengage(); - - // Check which mode we are switching to - if(General.Map.NewMode is VerticesMode) - { - // Convert selection to vertices - - // Clear selected sectors - General.Map.Map.ClearSelectedSectors(); - } - else if(General.Map.NewMode is LinedefsMode) - { - // Convert selection to linedefs - - // Clear selected sectors - General.Map.Map.ClearSelectedSectors(); - } - - // Hide highlight info - General.Interface.HideInfo(); - } - // This redraws the display public override void OnRedrawDisplay() { @@ -236,6 +132,7 @@ namespace CodeImp.DoomBuilder.BuilderModes PixelColor brightnesscolor = new PixelColor(255, (byte)s.Brightness, (byte)s.Brightness, (byte)s.Brightness); int brightnessint = brightnesscolor.ToInt(); + /* // Load texture image ImageData texture = General.Map.Data.GetFlatImage(s.LongFloorTexture); if(!texture.IsLoaded) texture.LoadImage(); @@ -251,6 +148,10 @@ namespace CodeImp.DoomBuilder.BuilderModes // Render the geometry renderer.RenderGeometry(verts, texture, true); + */ + + // Render the geometry + renderer.RenderGeometry(s.Vertices, null, true); } if(selecting) RenderMultiSelection(); @@ -259,256 +160,6 @@ namespace CodeImp.DoomBuilder.BuilderModes } } - // This highlights a new item - protected void Highlight(Sector s) - { - // Update display - if(renderer.StartPlotter(false)) - { - // Undraw previous highlight - if((highlighted != null) && !highlighted.IsDisposed) - renderer.PlotSector(highlighted); - - /* - // Undraw highlighted things - if(highlighted != null) - foreach(Thing t in highlighted.Things) - renderer.RenderThing(t, renderer.DetermineThingColor(t)); - */ - - // Set new highlight - highlighted = s; - - // Render highlighted item - if((highlighted != null) && !highlighted.IsDisposed) - renderer.PlotSector(highlighted, General.Colors.Highlight); - - /* - // Render highlighted things - if(highlighted != null) - foreach(Thing t in highlighted.Things) - renderer.RenderThing(t, General.Colors.Highlight); - */ - - // Done - renderer.Finish(); - renderer.Present(); - } - - // Show highlight info - if((highlighted != null) && !highlighted.IsDisposed) - General.Interface.ShowSectorInfo(highlighted); - else - General.Interface.HideInfo(); - } - - // Selection - protected override void OnSelect() - { - // Item highlighted? - if((highlighted != null) && !highlighted.IsDisposed) - { - // Flip selection - SelectSector(highlighted, !highlighted.Selected); - - // Update display - if(renderer.StartPlotter(false)) - { - // Redraw highlight to show selection - renderer.PlotSector(highlighted); - renderer.Finish(); - renderer.Present(); - } - } - else - { - // Start making a selection - StartMultiSelection(); - } - - base.OnSelect(); - } - - // End selection - protected override void OnEndSelect() - { - // Not stopping from multiselection? - if(!selecting) - { - // Item highlighted? - if((highlighted != null) && !highlighted.IsDisposed) - { - // Update display - if(renderer.StartPlotter(false)) - { - // Render highlighted item - renderer.PlotSector(highlighted, General.Colors.Highlight); - renderer.Finish(); - renderer.Present(); - } - } - } - - base.OnEndSelect(); - } - - // Start editing - protected override void OnEdit() - { - // Item highlighted? - if((highlighted != null) && !highlighted.IsDisposed) - { - // Edit pressed in this mode - editpressed = true; - - // Highlighted item not selected? - if(!highlighted.Selected) - { - // Make this the only selection - General.Map.Map.ClearSelectedSectors(); - General.Map.Map.ClearSelectedLinedefs(); - SelectSector(highlighted, true); - General.Interface.RedrawDisplay(); - } - - // Update display - if(renderer.StartPlotter(false)) - { - // Redraw highlight to show selection - renderer.PlotSector(highlighted); - renderer.Finish(); - renderer.Present(); - } - } - - base.OnEdit(); - } - - // Done editing - protected override void OnEndEdit() - { - // Edit pressed in this mode? - if(editpressed) - { - } - - editpressed = false; - base.OnEndEdit(); - } - - // Mouse moves - public override void OnMouseMove(MouseEventArgs e) - { - base.OnMouseMove(e); - - // Not holding any buttons? - if(e.Button == MouseButtons.None) - { - // Find the nearest linedef within highlight range - Linedef l = General.Map.Map.NearestLinedef(mousemappos); - if(l != null) - { - // 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) - { - // Highlight if not the same - if(l.Back.Sector != highlighted) Highlight(l.Back.Sector); - } - else - { - // Highlight nothing - if(highlighted != null) Highlight(null); - } - } - else - { - // Is there a sidedef here? - if(l.Front != null) - { - // Highlight if not the same - if(l.Front.Sector != highlighted) Highlight(l.Front.Sector); - } - else - { - // Highlight nothing - if(highlighted != null) Highlight(null); - } - } - } - else - { - // Highlight nothing - if(highlighted != null) Highlight(null); - } - } - } - - // Mouse leaves - public override void OnMouseLeave(EventArgs e) - { - base.OnMouseLeave(e); - - // Highlight nothing - Highlight(null); - } - - // This is called wheh selection ends - protected override void OnEndMultiSelection() - { - // Go for all lines - foreach(Linedef l in General.Map.Map.Linedefs) - { - l.Selected = ((l.Start.Position.x >= selectionrect.Left) && - (l.Start.Position.y >= selectionrect.Top) && - (l.Start.Position.x <= selectionrect.Right) && - (l.Start.Position.y <= selectionrect.Bottom) && - (l.End.Position.x >= selectionrect.Left) && - (l.End.Position.y >= selectionrect.Top) && - (l.End.Position.x <= selectionrect.Right) && - (l.End.Position.y <= selectionrect.Bottom)); - } - - // Go for all sectors - foreach(Sector s in General.Map.Map.Sectors) - { - // Go for all sidedefs - bool allselected = true; - foreach(Sidedef sd in s.Sidedefs) - { - if(!sd.Line.Selected) - { - allselected = false; - break; - } - } - - // Sector completely selected? - s.Selected = allselected; - } - - // Make sure all linedefs reflect selected sectors - foreach(Sector s in General.Map.Map.Sectors) - SelectSector(s, s.Selected); - - base.OnEndMultiSelection(); - if(renderer.StartOverlay(true)) renderer.Finish(); - General.Interface.RedrawDisplay(); - } - - // This is called when the selection is updated - protected override void OnUpdateMultiSelection() - { - base.OnUpdateMultiSelection(); - - // Render overlay - UpdateOverlay(); - renderer.Present(); - } - #endregion #region ================== Actions diff --git a/Source/BuilderModes/ClassicModes/DragGeometryMode.cs b/Source/BuilderModes/ClassicModes/DragGeometryMode.cs index 555f6314..9c80fae1 100644 --- a/Source/BuilderModes/ClassicModes/DragGeometryMode.cs +++ b/Source/BuilderModes/ClassicModes/DragGeometryMode.cs @@ -114,11 +114,13 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Methods // Constructor to start dragging immediately - protected void StartDrag(EditMode basemode, Vector2D dragstartmappos) + protected void StartDrag(Vector2D dragstartmappos) { // Initialize this.dragstartmappos = dragstartmappos; - this.basemode = basemode; + + // Create new instance of the previous mode + this.basemode = (EditMode)Assembly.GetCallingAssembly().CreateInstance(General.Map.Mode.GetType().FullName, false, BindingFlags.Default, null, null, CultureInfo.CurrentCulture, new object[0]); Cursor.Current = Cursors.AppStarting; diff --git a/Source/BuilderModes/ClassicModes/DragLinedefsMode.cs b/Source/BuilderModes/ClassicModes/DragLinedefsMode.cs index c75691f6..6646191d 100644 --- a/Source/BuilderModes/ClassicModes/DragLinedefsMode.cs +++ b/Source/BuilderModes/ClassicModes/DragLinedefsMode.cs @@ -64,7 +64,7 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Constructor / Disposer // Constructor to start dragging immediately - public DragLinedefsMode(EditMode basemode, Vector2D dragstartmappos) + public DragLinedefsMode(Vector2D dragstartmappos) { // Mark what we are dragging General.Map.Map.ClearAllMarks(); @@ -77,7 +77,7 @@ namespace CodeImp.DoomBuilder.BuilderModes unselectedlines = General.Map.Map.GetSelectedLinedefs(false); // Initialize - base.StartDrag(basemode, dragstartmappos); + base.StartDrag(dragstartmappos); // We have no destructor GC.SuppressFinalize(this); diff --git a/Source/BuilderModes/ClassicModes/DragSectorsMode.cs b/Source/BuilderModes/ClassicModes/DragSectorsMode.cs index 3cb40314..d9841204 100644 --- a/Source/BuilderModes/ClassicModes/DragSectorsMode.cs +++ b/Source/BuilderModes/ClassicModes/DragSectorsMode.cs @@ -64,7 +64,7 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Constructor / Disposer // Constructor to start dragging immediately - public DragSectorsMode(EditMode basemode, Vector2D dragstartmappos) + public DragSectorsMode(Vector2D dragstartmappos) { // Mark what we are dragging General.Map.Map.ClearAllMarks(); @@ -77,7 +77,7 @@ namespace CodeImp.DoomBuilder.BuilderModes selectedsectors = General.Map.Map.GetSelectedSectors(true); // Initialize - base.StartDrag(basemode, dragstartmappos); + base.StartDrag(dragstartmappos); // We have no destructor GC.SuppressFinalize(this); diff --git a/Source/BuilderModes/ClassicModes/DragVerticesMode.cs b/Source/BuilderModes/ClassicModes/DragVerticesMode.cs index 0ac78164..78ea24d5 100644 --- a/Source/BuilderModes/ClassicModes/DragVerticesMode.cs +++ b/Source/BuilderModes/ClassicModes/DragVerticesMode.cs @@ -61,14 +61,14 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Constructor / Disposer // Constructor to start dragging immediately - public DragVerticesMode(EditMode basemode, Vertex dragitem, Vector2D dragstartmappos) + public DragVerticesMode(Vertex dragitem, Vector2D dragstartmappos) { // Mark what we are dragging General.Map.Map.ClearAllMarks(); General.Map.Map.MarkSelectedVertices(true, true); // Initialize - base.StartDrag(basemode, dragstartmappos); + base.StartDrag(dragstartmappos); // We have no destructor GC.SuppressFinalize(this); diff --git a/Source/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/BuilderModes/ClassicModes/LinedefsMode.cs index b953acd7..aa3e0698 100644 --- a/Source/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/BuilderModes/ClassicModes/LinedefsMode.cs @@ -363,7 +363,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } // Start dragging the selection - General.Map.ChangeMode(new DragLinedefsMode(new LinedefsMode(), mousedownmappos)); + General.Map.ChangeMode(new DragLinedefsMode(mousedownmappos)); } } } diff --git a/Source/BuilderModes/ClassicModes/SectorsMode.cs b/Source/BuilderModes/ClassicModes/SectorsMode.cs index bd345027..e0f625f9 100644 --- a/Source/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/BuilderModes/ClassicModes/SectorsMode.cs @@ -51,15 +51,15 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Variables // Highlighted item - private Sector highlighted; + protected Sector highlighted; // Interface - private bool editpressed; + protected bool editpressed; // The methods GetSelected* and MarkSelected* on the MapSet do not // retain the order in which items were selected. // This list keeps in order while sectors are selected/deselected. - private List orderedselection; + protected List orderedselection; #endregion @@ -464,7 +464,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } // Start dragging the selection - General.Map.ChangeMode(new DragSectorsMode(new SectorsMode(), mousedownmappos)); + General.Map.ChangeMode(new DragSectorsMode(mousedownmappos)); } } } diff --git a/Source/BuilderModes/ClassicModes/VerticesMode.cs b/Source/BuilderModes/ClassicModes/VerticesMode.cs index 58b0be22..a47a22a9 100644 --- a/Source/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/BuilderModes/ClassicModes/VerticesMode.cs @@ -340,7 +340,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } // Start dragging the selection - General.Map.ChangeMode(new DragVerticesMode(new VerticesMode(), highlighted, mousedownmappos)); + General.Map.ChangeMode(new DragVerticesMode(highlighted, mousedownmappos)); } } } diff --git a/Source/BuilderModes/Interface/MenusForm.Designer.cs b/Source/BuilderModes/Interface/MenusForm.Designer.cs index 9ff21c6b..a961f680 100644 --- a/Source/BuilderModes/Interface/MenusForm.Designer.cs +++ b/Source/BuilderModes/Interface/MenusForm.Designer.cs @@ -34,6 +34,8 @@ namespace CodeImp.DoomBuilder.BuilderModes this.flipsidedefsitem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.curvelinedefsitem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator(); + this.splitlinedefsitem = new System.Windows.Forms.ToolStripMenuItem(); this.sectorsmenu = new System.Windows.Forms.ToolStripMenuItem(); this.joinsectorsitem = new System.Windows.Forms.ToolStripMenuItem(); this.mergesectorsitem = new System.Windows.Forms.ToolStripMenuItem(); @@ -41,8 +43,6 @@ namespace CodeImp.DoomBuilder.BuilderModes this.thingsmenu = new System.Windows.Forms.ToolStripMenuItem(); this.rotatethingscwitem = new System.Windows.Forms.ToolStripMenuItem(); this.rotatethingsccwitem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator(); - this.splitlinedefsitem = new System.Windows.Forms.ToolStripMenuItem(); this.menustrip.SuspendLayout(); this.SuspendLayout(); // @@ -100,6 +100,19 @@ namespace CodeImp.DoomBuilder.BuilderModes this.curvelinedefsitem.Tag = "curvelinesmode"; this.curvelinedefsitem.Text = "Curve Linedefs..."; // + // toolStripMenuItem3 + // + this.toolStripMenuItem3.Name = "toolStripMenuItem3"; + this.toolStripMenuItem3.Size = new System.Drawing.Size(166, 6); + // + // splitlinedefsitem + // + this.splitlinedefsitem.Name = "splitlinedefsitem"; + this.splitlinedefsitem.Size = new System.Drawing.Size(169, 22); + this.splitlinedefsitem.Tag = "splitlinedefs"; + this.splitlinedefsitem.Text = "Split Linedefs"; + this.splitlinedefsitem.Click += new System.EventHandler(this.InvokeTaggedAction); + // // sectorsmenu // this.sectorsmenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -154,19 +167,6 @@ namespace CodeImp.DoomBuilder.BuilderModes this.rotatethingsccwitem.Size = new System.Drawing.Size(204, 22); this.rotatethingsccwitem.Text = "Rotate Counterclockwise"; // - // toolStripMenuItem3 - // - this.toolStripMenuItem3.Name = "toolStripMenuItem3"; - this.toolStripMenuItem3.Size = new System.Drawing.Size(166, 6); - // - // splitlinedefsitem - // - this.splitlinedefsitem.Name = "splitlinedefsitem"; - this.splitlinedefsitem.Size = new System.Drawing.Size(169, 22); - this.splitlinedefsitem.Tag = "splitlinedefs"; - this.splitlinedefsitem.Text = "Split Linedefs"; - this.splitlinedefsitem.Click += new System.EventHandler(this.InvokeTaggedAction); - // // MenusForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; diff --git a/Source/Config/GameConfiguration.cs b/Source/Config/GameConfiguration.cs index daa865e8..74d31bda 100644 --- a/Source/Config/GameConfiguration.cs +++ b/Source/Config/GameConfiguration.cs @@ -566,7 +566,7 @@ namespace CodeImp.DoomBuilder.Config // This checks if a specific edit mode class is listed public bool IsEditModeSpecified(string classname) { - return cfg.SettingExists("additionalmodes." + classname.ToString(CultureInfo.InvariantCulture)); + return cfg.SettingExists("editingmodes." + classname.ToString(CultureInfo.InvariantCulture)); } #endregion diff --git a/Source/Plugins/PluginManager.cs b/Source/Plugins/PluginManager.cs index 67b88b1a..ca554868 100644 --- a/Source/Plugins/PluginManager.cs +++ b/Source/Plugins/PluginManager.cs @@ -125,7 +125,7 @@ namespace CodeImp.DoomBuilder.Plugins foreach(Type t in editclasses) { // For all defined EditMode attributes - emattrs = (EditModeAttribute[])t.GetCustomAttributes(typeof(EditModeAttribute), true); + emattrs = (EditModeAttribute[])t.GetCustomAttributes(typeof(EditModeAttribute), false); foreach(EditModeAttribute a in emattrs) { // Make edit mode information