0
0
Fork 0
mirror of https://git.do.srb2.org/STJr/UltimateZoneBuilder.git synced 2025-02-26 05:40:53 +00:00

Fixed, Fit Textures action: fixed a crash when trying to use the action on a 3d floor side.

Added, Fit Textures action: the action now takes 3d floor's control side texture offsets into account when used on 3d floor sides.
Updated ZDoom ACC.
This commit is contained in:
MaxED 2015-03-10 18:49:29 +00:00
parent 141a4bdaff
commit bb68e1fe43
7 changed files with 54 additions and 19 deletions

Binary file not shown.

View file

@ -364,8 +364,8 @@ special
-125:GetDBEntries(1), -125:GetDBEntries(1),
// ZDaemon's // ZDaemon's
-19260:GetTeamScore(1), -19620:GetTeamScore(1),
-19261:SetTeamScore(2), -19621:SetTeamScore(2),
-100000:__EndOfList__(10); -100000:__EndOfList__(10);

View file

@ -29,6 +29,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
//Initial texture coordinates //Initial texture coordinates
private readonly float OffsetX; private readonly float OffsetX;
private readonly float OffsetY; private readonly float OffsetY;
private readonly float ControlSideOffsetX;
private readonly float ControlSideOffsetY;
private readonly float ScaleX; private readonly float ScaleX;
private readonly float ScaleY; private readonly float ScaleY;
@ -67,8 +69,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
case VisualGeometryType.WALL_MIDDLE_3D: case VisualGeometryType.WALL_MIDDLE_3D:
Sidedef cs = side.GetControlLinedef().Front; Sidedef cs = side.GetControlLinedef().Front;
OffsetX = UDMFTools.GetFloat(cs.Fields, "offsetx_mid"); ControlSideOffsetX = cs.OffsetX + UDMFTools.GetFloat(cs.Fields, "offsetx_mid");
OffsetY = UDMFTools.GetFloat(cs.Fields, "offsety_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); ScaleX = UDMFTools.GetFloat(cs.Fields, "scalex_mid", 1.0f);
ScaleY = UDMFTools.GetFloat(cs.Fields, "scaley_mid", 1.0f); ScaleY = UDMFTools.GetFloat(cs.Fields, "scaley_mid", 1.0f);
break; break;
@ -91,6 +95,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
options.GlobalBounds = GlobalBounds; options.GlobalBounds = GlobalBounds;
options.InitialOffsetX = OffsetX; options.InitialOffsetX = OffsetX;
options.InitialOffsetY = OffsetY; options.InitialOffsetY = OffsetY;
options.ControlSideOffsetX = ControlSideOffsetX;
options.ControlSideOffsetY = ControlSideOffsetY;
options.InitialScaleX = ScaleX; options.InitialScaleX = ScaleX;
options.InitialScaleY = ScaleY; options.InitialScaleY = ScaleY;
@ -185,8 +191,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
foreach (BaseVisualGeometrySidedef side in tosort) foreach (BaseVisualGeometrySidedef side in tosort)
{ {
long texturelong; long texturelong;
if (side is VisualLower) texturelong = side.Sidedef.LongLowTexture; if(side is VisualLower) texturelong = side.Sidedef.LongLowTexture;
else if (side is VisualUpper) texturelong = side.Sidedef.LongHighTexture; else if(side is VisualUpper) texturelong = side.Sidedef.LongHighTexture;
else if(side is VisualMiddle3D) texturelong = side.GetControlLinedef().Front.LongMiddleTexture;
else texturelong = side.Sidedef.LongMiddleTexture; else texturelong = side.Sidedef.LongMiddleTexture;
if(texturelong == MapSet.EmptyLongName) continue; //not interested... if(texturelong == MapSet.EmptyLongName) continue; //not interested...

View file

@ -24,6 +24,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
//Initial texture coordinats //Initial texture coordinats
public float InitialOffsetX; public float InitialOffsetX;
public float InitialOffsetY; public float InitialOffsetY;
public float ControlSideOffsetX;
public float ControlSideOffsetY;
public float InitialScaleX; public float InitialScaleX;
public float InitialScaleY; public float InitialScaleY;
} }
@ -70,7 +72,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods #region ================== Methods
public void Setup(IEnumerable<BaseVisualGeometrySidedef> sides) public bool Setup(IEnumerable<BaseVisualGeometrySidedef> sides)
{ {
// Get shapes // Get shapes
strips = BuilderModesTools.SortVisualSides(sides); strips = BuilderModesTools.SortVisualSides(sides);
@ -81,7 +83,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.DisplayStatus(StatusType.Warning, "Failed to setup sidedef chains..."); General.Interface.DisplayStatus(StatusType.Warning, "Failed to setup sidedef chains...");
this.DialogResult = DialogResult.Cancel; this.DialogResult = DialogResult.Cancel;
this.Close(); this.Close();
return; return false;
} }
#if DEBUG #if DEBUG
@ -106,6 +108,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
//trigger update //trigger update
UpdateChanges(); UpdateChanges();
return true;
} }
private void UpdateChanges() private void UpdateChanges()

View file

@ -634,9 +634,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
else if(options.FitWidth) s = "width"; else if(options.FitWidth) s = "width";
else s = "height"; else s = "height";
//create undo // Create undo
mode.CreateUndo("Fit texture (" + s + ")", UndoGroup.TextureOffsetChange, Sector.Sector.FixedIndex); mode.CreateUndo("Fit texture (" + s + ")", UndoGroup.TextureOffsetChange, Sector.Sector.FixedIndex);
Sidedef.Fields.BeforeFieldsChange(); 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 // Fit width
if(options.FitWidth) if(options.FitWidth)
@ -646,21 +659,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(options.FitAcrossSurfaces) if(options.FitAcrossSurfaces)
{ {
scalex = Texture.ScaledWidth / (Sidedef.Line.Length * (options.GlobalBounds.Width / Sidedef.Line.Length)) * options.HorizontalRepeat; 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 else
{ {
scalex = Texture.ScaledWidth / Sidedef.Line.Length * options.HorizontalRepeat; 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); UDMFTools.SetFloat(Sidedef.Fields, "offsetx_" + partname, offsetx, 0.0f);
} }
else else
{ {
// Restore initial offsets // 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); UDMFTools.SetFloat(Sidedef.Fields, "offsetx_" + partname, options.InitialOffsetX, 0.0f);
} }
@ -692,7 +705,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
else 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 else
@ -702,17 +715,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(this is VisualLower) // Special cases, special cases... if(this is VisualLower) // Special cases, special cases...
offsety = GetLowerOffsetY(scaley); offsety = GetLowerOffsetY(scaley);
else 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); UDMFTools.SetFloat(Sidedef.Fields, "offsety_" + partname, (float)Math.Round(offsety, General.Map.FormatInterface.VertexDecimals), 0.0f);
} }
} }
else else
{ {
// Restore initial offsets // 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); UDMFTools.SetFloat(Sidedef.Fields, "offsety_" + partname, options.InitialOffsetY, 0.0f);
} }
} }

View file

@ -2877,10 +2877,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Show form // Show form
FitTexturesForm form = new FitTexturesForm(); FitTexturesForm form = new FitTexturesForm();
form.Setup(sides);
// Undo changes? // 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(); General.Map.UndoRedo.WithdrawUndo();
PostAction(); PostAction();

View file

@ -385,6 +385,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
SelectNeighbours(extrafloor.Linedef.Front.MiddleTexture, select, withSameTexture, withSameHeight); 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 #endregion
} }