From 4632fdbe997253052537a9e9559a1e17261eb25b Mon Sep 17 00:00:00 2001 From: MaxED Date: Mon, 8 Oct 2012 13:07:56 +0000 Subject: [PATCH] Visual modes: selected objects are not highlighted when "Toggle highlight" (H key) option is set to off. Error Checks Mode: added linedef index to message text of all linedef-related errors. UDMF: wall texture offsets are now rounded when user edits them via cursor keys or mouse dragging (because they are stored as integers anyway). --- .../ErrorChecks/ResultLineMissingFront.cs | 2 +- .../ErrorChecks/ResultLineMissingSides.cs | 2 +- .../ErrorChecks/ResultLineNotDoubleSided.cs | 2 +- .../ErrorChecks/ResultLineNotSingleSided.cs | 2 +- .../BuilderModes/ErrorChecks/ResultLineOverlapping.cs | 2 +- .../BuilderModes/ErrorChecks/ResultTextureMissing.cs | 6 +++--- .../BuilderModes/ErrorChecks/ResultUnknownThing.cs | 2 -- Source/Plugins/BuilderModes/General/BuilderPlug.cs | 11 ++++++++++- .../BuilderModes/VisualModes/BaseVisualMode.cs | 7 +++++-- .../VisualModes/BaseVisualGeometrySidedef.cs | 8 ++++++++ .../GZDoomEditing/VisualModes/BaseVisualMode.cs | 2 ++ .../Plugins/GZDoomEditing/VisualModes/VisualLower.cs | 6 ++++-- .../GZDoomEditing/VisualModes/VisualMiddleDouble.cs | 6 ++++-- .../GZDoomEditing/VisualModes/VisualMiddleSingle.cs | 6 ++++-- .../Plugins/GZDoomEditing/VisualModes/VisualUpper.cs | 6 ++++-- 15 files changed, 49 insertions(+), 21 deletions(-) diff --git a/Source/Plugins/BuilderModes/ErrorChecks/ResultLineMissingFront.cs b/Source/Plugins/BuilderModes/ErrorChecks/ResultLineMissingFront.cs index 50535e98..99d7d07d 100644 --- a/Source/Plugins/BuilderModes/ErrorChecks/ResultLineMissingFront.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/ResultLineMissingFront.cs @@ -110,7 +110,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // This must return the string that is displayed in the listbox public override string ToString() { - return "Linedef is missing front side"; + return "Linedef " + line.Index + " is missing front side"; } // Rendering diff --git a/Source/Plugins/BuilderModes/ErrorChecks/ResultLineMissingSides.cs b/Source/Plugins/BuilderModes/ErrorChecks/ResultLineMissingSides.cs index 8499cc55..748012d6 100644 --- a/Source/Plugins/BuilderModes/ErrorChecks/ResultLineMissingSides.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/ResultLineMissingSides.cs @@ -143,7 +143,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // This must return the string that is displayed in the listbox public override string ToString() { - return "Linedef is missing both sides"; + return "Linedef " + line.Index + " is missing both sides"; } // Rendering diff --git a/Source/Plugins/BuilderModes/ErrorChecks/ResultLineNotDoubleSided.cs b/Source/Plugins/BuilderModes/ErrorChecks/ResultLineNotDoubleSided.cs index 3f719a57..8e7b671f 100644 --- a/Source/Plugins/BuilderModes/ErrorChecks/ResultLineNotDoubleSided.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/ResultLineNotDoubleSided.cs @@ -108,7 +108,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // This must return the string that is displayed in the listbox public override string ToString() { - return "Linedef is marked double-sided but has no back side"; + return "Linedef " + line.Index + " is marked double-sided but has no back side"; } // Rendering diff --git a/Source/Plugins/BuilderModes/ErrorChecks/ResultLineNotSingleSided.cs b/Source/Plugins/BuilderModes/ErrorChecks/ResultLineNotSingleSided.cs index 6a25a849..2bad511b 100644 --- a/Source/Plugins/BuilderModes/ErrorChecks/ResultLineNotSingleSided.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/ResultLineNotSingleSided.cs @@ -73,7 +73,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // This must return the string that is displayed in the listbox public override string ToString() { - return "Linedef is marked single-sided but has two sides"; + return "Linedef " + line.Index + " is marked single-sided but has two sides"; } // Rendering diff --git a/Source/Plugins/BuilderModes/ErrorChecks/ResultLineOverlapping.cs b/Source/Plugins/BuilderModes/ErrorChecks/ResultLineOverlapping.cs index 58575b0f..965dc87d 100644 --- a/Source/Plugins/BuilderModes/ErrorChecks/ResultLineOverlapping.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/ResultLineOverlapping.cs @@ -73,7 +73,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // This must return the string that is displayed in the listbox public override string ToString() { - return "Linedefs are overlapping and references different sectors"; + return "Linedefs " + line1.Index + " and " + line2.Index + " are overlapping and references different sectors"; } // Rendering diff --git a/Source/Plugins/BuilderModes/ErrorChecks/ResultTextureMissing.cs b/Source/Plugins/BuilderModes/ErrorChecks/ResultTextureMissing.cs index 4e957f62..0546fb23 100644 --- a/Source/Plugins/BuilderModes/ErrorChecks/ResultTextureMissing.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/ResultTextureMissing.cs @@ -78,13 +78,13 @@ namespace CodeImp.DoomBuilder.BuilderModes switch (part) { case SidedefPart.Upper: - return "Sidedef has missing upper texture (" + sidestr + " side)"; + return "Sidedef " + side.Index + " has missing upper texture (" + sidestr + " side)"; case SidedefPart.Middle: - return "Sidedef has missing middle texture (" + sidestr + " side)"; + return "Sidedef " + side.Index + " has missing middle texture (" + sidestr + " side)"; case SidedefPart.Lower: - return "Sidedef has missing lower texture (" + sidestr + " side)"; + return "Sidedef " + side.Index + " has missing lower texture (" + sidestr + " side)"; default: return "ERROR"; diff --git a/Source/Plugins/BuilderModes/ErrorChecks/ResultUnknownThing.cs b/Source/Plugins/BuilderModes/ErrorChecks/ResultUnknownThing.cs index 191b198f..4de705a1 100644 --- a/Source/Plugins/BuilderModes/ErrorChecks/ResultUnknownThing.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/ResultUnknownThing.cs @@ -1,6 +1,4 @@ using System; -//using System.Collections.Generic; -//using System.Text; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Rendering; diff --git a/Source/Plugins/BuilderModes/General/BuilderPlug.cs b/Source/Plugins/BuilderModes/General/BuilderPlug.cs index c21c68b6..a4720d44 100644 --- a/Source/Plugins/BuilderModes/General/BuilderPlug.cs +++ b/Source/Plugins/BuilderModes/General/BuilderPlug.cs @@ -149,7 +149,16 @@ namespace CodeImp.DoomBuilder.BuilderModes public float HighlightRange { get { return highlightrange; } } public float HighlightThingsRange { get { return highlightthingsrange; } } public float SplitLinedefsRange { get { return splitlinedefsrange; } } - public bool UseHighlight { get { return usehighlight; } set { usehighlight = value; } } + public bool UseHighlight { + get { + return usehighlight; + } + set { + usehighlight = value; + General.Map.Renderer3D.ShowSelection = usehighlight; + General.Map.Renderer3D.ShowHighlight = usehighlight; + } + } public bool AutoDragOnPaste { get { return autodragonpaste; } set { autodragonpaste = value; } } #endregion diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index ed322258..ee2da3cc 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -613,8 +613,11 @@ namespace CodeImp.DoomBuilder.BuilderModes renderer.SetFogMode(true); // Set target for highlighting - if(BuilderPlug.Me.UseHighlight) - renderer.SetHighlightedObject(target.picked); + renderer.ShowSelection = BuilderPlug.Me.UseHighlight; //mxd + + if (BuilderPlug.Me.UseHighlight) + renderer.SetHighlightedObject(target.picked); + // Begin with geometry renderer.StartGeometry(); diff --git a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs index e44bfad5..224c2138 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs @@ -365,6 +365,14 @@ namespace CodeImp.DoomBuilder.GZDoomEditing poly = newp; } + + //mxd + protected float getRoundedTextureOffset(float offset, float scale) { + if (offset == 0f) return 0f; + float result = (float)Math.Round(offset * scale); + if (result == 0) result = 1f * (offset < 0 ? -1 : 1); + return result; + } #endregion diff --git a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs index 5e1c8377..b58d33a7 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs @@ -828,6 +828,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing renderer.SetFogMode(true); // Set target for highlighting + renderer.ShowSelection = BuilderPlug.Me.UseHighlight; //mxd + if(BuilderPlug.Me.UseHighlight) renderer.SetHighlightedObject(target.picked); diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs index d3688b99..f39ddfc5 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs @@ -236,8 +236,10 @@ namespace CodeImp.DoomBuilder.GZDoomEditing float oldy = Sidedef.Fields.GetValue("offsety_bottom", 0.0f); float scalex = Sidedef.Fields.GetValue("scalex_bottom", 1.0f); float scaley = Sidedef.Fields.GetValue("scaley_bottom", 1.0f); - 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); + 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/VisualMiddleDouble.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleDouble.cs index 134a8d01..5ecabce4 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleDouble.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleDouble.cs @@ -309,8 +309,10 @@ namespace CodeImp.DoomBuilder.GZDoomEditing float oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0f); float scalex = Sidedef.Fields.GetValue("scalex_mid", 1.0f); float scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0f); - 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); + 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 3037e381..e2036a64 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleSingle.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleSingle.cs @@ -237,8 +237,10 @@ namespace CodeImp.DoomBuilder.GZDoomEditing float oldy = Sidedef.Fields.GetValue("offsety_mid", 0.0f); float scalex = Sidedef.Fields.GetValue("scalex_mid", 1.0f); float scaley = Sidedef.Fields.GetValue("scaley_mid", 1.0f); - 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); + 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 dd47f94d..75a1ed8c 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualUpper.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualUpper.cs @@ -236,8 +236,10 @@ namespace CodeImp.DoomBuilder.GZDoomEditing float oldy = Sidedef.Fields.GetValue("offsety_top", 0.0f); float scalex = Sidedef.Fields.GetValue("scalex_top", 1.0f); float scaley = Sidedef.Fields.GetValue("scaley_top", 1.0f); - 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); + 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()