diff --git a/Source/BuilderModes/ClassicModes/BrightnessMode.cs b/Source/BuilderModes/ClassicModes/BrightnessMode.cs index be8bbb5b..7863f02d 100644 --- a/Source/BuilderModes/ClassicModes/BrightnessMode.cs +++ b/Source/BuilderModes/ClassicModes/BrightnessMode.cs @@ -660,7 +660,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(orderedselection.Count > 0) { // Create undo - undoticket = General.Map.UndoRedo.CreateUndo("Adjust brightness", UndoGroup.None, 0); + undoticket = General.Map.UndoRedo.CreateUndo("Adjust brightness"); // Start editing mode = ModifyMode.Adjusting; diff --git a/Source/BuilderModes/ClassicModes/CurveLinedefsMode.cs b/Source/BuilderModes/ClassicModes/CurveLinedefsMode.cs index 19221c98..d45c8b2d 100644 --- a/Source/BuilderModes/ClassicModes/CurveLinedefsMode.cs +++ b/Source/BuilderModes/ClassicModes/CurveLinedefsMode.cs @@ -188,7 +188,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public override void OnAccept() { // Create undo - General.Map.UndoRedo.CreateUndo("Curve linedefs", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Curve linedefs"); // Go for all selected lines foreach(Linedef ld in selectedlines) diff --git a/Source/BuilderModes/ClassicModes/DragGeometryMode.cs b/Source/BuilderModes/ClassicModes/DragGeometryMode.cs index 7050b0b2..94a68fc0 100644 --- a/Source/BuilderModes/ClassicModes/DragGeometryMode.cs +++ b/Source/BuilderModes/ClassicModes/DragGeometryMode.cs @@ -307,7 +307,7 @@ namespace CodeImp.DoomBuilder.BuilderModes MoveGeometryRelative(new Vector2D(0f, 0f), false, false); // Make undo for the dragging - General.Map.UndoRedo.CreateUndo("Drag geometry", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Drag geometry"); // Move selected geometry to final position MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest); diff --git a/Source/BuilderModes/ClassicModes/DragThingsMode.cs b/Source/BuilderModes/ClassicModes/DragThingsMode.cs index 005cd01a..ac76cb75 100644 --- a/Source/BuilderModes/ClassicModes/DragThingsMode.cs +++ b/Source/BuilderModes/ClassicModes/DragThingsMode.cs @@ -291,7 +291,7 @@ namespace CodeImp.DoomBuilder.BuilderModes MoveThingsRelative(new Vector2D(0f, 0f), false, false); // Make undo for the dragging - General.Map.UndoRedo.CreateUndo("Drag things", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Drag things"); // Move selected geometry to final position MoveThingsRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest); diff --git a/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs b/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs index 13400ff6..410729ed 100644 --- a/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs +++ b/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs @@ -356,7 +356,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(points.Count > 0) { // Make undo for the draw - General.Map.UndoRedo.CreateUndo("Line draw", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Line draw"); // Make the drawing Tools.DrawLines(points); diff --git a/Source/BuilderModes/ClassicModes/EditSelectionMode.cs b/Source/BuilderModes/ClassicModes/EditSelectionMode.cs index 97e83538..79e08f41 100644 --- a/Source/BuilderModes/ClassicModes/EditSelectionMode.cs +++ b/Source/BuilderModes/ClassicModes/EditSelectionMode.cs @@ -736,7 +736,7 @@ namespace CodeImp.DoomBuilder.BuilderModes t.Move(thingpos[index++]); // Make undo - General.Map.UndoRedo.CreateUndo("Edit selection", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Edit selection"); // Mark selected geometry General.Map.Map.ClearAllMarks(false); diff --git a/Source/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/BuilderModes/ClassicModes/LinedefsMode.cs index e9332503..baf338c5 100644 --- a/Source/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/BuilderModes/ClassicModes/LinedefsMode.cs @@ -545,9 +545,9 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Make undo if(selected.Count > 1) - General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " linedefs", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " linedefs"); else - General.Map.UndoRedo.CreateUndo("Delete linedef", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Delete linedef"); // Dispose selected linedefs foreach(Linedef ld in selected) ld.Dispose(); @@ -577,9 +577,9 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Make undo if(selected.Count > 1) - General.Map.UndoRedo.CreateUndo("Split " + selected.Count + " linedefs", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Split " + selected.Count + " linedefs"); else - General.Map.UndoRedo.CreateUndo("Split linedef", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Split linedef"); // Go for all linedefs to split foreach(Linedef ld in selected) @@ -648,9 +648,9 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Make undo if(selected.Count > 1) - General.Map.UndoRedo.CreateUndo("Flip " + selected.Count + " linedefs", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Flip " + selected.Count + " linedefs"); else - General.Map.UndoRedo.CreateUndo("Flip linedef", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Flip linedef"); // Flip all selected linedefs foreach(Linedef l in selected) @@ -674,9 +674,9 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Make undo if(selected.Count > 1) - General.Map.UndoRedo.CreateUndo("Flip " + selected.Count + " sidedefs", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Flip " + selected.Count + " sidedefs"); else - General.Map.UndoRedo.CreateUndo("Flip sidedef", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Flip sidedef"); // Flip sidedefs in all selected linedefs foreach(Linedef l in selected) diff --git a/Source/BuilderModes/ClassicModes/MakeSectorMode.cs b/Source/BuilderModes/ClassicModes/MakeSectorMode.cs index b8ad61b0..f7a5f162 100644 --- a/Source/BuilderModes/ClassicModes/MakeSectorMode.cs +++ b/Source/BuilderModes/ClassicModes/MakeSectorMode.cs @@ -326,7 +326,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // Make the sector General.Interface.SetCursor(Cursors.WaitCursor); General.Settings.FindDefaultDrawSettings(); - General.Map.UndoRedo.CreateUndo("Make Sector", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Make Sector"); Sector s = Tools.MakeSector(allsides); General.Interface.SetCursor(Cursors.Default); @@ -371,7 +371,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // Make the sector General.Interface.SetCursor(Cursors.WaitCursor); General.Settings.FindDefaultDrawSettings(); - General.Map.UndoRedo.CreateUndo("Make Sector", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Make Sector"); Sector s = Tools.MakeSector(allsides); General.Interface.SetCursor(Cursors.Default); diff --git a/Source/BuilderModes/ClassicModes/SectorsMode.cs b/Source/BuilderModes/ClassicModes/SectorsMode.cs index e69f7e22..03901fe1 100644 --- a/Source/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/BuilderModes/ClassicModes/SectorsMode.cs @@ -730,7 +730,7 @@ namespace CodeImp.DoomBuilder.BuilderModes floortex = form.FloorTexture; // Create undo - General.Map.UndoRedo.CreateUndo("Make door (" + doortex + ")", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Make door (" + doortex + ")"); // Go for all selected sectors foreach(Sector s in orderedselection) @@ -824,9 +824,9 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Make undo if(selected.Count > 1) - General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " sectors", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " sectors"); else - General.Map.UndoRedo.CreateUndo("Delete sector", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Delete sector"); // Dispose selected sectors foreach(Sector s in selected) @@ -874,7 +874,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(count > 1) { // Make undo - General.Map.UndoRedo.CreateUndo("Join " + count + " sectors", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Join " + count + " sectors"); // Merge JoinMergeSectors(false); @@ -898,7 +898,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(count > 1) { // Make undo - General.Map.UndoRedo.CreateUndo("Merge " + count + " sectors", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Merge " + count + " sectors"); // Merge JoinMergeSectors(true); diff --git a/Source/BuilderModes/ClassicModes/ThingsMode.cs b/Source/BuilderModes/ClassicModes/ThingsMode.cs index 1cb40d4c..327215f5 100644 --- a/Source/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/BuilderModes/ClassicModes/ThingsMode.cs @@ -552,9 +552,9 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Make undo if(selected.Count > 1) - General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " things", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " things"); else - General.Map.UndoRedo.CreateUndo("Delete thing", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Delete thing"); // Dispose selected things foreach(Thing t in selected) t.Dispose(); diff --git a/Source/BuilderModes/ClassicModes/VerticesMode.cs b/Source/BuilderModes/ClassicModes/VerticesMode.cs index fd1a8fb9..0ccd34e3 100644 --- a/Source/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/BuilderModes/ClassicModes/VerticesMode.cs @@ -252,7 +252,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(l != null) { // Create undo - General.Map.UndoRedo.CreateUndo("Split linedef", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Split linedef"); // Create vertex at nearest point on line Vector2D nearestpos = l.NearestOnLine(mousemappos); @@ -457,9 +457,9 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Make undo if(selected.Count > 1) - General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " vertices", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " vertices"); else - General.Map.UndoRedo.CreateUndo("Delete vertex", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Delete vertex"); // Dispose selected vertices foreach(Vertex v in selected) v.Dispose(); diff --git a/Source/BuilderModes/ErrorChecks/ResultStuckedThing.cs b/Source/BuilderModes/ErrorChecks/ResultStuckedThing.cs index 40947b69..932afdfd 100644 --- a/Source/BuilderModes/ErrorChecks/ResultStuckedThing.cs +++ b/Source/BuilderModes/ErrorChecks/ResultStuckedThing.cs @@ -82,7 +82,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // This removes the thing public override bool Button1Click() { - General.Map.UndoRedo.CreateUndo("Delete thing", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Delete thing"); thing.Dispose(); General.Map.IsChanged = true; General.Map.ThingsFilter.Update(); diff --git a/Source/BuilderModes/ErrorChecks/ResultThingOutside.cs b/Source/BuilderModes/ErrorChecks/ResultThingOutside.cs index 8ba0ff65..87b82e61 100644 --- a/Source/BuilderModes/ErrorChecks/ResultThingOutside.cs +++ b/Source/BuilderModes/ErrorChecks/ResultThingOutside.cs @@ -82,7 +82,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // This removes the thing public override bool Button1Click() { - General.Map.UndoRedo.CreateUndo("Delete thing", UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Delete thing"); thing.Dispose(); General.Map.IsChanged = true; General.Map.ThingsFilter.Update(); diff --git a/Source/BuilderModes/Resources/Actions.cfg b/Source/BuilderModes/Resources/Actions.cfg index 357af315..be69f143 100644 --- a/Source/BuilderModes/Resources/Actions.cfg +++ b/Source/BuilderModes/Resources/Actions.cfg @@ -272,37 +272,40 @@ lowersector8 { title = "Lower Floor/Ceiling by 8 mp"; category = "visual"; - description = "Lowers the targeted or selected floors/ceilings by 8 mp."; + description = "Lowers the targeted or selected floors/ceilings by 8 mp. This also lowers selected or targeted things."; allowkeys = true; allowmouse = true; allowscroll = true; + repeat = true; } raisesector8 { title = "Raise Floor/Ceiling by 8 mp"; category = "visual"; - description = "Raises the targeted or selected floors/ceilings by 8 mp."; + description = "Raises the targeted or selected floors/ceilings by 8 mp. This also raises selected or targeted things."; allowkeys = true; allowmouse = true; allowscroll = true; + repeat = true; } lowersector1 { title = "Lower Floor/Ceiling by 1 mp"; category = "visual"; - description = "Lowers the targeted or selected floors/ceilings by 1 mp."; + description = "Lowers the targeted or selected floors/ceilings by 1 mp. This also lowers selected or targeted things."; allowkeys = true; allowmouse = true; allowscroll = true; + repeat = true; } raisesector1 { title = "Raise Floor/Ceiling by 1 mp"; category = "visual"; - description = "Raises the targeted or selected floors/ceilings by 1 mp."; + description = "Raises the targeted or selected floors/ceilings by 1 mp. This also raises selected or targeted things."; allowkeys = true; allowmouse = true; allowscroll = true; @@ -320,22 +323,24 @@ showvisualthings lowerbrightness8 { - title = "Lower Brightness by 8"; + title = "Increase Brightness by 8"; category = "visual"; - description = "Lowers the targeted or selected sector brightness level by 8."; + description = "Increases the targeted or selected sector brightness level by 8."; allowkeys = true; allowmouse = true; allowscroll = true; + repeat = true; } raisebrightness8 { - title = "Raise Brightness by 8"; + title = "Decrease Brightness by 8"; category = "visual"; - description = "Raises the targeted or selected sector brightness level by 8."; + description = "Decreases the targeted or selected sector brightness level by 8."; allowkeys = true; allowmouse = true; allowscroll = true; + repeat = true; } movetextureleft @@ -346,6 +351,7 @@ movetextureleft allowkeys = true; allowmouse = true; allowscroll = true; + repeat = true; } movetextureright @@ -356,6 +362,7 @@ movetextureright allowkeys = true; allowmouse = true; allowscroll = true; + repeat = true; } movetextureup @@ -366,6 +373,7 @@ movetextureup allowkeys = true; allowmouse = true; allowscroll = true; + repeat = true; } movetexturedown @@ -376,4 +384,5 @@ movetexturedown allowkeys = true; allowmouse = true; allowscroll = true; + repeat = true; } diff --git a/Source/BuilderModes/VisualModes/BaseVisualGeometrySector.cs b/Source/BuilderModes/VisualModes/BaseVisualGeometrySector.cs index ce1fe5b4..34791588 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualGeometrySector.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualGeometrySector.cs @@ -78,6 +78,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public virtual void OnSelectEnd() { } public virtual void OnEditBegin() { } public virtual void OnMouseMove(MouseEventArgs e) { } + public virtual void OnChangeTextureOffset(int horizontal, int vertical) { } // Edit button released public virtual void OnEditEnd() @@ -96,6 +97,20 @@ namespace CodeImp.DoomBuilder.BuilderModes // Rebuild sector Sector.Rebuild(); + // Go for all things in this sector + foreach(Thing t in General.Map.Map.Things) + { + if(t.Sector == Sector.Sector) + { + if(mode.VisualThingExists(t)) + { + // Update thing + BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing); + vt.Setup(); + } + } + } + // Also rebuild surrounding sectors, because outside sidedefs may need to be adjusted foreach(Sidedef sd in Sector.Sector.Sidedefs) { @@ -116,6 +131,20 @@ namespace CodeImp.DoomBuilder.BuilderModes // Rebuild sector Sector.Rebuild(); + + // Go for all things in this sector + foreach(Thing t in General.Map.Map.Things) + { + if(t.Sector == Sector.Sector) + { + if(mode.VisualThingExists(t)) + { + // Update thing + BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing); + vt.Setup(); + } + } + } } #endregion diff --git a/Source/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs b/Source/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs index 979e6ec0..f6183b11 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs @@ -40,7 +40,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { #region ================== Constants - private const float DRAG_ANGLE_TOLERANCE = 0.02f; + private const float DRAG_ANGLE_TOLERANCE = 0.1f; #endregion @@ -60,6 +60,9 @@ namespace CodeImp.DoomBuilder.BuilderModes private int startoffsetx; private int startoffsety; protected bool uvdragging; + + // Undo/redo + private int undoticket; #endregion @@ -162,6 +165,8 @@ namespace CodeImp.DoomBuilder.BuilderModes float deltaz = mode.CameraAngleZ - dragstartanglez; if((Math.Abs(deltaxy) + Math.Abs(deltaz)) > DRAG_ANGLE_TOLERANCE) { + General.Map.UndoRedo.CreateUndo("Change texture offsets"); + // Start drag now uvdragging = true; mode.LockTarget(); @@ -211,6 +216,38 @@ namespace CodeImp.DoomBuilder.BuilderModes // Rebuild sector Sector.Rebuild(); + + // Go for all things in this sector + foreach(Thing t in General.Map.Map.Things) + { + if(t.Sector == Sector.Sector) + { + if(mode.VisualThingExists(t)) + { + // Update thing + BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing); + vt.Setup(); + } + } + } + } + + // Texture offset change + public virtual void OnChangeTextureOffset(int horizontal, int vertical) + { + if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) + undoticket = General.Map.UndoRedo.CreateUndo("Change texture offsets"); + + // Apply offsets + Sidedef.OffsetX -= horizontal; + Sidedef.OffsetY -= vertical; + + // Update sidedef geometry + VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef); + if(parts.lower != null) parts.lower.Setup(); + if(parts.middledouble != null) parts.middledouble.Setup(); + if(parts.middlesingle != null) parts.middlesingle.Setup(); + if(parts.upper != null) parts.upper.Setup(); } #endregion diff --git a/Source/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/BuilderModes/VisualModes/BaseVisualMode.cs index a8fa8bdc..aeb6f264 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualMode.cs @@ -343,6 +343,34 @@ namespace CodeImp.DoomBuilder.BuilderModes PickTargetUnlocked(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTargetBrightness(-8); } + + [BeginAction("movetextureleft")] + public void MoveTextureLeft() + { + PickTargetUnlocked(); + if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(-1, 0); + } + + [BeginAction("movetextureright")] + public void MoveTextureRight() + { + PickTargetUnlocked(); + if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(1, 0); + } + + [BeginAction("movetextureup")] + public void MoveTextureUp() + { + PickTargetUnlocked(); + if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, -1); + } + + [BeginAction("movetexturedown")] + public void MoveTextureDown() + { + PickTargetUnlocked(); + if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, 1); + } #endregion } diff --git a/Source/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/BuilderModes/VisualModes/BaseVisualThing.cs index 57f2db29..808b79bf 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualThing.cs @@ -56,6 +56,9 @@ namespace CodeImp.DoomBuilder.BuilderModes private Vector3D boxp1; private Vector3D boxp2; + // Undo/redo + private int undoticket; + #endregion #region ================== Properties @@ -93,6 +96,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } // Check if the texture is loaded + sprite.LoadImage(); isloaded = sprite.IsImageLoaded; if(isloaded) { @@ -332,8 +336,8 @@ namespace CodeImp.DoomBuilder.BuilderModes public virtual void OnSelectEnd() { } public virtual void OnEditBegin() { } public virtual void OnMouseMove(MouseEventArgs e) { } - public virtual void OnChangeTargetHeight(int amount) { } public virtual void OnChangeTargetBrightness(int amount) { } + public virtual void OnChangeTextureOffset(int horizontal, int vertical) { } // Edit button released public virtual void OnEditEnd() @@ -344,6 +348,17 @@ namespace CodeImp.DoomBuilder.BuilderModes if(result == DialogResult.OK) this.Rebuild(); } + // Raise/lower thing + public virtual void OnChangeTargetHeight(int amount) + { + if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) + undoticket = General.Map.UndoRedo.CreateUndo("Change thing height"); + + Thing.Move(Thing.Position + new Vector3D(0.0f, 0.0f, (float)amount)); + + this.Setup(); + } + #endregion } } diff --git a/Source/BuilderModes/VisualModes/IVisualEventReceiver.cs b/Source/BuilderModes/VisualModes/IVisualEventReceiver.cs index 963f0134..b64e7238 100644 --- a/Source/BuilderModes/VisualModes/IVisualEventReceiver.cs +++ b/Source/BuilderModes/VisualModes/IVisualEventReceiver.cs @@ -46,5 +46,6 @@ namespace CodeImp.DoomBuilder.BuilderModes void OnMouseMove(MouseEventArgs e); void OnChangeTargetHeight(int amount); void OnChangeTargetBrightness(int amount); + void OnChangeTextureOffset(int horizontal, int vertical); } } diff --git a/Source/Editing/EditMode.cs b/Source/Editing/EditMode.cs index 877cc08f..ca7fe28b 100644 --- a/Source/Editing/EditMode.cs +++ b/Source/Editing/EditMode.cs @@ -206,6 +206,8 @@ namespace CodeImp.DoomBuilder.Editing // Generic events public virtual void OnReloadResources() { } + public virtual void OnMapSetChangeBegin() { } + public virtual void OnMapSetChangeEnd() { } #endregion } diff --git a/Source/Editing/UndoGroup.cs b/Source/Editing/UndoGroup.cs index 4698ce20..2297b0df 100644 --- a/Source/Editing/UndoGroup.cs +++ b/Source/Editing/UndoGroup.cs @@ -35,6 +35,6 @@ namespace CodeImp.DoomBuilder.Editing None, FloorHeightChange, CeilingHeightChange, - SectorBrightnessChange, + SectorBrightnessChange } } diff --git a/Source/Editing/UndoManager.cs b/Source/Editing/UndoManager.cs index 71706828..8a45ca2c 100644 --- a/Source/Editing/UndoManager.cs +++ b/Source/Editing/UndoManager.cs @@ -61,8 +61,8 @@ namespace CodeImp.DoomBuilder.Editing #region ================== Properties - 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 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; } } public bool IsDisposed { get { return isdisposed; } } #endregion @@ -111,7 +111,7 @@ namespace CodeImp.DoomBuilder.Editing private void ClearRedos() { // Dispose all redos - foreach(UndoSnapshot u in redos) u.mapdata.Dispose(); + foreach(UndoSnapshot u in redos) u.Dispose(); redos.Clear(); } @@ -119,7 +119,7 @@ namespace CodeImp.DoomBuilder.Editing private void ClearUndos() { // Dispose all undos - foreach(UndoSnapshot u in undos) u.mapdata.Dispose(); + foreach(UndoSnapshot u in undos) u.Dispose(); undos.Clear(); } @@ -133,7 +133,7 @@ namespace CodeImp.DoomBuilder.Editing { // Remove one and dispose map u = list[list.Count - 1]; - u.mapdata.Dispose(); + u.Dispose(); list.RemoveAt(list.Count - 1); } } @@ -149,6 +149,12 @@ namespace CodeImp.DoomBuilder.Editing General.MainWindow.UpdateInterface(); } + // This makes an undo and returns the unique ticket id + public int CreateUndo(string description) + { + return CreateUndo(description, UndoGroup.None, 0); + } + // This makes an undo and returns the unique ticket id public int CreateUndo(string description, UndoGroup group, int grouptag) { @@ -197,12 +203,12 @@ namespace CodeImp.DoomBuilder.Editing if(undos.Count > 0) { // Check if the ticket id matches - if(ticket == undos[0].ticketid) + if(ticket == undos[0].TicketID) { - General.WriteLogLine("Withdrawing undo snapshot \"" + undos[0].description + "\", Ticket ID " + ticket + "..."); + General.WriteLogLine("Withdrawing undo snapshot \"" + undos[0].Description + "\", Ticket ID " + ticket + "..."); // Remove the last made undo - undos[0].mapdata.Dispose(); + undos[0].Dispose(); undos.RemoveAt(0); // Update @@ -236,7 +242,7 @@ namespace CodeImp.DoomBuilder.Editing u = undos[0]; undos.RemoveAt(0); - General.WriteLogLine("Performing undo \"" + u.description + "\", Ticket ID " + u.ticketid + "..."); + General.WriteLogLine("Performing undo \"" + u.Description + "\", Ticket ID " + u.TicketID + "..."); // Make a snapshot for redo r = new UndoSnapshot(u, General.Map.Map.Serialize()); @@ -249,7 +255,7 @@ namespace CodeImp.DoomBuilder.Editing lastgroup = UndoGroup.None; // Change map set - General.Map.ChangeMapSet(new MapSet(u.mapdata)); + General.Map.ChangeMapSet(new MapSet(u.MapData)); // Remove selection General.Map.Map.ClearAllMarks(false); @@ -294,7 +300,7 @@ namespace CodeImp.DoomBuilder.Editing r = redos[0]; redos.RemoveAt(0); - General.WriteLogLine("Performing redo \"" + r.description + "\", Ticket ID " + r.ticketid + "..."); + General.WriteLogLine("Performing redo \"" + r.Description + "\", Ticket ID " + r.TicketID + "..."); // Make a snapshot for undo u = new UndoSnapshot(r, General.Map.Map.Serialize()); @@ -307,7 +313,7 @@ namespace CodeImp.DoomBuilder.Editing lastgroup = UndoGroup.None; // Change map set - General.Map.ChangeMapSet(new MapSet(r.mapdata)); + General.Map.ChangeMapSet(new MapSet(r.MapData)); // Remove selection General.Map.Map.ClearAllMarks(false); diff --git a/Source/Editing/UndoSnapshot.cs b/Source/Editing/UndoSnapshot.cs index 8ba49d10..7f55724f 100644 --- a/Source/Editing/UndoSnapshot.cs +++ b/Source/Editing/UndoSnapshot.cs @@ -35,14 +35,20 @@ using CodeImp.DoomBuilder.Actions; namespace CodeImp.DoomBuilder.Editing { - internal class UndoSnapshot + public class UndoSnapshot { - public MemoryStream mapdata; - public string description; - public int ticketid; // For safe withdrawing + // Variables + private MemoryStream mapdata; + private string description; + private int ticketid; // For safe withdrawing + // Properties + internal MemoryStream MapData { get { return mapdata; } } + public string Description { get { return description; } } + public int TicketID { get { return ticketid; } } + // Constructor - public UndoSnapshot(string description, MemoryStream mapdata, int ticketid) + internal UndoSnapshot(string description, MemoryStream mapdata, int ticketid) { this.ticketid = ticketid; this.description = description; @@ -50,11 +56,18 @@ namespace CodeImp.DoomBuilder.Editing } // Constructor - public UndoSnapshot(UndoSnapshot info, MemoryStream mapdata) + internal UndoSnapshot(UndoSnapshot info, MemoryStream mapdata) { this.ticketid = info.ticketid; this.description = info.description; this.mapdata = mapdata; } + + // Disposer + public void Dispose() + { + if(mapdata != null) mapdata.Dispose(); + mapdata = null; + } } } diff --git a/Source/General/MapManager.cs b/Source/General/MapManager.cs index fab6018e..d78fab68 100644 --- a/Source/General/MapManager.cs +++ b/Source/General/MapManager.cs @@ -938,7 +938,7 @@ namespace CodeImp.DoomBuilder General.Interface.SetCursor(Cursors.WaitCursor); // Make undo - undoredo.CreateUndo("Assign to group " + groupindex, UndoGroup.None, 0); + undoredo.CreateUndo("Assign to group " + groupindex); // Make selection map.AddSelectionToGroup(0x01 << groupindex); @@ -1240,6 +1240,10 @@ namespace CodeImp.DoomBuilder // This sets a new mapset for editing internal void ChangeMapSet(MapSet newmap) { + // Let the plugin and editing mode know + General.Plugins.OnMapSetChangeBegin(); + if(General.Editing.Mode != null) General.Editing.Mode.OnMapSetChangeBegin(); + // Can't have a selection in an old map set map.ClearAllSelected(); @@ -1249,6 +1253,10 @@ namespace CodeImp.DoomBuilder map.UpdateConfiguration(); map.Update(); thingsfilter.Update(); + + // Let the plugin and editing mode know + General.Plugins.OnMapSetChangeEnd(); + if(General.Editing.Mode != null) General.Editing.Mode.OnMapSetChangeEnd(); } // This reloads resources diff --git a/Source/Map/Sector.cs b/Source/Map/Sector.cs index 646bcdd8..7c98a3e2 100644 --- a/Source/Map/Sector.cs +++ b/Source/Map/Sector.cs @@ -49,9 +49,6 @@ namespace CodeImp.DoomBuilder.Map // Sidedefs private LinkedList sidedefs; - - // Things - //private LinkedList things; // Properties private int index; @@ -85,7 +82,6 @@ namespace CodeImp.DoomBuilder.Map public MapSet Map { get { return map; } } public ICollection Sidedefs { get { return sidedefs; } } - //public ICollection Things { get { return things; } } public int Index { get { return index; } } public int FloorHeight { get { return floorheight; } set { floorheight = value; } } public int CeilHeight { get { return ceilheight; } set { ceilheight = value; } } @@ -117,7 +113,6 @@ namespace CodeImp.DoomBuilder.Map this.map = map; this.mainlistitem = listitem; this.sidedefs = new LinkedList(); - //this.things = new LinkedList(); this.index = index; this.floortexname = "-"; this.ceiltexname = "-"; @@ -138,7 +133,6 @@ namespace CodeImp.DoomBuilder.Map this.map = map; this.mainlistitem = listitem; this.sidedefs = new LinkedList(); - //this.things = new LinkedList(); this.triangulationneeded = true; ReadWrite(stream); @@ -177,7 +171,6 @@ namespace CodeImp.DoomBuilder.Map flatfloorbuffer = null; mainlistitem = null; sidedefs = null; - //things = null; map = null; // Dispose base @@ -251,12 +244,6 @@ namespace CodeImp.DoomBuilder.Map } } - // This attaches a thing and returns the listitem - //public LinkedListNode AttachThing(Thing t) { return things.AddLast(t); } - - // This detaches a thing - //public void DetachThing(LinkedListNode l) { if(!isdisposed) things.Remove(l); } - // This updates the sector when changes have been made public void UpdateCache() { diff --git a/Source/Plugins/Plug.cs b/Source/Plugins/Plug.cs index 803a9164..0636dd8a 100644 --- a/Source/Plugins/Plug.cs +++ b/Source/Plugins/Plug.cs @@ -152,6 +152,20 @@ namespace CodeImp.DoomBuilder.Plugins { } + /// + /// Occurs before the MapSet is changed. This means that the active MapSet will be disposed and changed to a new one. + /// + public virtual void OnMapSetChangeBegin() + { + } + + /// + /// Occurs after the MapSet is changed. + /// + public virtual void OnMapSetChangeEnd() + { + } + /// /// This is called after the constructor to allow a plugin to initialize. /// diff --git a/Source/Plugins/PluginManager.cs b/Source/Plugins/PluginManager.cs index 5c237545..121ffc48 100644 --- a/Source/Plugins/PluginManager.cs +++ b/Source/Plugins/PluginManager.cs @@ -256,6 +256,18 @@ namespace CodeImp.DoomBuilder.Plugins { foreach(Plugin p in plugins) p.Plug.OnMapNewEnd(); } + + + public void OnMapSetChangeBegin() + { + foreach(Plugin p in plugins) p.Plug.OnMapSetChangeBegin(); + } + + + public void OnMapSetChangeEnd() + { + foreach(Plugin p in plugins) p.Plug.OnMapSetChangeEnd(); + } public void OnSectorCeilingSurfaceUpdate(Sector s, ref FlatVertex[] vertices) diff --git a/Source/Windows/LinedefEditForm.cs b/Source/Windows/LinedefEditForm.cs index 22379fbc..06e427af 100644 --- a/Source/Windows/LinedefEditForm.cs +++ b/Source/Windows/LinedefEditForm.cs @@ -308,7 +308,7 @@ namespace CodeImp.DoomBuilder.Windows // Make undo if(lines.Count > 1) undodesc = lines.Count + " linedefs"; - General.Map.UndoRedo.CreateUndo("Edit " + undodesc, UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Edit " + undodesc); // Go for all the lines foreach(Linedef l in lines) diff --git a/Source/Windows/MainForm.cs b/Source/Windows/MainForm.cs index b23343aa..8f7e89f5 100644 --- a/Source/Windows/MainForm.cs +++ b/Source/Windows/MainForm.cs @@ -1690,13 +1690,13 @@ namespace CodeImp.DoomBuilder.Windows // Determine undo description if(itemundo.Enabled) - itemundo.Text = "Undo " + General.Map.UndoRedo.NextUndo.description; + itemundo.Text = "Undo " + General.Map.UndoRedo.NextUndo.Description; else itemundo.Text = "Undo"; // Determine redo description if(itemredo.Enabled) - itemredo.Text = "Redo " + General.Map.UndoRedo.NextRedo.description; + itemredo.Text = "Redo " + General.Map.UndoRedo.NextRedo.Description; else itemredo.Text = "Redo"; diff --git a/Source/Windows/SectorEditForm.cs b/Source/Windows/SectorEditForm.cs index 22e6abc8..c52e9d58 100644 --- a/Source/Windows/SectorEditForm.cs +++ b/Source/Windows/SectorEditForm.cs @@ -129,7 +129,7 @@ namespace CodeImp.DoomBuilder.Windows // Make undo if(sectors.Count > 1) undodesc = sectors.Count + " sectors"; - General.Map.UndoRedo.CreateUndo("Edit " + undodesc, UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Edit " + undodesc); // Go for all sectors foreach(Sector s in sectors) diff --git a/Source/Windows/ThingEditForm.cs b/Source/Windows/ThingEditForm.cs index 2b9c6fcb..9f7798b9 100644 --- a/Source/Windows/ThingEditForm.cs +++ b/Source/Windows/ThingEditForm.cs @@ -331,7 +331,7 @@ namespace CodeImp.DoomBuilder.Windows // Make undo if(things.Count > 1) undodesc = things.Count + " things"; - General.Map.UndoRedo.CreateUndo("Edit " + undodesc, UndoGroup.None, 0); + General.Map.UndoRedo.CreateUndo("Edit " + undodesc); // Go for all the things foreach(Thing t in things)