diff --git a/Help/gzdb/features/features.html b/Help/gzdb/features/features.html index 2f055e74..182cbf3c 100644 --- a/Help/gzdb/features/features.html +++ b/Help/gzdb/features/features.html @@ -261,21 +261,22 @@
  • [UDMF] "Auto-align textures" actions now work on floors and ceilings.
  • [new] [UDMF] New action: "Match Brightness": this action makes the brightness of selected surfaces the same as the brightness of highlighted surface.
  • [new] New actions: "Lower Floor/Ceiling to adjacent sector" and "Raise Floor/Ceiling to adjacent sector" (default keys are PageDown and PageUp). By default, they will find next lower/higher surface in sectors, adjacent to selected ones, and lower/raise selected sectors to this height. If you hold Ctrl, they will lower/raise sectors to lowest/highest sector inside selection. And they will also drop selected things to ground or align them to ceiling.
  • -
  • [new] [UDMF] New actions: "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.
    +
  • [new] [UDMF] New actions: "Increase Scale" (Num9), "Decrease Scale" (Num7), "Increase Horizontal Scale" (Num6), "Decrease Horizontal Scale" (Num4), "Increase Vertical Scale" (Num8), "Decrease Vertical Scale" (Num5) actions. These actions can be used to change thing scale and sidedef/floor/ceiling texture scale.
  • [new] [UDMF] New actions: "Fit Texture" (default key is Ctrl-Alt-A), "Fit Texture's Width" (Alt-A) and "Fit Texture's Height" (Alt-Shift-A).
  • [new] New action: "Toggle slope" (default key is Alt-S). Select or highlight upper/lower walls then call this action to add slopes. Select or highlight floors or ceilings then call this action to remove slopes.
  • [new] New action: "Look Through Selection" (default key is "Y"). This action places visual camera at the same position as selected/highlighted thing and rotates it to match thing's angle. Special handling is available if targeted thing is AimingCamera, MovingCamera, SecurityCamera or InterpolationPoint.
  • [new] New actions: "Auto-align Textures to Selection (X)", "Auto-align Textures to Selection (Y)" and "Auto-align Textures to Selection (X and Y)".
  • New actions: "Rotate Clockwise" and "Rotate Counterclockwise", which can be used to rotate things and [new][UDMF] floor/ceiling textures.
  • +
  • [new] New actions: "Change Pitch Clockwise", "Change Pitch Counterclockwise", "Change Roll Clockwise" and "Change Roll Counterclockwise", which can be used to change pitch and roll of selected or highlighted things.
  • Things can be moved horizontally using "Move Thing Forward/Backward/Left/Right" actions.
  • Things can be moved to cursor position using "Move Thing To Cursor Location" (default key is Ctrl + Middle mouse) action.
  • Things can be inserted at cursor position using "Insert Item" action (default key is Insert).
  • Selected things can be deleted using "Delete Item" action (default key is Delete).
  • Selected things can be cut/copied/pasted at cursor position.
  • [new] [UDMF] Floor/ceiling texture rotation is now taken into account when moving texture offsets with arrow keys.
  • -
  • [new] [UDMF] New action: "Reset Local Texture Offsets (UDMF)". It will reset upper/middle/lower texture offsets, texture scale and rotation.
  • -
  • [new] [UDMF] "Reset Texture Offsets" action works on floors and ceilings.
  • +
  • [new] [UDMF] New action: "Reset Local Texture Offsets (UDMF)". It resets upper/middle/lower texture offsets, scale and brightness of targeted or selected sidedefs, resets texture offsets, rotation, scale and brightness of targeted or selected floors/ceilings and resets scale, pitch and roll of targeted or selected things.
  • +
  • [new] [UDMF] "Reset Texture Offsets" action now resets texture offsets of targeted or selected floors and ceilings and also resets scale of targeted or selected things.
  • diff --git a/Source/Core/GZBuilder/Rendering/ThingBoundingBox.cs b/Source/Core/GZBuilder/Rendering/ThingBoundingBox.cs index 99823594..9dd86504 100644 --- a/Source/Core/GZBuilder/Rendering/ThingBoundingBox.cs +++ b/Source/Core/GZBuilder/Rendering/ThingBoundingBox.cs @@ -91,11 +91,11 @@ namespace CodeImp.DoomBuilder.GZBuilder.Rendering //arrow WorldVertex a0 = new WorldVertex(); //start - WorldVertex a1 = new WorldVertex(1.5f, 0.0f, 0.0f); //end - WorldVertex a2 = new WorldVertex(1.1f, 0.2f, 0.2f); - WorldVertex a3 = new WorldVertex(1.1f, -0.2f, 0.2f); - WorldVertex a4 = new WorldVertex(1.1f, 0.2f, -0.2f); - WorldVertex a5 = new WorldVertex(1.1f, -0.2f, -0.2f); + WorldVertex a1 = new WorldVertex( 0.0f, -1.5f, 0.0f); //end + WorldVertex a2 = new WorldVertex( 0.2f, -1.1f, 0.2f); + WorldVertex a3 = new WorldVertex(-0.2f, -1.1f, 0.2f); + WorldVertex a4 = new WorldVertex( 0.2f, -1.1f, -0.2f); + WorldVertex a5 = new WorldVertex(-0.2f, -1.1f, -0.2f); WorldVertex[] arrowVerts = new WorldVertex[] {a0, a1, a1, a2, diff --git a/Source/Core/Map/Thing.cs b/Source/Core/Map/Thing.cs index 33bd52a3..abf79dd2 100644 --- a/Source/Core/Map/Thing.cs +++ b/Source/Core/Map/Thing.cs @@ -418,19 +418,19 @@ namespace CodeImp.DoomBuilder.Map BeforePropsChange(); // Change angle - this.anglerad = Angle2D.DoomToReal(newangle); - this.angledoom = newangle; + anglerad = Angle2D.DoomToReal(newangle); + angledoom = newangle; if(type != General.Map.Config.Start3DModeThingType) General.Map.IsChanged = true; } //mxd - public void SetPitch(int p) + public void SetPitch(int newpitch) { BeforePropsChange(); - pitch = p; + pitch = General.ClampAngle(newpitch); pitchrad = ((isModel && General.Map.Data.ModeldefEntries[type].InheritActorPitch) ? Angle2D.DegToRad(pitch) : 0); if (type != General.Map.Config.Start3DModeThingType) @@ -438,11 +438,11 @@ namespace CodeImp.DoomBuilder.Map } //mxd - public void SetRoll(int r) + public void SetRoll(int newroll) { BeforePropsChange(); - roll = r; + roll = General.ClampAngle(newroll); rollrad = ((isModel && General.Map.Data.ModeldefEntries[type].InheritActorRoll) ? Angle2D.DegToRad(roll) : 0); if (type != General.Map.Config.Start3DModeThingType) diff --git a/Source/Core/Rendering/Renderer3D.cs b/Source/Core/Rendering/Renderer3D.cs index f62ba5f7..935a040d 100644 --- a/Source/Core/Rendering/Renderer3D.cs +++ b/Source/Core/Rendering/Renderer3D.cs @@ -621,7 +621,7 @@ namespace CodeImp.DoomBuilder.Rendering { world = Matrix.Multiply(arrowScaler, t.Position * Matrix.Translation(0.0f, 0.0f, t.CageScales.M33 / 2)); } - Matrix rot = Matrix.RotationZ(t.Thing.Angle - Angle2D.PI / 2); + Matrix rot = Matrix.RotationY(-t.Thing.RollRad) * Matrix.RotationX(-t.Thing.PitchRad) * Matrix.RotationZ(t.Thing.Angle); world = Matrix.Multiply(rot, world); ApplyMatrices3D(); diff --git a/Source/Core/Windows/ThingEditFormUDMF.Designer.cs b/Source/Core/Windows/ThingEditFormUDMF.Designer.cs index 3c0519e5..60ae8c75 100644 --- a/Source/Core/Windows/ThingEditFormUDMF.Designer.cs +++ b/Source/Core/Windows/ThingEditFormUDMF.Designer.cs @@ -201,7 +201,7 @@ // roll // this.roll.AllowDecimal = false; - this.roll.AllowNegative = false; + this.roll.AllowNegative = true; this.roll.AllowRelative = true; this.roll.ButtonStep = 5; this.roll.ButtonStepBig = 15F; @@ -228,7 +228,7 @@ // pitch // this.pitch.AllowDecimal = false; - this.pitch.AllowNegative = false; + this.pitch.AllowNegative = true; this.pitch.AllowRelative = true; this.pitch.ButtonStep = 5; this.pitch.ButtonStepBig = 15F; diff --git a/Source/Core/Windows/ThingEditFormUDMF.resx b/Source/Core/Windows/ThingEditFormUDMF.resx index 853abdf8..90f1f8dc 100644 --- a/Source/Core/Windows/ThingEditFormUDMF.resx +++ b/Source/Core/Windows/ThingEditFormUDMF.resx @@ -120,7 +120,4 @@ 17, 17 - - 17, 17 - \ No newline at end of file diff --git a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs index e39afa4b..439acbf6 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs @@ -1045,12 +1045,12 @@ namespace CodeImp.DoomBuilder.BuilderModes // Make undo if(selected.Count > 1) { - General.Map.UndoRedo.CreateUndo("Rotate " + selected.Count + " things", this, UndoGroup.ThingRotate, CreateSelectionCRC(selected)); + General.Map.UndoRedo.CreateUndo("Rotate " + selected.Count + " things", this, UndoGroup.ThingAngleChange, CreateSelectionCRC(selected)); General.Interface.DisplayStatus(StatusType.Action, "Rotated " + selected.Count + " things."); } else { - General.Map.UndoRedo.CreateUndo("Rotate thing", this, UndoGroup.ThingRotate, CreateSelectionCRC(selected)); + General.Map.UndoRedo.CreateUndo("Rotate thing", this, UndoGroup.ThingAngleChange, CreateSelectionCRC(selected)); General.Interface.DisplayStatus(StatusType.Action, "Rotated a thing."); } diff --git a/Source/Plugins/BuilderModes/General/UndoGroup.cs b/Source/Plugins/BuilderModes/General/UndoGroup.cs index 731311ed..511427cb 100644 --- a/Source/Plugins/BuilderModes/General/UndoGroup.cs +++ b/Source/Plugins/BuilderModes/General/UndoGroup.cs @@ -32,6 +32,8 @@ namespace CodeImp.DoomBuilder.BuilderModes public const int SurfaceBrightnessChange = 7; //mxd public const int SectorHeightChange = 8; public const int ThingMove = 9; //mxd - public const int ThingRotate = 10; //mxd + public const int ThingAngleChange = 10; //mxd + public const int ThingPitchChange = 11; //mxd + public const int ThingRollChange = 12; //mxd } } diff --git a/Source/Plugins/BuilderModes/Resources/Actions.cfg b/Source/Plugins/BuilderModes/Resources/Actions.cfg index 59ee7bb0..9488ff10 100644 --- a/Source/Plugins/BuilderModes/Resources/Actions.cfg +++ b/Source/Plugins/BuilderModes/Resources/Actions.cfg @@ -770,6 +770,32 @@ movetexturedown8 default = 65576; } +//mxd +scaleup +{ + title = "Increase Scale"; + category = "visual"; + description = "Increases the scale of targeted or selected textures or things by 0.1 (UDMF only)."; + allowkeys = true; + allowmouse = true; + allowscroll = true; + repeat = true; + default = 105; // Num 9 +} + +//mxd +scaledown +{ + title = "Decrease Scale"; + category = "visual"; + description = "Decreases the scale of targeted or selected textures or things by 0.1 (UDMF only)."; + allowkeys = true; + allowmouse = true; + allowscroll = true; + repeat = true; + default = 103; // Num 7 +} + //mxd scaleupx { @@ -974,7 +1000,7 @@ resettexture { title = "Reset Texture Offsets"; category = "visual"; - description = "Resets the texture offsets on targeted or selected sidedefs."; + description = "Resets the texture offsets of targeted or selected sidedefs (all map formats) and floors/ceilings (UDMF only). Also resets scale of targeted or selected things (UDMF only)"; allowkeys = true; allowmouse = true; allowscroll = true; @@ -985,7 +1011,7 @@ resettextureudmf { title = "Reset Local Texture Offsets (UDMF)"; category = "visual"; - description = "Resets upper/middle/lower texture offsets and scale on targeted or selected sidedefs. Resets texture offsets, rotation and scale on targeted or selected floors/ceilings."; + description = "Resets upper/middle/lower texture offsets, scale and brightness of targeted or selected sidedefs. Resets texture offsets, rotation, scale and brightness of targeted or selected floors/ceilings. Resets scale, pitch and roll of targeted or selected things."; allowkeys = true; allowmouse = true; allowscroll = true; @@ -1129,7 +1155,7 @@ rotateclockwise allowmouse = false; allowscroll = true; repeat = true; - default = 262138; + default = 262138; // Ctrl + Shift + ScrollUp } //mxd @@ -1142,7 +1168,59 @@ rotatecounterclockwise allowmouse = false; allowscroll = true; repeat = true; - default = 262139; + default = 262139; // Ctrl + Shift + ScrollDown +} + +//mxd +pitchclockwise +{ + title = "Change Pitch Clockwise"; + category = "visual"; + description = "Increases pitch of selected or highlighted things (UDMF only)."; + allowkeys = true; + allowmouse = false; + allowscroll = true; + repeat = true; + default = 458746; // Ctrl + Alt + ScrollUp +} + +//mxd +pitchcounterclockwise +{ + title = "Change Pitch Counterclockwise"; + category = "visual"; + description = "Decreases pitch of selected or highlighted things (UDMF only)."; + allowkeys = true; + allowmouse = false; + allowscroll = true; + repeat = true; + default = 458747; // Ctrl + Alt + ScrollDown +} + +//mxd +rollclockwise +{ + title = "Change Roll Clockwise"; + category = "visual"; + description = "Increases roll of selected or highlighted things (UDMF only)."; + allowkeys = true; + allowmouse = false; + allowscroll = true; + repeat = true; + default = 327674; // Alt + ScrollUp +} + +//mxd +rollcounterclockwise +{ + title = "Change Roll Counterclockwise"; + category = "visual"; + description = "Decreases roll of selected or highlighted things (UDMF only)."; + allowkeys = true; + allowmouse = false; + allowscroll = true; + repeat = true; + default = 327675; // Alt + ScrollDown } //mxd diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs index 36863bb8..7589aaa9 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs @@ -419,6 +419,27 @@ namespace CodeImp.DoomBuilder.BuilderModes //update geometry Sector.UpdateSectorGeometry(false); } + + //mxd + protected void ClearFields(IEnumerable keys, string undodescription, string resultdescription) + { + if(!General.Map.UDMF) return; + + mode.CreateUndo(undodescription); + mode.SetActionResult(resultdescription); + Sector.Sector.Fields.BeforeFieldsChange(); + + foreach(string key in keys) + { + if(Sector.Sector.Fields.ContainsKey(key)) + { + Sector.Sector.Fields.Remove(key); + Sector.Sector.UpdateNeeded = true; + } + } + + if(Sector.Sector.UpdateNeeded) Sector.UpdateSectorGeometry(false); + } #endregion diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs index a624da2f..d7692bc2 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs @@ -862,14 +862,20 @@ namespace CodeImp.DoomBuilder.BuilderModes return; } - mode.CreateUndo("Reset local texture offsets"); - mode.SetActionResult("Local texture offsets reset."); + mode.CreateUndo("Reset local texture offsets, scale and brightness"); + mode.SetActionResult("Local texture offsets, scale and brightness reset."); - // Apply offsets + // Reset texture offsets SetTextureOffsetX(0); SetTextureOffsetY(0); + + // Scale ResetTextureScale(); + // And brightness + if(Sidedef.Fields.ContainsKey("light")) Sidedef.Fields.Remove("light"); + if(Sidedef.Fields.ContainsKey("lightabsolute")) Sidedef.Fields.Remove("lightabsolute"); + // Update sidedef geometry VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef); parts.SetupAllParts(); @@ -1504,7 +1510,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(incrementX != 0) { - float pix = (int)Math.Round(Texture.Width * scaleX) + incrementX; + float pix = (int)Math.Round(Texture.Width * scaleX) - incrementX; float newscaleX = (float)Math.Round(pix / Texture.Width, 3); scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX); UDMFTools.SetFloat(Sidedef.Fields, keyX, scaleX, 1.0f); @@ -1512,7 +1518,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(incrementY != 0) { - float pix = (int)Math.Round(Texture.Height * scaleY) + incrementY; + float pix = (int)Math.Round(Texture.Height * scaleY) - incrementY; float newscaleY = (float)Math.Round(pix / Texture.Height, 3); scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY); UDMFTools.SetFloat(Sidedef.Fields, keyY, scaleY, 1.0f); diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index f99af497..26b8e741 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -2637,13 +2637,33 @@ namespace CodeImp.DoomBuilder.BuilderModes PostAction(); } + //mxd + [BeginAction("scaleup")] + public void ScaleTextureUp() + { + PreAction(UndoGroup.TextureScaleChange); + List objs = GetSelectedObjects(true, true, true, false); + foreach(IVisualEventReceiver i in objs) i.OnChangeScale(1, 1); + PostAction(); + } + + //mxd + [BeginAction("scaledown")] + public void ScaleTextureDown() + { + PreAction(UndoGroup.TextureScaleChange); + List objs = GetSelectedObjects(true, true, true, false); + foreach(IVisualEventReceiver i in objs) i.OnChangeScale(-1, -1); + PostAction(); + } + //mxd [BeginAction("scaleupx")] public void ScaleTextureUpX() { PreAction(UndoGroup.TextureScaleChange); List objs = GetSelectedObjects(true, true, true, false); - foreach(IVisualEventReceiver i in objs) i.OnChangeScale(-1, 0); + foreach(IVisualEventReceiver i in objs) i.OnChangeScale(1, 0); PostAction(); } @@ -2653,7 +2673,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { PreAction(UndoGroup.TextureScaleChange); List objs = GetSelectedObjects(true, true, true, false); - foreach(IVisualEventReceiver i in objs) i.OnChangeScale(1, 0); + foreach(IVisualEventReceiver i in objs) i.OnChangeScale(-1, 0); PostAction(); } @@ -2898,7 +2918,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public void ResetTexture() { PreAction(UndoGroup.None); - List objs = GetSelectedObjects(true, true, false, false); + List objs = GetSelectedObjects(true, true, true, false); foreach(IVisualEventReceiver i in objs) i.OnResetTextureOffset(); PostAction(); } @@ -2907,7 +2927,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public void ResetLocalOffsets() { PreAction(UndoGroup.None); - List objs = GetSelectedObjects(true, true, false, false); + List objs = GetSelectedObjects(true, true, true, false); foreach(IVisualEventReceiver i in objs) i.OnResetLocalTextureOffset(); PostAction(); } @@ -3089,14 +3109,14 @@ namespace CodeImp.DoomBuilder.BuilderModes PostAction(); } - //mxd. rotate clockwise + //mxd. Rotate clockwise [BeginAction("rotateclockwise")] public void RotateCW() { RotateThingsAndTextures(5); } - //mxd. rotate counterclockwise + //mxd. Rotate counterclockwise [BeginAction("rotatecounterclockwise")] public void RotateCCW() { @@ -3106,7 +3126,7 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd private void RotateThingsAndTextures(int increment) { - PreAction(UndoGroup.ThingRotate); + PreAction(UndoGroup.ThingAngleChange); List selection = GetSelectedObjects(true, false, true, false); if(selection.Count == 0) return; @@ -3116,7 +3136,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(obj is BaseVisualThing) { BaseVisualThing t = obj as BaseVisualThing; - t.Rotate(General.ClampAngle(t.Thing.AngleDoom + increment)); + t.SetAngle(General.ClampAngle(t.Thing.AngleDoom + increment)); } else if(obj is VisualFloor) { @@ -3133,6 +3153,70 @@ namespace CodeImp.DoomBuilder.BuilderModes PostAction(); } + //mxd. Change pitch clockwise + [BeginAction("pitchclockwise")] + public void PitchCW() + { + ChangeThingsPitch(-5); + } + + //mxd. Change pitch counterclockwise + [BeginAction("pitchcounterclockwise")] + public void PitchCCW() + { + ChangeThingsPitch(5); + } + + //mxd + private void ChangeThingsPitch(int increment) + { + PreAction(UndoGroup.ThingPitchChange); + + List selection = GetSelectedObjects(false, false, true, false); + if(selection.Count == 0) return; + + foreach(IVisualEventReceiver obj in selection) + { + if(!(obj is BaseVisualThing)) continue; + BaseVisualThing t = obj as BaseVisualThing; + t.SetPitch(General.ClampAngle(t.Thing.Pitch + increment)); + } + + PostAction(); + } + + //mxd. Change pitch clockwise + [BeginAction("rollclockwise")] + public void RollCW() + { + ChangeThingsRoll(-5); + } + + //mxd. Change pitch counterclockwise + [BeginAction("rollcounterclockwise")] + public void RollCCW() + { + ChangeThingsRoll(5); + } + + //mxd + private void ChangeThingsRoll(int increment) + { + PreAction(UndoGroup.ThingRollChange); + + List selection = GetSelectedObjects(false, false, true, false); + if(selection.Count == 0) return; + + foreach(IVisualEventReceiver obj in selection) + { + if(!(obj is BaseVisualThing)) continue; + BaseVisualThing t = obj as BaseVisualThing; + t.SetRoll(General.ClampAngle(t.Thing.Roll + increment)); + } + + PostAction(); + } + //mxd [BeginAction("togglegzdoomgeometryeffects")] public void ToggleGZDoomRenderingEffects() diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index 38f33555..5535a4bc 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -469,8 +469,6 @@ namespace CodeImp.DoomBuilder.BuilderModes public virtual void OnTextureAlign(bool alignx, bool aligny) { } public virtual void OnToggleUpperUnpegged() { } public virtual void OnToggleLowerUnpegged() { } - public virtual void OnResetTextureOffset() { } - public virtual void OnResetLocalTextureOffset() { } //mxd public virtual void OnProcess(float deltatime) { } public virtual void OnTextureFloodfill() { } public virtual void OnInsert() { } @@ -564,6 +562,32 @@ namespace CodeImp.DoomBuilder.BuilderModes { foreach(BaseVisualThing vt in updateList) vt.Changed = true; } + + //mxd + public virtual void OnResetTextureOffset() + { + mode.CreateUndo("Reset thing scale"); + mode.SetActionResult("Thing scale reset."); + + Thing.SetScale(1.0f, 1.0f); + + // Update what must be updated + this.Changed = true; + } + + //mxd + public virtual void OnResetLocalTextureOffset() + { + mode.CreateUndo("Reset thing scale, pitch and roll"); + mode.SetActionResult("Thing scale, pitch and roll reset."); + + Thing.SetScale(1.0f, 1.0f); + Thing.SetPitch(0); + Thing.SetRoll(0); + + // Update what must be updated + this.Changed = true; + } // Raise/lower thing public virtual void OnChangeTargetHeight(int amount) @@ -647,12 +671,34 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd - public void Rotate(int ammount) + public void SetAngle(int newangle) { if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) - undoticket = mode.CreateUndo("Rotate thing"); - Thing.Rotate(ammount); - mode.SetActionResult("Changed thing rotation to " + Thing.AngleDoom + "."); + undoticket = mode.CreateUndo("Change thing angle"); + Thing.Rotate(newangle); + mode.SetActionResult("Changed thing angle to " + Thing.AngleDoom + "."); + this.Changed = true; + } + + //mxd + public void SetPitch(int newpitch) + { + if(!General.Map.UDMF) return; + if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) + undoticket = mode.CreateUndo("Change thing pitch"); + Thing.SetPitch(newpitch); + mode.SetActionResult("Changed thing pitch to " + Thing.Pitch + "."); + this.Changed = true; + } + + //mxd + public void SetRoll(int newroll) + { + if(!General.Map.UDMF) return; + if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) + undoticket = mode.CreateUndo("Change thing roll"); + Thing.SetRoll(newroll); + mode.SetActionResult("Changed thing roll to " + Thing.Roll + "."); this.Changed = true; } diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs index f58529e2..a52377fe 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs @@ -212,7 +212,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(incrementX != 0) { - float pix = (int)Math.Round(Texture.Width * scaleX) + incrementX; + float pix = (int)Math.Round(Texture.Width * scaleX) - incrementX; float newscaleX = (float)Math.Round(pix / Texture.Width, 3); scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX); UDMFTools.SetFloat(s.Fields, "xscaleceiling", scaleX, 1.0f); @@ -220,7 +220,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(incrementY != 0) { - float pix = (int)Math.Round(Texture.Height * scaleY) + incrementY; + float pix = (int)Math.Round(Texture.Height * scaleY) - incrementY; float newscaleY = (float)Math.Round(pix / Texture.Height, 3); scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY); UDMFTools.SetFloat(s.Fields, "yscaleceiling", scaleY, 1.0f); @@ -243,31 +243,14 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd public override void OnResetTextureOffset() { - if(!General.Map.UDMF) return; - - mode.CreateUndo("Reset texture offsets"); - mode.SetActionResult("Texture offsets reset."); - Sector.Sector.Fields.BeforeFieldsChange(); - - string[] keys = new[] { "xpanningceiling", "ypanningceiling", "xscaleceiling", "yscaleceiling", "rotationceiling" }; - - foreach(string key in keys) - { - if(Sector.Sector.Fields.ContainsKey(key)) - { - Sector.Sector.Fields.Remove(key); - Sector.Sector.UpdateNeeded = true; - } - } - - if(Sector.Sector.UpdateNeeded) - Sector.UpdateSectorGeometry(false); + ClearFields(new[] { "xpanningceiling", "ypanningceiling" }, "Reset texture offsets", "Texture offsets reset."); } //mxd public override void OnResetLocalTextureOffset() { - OnResetTextureOffset(); + ClearFields(new[] { "xpanningceiling", "ypanningceiling", "xscaleceiling", "yscaleceiling", "rotationceiling", "lightceiling", "lightceilingabsolute" }, + "Reset texture offsets, scale, rotation and brightness", "Texture offsets, scale, rotation and brightness reset."); } // Paste texture diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs index 5e9d7a4b..02474d58 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs @@ -214,7 +214,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(incrementX != 0) { - float pix = (int)Math.Round(Texture.Width * scaleX) + incrementX; + float pix = (int)Math.Round(Texture.Width * scaleX) - incrementX; float newscaleX = (float)Math.Round(pix / Texture.Width, 3); scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX); UDMFTools.SetFloat(s.Fields, "xscalefloor", scaleX, 1.0f); @@ -222,7 +222,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(incrementY != 0) { - float pix = (int)Math.Round(Texture.Height * scaleY) + incrementY; + float pix = (int)Math.Round(Texture.Height * scaleY) - incrementY; float newscaleY = (float)Math.Round(pix / Texture.Height, 3); scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY); UDMFTools.SetFloat(s.Fields, "yscalefloor", scaleY, 1.0f); @@ -245,31 +245,14 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd public override void OnResetTextureOffset() { - if(!General.Map.UDMF) return; - - mode.CreateUndo("Reset texture offsets"); - mode.SetActionResult("Texture offsets reset."); - Sector.Sector.Fields.BeforeFieldsChange(); - - string[] keys = new[] { "xpanningfloor", "ypanningfloor", "xscalefloor", "yscalefloor", "rotationfloor" }; - - foreach(string key in keys) - { - if(Sector.Sector.Fields.ContainsKey(key)) - { - Sector.Sector.Fields.Remove(key); - Sector.Sector.UpdateNeeded = true; - } - } - - if(Sector.Sector.UpdateNeeded) - Sector.UpdateSectorGeometry(false); + ClearFields(new[] { "xpanningfloor", "ypanningfloor" }, "Reset texture offsets", "Texture offsets reset."); } //mxd public override void OnResetLocalTextureOffset() { - OnResetTextureOffset(); + ClearFields(new[] { "xpanningfloor", "ypanningfloor", "xscalefloor", "yscalefloor", "rotationfloor", "lightfloor", "lightfloorabsolute" }, + "Reset texture offsets, scale, rotation and brightness", "Texture offsets, scale, rotation and brightness reset."); } // Paste texture