diff --git a/Build/Scripting/ZDoom_ACS.cfg b/Build/Scripting/ZDoom_ACS.cfg index c46c9a7f..da7d800d 100644 --- a/Build/Scripting/ZDoom_ACS.cfg +++ b/Build/Scripting/ZDoom_ACS.cfg @@ -390,7 +390,7 @@ keywords SetPointer = "bool SetPointer(int assign_slot, int tid[, int pointer_selector[, int flags]])\nSet the value of one of the caller's stored pointers."; SetResultValue = "void SetResultValue(int value)"; SetSkyScrollSpeed = "void SetSkyScrollSpeed(int sky, fixed skyspeed)\nChanges the scrolling speed of a sky.\nThis is useful in conjunction with ChangeSky.\nsky: either 1 or 2.\nskyspeed: the desired scrolling speed."; - SetTeleFog = "void SetTeleFog(int tid, str telefogsrcclass, str telefogdestclass"; + SetActorTeleFog = "void SetActorTeleFog(int tid, str telefogsrcclass, str telefogdestclass"; SetThingSpecial = "void SetThingSpecial(int tid, int special[, int arg0[, int arg1[, int arg2[, int arg3[, int arg4]]]]])\nSets the special for any things with the same TID.\nThis is similar to Thing_SetSpecial, except it can only be used from ACS,\nand it can set all of a thing's special arguments.\nIf tid is 0, then the activator is used."; SetUserArray = "void SetUserArray(int tid, str name, int pos, int value)\nSets one of the affected actor's user array-bound variables."; SetUserCVar = "bool SetUserCVar(int playernumber, str cvar, int value)\nSets the console variable of a particular player.\nOnly mod-defined console variables through CVARINFO can be changed by using this function.\nReturns FALSE if cvar is invalid, it is not writable, or the player doesn't exist."; @@ -430,7 +430,7 @@ keywords StrParam = "int StrParam(type:expression)\nStrParam will create a new string formatted based upon the same method for Print or Log.\nThe return value is the string table index of the new string."; StrRight = "str StrRight(str string, int length)\nCreates a new string containing the length last characters of string.\nIf string does not exist, an empty string is returned.\nIf string is shorter than length characters, the entire string is returned."; Suspend = "Suspend"; - SwapTeleFog = "int SwapTeleFog(int tid)"; + SwapActorTeleFog = "int SwapActorTeleFog(int tid)"; Switch = "Switch(expression)"; TagWait = "void TagWait(int tag)"; TakeActorInventory = "void TakeActorInventory(int tid, str inventory_item, int amount)\nThis function will take the amount of items from the specified actor.\nTakeActorInventory can remove items that are flagged as undroppable."; diff --git a/Source/Core/Controls/LinedefInfoPanel.cs b/Source/Core/Controls/LinedefInfoPanel.cs index 8672c145..0dbc0995 100644 --- a/Source/Core/Controls/LinedefInfoPanel.cs +++ b/Source/Core/Controls/LinedefInfoPanel.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Globalization; using System.Windows.Forms; using CodeImp.DoomBuilder.GZBuilder.Tools; using CodeImp.DoomBuilder.Map; @@ -481,7 +482,7 @@ namespace CodeImp.DoomBuilder.Controls if(x != defaultvalue || y != defaultvalue) { - valuelabel.Text = String.Format("{0:0.##}", x) + ", " + String.Format("{0:0.##}", y); + valuelabel.Text = x.ToString(CultureInfo.InvariantCulture) + ", " + y.ToString(CultureInfo.InvariantCulture); valuelabel.Enabled = true; namelabel.Enabled = true; return true; diff --git a/Source/Core/Controls/SectorInfoPanel.cs b/Source/Core/Controls/SectorInfoPanel.cs index 37ae1e6a..43120ea0 100644 --- a/Source/Core/Controls/SectorInfoPanel.cs +++ b/Source/Core/Controls/SectorInfoPanel.cs @@ -18,6 +18,7 @@ using System; using System.Drawing; +using System.Globalization; using System.Windows.Forms; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Data; @@ -188,7 +189,7 @@ namespace CodeImp.DoomBuilder.Controls showExtededCeilingInfo = true; ceilingOffset.Enabled = true; ceilingOffsetLabel.Enabled = true; - ceilingOffset.Text = String.Format("{0:0.##}", panX) + ", " + String.Format("{0:0.##}", panY); + ceilingOffset.Text = panX.ToString(CultureInfo.InvariantCulture) + ", " + panY.ToString(CultureInfo.InvariantCulture); } else { @@ -206,7 +207,7 @@ namespace CodeImp.DoomBuilder.Controls showExtededFloorInfo = true; floorOffset.Enabled = true; floorOffsetLabel.Enabled = true; - floorOffset.Text = String.Format("{0:0.##}", panX) + ", " + String.Format("{0:0.##}", panY); + floorOffset.Text = panX.ToString(CultureInfo.InvariantCulture) + ", " + panY.ToString(CultureInfo.InvariantCulture); } else { @@ -216,7 +217,7 @@ namespace CodeImp.DoomBuilder.Controls } //ceiling scale - float scaleX = s.Fields.GetValue("xscaleceiling", 1.0f);//1.0f; + float scaleX = s.Fields.GetValue("xscaleceiling", 1.0f); float scaleY = s.Fields.GetValue("yscaleceiling", 1.0f); if(scaleX != 1.0f || scaleY != 1.0f) @@ -224,7 +225,7 @@ namespace CodeImp.DoomBuilder.Controls showExtededCeilingInfo = true; ceilingScale.Enabled = true; ceilingScaleLabel.Enabled = true; - ceilingScale.Text = String.Format("{0:0.##}", scaleX) + ", " + String.Format("{0:0.##}", scaleY); + ceilingScale.Text = scaleX.ToString(CultureInfo.InvariantCulture) + ", " + scaleY.ToString(CultureInfo.InvariantCulture); } else { @@ -242,7 +243,7 @@ namespace CodeImp.DoomBuilder.Controls showExtededFloorInfo = true; floorScale.Enabled = true; floorScaleLabel.Enabled = true; - floorScale.Text = String.Format("{0:0.##}", scaleX) + ", " + String.Format("{0:0.##}", scaleY); + floorScale.Text = scaleX.ToString(CultureInfo.InvariantCulture) + ", " + scaleY.ToString(CultureInfo.InvariantCulture); } else { diff --git a/Source/Core/Controls/ThingInfoPanel.cs b/Source/Core/Controls/ThingInfoPanel.cs index ecfe37e1..37d54c4f 100644 --- a/Source/Core/Controls/ThingInfoPanel.cs +++ b/Source/Core/Controls/ThingInfoPanel.cs @@ -17,6 +17,7 @@ #region ================== Namespaces using System; +using System.Globalization; using System.Windows.Forms; using CodeImp.DoomBuilder.Data; using CodeImp.DoomBuilder.Map; @@ -94,7 +95,6 @@ namespace CodeImp.DoomBuilder.Controls if(ti.AbsoluteZ) { zvalue = t.Position.z; - zinfo = zvalue.ToString(); } else { @@ -104,20 +104,18 @@ namespace CodeImp.DoomBuilder.Controls if(ti.Hangs) { zvalue = t.Sector.CeilHeight - t.Position.z - ti.Height; //mxd - zinfo = zvalue.ToString(); } else { zvalue = t.Sector.FloorHeight + t.Position.z; - zinfo = zvalue.ToString(); } } else { zvalue = t.Position.z; - if(zvalue >= 0.0f) zinfo = "+" + zvalue; else zinfo = zvalue.ToString(); } } + zinfo = zvalue.ToString(CultureInfo.InvariantCulture); //mxd // Thing info infopanel.Text = " Thing " + t.Index + " "; @@ -126,7 +124,7 @@ namespace CodeImp.DoomBuilder.Controls labelclass.Enabled = !string.IsNullOrEmpty(ti.ClassName); //mxd classname.Enabled = labelclass.Enabled; //mxd classname.Text = (!string.IsNullOrEmpty(ti.ClassName) ? ti.ClassName : "--"); //mxd - position.Text = t.Position.x + ", " + t.Position.y + ", " + zinfo; + position.Text = t.Position.x.ToString(CultureInfo.InvariantCulture) + ", " + t.Position.y.ToString(CultureInfo.InvariantCulture) + ", " + zinfo; tag.Text = t.Tag + (General.Map.Options.TagLabels.ContainsKey(t.Tag) ? " - " + General.Map.Options.TagLabels[t.Tag] : string.Empty); angle.Text = t.AngleDoom + "\u00B0"; anglecontrol.Angle = t.AngleDoom; diff --git a/Source/Core/Controls/VertexInfoPanel.Designer.cs b/Source/Core/Controls/VertexInfoPanel.Designer.cs index 9219c7c7..162bc408 100644 --- a/Source/Core/Controls/VertexInfoPanel.Designer.cs +++ b/Source/Core/Controls/VertexInfoPanel.Designer.cs @@ -57,7 +57,7 @@ namespace CodeImp.DoomBuilder.Controls this.vertexinfo.Controls.Add(label1); this.vertexinfo.Location = new System.Drawing.Point(0, 0); this.vertexinfo.Name = "vertexinfo"; - this.vertexinfo.Size = new System.Drawing.Size(163, 100); + this.vertexinfo.Size = new System.Drawing.Size(200, 100); this.vertexinfo.TabIndex = 0; this.vertexinfo.TabStop = false; this.vertexinfo.Text = " Vertex "; @@ -85,7 +85,7 @@ namespace CodeImp.DoomBuilder.Controls // labelCeilingOffset // this.labelCeilingOffset.AutoSize = true; - this.labelCeilingOffset.Location = new System.Drawing.Point(7, 3); + this.labelCeilingOffset.Location = new System.Drawing.Point(5, 3); this.labelCeilingOffset.Name = "labelCeilingOffset"; this.labelCeilingOffset.Size = new System.Drawing.Size(70, 13); this.labelCeilingOffset.TabIndex = 4; @@ -103,7 +103,7 @@ namespace CodeImp.DoomBuilder.Controls // labelFloorOffset // this.labelFloorOffset.AutoSize = true; - this.labelFloorOffset.Location = new System.Drawing.Point(14, 26); + this.labelFloorOffset.Location = new System.Drawing.Point(12, 26); this.labelFloorOffset.Name = "labelFloorOffset"; this.labelFloorOffset.Size = new System.Drawing.Size(62, 13); this.labelFloorOffset.TabIndex = 5; diff --git a/Source/Core/Controls/VertexInfoPanel.cs b/Source/Core/Controls/VertexInfoPanel.cs index d1d60252..50049968 100644 --- a/Source/Core/Controls/VertexInfoPanel.cs +++ b/Source/Core/Controls/VertexInfoPanel.cs @@ -16,6 +16,7 @@ #region ================== Namespaces +using System.Globalization; using System.Windows.Forms; using CodeImp.DoomBuilder.Map; @@ -37,14 +38,14 @@ namespace CodeImp.DoomBuilder.Controls { // Vertex info vertexinfo.Text = " Vertex " + v.Index + " "; - position.Text = v.Position.x.ToString("0.##") + ", " + v.Position.y.ToString("0.##"); + position.Text = v.Position.x.ToString(CultureInfo.InvariantCulture) + ", " + v.Position.y.ToString(CultureInfo.InvariantCulture); //mxd. Height offsets if(General.Map.UDMF) { if(!float.IsNaN(v.ZCeiling)) { - zceiling.Text = v.ZCeiling.ToString("0.##"); + zceiling.Text = v.ZCeiling.ToString(CultureInfo.InvariantCulture); zceiling.Enabled = true; labelCeilingOffset.Enabled = true; } @@ -55,7 +56,7 @@ namespace CodeImp.DoomBuilder.Controls if(!float.IsNaN(v.ZFloor)) { - zfloor.Text = v.ZFloor.ToString("0.##"); + zfloor.Text = v.ZFloor.ToString(CultureInfo.InvariantCulture); zfloor.Enabled = true; labelFloorOffset.Enabled = true; } diff --git a/Source/Core/Windows/VertexEditForm.Designer.cs b/Source/Core/Windows/VertexEditForm.Designer.cs index c9fd7e75..74dde274 100644 --- a/Source/Core/Windows/VertexEditForm.Designer.cs +++ b/Source/Core/Windows/VertexEditForm.Designer.cs @@ -153,7 +153,7 @@ namespace CodeImp.DoomBuilder.Windows // label2 // label2.AutoSize = true; - label2.Location = new System.Drawing.Point(71, 37); + label2.Location = new System.Drawing.Point(68, 37); label2.Name = "label2"; label2.Size = new System.Drawing.Size(111, 13); label2.TabIndex = 26; @@ -162,7 +162,7 @@ namespace CodeImp.DoomBuilder.Windows // label3 // label3.AutoSize = true; - label3.Location = new System.Drawing.Point(63, 5); + label3.Location = new System.Drawing.Point(60, 5); label3.Name = "label3"; label3.Size = new System.Drawing.Size(119, 13); label3.TabIndex = 27; diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs index ea5a4124..53de992b 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySector.cs @@ -95,7 +95,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // This changes the height protected abstract void ChangeHeight(int amount); - protected abstract void ChangeTextureScale(float incrementX, float incrementY); //mxd + protected abstract void ChangeTextureScale(int incrementX, int incrementY); //mxd public virtual void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd // This swaps triangles so that the plane faces the other way @@ -895,9 +895,9 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd - public virtual void OnChangeScale(float incrementX, float incrementY) + public virtual void OnChangeScale(int incrementX, int incrementY) { - if(!General.Map.UDMF) return; + if(!General.Map.UDMF || !Texture.IsImageLoaded) return; if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) undoticket = mode.CreateUndo("Change texture scale"); diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs index f19f1e7e..8e8a59de 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs @@ -28,6 +28,7 @@ using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Types; using CodeImp.DoomBuilder.VisualModes; +using System.Globalization; #endregion @@ -1451,9 +1452,9 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd - public virtual void OnChangeScale(float incrementX, float incrementY) + public virtual void OnChangeScale(int incrementX, int incrementY) { - if(!General.Map.UDMF) return; + if(!General.Map.UDMF || !Texture.IsImageLoaded) return; if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) undoticket = mode.CreateUndo("Change wall scale"); @@ -1488,27 +1489,25 @@ namespace CodeImp.DoomBuilder.BuilderModes Sidedef.Fields.BeforeFieldsChange(); - if(incrementX != 0) + if(incrementX != 0) { - if(scaleX + incrementX == 0) - scaleX *= -1; - else - 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); } if(incrementY != 0) { - if(scaleY + incrementY == 0) - scaleY *= -1; - else - 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); } //update geometry Setup(); - mode.SetActionResult("Wall scale changed to " + scaleX + ", " + scaleY); + mode.SetActionResult("Wall scale changed to " + scaleX.ToString("F03", CultureInfo.InvariantCulture) + ", " + scaleY.ToString("F03", CultureInfo.InvariantCulture) + " (" + (int)Math.Round(Texture.Width / scaleX) + " x " + (int)Math.Round(Texture.Height / scaleY) + ")."); } #endregion diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 95449339..b6304926 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -2666,7 +2666,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { PreAction(UndoGroup.TextureScaleChange); List objs = GetSelectedObjects(true, true, true, false); - foreach(IVisualEventReceiver i in objs) i.OnChangeScale(-0.1f, 0); + foreach(IVisualEventReceiver i in objs) i.OnChangeScale(-1, 0); PostAction(); } @@ -2676,7 +2676,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { PreAction(UndoGroup.TextureScaleChange); List objs = GetSelectedObjects(true, true, true, false); - foreach(IVisualEventReceiver i in objs) i.OnChangeScale(0.1f, 0); + foreach(IVisualEventReceiver i in objs) i.OnChangeScale(1, 0); PostAction(); } @@ -2686,7 +2686,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { PreAction(UndoGroup.TextureScaleChange); List objs = GetSelectedObjects(true, true, true, false); - foreach(IVisualEventReceiver i in objs) i.OnChangeScale(0, 0.1f); + foreach(IVisualEventReceiver i in objs) i.OnChangeScale(0, 1); PostAction(); } @@ -2696,7 +2696,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { PreAction(UndoGroup.TextureScaleChange); List objs = GetSelectedObjects(true, true, true, false); - foreach(IVisualEventReceiver i in objs) i.OnChangeScale(0, -0.1f); + foreach(IVisualEventReceiver i in objs) i.OnChangeScale(0, -1); PostAction(); } diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index 5db760d3..246fdd95 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Windows.Forms; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Rendering; @@ -578,29 +579,32 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd - public virtual void OnChangeScale(float incrementX, float incrementY) + public virtual void OnChangeScale(int incrementX, int incrementY) { - if(!General.Map.UDMF) return; + if(!General.Map.UDMF || !sprite.IsImageLoaded) return; if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) undoticket = mode.CreateUndo("Change thing scale"); - float sx = Thing.ScaleX; - float sy = Thing.ScaleY; + float scaleX = Thing.ScaleX; + float scaleY = Thing.ScaleY; + if(incrementX != 0) { - if(sx - incrementX == 0) sx *= -1; - else sx -= incrementX; + float pix = (int)Math.Round(sprite.Width * scaleX) + incrementX; + float newscaleX = (float)Math.Round(pix / sprite.Width, 3); + scaleX = (newscaleX == 0 ? scaleX * -1 : newscaleX); } if(incrementY != 0) { - if(sy + incrementY == 0) sy *= -1; - else sy += incrementY; + float pix = (int)Math.Round(sprite.Height * scaleY) + incrementY; + float newscaleY = (float)Math.Round(pix / sprite.Height, 3); + scaleY = (newscaleY == 0 ? scaleY * -1 : newscaleY); } - Thing.SetScale((float)Math.Round(sx, 3), (float)Math.Round(sy, 3)); - mode.SetActionResult("Changed thing scale to " + Thing.ScaleX + ", " + Thing.ScaleY + "."); + Thing.SetScale(scaleX, scaleY); + mode.SetActionResult("Changed thing scale to " + scaleX.ToString("F03", CultureInfo.InvariantCulture) + ", " + scaleY.ToString("F03", CultureInfo.InvariantCulture) + " (" + (int)Math.Round(sprite.Width * scaleX) + " x " + (int)Math.Round(sprite.Height * scaleY) + ")."); // Update what must be updated this.Changed = true; diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualVertex.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualVertex.cs index 76b96ecc..793a150b 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualVertex.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualVertex.cs @@ -231,7 +231,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public virtual void OnMouseMove(MouseEventArgs e) { } public virtual void OnChangeTargetBrightness(bool up) { } public virtual void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { } - public virtual void OnChangeScale(float incrementX, float incrementY) { } + public virtual void OnChangeScale(int incrementX, int incrementY) { } public virtual void OnSelectTexture() { } public virtual void OnCopyTexture() { } public virtual void OnPasteTexture() { } diff --git a/Source/Plugins/BuilderModes/VisualModes/IVisualEventReceiver.cs b/Source/Plugins/BuilderModes/VisualModes/IVisualEventReceiver.cs index 0c9d19f3..0eeba484 100644 --- a/Source/Plugins/BuilderModes/VisualModes/IVisualEventReceiver.cs +++ b/Source/Plugins/BuilderModes/VisualModes/IVisualEventReceiver.cs @@ -33,7 +33,7 @@ namespace CodeImp.DoomBuilder.BuilderModes void OnChangeTargetHeight(int amount); void OnChangeTargetBrightness(bool up); void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection); - void OnChangeScale(float incrementX, float incrementY); //mxd + void OnChangeScale(int incrementX, int incrementY); //mxd void OnResetTextureOffset(); void OnResetLocalTextureOffset(); //mxd. This should reset upper/middle/lower offsets (UDMF only) void OnSelectTexture(); diff --git a/Source/Plugins/BuilderModes/VisualModes/NullVisualEventReceiver.cs b/Source/Plugins/BuilderModes/VisualModes/NullVisualEventReceiver.cs index e4cf129e..fdb30b81 100644 --- a/Source/Plugins/BuilderModes/VisualModes/NullVisualEventReceiver.cs +++ b/Source/Plugins/BuilderModes/VisualModes/NullVisualEventReceiver.cs @@ -34,7 +34,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public void OnChangeTargetHeight(int amount) { } public void OnChangeTargetBrightness(bool up) { } public void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { } - public virtual void OnChangeScale(float incrementX, float incrementY) { } //mxd + public virtual void OnChangeScale(int incrementX, int incrementY) { } //mxd public void OnResetTextureOffset() { } public void OnResetLocalTextureOffset() { } //mxd public void OnSelectTexture() { } diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs index 3fbc175c..f58529e2 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualCeiling.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Drawing; +using System.Globalization; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Geometry; using CodeImp.DoomBuilder.Rendering; @@ -201,7 +202,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd. Texture scale change - protected override void ChangeTextureScale(float incrementX, float incrementY) + protected override void ChangeTextureScale(int incrementX, int incrementY) { Sector s = GetControlSector(); float scaleX = s.Fields.GetValue("xscaleceiling", 1.0f); @@ -211,19 +212,17 @@ namespace CodeImp.DoomBuilder.BuilderModes if(incrementX != 0) { - if(scaleX + incrementX == 0) - scaleX *= -1; - else - 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); } if(incrementY != 0) { - if(scaleY + incrementY == 0) - scaleY *= -1; - else - 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); } @@ -238,7 +237,7 @@ namespace CodeImp.DoomBuilder.BuilderModes Sector.Sector.UpdateCache(); } - mode.SetActionResult("Ceiling scale changed to " + scaleX + ", " + scaleY); + mode.SetActionResult("Ceiling scale changed to " + scaleX.ToString("F03", CultureInfo.InvariantCulture) + ", " + scaleY.ToString("F03", CultureInfo.InvariantCulture) + " (" + (int)Math.Round(Texture.Width / scaleX) + " x " + (int)Math.Round(Texture.Height / scaleY) + ")."); } //mxd diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs index 5546f9f9..5e9d7a4b 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualFloor.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Drawing; +using System.Globalization; using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Geometry; using CodeImp.DoomBuilder.Rendering; @@ -203,7 +204,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd. Texture scale change - protected override void ChangeTextureScale(float incrementX, float incrementY) + protected override void ChangeTextureScale(int incrementX, int incrementY) { Sector s = GetControlSector(); float scaleX = s.Fields.GetValue("xscalefloor", 1.0f); @@ -213,19 +214,17 @@ namespace CodeImp.DoomBuilder.BuilderModes if(incrementX != 0) { - if(scaleX + incrementX == 0) - scaleX *= -1; - else - 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); } if(incrementY != 0) { - if(scaleY + incrementY == 0) - scaleY *= -1; - else - 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); } @@ -240,7 +239,7 @@ namespace CodeImp.DoomBuilder.BuilderModes Sector.Sector.UpdateCache(); } - mode.SetActionResult("Floor scale changed to " + scaleX + ", " + scaleY); + mode.SetActionResult("Floor scale changed to " + scaleX.ToString("F03", CultureInfo.InvariantCulture) + ", " + scaleY.ToString("F03", CultureInfo.InvariantCulture) + " (" + (int)Math.Round(Texture.Width / scaleX) + " x " + (int)Math.Round(Texture.Height / scaleY) + ")."); } //mxd