mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +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:
parent
141a4bdaff
commit
bb68e1fe43
7 changed files with 54 additions and 19 deletions
Binary file not shown.
|
@ -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);
|
||||
|
||||
|
|
|
@ -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...
|
||||
|
|
|
@ -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<BaseVisualGeometrySidedef> sides)
|
||||
public bool Setup(IEnumerable<BaseVisualGeometrySidedef> 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()
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue