mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-10 15:14:55 +00:00
Add wip bflyt saving.
Todo prts,usd, and bnd1 section is needed however
This commit is contained in:
parent
bb7d9d88b1
commit
f92195e8e1
28 changed files with 733 additions and 148 deletions
|
@ -51,8 +51,9 @@ namespace FirstPlugin
|
|||
}
|
||||
|
||||
public List<INode> nodes = new List<INode>();
|
||||
public List<FileEntry> files = new List<FileEntry>();
|
||||
|
||||
public IEnumerable<ArchiveFileInfo> Files => null;
|
||||
public IEnumerable<ArchiveFileInfo> Files => files;
|
||||
public IEnumerable<INode> Nodes => nodes;
|
||||
|
||||
public void ClearFiles() { nodes.Clear(); }
|
||||
|
@ -150,6 +151,7 @@ namespace FirstPlugin
|
|||
|
||||
reader.SeekBegin(entry.nodeEntry.Setting1);
|
||||
entry.FileData = reader.ReadBytes((int)entry.nodeEntry.Setting2);
|
||||
files.Add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,6 +168,11 @@ namespace FirstPlugin
|
|||
|
||||
public class FileEntry : ArchiveFileInfo
|
||||
{
|
||||
public override bool OpenFileFormatOnLoad
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public NodeEntry nodeEntry;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ using SharpYaml.Serialization;
|
|||
using FirstPlugin;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace LayoutBXLYT
|
||||
namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
public class BFLYT : IFileFormat, IEditorForm<LayoutEditor>, IConvertableTextFormat
|
||||
{
|
||||
|
@ -305,6 +305,8 @@ namespace LayoutBXLYT
|
|||
ushort sectionCount = reader.ReadUInt16();
|
||||
reader.ReadUInt16(); //Padding
|
||||
|
||||
IsBigEndian = reader.ByteOrder == Syroot.BinaryData.ByteOrder.BigEndian;
|
||||
|
||||
bool setRoot = false;
|
||||
bool setGroupRoot = false;
|
||||
|
||||
|
@ -411,11 +413,17 @@ namespace LayoutBXLYT
|
|||
break;
|
||||
//If the section is not supported store the raw bytes
|
||||
default:
|
||||
section.Data = reader.ReadBytes((int)SectionSize);
|
||||
section.Data = reader.ReadBytes((int)SectionSize - 8);
|
||||
break;
|
||||
}
|
||||
//Check if we reached the end or not
|
||||
long endPos = reader.Position;
|
||||
if (reader.Position < pos + SectionSize)
|
||||
{
|
||||
int size = (int)(endPos - pos);
|
||||
section.Data = reader.ReadBytes(size);
|
||||
}
|
||||
|
||||
section.Signature = Signature;
|
||||
section.SectionSize = SectionSize;
|
||||
|
||||
reader.SeekBegin(pos + SectionSize);
|
||||
|
@ -435,22 +443,112 @@ namespace LayoutBXLYT
|
|||
{
|
||||
Version = VersionMajor << 24 | VersionMinor << 16 | VersionMicro << 8 | VersionMicro2;
|
||||
|
||||
writer.SetByteOrder(true);
|
||||
writer.WriteSignature(Magic);
|
||||
writer.Write(ByteOrderMark);
|
||||
writer.SetByteOrder(IsBigEndian);
|
||||
writer.Write(HeaderSize);
|
||||
writer.Write(Version);
|
||||
writer.Write(uint.MaxValue); //Reserve space for file size later
|
||||
writer.Write(ushort.MaxValue); //Reserve space for section count later
|
||||
writer.Seek(2); //padding
|
||||
|
||||
int sectionCount = 1;
|
||||
|
||||
WriteSection(writer, "lyt1", LayoutInfo,() => LayoutInfo.Write(writer, this));
|
||||
|
||||
if (TextureList != null && TextureList.Textures.Count > 0)
|
||||
{
|
||||
WriteSection(writer, "txl1", TextureList,() => TextureList.Write(writer, this));
|
||||
sectionCount++;
|
||||
}
|
||||
if (FontList != null && FontList.Fonts.Count > 0)
|
||||
{
|
||||
WriteSection(writer, "fnl1", FontList,() => FontList.Write(writer, this));
|
||||
sectionCount++;
|
||||
}
|
||||
if (MaterialList != null && MaterialList.Materials.Count > 0)
|
||||
{
|
||||
WriteSection(writer, "mat1", MaterialList,() => MaterialList.Write(writer, this));
|
||||
sectionCount++;
|
||||
}
|
||||
|
||||
WritePanes(writer, RootPane, this, ref sectionCount);
|
||||
WriteGroupPanes(writer, RootGroup, this, ref sectionCount);
|
||||
|
||||
//Write the total section count
|
||||
using (writer.TemporarySeek(0x10, System.IO.SeekOrigin.Begin))
|
||||
{
|
||||
writer.Write((ushort)sectionCount);
|
||||
}
|
||||
|
||||
//Write the total file size
|
||||
using (writer.TemporarySeek(0x0C, System.IO.SeekOrigin.Begin))
|
||||
{
|
||||
writer.Write((uint)writer.BaseStream.Length);
|
||||
}
|
||||
}
|
||||
|
||||
private void WritePanes(FileWriter writer, BasePane pane, BxlytHeader header, ref int sectionCount)
|
||||
{
|
||||
WriteSection(writer, pane.Signature, pane,() => pane.Write(writer, header));
|
||||
sectionCount++;
|
||||
|
||||
if (pane.HasChildern)
|
||||
{
|
||||
sectionCount += 2;
|
||||
|
||||
//Write start of children section
|
||||
WriteSection(writer, "pas1", null);
|
||||
|
||||
foreach (var child in pane.Childern)
|
||||
WritePanes(writer, child, header, ref sectionCount);
|
||||
|
||||
//Write pae1 of children section
|
||||
WriteSection(writer, "pae1", null);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteGroupPanes(FileWriter writer, BasePane pane, BxlytHeader header, ref int sectionCount)
|
||||
{
|
||||
WriteSection(writer, pane.Signature, pane, () => pane.Write(writer, header));
|
||||
sectionCount++;
|
||||
|
||||
if (pane.HasChildern)
|
||||
{
|
||||
sectionCount += 2;
|
||||
|
||||
//Write start of children section
|
||||
WriteSection(writer, "grs1", null);
|
||||
|
||||
foreach (var child in pane.Childern)
|
||||
WriteGroupPanes(writer, child, header, ref sectionCount);
|
||||
|
||||
//Write pae1 of children section
|
||||
WriteSection(writer, "gre1", null);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteSection(FileWriter writer, string magic, SectionCommon section, Action WriteMethod = null)
|
||||
{
|
||||
long startPos = writer.Position;
|
||||
writer.WriteSignature(magic);
|
||||
writer.Write(uint.MaxValue);
|
||||
WriteMethod?.Invoke();
|
||||
if (section != null && section.Data != null)
|
||||
writer.Write(section.Data);
|
||||
|
||||
long endPos = writer.Position;
|
||||
|
||||
using (writer.TemporarySeek(startPos + 4, System.IO.SeekOrigin.Begin))
|
||||
{
|
||||
writer.Write((uint)(endPos - startPos));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class TexCoord
|
||||
{
|
||||
public Vector2F TopLeft { get; set; }
|
||||
|
@ -469,6 +567,8 @@ namespace LayoutBXLYT
|
|||
|
||||
public class TXT1 : PAN1
|
||||
{
|
||||
public override string Signature { get; } = "txt1";
|
||||
|
||||
public TXT1() : base()
|
||||
{
|
||||
|
||||
|
@ -570,7 +670,7 @@ namespace LayoutBXLYT
|
|||
|
||||
public override void Write(FileWriter writer, BxlytHeader header)
|
||||
{
|
||||
long pos = writer.Position;
|
||||
long pos = writer.Position - 8;
|
||||
|
||||
base.Write(writer, header);
|
||||
writer.Write(TextLength);
|
||||
|
@ -620,6 +720,8 @@ namespace LayoutBXLYT
|
|||
|
||||
public class WND1 : PAN1
|
||||
{
|
||||
public override string Signature { get; } = "wnd1";
|
||||
|
||||
public WND1() : base()
|
||||
{
|
||||
|
||||
|
@ -662,6 +764,8 @@ namespace LayoutBXLYT
|
|||
reader.SeekBegin(pos + contentOffset);
|
||||
Content = new WindowContent(reader);
|
||||
|
||||
reader.SeekBegin(pos + frameOffsetTbl);
|
||||
|
||||
var offsets = reader.ReadUInt32s(FrameCount);
|
||||
foreach (int offset in offsets)
|
||||
{
|
||||
|
@ -672,7 +776,7 @@ namespace LayoutBXLYT
|
|||
|
||||
public override void Write(FileWriter writer, BxlytHeader header)
|
||||
{
|
||||
long pos = writer.Position;
|
||||
long pos = writer.Position - 8;
|
||||
|
||||
base.Write(writer, header);
|
||||
writer.Write(StretchLeft);
|
||||
|
@ -685,7 +789,7 @@ namespace LayoutBXLYT
|
|||
writer.Write(FrameElementBottm);
|
||||
writer.Write(FrameCount);
|
||||
writer.Write(_flag);
|
||||
writer.Seek(2);
|
||||
writer.Write((ushort)0);
|
||||
|
||||
long _ofsContentPos = writer.Position;
|
||||
writer.Write(0);
|
||||
|
@ -693,6 +797,19 @@ namespace LayoutBXLYT
|
|||
|
||||
writer.WriteUint32Offset(_ofsContentPos, pos);
|
||||
Content.Write(writer);
|
||||
|
||||
if (WindowFrames.Count > 0)
|
||||
{
|
||||
writer.WriteUint32Offset(_ofsContentPos + 4, pos);
|
||||
//Reserve space for frame offsets
|
||||
long _ofsFramePos = writer.Position;
|
||||
writer.Write(new uint[WindowFrames.Count]);
|
||||
for (int i = 0; i < WindowFrames.Count; i++)
|
||||
{
|
||||
writer.WriteUint32Offset(_ofsFramePos + (i * 4), pos);
|
||||
WindowFrames[i].Write(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class WindowContent
|
||||
|
@ -768,6 +885,8 @@ namespace LayoutBXLYT
|
|||
|
||||
public class BND1 : PAN1
|
||||
{
|
||||
public override string Signature { get; } = "bnd1";
|
||||
|
||||
public BND1() : base()
|
||||
{
|
||||
|
||||
|
@ -786,6 +905,8 @@ namespace LayoutBXLYT
|
|||
|
||||
public class GRP1 : BasePane
|
||||
{
|
||||
public override string Signature { get; } = "grp1";
|
||||
|
||||
public List<string> Panes { get; set; } = new List<string>();
|
||||
|
||||
public GRP1() : base()
|
||||
|
@ -833,6 +954,8 @@ namespace LayoutBXLYT
|
|||
|
||||
public class PRT1 : PAN1
|
||||
{
|
||||
public override string Signature { get; } = "prt1";
|
||||
|
||||
public PRT1() : base()
|
||||
{
|
||||
|
||||
|
@ -851,6 +974,8 @@ namespace LayoutBXLYT
|
|||
|
||||
public class PIC1 : PAN1
|
||||
{
|
||||
public override string Signature { get; } = "pic1";
|
||||
|
||||
public TexCoord[] TexCoords { get; set; }
|
||||
|
||||
public STColor8 ColorTopLeft { get; set; }
|
||||
|
@ -890,10 +1015,10 @@ namespace LayoutBXLYT
|
|||
{
|
||||
ParentLayout = header;
|
||||
|
||||
ColorTopLeft = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
ColorTopRight = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
ColorBottomLeft = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
ColorBottomRight = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
ColorTopLeft = reader.ReadColor8RGBA();
|
||||
ColorTopRight = reader.ReadColor8RGBA();
|
||||
ColorBottomLeft = reader.ReadColor8RGBA();
|
||||
ColorBottomRight = reader.ReadColor8RGBA();
|
||||
MaterialIndex = reader.ReadUInt16();
|
||||
byte numUVs = reader.ReadByte();
|
||||
reader.Seek(1); //padding
|
||||
|
@ -914,17 +1039,28 @@ namespace LayoutBXLYT
|
|||
public override void Write(FileWriter writer, BxlytHeader header)
|
||||
{
|
||||
base.Write(writer, header);
|
||||
writer.Write(ColorTopLeft.ToBytes());
|
||||
writer.Write(ColorTopRight.ToBytes());
|
||||
writer.Write(ColorBottomLeft.ToBytes());
|
||||
writer.Write(ColorBottomRight.ToBytes());
|
||||
writer.Write(ColorTopLeft);
|
||||
writer.Write(ColorTopRight);
|
||||
writer.Write(ColorBottomLeft);
|
||||
writer.Write(ColorBottomRight);
|
||||
writer.Write(MaterialIndex);
|
||||
writer.Write(TexCoords != null ? TexCoords.Length : 0);
|
||||
writer.Write((byte)TexCoords.Length);
|
||||
writer.Write((byte)0);
|
||||
|
||||
for (int i = 0; i < TexCoords.Length; i++)
|
||||
{
|
||||
writer.Write(TexCoords[i].TopLeft);
|
||||
writer.Write(TexCoords[i].TopRight);
|
||||
writer.Write(TexCoords[i].BottomLeft);
|
||||
writer.Write(TexCoords[i].BottomRight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PAN1 : BasePane
|
||||
{
|
||||
public override string Signature { get; } = "pan1";
|
||||
|
||||
private byte _flags1;
|
||||
private byte _flags2;
|
||||
|
||||
|
@ -1086,21 +1222,37 @@ namespace LayoutBXLYT
|
|||
|
||||
public override void Write(FileWriter writer, BxlytHeader header)
|
||||
{
|
||||
long pos = writer.Position - 8;
|
||||
|
||||
writer.Write((ushort)Materials.Count);
|
||||
writer.Seek(2);
|
||||
|
||||
long _ofsPos = writer.Position;
|
||||
//Fill empty spaces for offsets later
|
||||
writer.Write(new uint[Materials.Count]);
|
||||
|
||||
//Save offsets and strings
|
||||
for (int i = 0; i < Materials.Count; i++)
|
||||
{
|
||||
writer.WriteUint32Offset(_ofsPos + (i * 4), pos);
|
||||
Materials[i].Write(writer, header);
|
||||
writer.Align(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Thanks to shibbs for the material info
|
||||
//https://github.com/shibbo/flyte/blob/master/flyte/lyt/common/MAT1.cs
|
||||
public class Material
|
||||
{
|
||||
[DisplayName("Name"), CategoryAttribute("General")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Fore Color"), CategoryAttribute("Color")]
|
||||
public STColor8 ForeColor { get; set; }
|
||||
[DisplayName("Black Color"), CategoryAttribute("Color")]
|
||||
public STColor8 BlackColor { get; set; }
|
||||
|
||||
[DisplayName("Back Color"), CategoryAttribute("Color")]
|
||||
public STColor8 BackColor { get; set; }
|
||||
[DisplayName("White Color"), CategoryAttribute("Color")]
|
||||
public STColor8 WhiteColor { get; set; }
|
||||
|
||||
[DisplayName("Texture Maps"), CategoryAttribute("Texture")]
|
||||
public TextureRef[] TextureMaps { get; set; }
|
||||
|
@ -1108,6 +1260,30 @@ namespace LayoutBXLYT
|
|||
[DisplayName("Texture Transforms"), CategoryAttribute("Texture")]
|
||||
public TextureTransform[] TextureTransforms { get; set; }
|
||||
|
||||
[DisplayName("Texture Coordinate Params"), CategoryAttribute("Texture")]
|
||||
public TexCoordGen[] TexCoords { get; set; }
|
||||
|
||||
[DisplayName("Tev Stages"), CategoryAttribute("Tev")]
|
||||
public TevStage[] TevStages { get; set; }
|
||||
|
||||
[DisplayName("Alpha Compare"), CategoryAttribute("Alpha")]
|
||||
public AlphaCompare AlphaCompare { get; set; }
|
||||
|
||||
[DisplayName("Blend Mode"), CategoryAttribute("Blend")]
|
||||
public BlendMode BlendMode { get; set; }
|
||||
|
||||
[DisplayName("Blend Mode Logic"), CategoryAttribute("Blend")]
|
||||
public BlendMode BlendModeLogic { get; set; }
|
||||
|
||||
[DisplayName("Indirect Parameter"), CategoryAttribute("Texture")]
|
||||
public IndirectParameter IndParameter { get; set; }
|
||||
|
||||
[DisplayName("Projection Texture Coord Parameters"), CategoryAttribute("Texture")]
|
||||
public ProjectionTexGenParam[] ProjTexGenParams { get; set; }
|
||||
|
||||
[DisplayName("Font Shadow Parameters"), CategoryAttribute("Font")]
|
||||
public FontShadowParameter FontShadowParameter { get; set; }
|
||||
|
||||
private uint flags;
|
||||
private int unknown;
|
||||
|
||||
|
@ -1135,42 +1311,77 @@ namespace LayoutBXLYT
|
|||
{
|
||||
flags = reader.ReadUInt32();
|
||||
unknown = reader.ReadInt32();
|
||||
ForeColor = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
BackColor = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
BlackColor = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
WhiteColor = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
}
|
||||
else
|
||||
{
|
||||
ForeColor = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
BackColor = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
BlackColor = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
WhiteColor = STColor8.FromBytes(reader.ReadBytes(4));
|
||||
flags = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
uint texCount = Convert.ToUInt32(flags & 3);
|
||||
uint mtxCount = Convert.ToUInt32(flags >> 2) & 3;
|
||||
uint texCoordGenCount = Convert.ToUInt32(flags >> 4) & 3;
|
||||
uint tevStageCount = Convert.ToUInt32(flags >> 6) & 0x7;
|
||||
var hasAlphaCompare = Convert.ToBoolean((flags >> 9) & 0x1);
|
||||
var hasBlendMode = Convert.ToBoolean((flags >> 10) & 0x1);
|
||||
var useTextureOnly = Convert.ToBoolean((flags >> 11) & 0x1);
|
||||
var seperateBlendMode = Convert.ToBoolean((flags >> 12) & 0x1);
|
||||
var hasIndParam = Convert.ToBoolean((flags >> 14) & 0x1);
|
||||
var projTexGenParamCount = Convert.ToUInt32((flags >> 15) & 0x3);
|
||||
var hasFontShadowParam = Convert.ToBoolean((flags >> 17) & 0x1);
|
||||
var thresholdingAlphaInterpolation = Convert.ToBoolean((flags >> 18) & 0x1);
|
||||
|
||||
TextureMaps = new TextureRef[texCount];
|
||||
TextureTransforms = new TextureTransform[mtxCount];
|
||||
TexCoords = new TexCoordGen[texCoordGenCount];
|
||||
TevStages = new TevStage[tevStageCount];
|
||||
ProjTexGenParams = new ProjectionTexGenParam[projTexGenParamCount];
|
||||
|
||||
for (int i = 0; i < texCount; i++)
|
||||
TextureMaps[i] = new TextureRef(reader, header);
|
||||
|
||||
TextureTransforms = new TextureTransform[mtxCount];
|
||||
for (int i = 0; i < mtxCount; i++)
|
||||
TextureTransforms[i] = new TextureTransform(reader);
|
||||
|
||||
for (int i = 0; i < texCoordGenCount; i++)
|
||||
TexCoords[i] = new TexCoordGen(reader, header);
|
||||
|
||||
for (int i = 0; i < tevStageCount; i++)
|
||||
TevStages[i] = new TevStage(reader, header);
|
||||
|
||||
if (hasAlphaCompare)
|
||||
AlphaCompare = new AlphaCompare(reader, header);
|
||||
if (hasBlendMode)
|
||||
BlendMode = new BlendMode(reader, header);
|
||||
if (seperateBlendMode)
|
||||
BlendModeLogic = new BlendMode(reader, header);
|
||||
if (hasIndParam)
|
||||
IndParameter = new IndirectParameter(reader, header);
|
||||
|
||||
for (int i = 0; i < projTexGenParamCount; i++)
|
||||
ProjTexGenParams[i] = new ProjectionTexGenParam(reader, header);
|
||||
|
||||
if (hasFontShadowParam)
|
||||
FontShadowParameter = new FontShadowParameter(reader, header);
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer, Header header)
|
||||
public void Write(FileWriter writer, BxlytHeader header)
|
||||
{
|
||||
writer.WriteString(Name, 0x1C);
|
||||
if (header.Version == 0x8030000)
|
||||
if (header.VersionMajor >= 8)
|
||||
{
|
||||
writer.Write(flags);
|
||||
writer.Write(unknown);
|
||||
writer.Write(ForeColor);
|
||||
writer.Write(BackColor);
|
||||
writer.Write(BlackColor);
|
||||
writer.Write(WhiteColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(ForeColor);
|
||||
writer.Write(BackColor);
|
||||
writer.Write(BlackColor);
|
||||
writer.Write(WhiteColor);
|
||||
writer.Write(flags);
|
||||
}
|
||||
|
||||
|
@ -1179,88 +1390,27 @@ namespace LayoutBXLYT
|
|||
|
||||
for (int i = 0; i < TextureTransforms.Length; i++)
|
||||
TextureTransforms[i].Write(writer);
|
||||
}
|
||||
}
|
||||
|
||||
public class TextureTransform
|
||||
{
|
||||
public Vector2F Translate;
|
||||
public float Rotate;
|
||||
public Vector2F Scale;
|
||||
for (int i = 0; i < TexCoords.Length; i++)
|
||||
TexCoords[i].Write(writer);
|
||||
|
||||
public TextureTransform() { }
|
||||
for (int i = 0; i < TevStages.Length; i++)
|
||||
TevStages[i].Write(writer);
|
||||
|
||||
public TextureTransform(FileReader reader)
|
||||
{
|
||||
Translate = reader.ReadVec2SY();
|
||||
Rotate = reader.ReadSingle();
|
||||
Scale = reader.ReadVec2SY();
|
||||
}
|
||||
if (AlphaCompare != null)
|
||||
AlphaCompare.Write(writer);
|
||||
if (BlendMode != null)
|
||||
BlendMode.Write(writer);
|
||||
if (BlendModeLogic != null)
|
||||
BlendModeLogic.Write(writer);
|
||||
if (IndParameter != null)
|
||||
IndParameter.Write(writer);
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(Translate);
|
||||
writer.Write(Rotate);
|
||||
writer.Write(Scale);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < ProjTexGenParams.Length; i++)
|
||||
ProjTexGenParams[i].Write(writer);
|
||||
|
||||
public class TextureRef
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public short ID;
|
||||
byte flag1;
|
||||
byte flag2;
|
||||
|
||||
public WrapMode WrapModeU
|
||||
{
|
||||
get { return (WrapMode)(flag1 & 0x3); }
|
||||
}
|
||||
|
||||
public WrapMode WrapModeV
|
||||
{
|
||||
get { return (WrapMode)(flag2 & 0x3); }
|
||||
}
|
||||
|
||||
public FilterMode MinFilterMode
|
||||
{
|
||||
get { return (FilterMode)((flag1 >> 2) & 0x3); }
|
||||
}
|
||||
|
||||
public FilterMode MaxFilterMode
|
||||
{
|
||||
get { return (FilterMode)((flag2 >> 2) & 0x3); }
|
||||
}
|
||||
|
||||
public TextureRef() {}
|
||||
|
||||
public TextureRef(FileReader reader, BFLYT.Header header) {
|
||||
ID = reader.ReadInt16();
|
||||
flag1 = reader.ReadByte();
|
||||
flag2 = reader.ReadByte();
|
||||
|
||||
if (header.Textures.Count > 0 && ID != -1)
|
||||
Name = header.Textures[ID];
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(ID);
|
||||
writer.Write(flag1);
|
||||
writer.Write(flag2);
|
||||
}
|
||||
|
||||
public enum FilterMode
|
||||
{
|
||||
Near = 0,
|
||||
Linear = 1
|
||||
}
|
||||
|
||||
public enum WrapMode
|
||||
{
|
||||
Clamp = 0,
|
||||
Repeat = 1,
|
||||
Mirror = 2
|
||||
if (FontShadowParameter != null)
|
||||
FontShadowParameter.Write(writer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1399,7 +1549,8 @@ namespace LayoutBXLYT
|
|||
writer.Write(Height);
|
||||
writer.Write(MaxPartsWidth);
|
||||
writer.Write(MaxPartsHeight);
|
||||
writer.Write(Name);
|
||||
writer.WriteString(Name);
|
||||
writer.Align(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
using Toolbox.Library.IO;
|
||||
|
||||
namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
public class AlphaCompare
|
||||
{
|
||||
public byte CompareMode;
|
||||
public uint Value;
|
||||
|
||||
public AlphaCompare(FileReader reader, BFLYT.Header header)
|
||||
{
|
||||
CompareMode = reader.ReadByte();
|
||||
reader.ReadBytes(0x3);
|
||||
Value = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(CompareMode);
|
||||
writer.Seek(3);
|
||||
writer.Write(Value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
using Toolbox.Library.IO;
|
||||
|
||||
namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
public class BlendMode
|
||||
{
|
||||
public GX2BlendOp BlendOp { get; set; }
|
||||
public GX2BlendFactor SourceFactor { get; set; }
|
||||
public GX2BlendFactor DestFactor { get; set; }
|
||||
public GX2LogicOp LogicOp { get; set; }
|
||||
|
||||
public BlendMode(FileReader reader, BFLYT.Header header)
|
||||
{
|
||||
BlendOp = (GX2BlendOp)reader.ReadByte();
|
||||
SourceFactor = (GX2BlendFactor)reader.ReadByte();
|
||||
DestFactor = (GX2BlendFactor)reader.ReadByte();
|
||||
LogicOp = (GX2LogicOp)reader.ReadByte();
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(BlendOp, false);
|
||||
writer.Write(SourceFactor, false);
|
||||
writer.Write(DestFactor, false);
|
||||
writer.Write(LogicOp, false);
|
||||
}
|
||||
|
||||
public enum GX2BlendFactor : byte
|
||||
{
|
||||
Factor0 = 0,
|
||||
Factor1 = 1,
|
||||
DestColor = 2,
|
||||
DestInvColor = 3,
|
||||
SourceAlpha = 4,
|
||||
SourceInvAlpha = 5,
|
||||
DestAlpha = 6,
|
||||
DestInvAlpha = 7,
|
||||
SourceColor = 8,
|
||||
SourceInvColor = 9
|
||||
}
|
||||
|
||||
public enum GX2BlendOp : byte
|
||||
{
|
||||
Disable = 0,
|
||||
Add = 1,
|
||||
Subtract = 2,
|
||||
ReverseSubtract = 3,
|
||||
SelectMin = 4,
|
||||
SelectMax = 5
|
||||
}
|
||||
|
||||
public enum GX2LogicOp : byte
|
||||
{
|
||||
Disable = 0,
|
||||
NoOp = 1,
|
||||
Clear = 2,
|
||||
Set = 3,
|
||||
Copy = 4,
|
||||
InvCopy = 5,
|
||||
Inv = 6,
|
||||
And = 7,
|
||||
Nand = 8,
|
||||
Or = 9,
|
||||
Nor = 10,
|
||||
Xor = 11,
|
||||
Equiv = 12,
|
||||
RevAnd = 13,
|
||||
InvAd = 14,
|
||||
RevOr = 15,
|
||||
InvOr = 16
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using Toolbox.Library.IO;
|
||||
using Toolbox.Library;
|
||||
|
||||
namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
public class FontShadowParameter
|
||||
{
|
||||
public STColor8 BlackColor { get; set; }
|
||||
public STColor8 WhiteColor { get; set; }
|
||||
|
||||
public FontShadowParameter(FileReader reader, BFLYT.Header header)
|
||||
{
|
||||
BlackColor = reader.ReadColor8RGBA();
|
||||
WhiteColor = reader.ReadColor8RGBA();
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(BlackColor);
|
||||
writer.Write(WhiteColor);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using Toolbox.Library.IO;
|
||||
|
||||
namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
public class IndirectParameter
|
||||
{
|
||||
public float Rotation { get; set; }
|
||||
public float ScaleX { get; set; }
|
||||
public float ScaleY { get; set; }
|
||||
|
||||
public IndirectParameter(FileReader reader, BFLYT.Header header)
|
||||
{
|
||||
Rotation = reader.ReadSingle();
|
||||
ScaleX = reader.ReadSingle();
|
||||
ScaleY = reader.ReadSingle();
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(Rotation);
|
||||
writer.Write(ScaleX);
|
||||
writer.Write(ScaleY);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
using Toolbox.Library.IO;
|
||||
using System;
|
||||
|
||||
namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
public class ProjectionTexGenParam
|
||||
{
|
||||
public float PosX { get; set; }
|
||||
public float PosY { get; set; }
|
||||
public float ScaleX { get; set; }
|
||||
public float ScaleY { get; set; }
|
||||
|
||||
public bool IsFittingLayoutSize
|
||||
{
|
||||
get { return Convert.ToBoolean(flags & 0x1); }
|
||||
}
|
||||
|
||||
public bool IsFittingPaneSize
|
||||
{
|
||||
get { return Convert.ToBoolean(flags & 0x2); }
|
||||
}
|
||||
|
||||
public bool IsAdjustPRojectionSR
|
||||
{
|
||||
get { return Convert.ToBoolean(flags & 0x3); }
|
||||
}
|
||||
|
||||
byte flags;
|
||||
|
||||
public ProjectionTexGenParam(FileReader reader, BFLYT.Header header)
|
||||
{
|
||||
PosX = reader.ReadSingle();
|
||||
PosY = reader.ReadSingle();
|
||||
ScaleX = reader.ReadSingle();
|
||||
ScaleY = reader.ReadSingle();
|
||||
flags = reader.ReadByte();
|
||||
reader.Seek(3);
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(PosX);
|
||||
writer.Write(PosY);
|
||||
writer.Write(ScaleX);
|
||||
writer.Write(ScaleY);
|
||||
writer.Write(flags);
|
||||
writer.Seek(3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using Toolbox.Library.IO;
|
||||
|
||||
namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
public class TevStage
|
||||
{
|
||||
byte RGBMode;
|
||||
byte AlphaMode;
|
||||
ushort unk;
|
||||
|
||||
public TevStage(FileReader reader, BFLYT.Header header)
|
||||
{
|
||||
RGBMode = reader.ReadByte();
|
||||
AlphaMode = reader.ReadByte();
|
||||
unk = reader.ReadUInt16();
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(RGBMode);
|
||||
writer.Write(AlphaMode);
|
||||
writer.Write(unk);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
using Toolbox.Library.IO;
|
||||
|
||||
namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
public class TexCoordGen
|
||||
{
|
||||
public MatrixType GenType;
|
||||
public TextureGenerationType Source;
|
||||
|
||||
byte[] unkData;
|
||||
|
||||
public TexCoordGen(FileReader reader, BFLYT.Header header)
|
||||
{
|
||||
GenType = reader.ReadEnum<MatrixType>(false);
|
||||
Source = reader.ReadEnum<TextureGenerationType>(false);
|
||||
unkData = reader.ReadBytes(6);
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(GenType, false);
|
||||
writer.Write(Source, false);
|
||||
writer.Write(unkData);
|
||||
}
|
||||
|
||||
public enum MatrixType : byte
|
||||
{
|
||||
Matrix2x4 = 0
|
||||
}
|
||||
|
||||
public enum TextureGenerationType : byte
|
||||
{
|
||||
Tex0 = 0,
|
||||
Tex1 = 1,
|
||||
Tex2 = 2,
|
||||
Ortho = 3,
|
||||
PaneBased = 4,
|
||||
PerspectiveProj = 5
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
using Toolbox.Library.IO;
|
||||
|
||||
namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
public class TextureRef
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public short ID;
|
||||
byte flag1;
|
||||
byte flag2;
|
||||
|
||||
public WrapMode WrapModeU
|
||||
{
|
||||
get { return (WrapMode)(flag1 & 0x3); }
|
||||
}
|
||||
|
||||
public WrapMode WrapModeV
|
||||
{
|
||||
get { return (WrapMode)(flag2 & 0x3); }
|
||||
}
|
||||
|
||||
public FilterMode MinFilterMode
|
||||
{
|
||||
get { return (FilterMode)((flag1 >> 2) & 0x3); }
|
||||
}
|
||||
|
||||
public FilterMode MaxFilterMode
|
||||
{
|
||||
get { return (FilterMode)((flag2 >> 2) & 0x3); }
|
||||
}
|
||||
|
||||
public TextureRef() { }
|
||||
|
||||
public TextureRef(FileReader reader, BFLYT.Header header)
|
||||
{
|
||||
ID = reader.ReadInt16();
|
||||
flag1 = reader.ReadByte();
|
||||
flag2 = reader.ReadByte();
|
||||
|
||||
if (header.Textures.Count > 0 && ID != -1)
|
||||
Name = header.Textures[ID];
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(ID);
|
||||
writer.Write(flag1);
|
||||
writer.Write(flag2);
|
||||
}
|
||||
|
||||
public enum FilterMode
|
||||
{
|
||||
Near = 0,
|
||||
Linear = 1
|
||||
}
|
||||
|
||||
public enum WrapMode
|
||||
{
|
||||
Clamp = 0,
|
||||
Repeat = 1,
|
||||
Mirror = 2
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using Toolbox.Library.IO;
|
||||
using Syroot.Maths;
|
||||
|
||||
namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
public class TextureTransform
|
||||
{
|
||||
public Vector2F Translate;
|
||||
public float Rotate;
|
||||
public Vector2F Scale;
|
||||
|
||||
public TextureTransform() { }
|
||||
|
||||
public TextureTransform(FileReader reader)
|
||||
{
|
||||
Translate = reader.ReadVec2SY();
|
||||
Rotate = reader.ReadSingle();
|
||||
Scale = reader.ReadVec2SY();
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(Translate);
|
||||
writer.Write(Rotate);
|
||||
writer.Write(Scale);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -203,6 +203,8 @@ namespace LayoutBXLYT
|
|||
|
||||
public void Read(FileReader reader, BCLYT bclyt)
|
||||
{
|
||||
IsBigEndian = reader.ByteOrder == Syroot.BinaryData.ByteOrder.BigEndian;
|
||||
|
||||
LayoutInfo = new LYT1();
|
||||
TextureList = new TXL1();
|
||||
MaterialList = new MAT1();
|
||||
|
@ -332,7 +334,6 @@ namespace LayoutBXLYT
|
|||
break;
|
||||
}
|
||||
|
||||
section.Signature = Signature;
|
||||
section.SectionSize = SectionSize;
|
||||
|
||||
reader.SeekBegin(pos + SectionSize);
|
||||
|
@ -352,6 +353,7 @@ namespace LayoutBXLYT
|
|||
{
|
||||
Version = VersionMajor << 24 | VersionMinor << 16 | VersionMicro << 8 | VersionMicro2;
|
||||
|
||||
writer.SetByteOrder(IsBigEndian);
|
||||
writer.WriteSignature(Magic);
|
||||
writer.Write(ByteOrderMark);
|
||||
writer.Write(HeaderSize);
|
||||
|
|
|
@ -146,6 +146,8 @@ namespace LayoutBXLYT
|
|||
get { return FileInfo.FileName; }
|
||||
}
|
||||
|
||||
public bool IsBigEndian { get; set; }
|
||||
|
||||
internal IFileFormat FileInfo;
|
||||
|
||||
public BasePane RootPane { get; set; }
|
||||
|
@ -196,10 +198,11 @@ namespace LayoutBXLYT
|
|||
}
|
||||
}
|
||||
|
||||
public class SectionCommon
|
||||
public class SectionCommon
|
||||
{
|
||||
internal string Signature { get; set; }
|
||||
internal uint SectionSize { get; set; }
|
||||
public virtual string Signature { get; }
|
||||
public uint SectionSize { get; set; }
|
||||
public long StartPosition { get; set; }
|
||||
|
||||
internal byte[] Data { get; set; }
|
||||
|
||||
|
@ -208,7 +211,7 @@ namespace LayoutBXLYT
|
|||
writer.WriteSignature(Signature);
|
||||
if (Data != null)
|
||||
{
|
||||
writer.Write(Data.Length);
|
||||
writer.Write(Data.Length + 8);
|
||||
writer.Write(Data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,11 +114,15 @@ namespace LayoutBXLYT
|
|||
{
|
||||
foreach (var file in IFileInfo.ArchiveParent.Files)
|
||||
{
|
||||
if (Utils.GetExtension(file.FileName) == ".bclim")
|
||||
if (Utils.GetExtension(file.FileName) == ".tpl")
|
||||
{
|
||||
BCLIM bclim = (BCLIM)file.OpenFile();
|
||||
file.FileFormat = bclim;
|
||||
textures.Add(bclim.FileName, bclim);
|
||||
TPL tpl = (TPL)file.OpenFile();
|
||||
file.FileFormat = tpl;
|
||||
foreach (var tex in tpl.IconTextureList)
|
||||
{
|
||||
if (!textures.ContainsKey(tex.Text))
|
||||
textures.Add(tex.Text, tex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,6 +208,8 @@ namespace LayoutBXLYT
|
|||
|
||||
public void Read(FileReader reader, BRLYT brlyt)
|
||||
{
|
||||
IsBigEndian = reader.ByteOrder == Syroot.BinaryData.ByteOrder.BigEndian;
|
||||
|
||||
LayoutInfo = new LYT1();
|
||||
TextureList = new TXL1();
|
||||
MaterialList = new MAT1();
|
||||
|
@ -333,7 +339,6 @@ namespace LayoutBXLYT
|
|||
break;
|
||||
}
|
||||
|
||||
section.Signature = Signature;
|
||||
section.SectionSize = SectionSize;
|
||||
|
||||
reader.SeekBegin(pos + SectionSize);
|
||||
|
@ -351,6 +356,7 @@ namespace LayoutBXLYT
|
|||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.SetByteOrder(IsBigEndian);
|
||||
writer.WriteSignature(Magic);
|
||||
writer.Write(ByteOrderMark);
|
||||
writer.Write(HeaderSize);
|
||||
|
|
|
@ -374,6 +374,7 @@ namespace FirstPlugin
|
|||
STFileSaver.SaveFileFormat(this, sfd.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
public void Read(FileReader reader)
|
||||
{
|
||||
ImageKey = "Texture";
|
||||
|
|
|
@ -293,6 +293,15 @@
|
|||
<Compile Include="FileFormats\Font\BFTTF.cs" />
|
||||
<Compile Include="FileFormats\HyruleWarriors\G1M\G1M.cs" />
|
||||
<Compile Include="FileFormats\HyruleWarriors\LINKDATA.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\AlphaCompare.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\BlendMode.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\FontShadowParameter.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\IndirectParameter.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\ProjectionTexGenParam.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\TevStage.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\TexCoordGen.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\TextureRef.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\TextureTransform.cs" />
|
||||
<Compile Include="FileFormats\Layout\CTR\BCLYT.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\FLYT.cs" />
|
||||
<Compile Include="FileFormats\Layout\PaneTreeWrapper.cs" />
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.textureListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.textConverterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.backColorDisplay)).BeginInit();
|
||||
this.stToolStrip1.SuspendLayout();
|
||||
this.stMenuStrip1.SuspendLayout();
|
||||
|
@ -114,7 +115,8 @@
|
|||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.openToolStripMenuItem,
|
||||
this.clearWorkspaceToolStripMenuItem});
|
||||
this.clearWorkspaceToolStripMenuItem,
|
||||
this.saveToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
|
@ -122,14 +124,14 @@
|
|||
// openToolStripMenuItem
|
||||
//
|
||||
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(127, 22);
|
||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.openToolStripMenuItem.Text = "Open";
|
||||
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
|
||||
//
|
||||
// clearWorkspaceToolStripMenuItem
|
||||
//
|
||||
this.clearWorkspaceToolStripMenuItem.Name = "clearWorkspaceToolStripMenuItem";
|
||||
this.clearWorkspaceToolStripMenuItem.Size = new System.Drawing.Size(127, 22);
|
||||
this.clearWorkspaceToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.clearWorkspaceToolStripMenuItem.Text = "Clear Files";
|
||||
this.clearWorkspaceToolStripMenuItem.Click += new System.EventHandler(this.clearWorkspaceToolStripMenuItem_Click);
|
||||
//
|
||||
|
@ -151,17 +153,24 @@
|
|||
// textureListToolStripMenuItem
|
||||
//
|
||||
this.textureListToolStripMenuItem.Name = "textureListToolStripMenuItem";
|
||||
this.textureListToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.textureListToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
|
||||
this.textureListToolStripMenuItem.Text = "Texture List";
|
||||
this.textureListToolStripMenuItem.Click += new System.EventHandler(this.textureListToolStripMenuItem_Click);
|
||||
//
|
||||
// textConverterToolStripMenuItem
|
||||
//
|
||||
this.textConverterToolStripMenuItem.Name = "textConverterToolStripMenuItem";
|
||||
this.textConverterToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.textConverterToolStripMenuItem.Size = new System.Drawing.Size(150, 22);
|
||||
this.textConverterToolStripMenuItem.Text = "Text Converter";
|
||||
this.textConverterToolStripMenuItem.Click += new System.EventHandler(this.textConverterToolStripMenuItem_Click);
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveToolStripMenuItem.Text = "Save As";
|
||||
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
|
||||
//
|
||||
// LayoutEditor
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
|
@ -203,5 +212,6 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem clearWorkspaceToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem textConverterToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ using WeifenLuo.WinFormsUI.ThemeVS2015;
|
|||
using Toolbox.Library.IO;
|
||||
using Toolbox.Library;
|
||||
using FirstPlugin;
|
||||
using LayoutBXLYT.Cafe;
|
||||
|
||||
namespace LayoutBXLYT
|
||||
{
|
||||
|
@ -416,5 +417,20 @@ namespace LayoutBXLYT
|
|||
TextConverter.Show(dockPanel1, DockState.DockLeft);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ActiveLayout != null && ActiveLayout.FileInfo.CanSave)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = Utils.GetAllFilters(ActiveLayout.FileInfo);
|
||||
sfd.FileName = ActiveLayout.FileInfo.FileName;
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
STFileSaver.SaveFileFormat(ActiveLayout.FileInfo, sfd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
|||
using System.Windows.Forms;
|
||||
using FirstPlugin;
|
||||
using Toolbox.Library.Forms;
|
||||
using LayoutBXLYT.Cafe;
|
||||
|
||||
namespace LayoutBXLYT
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Toolbox.Library.Forms;
|
||||
using LayoutBXLYT.Cafe;
|
||||
|
||||
namespace LayoutBXLYT
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ using OpenTK;
|
|||
using Toolbox.Library;
|
||||
using Toolbox.Library.Rendering;
|
||||
using Toolbox.Library.IO;
|
||||
using LayoutBXLYT.Cafe;
|
||||
|
||||
namespace LayoutBXLYT
|
||||
{
|
||||
|
@ -306,9 +307,9 @@ namespace LayoutBXLYT
|
|||
textureMap0 = mat.GetTexture(0);
|
||||
|
||||
if (Textures.ContainsKey(textureMap0))
|
||||
{
|
||||
BindGLTexture(mat.TextureMaps[0], Textures[textureMap0]);
|
||||
}
|
||||
else
|
||||
GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.RenderableTex.TexID);
|
||||
|
||||
TexCoords = new Vector2[] {
|
||||
pane.TexCoords[0].TopLeft.ToTKVector2(),
|
||||
|
@ -354,7 +355,7 @@ namespace LayoutBXLYT
|
|||
}
|
||||
}
|
||||
|
||||
private static void BindGLTexture(BFLYT.TextureRef tex, STGenericTexture texture)
|
||||
private static void BindGLTexture(TextureRef tex, STGenericTexture texture)
|
||||
{
|
||||
if (texture.RenderableTex == null || !texture.RenderableTex.GLInitialized)
|
||||
texture.LoadOpenGLTexture();
|
||||
|
@ -370,34 +371,34 @@ namespace LayoutBXLYT
|
|||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, ConvertMinFilterMode(tex.MinFilterMode));
|
||||
}
|
||||
|
||||
private static int ConvertTextureWrap(BFLYT.TextureRef.WrapMode wrapMode)
|
||||
private static int ConvertTextureWrap(TextureRef.WrapMode wrapMode)
|
||||
{
|
||||
switch (wrapMode)
|
||||
{
|
||||
case BFLYT.TextureRef.WrapMode.Clamp: return (int)TextureWrapMode.Clamp;
|
||||
case BFLYT.TextureRef.WrapMode.Mirror: return (int)TextureWrapMode.MirroredRepeat;
|
||||
case BFLYT.TextureRef.WrapMode.Repeat: return (int)TextureWrapMode.Repeat;
|
||||
case TextureRef.WrapMode.Clamp: return (int)TextureWrapMode.Clamp;
|
||||
case TextureRef.WrapMode.Mirror: return (int)TextureWrapMode.MirroredRepeat;
|
||||
case TextureRef.WrapMode.Repeat: return (int)TextureWrapMode.Repeat;
|
||||
default: return (int)TextureWrapMode.Clamp;
|
||||
}
|
||||
}
|
||||
|
||||
private static int ConvertMagFilterMode(BFLYT.TextureRef.FilterMode filterMode)
|
||||
private static int ConvertMagFilterMode(TextureRef.FilterMode filterMode)
|
||||
{
|
||||
switch (filterMode)
|
||||
{
|
||||
case BFLYT.TextureRef.FilterMode.Linear: return (int)TextureMagFilter.Linear;
|
||||
case BFLYT.TextureRef.FilterMode.Near: return (int)TextureMagFilter.Nearest;
|
||||
default: return (int)BFLYT.TextureRef.FilterMode.Linear;
|
||||
case TextureRef.FilterMode.Linear: return (int)TextureMagFilter.Linear;
|
||||
case TextureRef.FilterMode.Near: return (int)TextureMagFilter.Nearest;
|
||||
default: return (int)TextureRef.FilterMode.Linear;
|
||||
}
|
||||
}
|
||||
|
||||
private static int ConvertMinFilterMode(BFLYT.TextureRef.FilterMode filterMode)
|
||||
private static int ConvertMinFilterMode(TextureRef.FilterMode filterMode)
|
||||
{
|
||||
switch (filterMode)
|
||||
{
|
||||
case BFLYT.TextureRef.FilterMode.Linear: return (int)TextureMinFilter.Linear;
|
||||
case BFLYT.TextureRef.FilterMode.Near: return (int)TextureMinFilter.Nearest;
|
||||
default: return (int)BFLYT.TextureRef.FilterMode.Linear;
|
||||
case TextureRef.FilterMode.Linear: return (int)TextureMinFilter.Linear;
|
||||
case TextureRef.FilterMode.Near: return (int)TextureMinFilter.Nearest;
|
||||
default: return (int)TextureRef.FilterMode.Linear;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -366,7 +366,7 @@ namespace FirstPlugin
|
|||
Formats.Add(typeof(CSAB));
|
||||
Formats.Add(typeof(CMB));
|
||||
Formats.Add(typeof(G1T));
|
||||
Formats.Add(typeof(LayoutBXLYT.BFLYT));
|
||||
Formats.Add(typeof(LayoutBXLYT.Cafe.BFLYT));
|
||||
Formats.Add(typeof(LayoutBXLYT.BCLYT));
|
||||
Formats.Add(typeof(LayoutBXLYT.BRLYT));
|
||||
Formats.Add(typeof(ZSI));
|
||||
|
|
22
Switch_Toolbox_Library/IO/Bits/Bit.cs
Normal file
22
Switch_Toolbox_Library/IO/Bits/Bit.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Toolbox.Library.IO
|
||||
{
|
||||
class Bit
|
||||
{
|
||||
//From https://github.com/shibbo/flyte/blob/337383c01c50dff155e4b4e170d248118db0c0aa/flyte/utils/Bit.cs
|
||||
public static uint ExtractBits(uint val, int numBits, int startBit)
|
||||
{
|
||||
uint mask = 0;
|
||||
|
||||
for (int i = startBit; i < startBit + numBits; i++)
|
||||
mask |= (0x80000000 >> i);
|
||||
|
||||
return (val & mask) >> (32 - (startBit + numBits));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -97,7 +97,7 @@ namespace Toolbox.Library.IO
|
|||
{
|
||||
long pos = Position;
|
||||
WriteString(text);
|
||||
Seek(pos + fixedSize);
|
||||
SeekBegin(pos + fixedSize);
|
||||
}
|
||||
|
||||
//Writes the total size of a section as a uint.
|
||||
|
@ -117,7 +117,7 @@ namespace Toolbox.Library.IO
|
|||
long pos = Position;
|
||||
using (TemporarySeek(target, SeekOrigin.Begin))
|
||||
{
|
||||
Write((uint)pos - (uint)RelativeOffsetPosition);
|
||||
Write((uint)(pos - RelativeOffsetPosition));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Toolbox.Library
|
|||
{
|
||||
// Opens the file format automatically (may take longer to open the archive file)
|
||||
[Browsable(false)]
|
||||
public bool OpenFileFormatOnLoad { get; set; }
|
||||
public virtual bool OpenFileFormatOnLoad { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
// The source file. If an archive is in another archive, this is necessary to get the original path
|
||||
|
|
|
@ -300,6 +300,7 @@
|
|||
<Compile Include="Interfaces\ModelData\IMeshContainer.cs" />
|
||||
<Compile Include="Interfaces\Textures\ITextureContainer.cs" />
|
||||
<Compile Include="Interfaces\Forms\IUpdateForm.cs" />
|
||||
<Compile Include="IO\Bits\Bit.cs" />
|
||||
<Compile Include="IO\Colors\STColor16.cs" />
|
||||
<Compile Include="IO\Extensions\ColorExtensions.cs" />
|
||||
<Compile Include="IO\Extensions\StreamExport.cs" />
|
||||
|
|
|
@ -993,7 +993,7 @@ namespace Toolbox
|
|||
|
||||
private void MainForm_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (!Runtime.EnableDragDrop) return;
|
||||
if (!Runtime.EnableDragDrop) return;
|
||||
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Toolbox
|
|||
{
|
||||
public class UpdateProgram
|
||||
{
|
||||
static Release[] releases;
|
||||
static List<Release> Releases = new List<Release>();
|
||||
public static bool CanUpdate = false;
|
||||
public static bool Downloaded = false;
|
||||
public static Release LatestRelease;
|
||||
|
@ -28,7 +28,7 @@ namespace Toolbox
|
|||
GetReleases(client).Wait();
|
||||
GetCommits(client).Wait();
|
||||
|
||||
foreach (Release latest in releases)
|
||||
foreach (Release latest in Releases)
|
||||
{
|
||||
Console.WriteLine(
|
||||
"The latest release is tagged at {0} and is named {1} commit {2} date {3}",
|
||||
|
@ -56,6 +56,8 @@ namespace Toolbox
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Releases.Clear();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -117,10 +119,9 @@ namespace Toolbox
|
|||
|
||||
static async Task GetReleases(GitHubClient client)
|
||||
{
|
||||
List<Release> Releases = new List<Release>();
|
||||
Releases = new List<Release>();
|
||||
foreach (Release r in await client.Repository.Release.GetAll("KillzXGaming", "Switch-Toolbox"))
|
||||
Releases.Add(r);
|
||||
releases = Releases.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue