From 082bb87c3c660e4573a627b0641f2c73979c385d Mon Sep 17 00:00:00 2001 From: MaxED Date: Thu, 22 Nov 2012 13:12:35 +0000 Subject: [PATCH] Doom/Hexen map formats: texture offsets of walls can now be edited properly in GZDoom Visual mode. --- .../VisualModes/BaseVisualGeometrySector.cs | 23 +++-- .../VisualModes/BaseVisualGeometrySidedef.cs | 34 ++++--- .../VisualModes/BaseVisualMode.cs | 99 ++++++------------- .../GZDoomEditing/VisualModes/VisualFloor.cs | 7 -- .../GZDoomEditing/VisualModes/VisualLower.cs | 4 - .../VisualModes/VisualMiddle3D.cs | 4 - .../VisualModes/VisualMiddleDouble.cs | 8 -- .../VisualModes/VisualMiddleSingle.cs | 8 -- .../GZDoomEditing/VisualModes/VisualUpper.cs | 8 -- 9 files changed, 64 insertions(+), 131 deletions(-) diff --git a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySector.cs b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySector.cs index 4b16dfe8..91264bc6 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySector.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySector.cs @@ -273,8 +273,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing mode.Renderer.ShowSelection = false; mode.Renderer.ShowHighlight = false; UpdateDragUV(); - } else { - General.ShowErrorMessage(BaseVisualMode.TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK); } } } @@ -488,17 +486,22 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Texture offset change public virtual void OnChangeTextureOffset(int horizontal, int vertical) { - if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) - undoticket = mode.CreateUndo("Change texture offsets"); + //mxd + if (General.Map.UDMF) { + if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) + undoticket = mode.CreateUndo("Change texture offsets"); - // Apply offsets - MoveTextureOffset(new Point(-horizontal, -vertical)); + // Apply offsets + MoveTextureOffset(new Point(-horizontal, -vertical)); - mode.SetActionResult("Changed texture offsets by " + -horizontal + ", " + -vertical + "."); + mode.SetActionResult("Changed texture offsets by " + -horizontal + ", " + -vertical + "."); - // Update sector geometry - Sector.UpdateSectorGeometry(false); - Sector.Rebuild(); + // Update sector geometry + Sector.UpdateSectorGeometry(false); + Sector.Rebuild(); + } else { + General.ShowErrorMessage("Floor/ceiling texture offsets cannot be changed in this map format!", MessageBoxButtons.OK); + } } #endregion diff --git a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs index 9794dc47..aa79c867 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs @@ -869,18 +869,14 @@ namespace CodeImp.DoomBuilder.GZDoomEditing float deltaz = General.Map.VisualCamera.AngleZ - dragstartanglez; if((Math.Abs(deltaxy) + Math.Abs(deltaz)) > DRAG_ANGLE_TOLERANCE) { - if(General.Map.UDMF) { //mxd - mode.PreAction(UndoGroup.TextureOffsetChange); - mode.CreateUndo("Change texture offsets"); + mode.PreAction(UndoGroup.TextureOffsetChange); + mode.CreateUndo("Change texture offsets"); - // Start drag now - uvdragging = true; - mode.Renderer.ShowSelection = false; - mode.Renderer.ShowHighlight = false; - UpdateDragUV(); - } else { - General.ShowErrorMessage(BaseVisualMode.TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK); - } + // Start drag now + uvdragging = true; + mode.Renderer.ShowSelection = false; + mode.Renderer.ShowHighlight = false; + UpdateDragUV(); } } } @@ -957,10 +953,18 @@ namespace CodeImp.DoomBuilder.GZDoomEditing if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) undoticket = mode.CreateUndo("Change texture offsets"); - // Apply offsets - MoveTextureOffset(new Point(-horizontal, -vertical)); - - mode.SetActionResult("Changed texture offsets by " + -horizontal + ", " + -vertical + "."); + //mxd + if (General.Map.UDMF) { + // Apply UDMF offsets + MoveTextureOffset(new Point(-horizontal, -vertical)); + Point p = GetTextureOffset(); + mode.SetActionResult("Changed texture offsets to " + p.X + ", " + p.Y + "."); + } else { + // Apply classic offsets + Sidedef.OffsetX -= horizontal; + Sidedef.OffsetY -= vertical; + mode.SetActionResult("Changed texture offsets to " + Sidedef.OffsetX + ", " + Sidedef.OffsetY + "."); + } // Update sidedef geometry VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef); diff --git a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs index 4fdb39c2..dbc75271 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs @@ -50,9 +50,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing public class BaseVisualMode : VisualMode { #region ================== Constants - //mxd - public const string TEXTURE_OFFSET_CHANGE_ERROR = "Texture offsets cannot be changed in this mode if the map is not in UDMF format.\nPlease use Visual mode to change them."; - // Object picking private const float PICK_INTERVAL = 80.0f; private const float PICK_RANGE = 0.98f; @@ -1431,105 +1428,73 @@ namespace CodeImp.DoomBuilder.GZDoomEditing [BeginAction("movetextureleft", Library = "BuilderModes")] public void MoveTextureLeft1() { - if(General.Map.UDMF) { - PreAction(UndoGroup.TextureOffsetChange); - List objs = GetSelectedObjects(true, true, true); - foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-1, 0); - PostAction(); - } else { - General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK); - } + PreAction(UndoGroup.TextureOffsetChange); + List objs = GetSelectedObjects(true, true, true); + foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-1, 0); + PostAction(); } [BeginAction("movetextureright", Library = "BuilderModes")] public void MoveTextureRight1() { - if(General.Map.UDMF) { - PreAction(UndoGroup.TextureOffsetChange); - List objs = GetSelectedObjects(true, true, true); - foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(1, 0); - PostAction(); - } else { - General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK); - } + PreAction(UndoGroup.TextureOffsetChange); + List objs = GetSelectedObjects(true, true, true); + foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(1, 0); + PostAction(); } [BeginAction("movetextureup", Library = "BuilderModes")] public void MoveTextureUp1() { - if(General.Map.UDMF) { - PreAction(UndoGroup.TextureOffsetChange); - List objs = GetSelectedObjects(true, true, true); - foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -1); - PostAction(); - } else { - General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK); - } + PreAction(UndoGroup.TextureOffsetChange); + List objs = GetSelectedObjects(true, true, true); + foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -1); + PostAction(); } [BeginAction("movetexturedown", Library = "BuilderModes")] public void MoveTextureDown1() { - if(General.Map.UDMF) { - PreAction(UndoGroup.TextureOffsetChange); - List objs = GetSelectedObjects(true, true, true); - foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 1); - PostAction(); - } else { - General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK); - } + PreAction(UndoGroup.TextureOffsetChange); + List objs = GetSelectedObjects(true, true, true); + foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 1); + PostAction(); } [BeginAction("movetextureleft8", Library = "BuilderModes")] public void MoveTextureLeft8() { - if(General.Map.UDMF) { - PreAction(UndoGroup.TextureOffsetChange); - List objs = GetSelectedObjects(true, true, true); - foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-8, 0); - PostAction(); - } else { - General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK); - } + PreAction(UndoGroup.TextureOffsetChange); + List objs = GetSelectedObjects(true, true, true); + foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-8, 0); + PostAction(); } [BeginAction("movetextureright8", Library = "BuilderModes")] public void MoveTextureRight8() { - if(General.Map.UDMF) { - PreAction(UndoGroup.TextureOffsetChange); - List objs = GetSelectedObjects(true, true, true); - foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(8, 0); - PostAction(); - } else { - General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK); - } + PreAction(UndoGroup.TextureOffsetChange); + List objs = GetSelectedObjects(true, true, true); + foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(8, 0); + PostAction(); } [BeginAction("movetextureup8", Library = "BuilderModes")] public void MoveTextureUp8() { - if(General.Map.UDMF) { - PreAction(UndoGroup.TextureOffsetChange); - List objs = GetSelectedObjects(true, true, true); - foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -8); - PostAction(); - } else { - General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK); - } + PreAction(UndoGroup.TextureOffsetChange); + List objs = GetSelectedObjects(true, true, true); + foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -8); + PostAction(); } [BeginAction("movetexturedown8", Library = "BuilderModes")] public void MoveTextureDown8() { - if(General.Map.UDMF) { - PreAction(UndoGroup.TextureOffsetChange); - List objs = GetSelectedObjects(true, true, true); - foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 8); - PostAction(); - } else { - General.ShowErrorMessage(TEXTURE_OFFSET_CHANGE_ERROR, MessageBoxButtons.OK); - } + PreAction(UndoGroup.TextureOffsetChange); + List objs = GetSelectedObjects(true, true, true); + foreach (IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 8); + PostAction(); } [BeginAction("textureselect", Library = "BuilderModes")] diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs index edbbfe9b..437764b9 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs @@ -175,13 +175,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing s.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, oldx + (float)xy.X); s.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y); s.UpdateNeeded = true; - - /*Sector.Sector.Fields.BeforeFieldsChange(); - float oldx = Sector.Sector.Fields.GetValue("xpanningfloor", 0.0f); - float oldy = Sector.Sector.Fields.GetValue("ypanningfloor", 0.0f); - Sector.Sector.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, oldx + (float)xy.X); - Sector.Sector.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y); - Sector.Sector.UpdateNeeded = true;*/ } // Paste texture diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs index f0dd8b24..d2904809 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs @@ -240,10 +240,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing float scaley = Sidedef.Fields.GetValue("scaley_bottom", 1.0f); Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, (float)xy.X, scalex)); //mxd Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd - //Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, oldx + getRoundedTextureOffset((float)xy.X, scalex)); //mxd - //Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, oldy + getRoundedTextureOffset((float)xy.Y, scaley)); //mxd - //Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, oldx + (float)xy.X * scalex); - //Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y * scaley); } protected override Point GetTextureOffset() diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddle3D.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddle3D.cs index cc3a36e3..e218905c 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddle3D.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddle3D.cs @@ -76,9 +76,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing Sidedef sourceside = extrafloor.Linedef.Front; this.extrafloor = extrafloor; - //int lightvalue = Sidedef.Fields.GetValue("light", 0); - //bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); - //mxd. lightfog flag support bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); bool ignoreUDMFLight = (!Sidedef.Fields.GetValue("lightfog", false) || !lightabsolute) && Sector.Sector.Fields.ContainsKey("fadecolor"); @@ -197,7 +194,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Determine initial color int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue; //mxd. This calculates light with doom-style wall shading - //PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel)); PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); poly.color = wallcolor.WithAlpha(255).ToInt(); diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleDouble.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleDouble.cs index 316e2739..2927d68f 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleDouble.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleDouble.cs @@ -77,9 +77,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing public override bool Setup() { Vector2D vl, vr; - - //int lightvalue = Sidedef.Fields.GetValue("light", 0); - //bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); //mxd. lightfog flag support bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); @@ -194,7 +191,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Determine initial color int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue; //mxd - //PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel)); PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); poly.color = wallcolor.WithAlpha(255).ToInt(); @@ -317,10 +313,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing float scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0f); Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, (float)xy.X, scalex)); //mxd Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd - //Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, oldx + getRoundedTextureOffset((float)xy.X, scalex)); //mxd - //Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, oldy + getRoundedTextureOffset((float)xy.Y, scaley)); //mxd - //Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, oldx + (float)xy.X * scalex); - //Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y * scaley); } protected override Point GetTextureOffset() diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleSingle.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleSingle.cs index ab0a6506..355f30d5 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleSingle.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleSingle.cs @@ -70,9 +70,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing public override bool Setup() { Vector2D vl, vr; - - //int lightvalue = Sidedef.Fields.GetValue("light", 0); - //bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); //mxd. lightfog flag support bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); @@ -189,7 +186,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Determine initial color int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue; //mxd - //PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel)); PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); poly.color = wallcolor.WithAlpha(255).ToInt(); @@ -245,10 +241,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing float scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0f); Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, (float)xy.X, scalex)); //mxd Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd - //Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, oldx + getRoundedTextureOffset((float)xy.X, scalex)); //mxd - //Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, oldy + getRoundedTextureOffset((float)xy.Y, scaley)); //mxd - //Sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, oldx + (float)xy.X * scalex); - //Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y * scaley); } protected override Point GetTextureOffset() diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualUpper.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualUpper.cs index 2d224237..63aaef03 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualUpper.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualUpper.cs @@ -71,9 +71,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing public override bool Setup() { Vector2D vl, vr; - - //int lightvalue = Sidedef.Fields.GetValue("light", 0); - //bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); //mxd. lightfog flag support bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); @@ -179,7 +176,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Determine initial color int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue; //mxd - //PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel)); PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); poly.color = wallcolor.WithAlpha(255).ToInt(); @@ -244,10 +240,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing float scaley = Sidedef.Fields.GetValue("scaley_top", 1.0f); Sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldx, (float)xy.X, scalex)); //mxd Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, getRoundedTextureOffset(oldy, (float)xy.Y, scaley)); //mxd - //Sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, oldx + getRoundedTextureOffset((float)xy.X, scalex)); //mxd - //Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, oldy + getRoundedTextureOffset((float)xy.Y, scaley)); //mxd - //Sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, oldx + (float)xy.X * scalex); - //Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y * scaley); } protected override Point GetTextureOffset()