2
0
Fork 0
mirror of https://github.com/KillzXGaming/Switch-Toolbox synced 2025-03-13 13:26:58 +00:00

Some layout file fixes

This commit is contained in:
KillzXGaming 2020-01-29 17:17:12 -05:00
parent ef12ed15d4
commit 2d18e4bbdc
5 changed files with 137 additions and 12 deletions
File_Format_Library
FileFormats/Layout
GUI/BFLYT

View file

@ -1081,6 +1081,10 @@ namespace LayoutBXLYT.Cafe
private float Unknown1 { get; set; } private float Unknown1 { get; set; }
private float Unknown2 { get; set; } private float Unknown2 { get; set; }
public void CopyMaterial() {
Material = Material.Clone();
}
public void UpdateTextRender() public void UpdateTextRender()
{ {
if (RenderableFont == null) return; if (RenderableFont == null) return;
@ -1123,8 +1127,9 @@ namespace LayoutBXLYT.Cafe
ShadowForeColor = STColor8.FromBytes(reader.ReadBytes(4)); ShadowForeColor = STColor8.FromBytes(reader.ReadBytes(4));
ShadowBackColor = STColor8.FromBytes(reader.ReadBytes(4)); ShadowBackColor = STColor8.FromBytes(reader.ReadBytes(4));
ShadowItalic = reader.ReadSingle(); ShadowItalic = reader.ReadSingle();
uint perCharTransformOffset = reader.ReadUInt32();
if (header.VersionMajor >= 8) { if (header.VersionMajor >= 8) {
Unknown1 = reader.ReadSingle();
Unknown2 = reader.ReadSingle(); Unknown2 = reader.ReadSingle();
} }
@ -1186,19 +1191,25 @@ namespace LayoutBXLYT.Cafe
writer.Write(ShadowForeColor.ToBytes()); writer.Write(ShadowForeColor.ToBytes());
writer.Write(ShadowBackColor.ToBytes()); writer.Write(ShadowBackColor.ToBytes());
writer.Write(ShadowItalic); writer.Write(ShadowItalic);
if (header.VersionMajor > 2)
writer.Write(0); //per character transform offset
if (header.VersionMajor >= 8) if (header.VersionMajor >= 8)
{ {
writer.Write(Unknown1);
writer.Write(Unknown2); writer.Write(Unknown2);
} }
if (Text != null) if (Text != null)
{ {
Encoding encoding = Encoding.Unicode;
if (writer.ByteOrder == Syroot.BinaryData.ByteOrder.BigEndian)
encoding = Encoding.BigEndianUnicode;
writer.WriteUint32Offset(_ofsTextPos, pos); writer.WriteUint32Offset(_ofsTextPos, pos);
if (RestrictedTextLengthEnabled) if (RestrictedTextLengthEnabled)
writer.WriteString(Text, MaxTextLength, Encoding.Unicode); writer.WriteString(Text, MaxTextLength, encoding);
else else
writer.WriteString(Text, TextLength, Encoding.Unicode); writer.WriteString(Text, TextLength, encoding);
writer.Align(4); writer.Align(4);
} }
@ -1222,6 +1233,12 @@ namespace LayoutBXLYT.Cafe
} }
public void CopyWindows() {
Content = (BxlytWindowContent)Content.Clone();
for (int f = 0; f < WindowFrames.Count; f++)
WindowFrames[f] = (BxlytWindowFrame)WindowFrames[f].Clone();
}
public WND1(Header header, string name) public WND1(Header header, string name)
{ {
layoutHeader = header; layoutHeader = header;
@ -1761,6 +1778,7 @@ namespace LayoutBXLYT.Cafe
if (openedFile == null) if (openedFile == null)
continue; continue;
openedFile.CanSave = false;
var bflan = openedFile as BXLAN; var bflan = openedFile as BXLAN;
layoutFile.PartsManager.AddAnimation(bflan.BxlanHeader); layoutFile.PartsManager.AddAnimation(bflan.BxlanHeader);
} }
@ -1774,6 +1792,7 @@ namespace LayoutBXLYT.Cafe
var openedFile = STFileLoader.OpenFileFormat(file); var openedFile = STFileLoader.OpenFileFormat(file);
if (openedFile == null) continue; if (openedFile == null) continue;
openedFile.CanSave = false;
openedFile.IFileInfo = new IFileInfo(); openedFile.IFileInfo = new IFileInfo();
openedFile.IFileInfo.ArchiveParent = fileFormat.IFileInfo.ArchiveParent; openedFile.IFileInfo.ArchiveParent = fileFormat.IFileInfo.ArchiveParent;
return (BFLYT)openedFile; return (BFLYT)openedFile;
@ -2198,6 +2217,10 @@ namespace LayoutBXLYT.Cafe
Material = new Material(name, header); Material = new Material(name, header);
} }
public void CopyMaterial() {
Material = Material.Clone();
}
public PIC1(FileReader reader, BFLYT.Header header) : base(reader, header) public PIC1(FileReader reader, BFLYT.Header header) : base(reader, header)
{ {
ParentLayout = header; ParentLayout = header;
@ -2562,6 +2585,24 @@ namespace LayoutBXLYT.Cafe
return ""; return "";
} }
public override BxlytMaterial Clone()
{
Material mat = new Material();
return mat;
}
public Material()
{
TextureMaps = new TextureRef[0];
TextureTransforms = new TextureTransform[0];
TexCoords = new TexCoordGen[0];
TevStages = new TevStage[0];
ProjTexGenParams = new ProjectionTexGenParam[0];
BlackColor = new STColor8(0, 0, 0, 0);
WhiteColor = STColor8.White;
}
public Material(string name, BxlytHeader header) public Material(string name, BxlytHeader header)
{ {
ParentLayout = header; ParentLayout = header;
@ -2612,6 +2653,18 @@ namespace LayoutBXLYT.Cafe
var projTexGenParamCount = Convert.ToUInt32((flags >> 15) & 0x3); var projTexGenParamCount = Convert.ToUInt32((flags >> 15) & 0x3);
var hasFontShadowParam = Convert.ToBoolean((flags >> 17) & 0x1); var hasFontShadowParam = Convert.ToBoolean((flags >> 17) & 0x1);
Console.WriteLine($"texCount {texCount}");
Console.WriteLine($"mtxCount {mtxCount}");
Console.WriteLine($"texCoordGenCount {texCoordGenCount}");
Console.WriteLine($"tevStageCount {tevStageCount}");
Console.WriteLine($"hasAlphaCompare {hasAlphaCompare}");
Console.WriteLine($"hasBlendMode {hasBlendMode}");
Console.WriteLine($"useTextureOnly {useTextureOnly}");
Console.WriteLine($"seperateBlendMode {seperateBlendMode}");
Console.WriteLine($"hasIndParam {hasIndParam}");
Console.WriteLine($"projTexGenParamCount {projTexGenParamCount}");
Console.WriteLine($"hasFontShadowParam {hasFontShadowParam}");
EnableAlphaCompare = hasAlphaCompare; EnableAlphaCompare = hasAlphaCompare;
EnableBlend = hasBlendMode; EnableBlend = hasBlendMode;
EnableBlendLogic = seperateBlendMode; EnableBlendLogic = seperateBlendMode;

View file

@ -692,6 +692,10 @@ namespace LayoutBXLYT
TexCoords[0] = new TexCoord(); TexCoords[0] = new TexCoord();
} }
public void CopyMaterial() {
Material = (BxlytMaterial)Material.Clone();
}
public PIC1(FileReader reader, BCLYT.Header header) : base(reader) public PIC1(FileReader reader, BCLYT.Header header) : base(reader)
{ {
ParentLayout = header; ParentLayout = header;

View file

@ -219,8 +219,15 @@ namespace LayoutBXLYT
} }
public object Clone() public object Clone()
{ {
return this.MemberwiseClone(); BasePane copiedPane = (BasePane)this.MemberwiseClone();
if (copiedPane is IPicturePane)
((IPicturePane)copiedPane).CopyMaterial();
if (copiedPane is ITextPane)
((ITextPane)copiedPane).CopyMaterial();
if (copiedPane is IWindowPane)
((IWindowPane)copiedPane).CopyWindows();
return copiedPane;
} }
public virtual UserData CreateUserData() public virtual UserData CreateUserData()
@ -1210,6 +1217,8 @@ namespace LayoutBXLYT
STColor8 ColorTopRight { get; set; } STColor8 ColorTopRight { get; set; }
STColor8 ColorBottomLeft { get; set; } STColor8 ColorBottomLeft { get; set; }
STColor8 ColorBottomRight { get; set; } STColor8 ColorBottomRight { get; set; }
void CopyMaterial();
} }
public interface IBoundryPane public interface IBoundryPane
@ -1261,6 +1270,8 @@ namespace LayoutBXLYT
bool ShadowEnabled { get; set; } bool ShadowEnabled { get; set; }
string FontName { get; set; } string FontName { get; set; }
ushort FontIndex { get; set; } ushort FontIndex { get; set; }
void CopyMaterial();
} }
public interface IPartPane public interface IPartPane
@ -1291,6 +1302,8 @@ namespace LayoutBXLYT
[Browsable(false)] [Browsable(false)]
List<BxlytWindowFrame> WindowFrames { get; set; } List<BxlytWindowFrame> WindowFrames { get; set; }
void CopyWindows();
} }
public class BXLAN public class BXLAN
@ -1298,7 +1311,7 @@ namespace LayoutBXLYT
public BxlanHeader BxlanHeader; public BxlanHeader BxlanHeader;
} }
public class BxlytWindowContent public class BxlytWindowContent : ICloneable
{ {
public STColor8 ColorTopLeft { get; set; } public STColor8 ColorTopLeft { get; set; }
public STColor8 ColorTopRight { get; set; } public STColor8 ColorTopRight { get; set; }
@ -1314,6 +1327,11 @@ namespace LayoutBXLYT
private BxlytHeader LayoutFile; private BxlytHeader LayoutFile;
public object Clone()
{
return this.MemberwiseClone();
}
public BxlytWindowContent(BxlytHeader header, string name) public BxlytWindowContent(BxlytHeader header, string name)
{ {
LayoutFile = header; LayoutFile = header;
@ -1372,7 +1390,7 @@ namespace LayoutBXLYT
} }
} }
public class BxlytWindowFrame public class BxlytWindowFrame : ICloneable
{ {
[TypeConverter(typeof(ExpandableObjectConverter))] [TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytMaterial Material { get; set; } public BxlytMaterial Material { get; set; }
@ -1380,6 +1398,11 @@ namespace LayoutBXLYT
public ushort MaterialIndex; public ushort MaterialIndex;
public WindowFrameTexFlip TextureFlip { get; set; } public WindowFrameTexFlip TextureFlip { get; set; }
public object Clone()
{
return this.MemberwiseClone();
}
public BxlytWindowFrame(BxlytHeader header, string materialName) public BxlytWindowFrame(BxlytHeader header, string materialName)
{ {
TextureFlip = WindowFrameTexFlip.None; TextureFlip = WindowFrameTexFlip.None;
@ -2150,7 +2173,7 @@ namespace LayoutBXLYT
} }
} }
public class BxlytMaterial public class BxlytMaterial
{ {
//Setup some enable booleans //Setup some enable booleans
//These determine wether to switch to default values or not //These determine wether to switch to default values or not
@ -2193,6 +2216,11 @@ namespace LayoutBXLYT
return false; return false;
} }
public virtual BxlytMaterial Clone()
{
return (BxlytMaterial)this.MemberwiseClone();
}
public void RemoveNodeWrapper() public void RemoveNodeWrapper()
{ {
if (NodeWrapper != null && NodeWrapper.Parent != null) if (NodeWrapper != null && NodeWrapper.Parent != null)
@ -2202,8 +2230,6 @@ namespace LayoutBXLYT
} }
} }
public virtual void AddTexture(string texture) public virtual void AddTexture(string texture)
{ {
int index = ParentLayout.AddTexture(texture); int index = ParentLayout.AddTexture(texture);

View file

@ -665,6 +665,12 @@ namespace LayoutBXLYT
} }
} }
public void CopyWindows() {
Content = (BxlytWindowContent)Content.Clone();
for (int f = 0; f < WindowFrames.Count; f++)
WindowFrames[f] = (BxlytWindowFrame)WindowFrames[f].Clone();
}
[TypeConverter(typeof(ExpandableObjectConverter))] [TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowContent Content { get; set; } public BxlytWindowContent Content { get; set; }
@ -862,6 +868,10 @@ namespace LayoutBXLYT
TexCoords[0] = new TexCoord(); TexCoords[0] = new TexCoord();
} }
public void CopyMaterial() {
Material = (BxlytMaterial)Material.Clone();
}
public PIC1(FileReader reader, BRLYT.Header header) : base(reader) public PIC1(FileReader reader, BRLYT.Header header) : base(reader)
{ {
ParentLayout = header; ParentLayout = header;
@ -1115,6 +1125,14 @@ namespace LayoutBXLYT
return ""; return "";
} }
public override BxlytMaterial Clone()
{
Material mat = new Material();
return mat;
}
public Material() { }
public Material(string name, Header header) public Material(string name, Header header)
{ {
TextureMaps = new TextureRef[0]; TextureMaps = new TextureRef[0];

View file

@ -151,6 +151,9 @@ namespace LayoutBXLYT
LayoutFiles.Add(header); LayoutFiles.Add(header);
ActiveLayout = header; ActiveLayout = header;
//Update the saving for the layout
ActiveLayout.FileInfo.CanSave = true;
LayoutViewer Viewport = new LayoutViewer(this, header, Textures); LayoutViewer Viewport = new LayoutViewer(this, header, Textures);
Viewport.DockContent = new DockContent(); Viewport.DockContent = new DockContent();
Viewport.DockContent.Text = header.FileName; Viewport.DockContent.Text = header.FileName;
@ -1115,7 +1118,28 @@ namespace LayoutBXLYT
name = name.Replace(numberedEnd, string.Empty); name = name.Replace(numberedEnd, string.Empty);
} }
pane.Name = RenamePane(name); name = RenamePane(name);
if (ActiveLayout.PaneLookup.ContainsKey(name))
throw new Exception("Pane name duplicate! " + name);
pane.Name = name;
pane.LayoutFile = ActiveLayout;
if (pane is IPicturePane)
{
((IPicturePane)pane).Material.Name = pane.Name;
((IPicturePane)pane).MaterialIndex = (ushort)ActiveLayout.AddMaterial(((IPicturePane)pane).Material);
}
if (pane is ITextPane)
{
((ITextPane)pane).Material.Name = pane.Name;
((ITextPane)pane).MaterialIndex = (ushort)ActiveLayout.AddMaterial(((ITextPane)pane).Material);
}
if (pane is IWindowPane)
{
}
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane); pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
ActiveLayout.AddPane(pane, pane.Parent); ActiveLayout.AddPane(pane, pane.Parent);
} }