diff --git a/Build/Compilers/ZDoom/acc.exe b/Build/Compilers/ZDoom/acc.exe index 87b7a64b..61f778e7 100644 Binary files a/Build/Compilers/ZDoom/acc.exe and b/Build/Compilers/ZDoom/acc.exe differ diff --git a/Build/Compilers/ZDoom/zspecial.acs b/Build/Compilers/ZDoom/zspecial.acs index a6922938..169d58ac 100644 --- a/Build/Compilers/ZDoom/zspecial.acs +++ b/Build/Compilers/ZDoom/zspecial.acs @@ -364,8 +364,8 @@ special -125:GetDBEntries(1), // ZDaemon's - -19260:GetTeamScore(1), - -19261:SetTeamScore(2), + -19620:GetTeamScore(1), + -19621:SetTeamScore(2), -100000:__EndOfList__(10); diff --git a/Source/Plugins/BuilderModes/General/BuilderModesTools.cs b/Source/Plugins/BuilderModes/General/BuilderModesTools.cs index 566be4a5..af53a620 100644 --- a/Source/Plugins/BuilderModes/General/BuilderModesTools.cs +++ b/Source/Plugins/BuilderModes/General/BuilderModesTools.cs @@ -29,6 +29,8 @@ namespace CodeImp.DoomBuilder.BuilderModes //Initial texture coordinates private readonly float OffsetX; private readonly float OffsetY; + private readonly float ControlSideOffsetX; + private readonly float ControlSideOffsetY; private readonly float ScaleX; private readonly float ScaleY; @@ -67,8 +69,10 @@ namespace CodeImp.DoomBuilder.BuilderModes case VisualGeometryType.WALL_MIDDLE_3D: Sidedef cs = side.GetControlLinedef().Front; - OffsetX = UDMFTools.GetFloat(cs.Fields, "offsetx_mid"); - OffsetY = UDMFTools.GetFloat(cs.Fields, "offsety_mid"); + ControlSideOffsetX = cs.OffsetX + UDMFTools.GetFloat(cs.Fields, "offsetx_mid"); + OffsetX = UDMFTools.GetFloat(side.Sidedef.Fields, "offsetx_mid"); + ControlSideOffsetY = cs.OffsetY + UDMFTools.GetFloat(cs.Fields, "offsety_mid"); + OffsetY = UDMFTools.GetFloat(side.Sidedef.Fields, "offsety_mid"); ScaleX = UDMFTools.GetFloat(cs.Fields, "scalex_mid", 1.0f); ScaleY = UDMFTools.GetFloat(cs.Fields, "scaley_mid", 1.0f); break; @@ -91,6 +95,8 @@ namespace CodeImp.DoomBuilder.BuilderModes options.GlobalBounds = GlobalBounds; options.InitialOffsetX = OffsetX; options.InitialOffsetY = OffsetY; + options.ControlSideOffsetX = ControlSideOffsetX; + options.ControlSideOffsetY = ControlSideOffsetY; options.InitialScaleX = ScaleX; options.InitialScaleY = ScaleY; @@ -185,8 +191,9 @@ namespace CodeImp.DoomBuilder.BuilderModes foreach (BaseVisualGeometrySidedef side in tosort) { long texturelong; - if (side is VisualLower) texturelong = side.Sidedef.LongLowTexture; - else if (side is VisualUpper) texturelong = side.Sidedef.LongHighTexture; + if(side is VisualLower) texturelong = side.Sidedef.LongLowTexture; + else if(side is VisualUpper) texturelong = side.Sidedef.LongHighTexture; + else if(side is VisualMiddle3D) texturelong = side.GetControlLinedef().Front.LongMiddleTexture; else texturelong = side.Sidedef.LongMiddleTexture; if(texturelong == MapSet.EmptyLongName) continue; //not interested... diff --git a/Source/Plugins/BuilderModes/Interface/FitTexturesForm.cs b/Source/Plugins/BuilderModes/Interface/FitTexturesForm.cs index 88449d61..668c7701 100644 --- a/Source/Plugins/BuilderModes/Interface/FitTexturesForm.cs +++ b/Source/Plugins/BuilderModes/Interface/FitTexturesForm.cs @@ -24,6 +24,8 @@ namespace CodeImp.DoomBuilder.BuilderModes //Initial texture coordinats public float InitialOffsetX; public float InitialOffsetY; + public float ControlSideOffsetX; + public float ControlSideOffsetY; public float InitialScaleX; public float InitialScaleY; } @@ -70,7 +72,7 @@ namespace CodeImp.DoomBuilder.BuilderModes #region ================== Methods - public void Setup(IEnumerable sides) + public bool Setup(IEnumerable sides) { // Get shapes strips = BuilderModesTools.SortVisualSides(sides); @@ -81,7 +83,7 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Interface.DisplayStatus(StatusType.Warning, "Failed to setup sidedef chains..."); this.DialogResult = DialogResult.Cancel; this.Close(); - return; + return false; } #if DEBUG @@ -106,6 +108,8 @@ namespace CodeImp.DoomBuilder.BuilderModes //trigger update UpdateChanges(); + + return true; } private void UpdateChanges() diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs index c5773c72..a624da2f 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs @@ -634,9 +634,22 @@ namespace CodeImp.DoomBuilder.BuilderModes else if(options.FitWidth) s = "width"; else s = "height"; - //create undo + // Create undo mode.CreateUndo("Fit texture (" + s + ")", UndoGroup.TextureOffsetChange, Sector.Sector.FixedIndex); Sidedef.Fields.BeforeFieldsChange(); + + // Get proper control side... + Linedef controlline = GetControlLinedef(); + Sidedef controlside; + if(controlline != Sidedef.Line) + { + controlside = controlline.Front; + controlside.Fields.BeforeFieldsChange(); + } + else + { + controlside = Sidedef; + } // Fit width if(options.FitWidth) @@ -646,21 +659,21 @@ namespace CodeImp.DoomBuilder.BuilderModes if(options.FitAcrossSurfaces) { scalex = Texture.ScaledWidth / (Sidedef.Line.Length * (options.GlobalBounds.Width / Sidedef.Line.Length)) * options.HorizontalRepeat; - offsetx = (float)Math.Round((options.Bounds.X * scalex - Sidedef.OffsetX) % Texture.Width, General.Map.FormatInterface.VertexDecimals); + offsetx = (float)Math.Round((options.Bounds.X * scalex - Sidedef.OffsetX - options.ControlSideOffsetX) % Texture.Width, General.Map.FormatInterface.VertexDecimals); } else { scalex = Texture.ScaledWidth / Sidedef.Line.Length * options.HorizontalRepeat; - offsetx = -Sidedef.OffsetX; + offsetx = -Sidedef.OffsetX - options.ControlSideOffsetX; } - UDMFTools.SetFloat(Sidedef.Fields, "scalex_" + partname, (float)Math.Round(scalex, General.Map.FormatInterface.VertexDecimals), 1.0f); + UDMFTools.SetFloat(controlside.Fields, "scalex_" + partname, (float)Math.Round(scalex, General.Map.FormatInterface.VertexDecimals), 1.0f); UDMFTools.SetFloat(Sidedef.Fields, "offsetx_" + partname, offsetx, 0.0f); } else { // Restore initial offsets - UDMFTools.SetFloat(Sidedef.Fields, "scalex_" + partname, options.InitialScaleX, 1.0f); + UDMFTools.SetFloat(controlside.Fields, "scalex_" + partname, options.InitialScaleX, 1.0f); UDMFTools.SetFloat(Sidedef.Fields, "offsetx_" + partname, options.InitialOffsetX, 0.0f); } @@ -692,7 +705,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } else { - offsety = Tools.GetSidedefOffsetY(Sidedef, geometrytype, options.Bounds.Y * scaley - Sidedef.OffsetY, scaley, true) % Texture.Height; + offsety = Tools.GetSidedefOffsetY(Sidedef, geometrytype, options.Bounds.Y * scaley - Sidedef.OffsetY - options.ControlSideOffsetY, scaley, true) % Texture.Height; } } else @@ -702,17 +715,17 @@ namespace CodeImp.DoomBuilder.BuilderModes if(this is VisualLower) // Special cases, special cases... offsety = GetLowerOffsetY(scaley); else - offsety = Tools.GetSidedefOffsetY(Sidedef, geometrytype, -Sidedef.OffsetY, scaley, true) % Texture.Height; + offsety = Tools.GetSidedefOffsetY(Sidedef, geometrytype, -Sidedef.OffsetY - options.ControlSideOffsetY, scaley, true) % Texture.Height; } - UDMFTools.SetFloat(Sidedef.Fields, "scaley_" + partname, (float)Math.Round(scaley, General.Map.FormatInterface.VertexDecimals), 1.0f); + UDMFTools.SetFloat(controlside.Fields, "scaley_" + partname, (float)Math.Round(scaley, General.Map.FormatInterface.VertexDecimals), 1.0f); UDMFTools.SetFloat(Sidedef.Fields, "offsety_" + partname, (float)Math.Round(offsety, General.Map.FormatInterface.VertexDecimals), 0.0f); } } else { // Restore initial offsets - UDMFTools.SetFloat(Sidedef.Fields, "scaley_" + partname, options.InitialScaleY, 1.0f); + UDMFTools.SetFloat(controlside.Fields, "scaley_" + partname, options.InitialScaleY, 1.0f); UDMFTools.SetFloat(Sidedef.Fields, "offsety_" + partname, options.InitialOffsetY, 0.0f); } } diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index b6304926..6898cbb2 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -2877,10 +2877,9 @@ namespace CodeImp.DoomBuilder.BuilderModes // Show form FitTexturesForm form = new FitTexturesForm(); - form.Setup(sides); // Undo changes? - if(form.ShowDialog((Form)General.Interface) == DialogResult.Cancel) + if(form.Setup(sides) && form.ShowDialog((Form)General.Interface) == DialogResult.Cancel) General.Map.UndoRedo.WithdrawUndo(); PostAction(); diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs b/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs index 9d263d03..175509ea 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualMiddle3D.cs @@ -385,6 +385,18 @@ namespace CodeImp.DoomBuilder.BuilderModes { SelectNeighbours(extrafloor.Linedef.Front.MiddleTexture, select, withSameTexture, withSameHeight); } + + //mxd + public override void OnTextureFit(FitTextureOptions options) + { + if(!General.Map.UDMF) return; + if(string.IsNullOrEmpty(extrafloor.Linedef.Front.MiddleTexture) || extrafloor.Linedef.Front.MiddleTexture == "-" || !Texture.IsImageLoaded) return; + FitTexture(options); + Setup(); + + // Update the model sector to update all 3d floors + mode.GetVisualSector(extrafloor.Linedef.Front.Sector).UpdateSectorGeometry(false); + } #endregion }