diff --git a/Source/Actions/ActionAttribute.cs b/Source/Actions/ActionAttribute.cs index 81935b0c..1f76ac4b 100644 --- a/Source/Actions/ActionAttribute.cs +++ b/Source/Actions/ActionAttribute.cs @@ -38,6 +38,7 @@ namespace CodeImp.DoomBuilder.Actions // The action to bind to protected string action; protected bool baseaction; + protected string library; #endregion @@ -47,6 +48,12 @@ namespace CodeImp.DoomBuilder.Actions /// Set to true to indicate this is a core Doom Builder action when used within a plugin. /// public bool BaseAction { get { return baseaction; } set { baseaction = value; } } + + /// + /// Set this to the name of the plugin library when this action is defined by another plugin. The library name is the filename without extension. + /// + public string Library { get { return library; } set { library = value; } } + internal string ActionName { get { return action; } } #endregion @@ -62,6 +69,7 @@ namespace CodeImp.DoomBuilder.Actions // Initialize this.action = action; this.baseaction = false; + this.library = ""; } #endregion @@ -73,7 +81,9 @@ namespace CodeImp.DoomBuilder.Actions { string asmname; - if(baseaction) + if(library.Length > 0) + asmname = library.ToLowerInvariant(); + else if(baseaction) asmname = General.ThisAssembly.GetName().Name.ToLowerInvariant(); else asmname = asm.GetName().Name.ToLowerInvariant(); @@ -81,19 +91,6 @@ namespace CodeImp.DoomBuilder.Actions return asmname + "_" + action; } - // 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; - } - #endregion } } diff --git a/Source/BuilderModes/Resources/Actions.cfg b/Source/BuilderModes/Resources/Actions.cfg index ce316356..54035140 100644 --- a/Source/BuilderModes/Resources/Actions.cfg +++ b/Source/BuilderModes/Resources/Actions.cfg @@ -267,3 +267,43 @@ errorcheckmode allowmouse = true; allowscroll = true; } + +lowersector8 +{ + title = "Lower Floor/Ceiling by 8 mp"; + category = "visual"; + description = "Lowers the targeted or selected floors/ceilings by 8 mp."; + allowkeys = true; + allowmouse = true; + allowscroll = true; +} + +raisesector8 +{ + title = "Raise Floor/Ceiling by 8 mp"; + category = "visual"; + description = "Raises the targeted or selected floors/ceilings by 8 mp."; + allowkeys = true; + allowmouse = true; + allowscroll = true; +} + +lowersector1 +{ + title = "Lower Floor/Ceiling by 1 mp"; + category = "visual"; + description = "Lowers the targeted or selected floors/ceilings by 1 mp."; + allowkeys = true; + allowmouse = true; + allowscroll = true; +} + +raisesector1 +{ + title = "Raise Floor/Ceiling by 1 mp"; + category = "visual"; + description = "Raises the targeted or selected floors/ceilings by 1 mp."; + allowkeys = true; + allowmouse = true; + allowscroll = true; +} diff --git a/Source/BuilderModes/VisualModes/BaseVisualGeometrySector.cs b/Source/BuilderModes/VisualModes/BaseVisualGeometrySector.cs index 666cc55b..7e7d737c 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualGeometrySector.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualGeometrySector.cs @@ -61,6 +61,9 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Methods + // This changes the height + public abstract void ChangeHeight(int amount); + #endregion #region ================== Events diff --git a/Source/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/BuilderModes/VisualModes/BaseVisualMode.cs index 2a944a16..b4e67ab6 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualMode.cs @@ -151,6 +151,29 @@ namespace CodeImp.DoomBuilder.BuilderModes // Apply new target target = newtarget; } + + // This changes the target's height + private void ChangeTargetHeight(int amount) + { + if(target.geometry is BaseVisualGeometrySector) + { + BaseVisualGeometrySector vgs = (target.geometry as BaseVisualGeometrySector); + vgs.ChangeHeight(amount); + + // Rebuild sector + (vgs.Sector as BaseVisualSector).Rebuild(); + + // Also rebuild surrounding sectors, because outside sidedefs may need to be adjusted + foreach(Sidedef sd in vgs.Sector.Sector.Sidedefs) + { + if((sd.Other != null) && VisualSectorExists(sd.Other.Sector)) + { + BaseVisualSector bvs = (BaseVisualSector)GetVisualSector(sd.Other.Sector); + bvs.Rebuild(); + } + } + } + } #endregion @@ -224,6 +247,30 @@ namespace CodeImp.DoomBuilder.BuilderModes if(target.geometry != null) (target.geometry as BaseVisualGeometry).OnEditEnd(); } + [BeginAction("raisesector8")] + public void RaiseSector8() + { + ChangeTargetHeight(8); + } + + [BeginAction("lowersector8")] + public void LowerSector8() + { + ChangeTargetHeight(-8); + } + + [BeginAction("raisesector1")] + public void RaiseSector1() + { + ChangeTargetHeight(1); + } + + [BeginAction("lowersector1")] + public void LowerSector1() + { + ChangeTargetHeight(-1); + } + #endregion } } diff --git a/Source/BuilderModes/VisualModes/VisualCeiling.cs b/Source/BuilderModes/VisualModes/VisualCeiling.cs index 18184d9d..f3a1f234 100644 --- a/Source/BuilderModes/VisualModes/VisualCeiling.cs +++ b/Source/BuilderModes/VisualModes/VisualCeiling.cs @@ -122,6 +122,13 @@ namespace CodeImp.DoomBuilder.BuilderModes #endregion #region ================== Methods + + // This changes the height + public override void ChangeHeight(int amount) + { + General.Map.UndoRedo.CreateUndo("Change ceiling height", UndoGroup.CeilingHeightChange, this.Sector.Sector.Index); + this.Sector.Sector.CeilHeight += amount; + } // This performs a fast test in object picking public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir) diff --git a/Source/BuilderModes/VisualModes/VisualFloor.cs b/Source/BuilderModes/VisualModes/VisualFloor.cs index 9eba9cfe..7c538895 100644 --- a/Source/BuilderModes/VisualModes/VisualFloor.cs +++ b/Source/BuilderModes/VisualModes/VisualFloor.cs @@ -109,7 +109,14 @@ namespace CodeImp.DoomBuilder.BuilderModes #endregion #region ================== Methods - + + // This changes the height + public override void ChangeHeight(int amount) + { + General.Map.UndoRedo.CreateUndo("Change floor height", UndoGroup.FloorHeightChange, this.Sector.Sector.Index); + this.Sector.Sector.FloorHeight += amount; + } + // This performs a fast test in object picking public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir) { diff --git a/Source/Editing/UndoGroup.cs b/Source/Editing/UndoGroup.cs index 57955f7e..ca2e3674 100644 --- a/Source/Editing/UndoGroup.cs +++ b/Source/Editing/UndoGroup.cs @@ -32,8 +32,10 @@ namespace CodeImp.DoomBuilder.Editing { public enum UndoGroup : int { - None = 0, - FloorTextureChange = 1, - CeilingTextureChange = 2 + None, + FloorTextureChange, + CeilingTextureChange, + FloorHeightChange, + CeilingHeightChange, } } diff --git a/Source/VisualModes/VisualMode.cs b/Source/VisualModes/VisualMode.cs index 3e30bcf8..f9e75268 100644 --- a/Source/VisualModes/VisualMode.cs +++ b/Source/VisualModes/VisualMode.cs @@ -567,6 +567,18 @@ namespace CodeImp.DoomBuilder.VisualModes // This creates a visual sector protected abstract VisualSector CreateVisualSector(Sector s); + // This returns a visual sector + protected VisualSector GetVisualSector(Sector s) + { + return allsectors[s]; + } + + // This returns true when a visual sector has been created for the specified sector + protected bool VisualSectorExists(Sector s) + { + return allsectors.ContainsKey(s); + } + // This fills the blockmap protected virtual void FillBlockMap() { diff --git a/Source/VisualModes/VisualSector.cs b/Source/VisualModes/VisualSector.cs index 64c5ba2d..424e8ce0 100644 --- a/Source/VisualModes/VisualSector.cs +++ b/Source/VisualModes/VisualSector.cs @@ -96,7 +96,6 @@ namespace CodeImp.DoomBuilder.VisualModes if(!isdisposed) { // Clean up - foreach(VisualGeometry g in allgeometry) g.Sector = null; if(geobuffer != null) geobuffer.Dispose(); geobuffer = null; @@ -195,7 +194,6 @@ namespace CodeImp.DoomBuilder.VisualModes /// public void ClearGeometry() { - foreach(VisualGeometry g in allgeometry) g.Sector = null; allgeometry.Clear(); fixedgeometry.Clear(); sidedefgeometry.Clear(); diff --git a/Source/Windows/MainForm.cs b/Source/Windows/MainForm.cs index 91e66a2d..82486ce5 100644 --- a/Source/Windows/MainForm.cs +++ b/Source/Windows/MainForm.cs @@ -351,6 +351,7 @@ namespace CodeImp.DoomBuilder.Windows { // Resume any exclusive mouse input ResumeExclusiveMouseInput(); + display.Focus(); } // Window loses focus