1
0
mirror of synced 2024-11-30 18:24:39 +01:00

Add alot of bflyt progress

This commit is contained in:
KillzXGaming 2019-08-27 16:38:06 -04:00
parent 78cb9177de
commit bb77a80ad3
20 changed files with 1326 additions and 16 deletions

View File

@ -7,10 +7,13 @@ using Toolbox;
using System.Windows.Forms;
using Toolbox.Library;
using Toolbox.Library.IO;
using FirstPlugin.Forms;
using Syroot.Maths;
using SharpYaml.Serialization;
namespace FirstPlugin
{
public class BFLYT : IFileFormat
public class BFLYT : IFileFormat, IEditor<LayoutEditor>, IConvertableTextFormat
{
public FileType FileType { get; set; } = FileType.Layout;
@ -38,29 +41,106 @@ namespace FirstPlugin
}
}
public void Load(System.IO.Stream stream)
#region Text Converter Interface
public TextFileType TextFileType => TextFileType.Xml;
public bool CanConvertBack => true;
public string ConvertToString()
{
var serializerSettings = new SerializerSettings()
{
// EmitTags = false
};
serializerSettings.DefaultStyle = SharpYaml.YamlStyle.Any;
serializerSettings.ComparerForKeySorting = null;
serializerSettings.RegisterTagMapping("Header", typeof(Header));
var serializer = new Serializer(serializerSettings);
string yaml = serializer.Serialize(header, typeof(Header));
return yaml;
}
public void ConvertFromString(string text)
{
}
#endregion
public LayoutEditor OpenForm()
{
LayoutEditor editor = new LayoutEditor();
editor.Dock = DockStyle.Fill;
editor.LoadBflyt(header, FileName);
return editor;
}
public void FillEditor(UserControl control) {
((LayoutEditor)control).LoadBflyt(header, FileName);
}
private Header header;
public void Load(System.IO.Stream stream)
{
CanSave = true;
header = new Header();
header.Read(new FileReader(stream), FileName);
}
public void Unload()
{
}
public void Save(System.IO.Stream stream)
{
public void Save(System.IO.Stream stream) {
header.Write(new FileWriter(stream));
}
//Thanks to SwitchThemes for flags, and enums
//https://github.com/FuryBaguette/SwitchLayoutEditor/tree/master/SwitchThemesCommon
public class Header
{
public string FileName { get; set; }
private const string Magic = "FLYT";
private ushort ByteOrderMark;
private ushort HeaderSize;
public uint Version;
internal uint Version;
public void Read(FileReader reader)
public string VersionFull
{
get
{
var major = Version >> 24;
var minor = Version >> 16 & 0xFF;
var micro = Version >> 8 & 0xFF;
var micro2 = Version & 0xFF;
return $"{major} {minor} {micro} {micro2}";
}
}
public LYT1 LayoutInfo { get; set; }
public TXL1 TextureList { get; set; }
public MAT1 MaterialList { get; set; }
public FNL1 FontList { get; set; }
// private List<SectionCommon> Sections;
public PAN1 RootPane { get; set; }
public GRP1 RootGroup { get; set; }
// public List<PAN1> Panes = new List<PAN1>();
public void Read(FileReader reader, string fileName)
{
FileName = fileName;
reader.SetByteOrder(true);
reader.ReadSignature(4, Magic);
ByteOrderMark = reader.ReadUInt16();
reader.CheckByteOrderMark(ByteOrderMark);
@ -70,6 +150,12 @@ namespace FirstPlugin
ushort sectionCount = reader.ReadUInt16();
reader.ReadUInt16(); //Padding
bool setRoot = false;
bool setGroupRoot = false;
BasePane currentPane = null;
BasePane parentPane = null;
reader.SeekBegin(HeaderSize);
for (int i = 0; i < sectionCount; i++)
{
@ -78,10 +164,91 @@ namespace FirstPlugin
string Signature = reader.ReadString(4, Encoding.ASCII);
uint SectionSize = reader.ReadUInt32();
Console.WriteLine($"{Signature} {SectionSize}");
SectionCommon section = new SectionCommon();
switch (Signature)
{
case "lyt1":
LayoutInfo = new LYT1(reader);
break;
case "txl1":
TextureList = new TXL1(reader);
break;
case "fnl1":
FontList = new FNL1(reader);
break;
case "mat1":
MaterialList = new MAT1(reader, this);
break;
case "pan1":
var panel = new PAN1(reader);
if (!setRoot)
{
RootPane = panel;
setRoot = true;
}
SetPane(panel, parentPane);
currentPane = panel;
break;
case "pic1":
var picturePanel = new PIC1(reader);
SetPane(picturePanel, parentPane);
currentPane = picturePanel;
break;
case "txt1":
var textPanel = new TXT1(reader);
SetPane(textPanel, parentPane);
currentPane = textPanel;
break;
case "bnd1":
var boundsPanel = new BND1(reader);
SetPane(boundsPanel, parentPane);
currentPane = boundsPanel;
break;
case "prt1":
var partsPanel = new PRT1(reader);
SetPane(partsPanel, parentPane);
currentPane = partsPanel;
break;
case "wnd1":
var windowPanel = new PRT1(reader);
SetPane(windowPanel, parentPane);
currentPane = windowPanel;
break;
case "cnt1":
break;
case "pas1":
if (currentPane != null)
parentPane = currentPane;
break;
case "pae1":
currentPane = parentPane;
parentPane = currentPane.Parent;
break;
case "grp1":
var groupPanel = new GRP1(reader, this);
if (!setGroupRoot)
{
RootGroup = groupPanel;
setGroupRoot = true;
}
break;
case "grs1":
break;
case "gre1":
break;
case "usd1":
break;
//If the section is not supported store the raw bytes
default:
section.Data = reader.ReadBytes((int)SectionSize);
@ -91,8 +258,16 @@ namespace FirstPlugin
section.Signature = Signature;
section.SectionSize = SectionSize;
reader.SeekBegin(pos + SectionSize + 0x10);
reader.Align(16);
reader.SeekBegin(pos + SectionSize);
}
}
private void SetPane(BasePane pane, BasePane parentPane)
{
if (parentPane != null)
{
parentPane.Childern.Add(pane);
pane.Parent = parentPane;
}
}
@ -106,9 +281,6 @@ namespace FirstPlugin
writer.Write(ushort.MaxValue); //Reserve space for section count later
writer.Seek(2); //padding
//Write the total file size
using (writer.TemporarySeek(0x0C, System.IO.SeekOrigin.Begin))
{
@ -117,8 +289,719 @@ namespace FirstPlugin
}
}
public class BasePane : SectionCommon
{
public BasePane Parent { get; set; }
public List<BasePane> Childern { get; set; } = new List<BasePane>();
}
public class TexCoord
{
public Vector2F TopLeft { get; set; }
public Vector2F TopRight { get; set; }
public Vector2F BottomLeft { get; set; }
public Vector2F BottomRight { get; set; }
public TexCoord()
{
TopLeft = new Vector2F(0, 0);
TopRight = new Vector2F(1, 0);
BottomLeft = new Vector2F(0, 1);
BottomRight = new Vector2F(1, 1);
}
}
public class TXT1 : PAN1
{
public TXT1() : base()
{
}
public OriginX HorizontalAlignment
{
get => (OriginX)((TextAlignment >> 2) & 0x3);
set
{
TextAlignment &= unchecked((byte)(~0xC));
TextAlignment |= (byte)((byte)(value) << 2);
}
}
public OriginX VerticalAlignment
{
get => (OriginX)((TextAlignment) & 0x3);
set
{
TextAlignment &= unchecked((byte)(~0x3));
TextAlignment |= (byte)(value);
}
}
public ushort TextLength;
public ushort MaxTextLength;
public ushort MaterialIndex;
public ushort FontIndex;
public byte TextAlignment { get; set; }
public LineAlign LineAlignment { get; set; }
public float ItalicTilt { get; set; }
public STColor8 FontForeColor { get; set; }
public STColor8 FontBackColor { get; set; }
public Vector2F FontSize { get; set; }
public float CharacterSpace { get; set; }
public float LineSpace { get; set; }
public Vector2F ShadowXY { get; set; }
public Vector2F ShadowXYSize { get; set; }
public STColor8 ShadowForeColor { get; set; }
public STColor8 ShadowBackColor { get; set; }
public float ShadowItalic { get; set; }
public bool PerCharTransform
{
get { return (_flags & 0x10) != 0; }
set { _flags = value ? (byte)(_flags | 0x10) : unchecked((byte)(_flags & (~0x10))); }
}
public bool RestrictedTextLengthEnabled
{
get { return (_flags & 0x2) != 0; }
set { _flags = value ? (byte)(_flags | 0x2) : unchecked((byte)(_flags & (~0x2))); }
}
public bool ShadowEnabled
{
get { return (_flags & 1) != 0; }
set { _flags = value ? (byte)(_flags | 1) : unchecked((byte)(_flags & (~1))); }
}
private byte _flags;
public TXT1(FileReader reader) : base(reader)
{
TextLength = reader.ReadUInt16();
MaxTextLength = reader.ReadUInt16();
MaterialIndex = reader.ReadUInt16();
FontIndex = reader.ReadUInt16();
TextAlignment = reader.ReadByte();
LineAlignment = (LineAlign)reader.ReadByte();
_flags = reader.ReadByte();
reader.Seek(1); //padding
ItalicTilt = reader.ReadSingle();
uint textOffset = reader.ReadUInt32();
FontForeColor = STColor8.FromBytes(reader.ReadBytes(4));
FontBackColor = STColor8.FromBytes(reader.ReadBytes(4));
FontSize = reader.ReadVec2SY();
CharacterSpace = reader.ReadSingle();
LineSpace = reader.ReadSingle();
ShadowXY = reader.ReadVec2SY();
ShadowXYSize = reader.ReadVec2SY();
ShadowForeColor = STColor8.FromBytes(reader.ReadBytes(4));
ShadowBackColor = STColor8.FromBytes(reader.ReadBytes(4));
ShadowItalic = reader.ReadSingle();
}
public override void Write(FileWriter writer, Header header)
{
base.Write(writer, header);
writer.Write(TextLength);
writer.Write(MaxTextLength);
writer.Write(MaterialIndex);
writer.Write(FontIndex);
writer.Write(TextAlignment);
writer.Write(LineAlignment, false);
writer.Write(_flags);
writer.Seek(1);
writer.Write(ItalicTilt);
writer.Write(0); //text offset
writer.Write(FontForeColor.ToBytes());
writer.Write(FontBackColor.ToBytes());
writer.Write(FontSize);
writer.Write(CharacterSpace);
writer.Write(LineSpace);
writer.Write(ShadowXY);
writer.Write(ShadowXYSize);
writer.Write(ShadowForeColor.ToBytes());
writer.Write(ShadowBackColor.ToBytes());
writer.Write(ShadowItalic);
}
public enum BorderType : byte
{
Standard = 0,
DeleteBorder = 1,
RenderTwoCycles = 2,
};
public enum LineAlign : byte
{
Unspecified = 0,
Left = 1,
Center = 2,
Right = 3,
};
}
public class WND1 : PAN1
{
public WND1() : base()
{
}
public WND1(FileReader reader) : base(reader)
{
}
public override void Write(FileWriter writer, Header header)
{
base.Write(writer, header);
}
}
public class BND1 : PAN1
{
public BND1() : base()
{
}
public BND1(FileReader reader) : base(reader)
{
}
public override void Write(FileWriter writer, Header header)
{
base.Write(writer, header);
}
}
public class GRP1 : BasePane
{
public string Name { get; set; }
public List<string> Panes { get; set; } = new List<string>();
public GRP1() : base()
{
}
public GRP1(FileReader reader, Header header)
{
ushort numNodes = 0;
if (header.Version >= 0x05020000)
{
Name = reader.ReadString(34).Replace("\0", string.Empty);
numNodes = reader.ReadUInt16();
}
else
{
Name = reader.ReadString(24).Replace("\0", string.Empty);
numNodes = reader.ReadUInt16();
reader.Seek(2); //padding
}
for (int i = 0; i < numNodes; i++)
Panes.Add(reader.ReadString(24));
}
public override void Write(FileWriter writer, Header header)
{
if (header.Version >= 0x05020000)
{
writer.WriteString(Name, 34);
writer.Write((ushort)Panes.Count);
}
else
{
writer.WriteString(Name, 24);
writer.Write((ushort)Panes.Count);
writer.Seek(2);
}
for (int i = 0; i < Panes.Count; i++)
writer.WriteString(Panes[i], 24);
}
}
public class PRT1 : PAN1
{
public PRT1() : base()
{
}
public PRT1(FileReader reader) : base(reader)
{
}
public override void Write(FileWriter writer, Header header)
{
base.Write(writer, header);
}
}
public class PIC1 : PAN1
{
public TexCoord[] TexCoords { get; set; }
public STColor8 ColorTopLeft { get; set; }
public STColor8 ColorTopRight { get; set; }
public STColor8 ColorBottomLeft { get; set; }
public STColor8 ColorBottomRight { get; set; }
public ushort MaterialIndex { get; set; }
public PIC1() : base() {
ColorTopLeft = STColor8.White;
ColorTopRight = STColor8.White;
ColorBottomLeft = STColor8.White;
ColorBottomRight = STColor8.White;
MaterialIndex = 0;
TexCoords = new TexCoord[1];
TexCoords[0] = new TexCoord();
}
public PIC1(FileReader reader) : base(reader)
{
ColorTopLeft = STColor8.FromBytes(reader.ReadBytes(4));
ColorTopRight = STColor8.FromBytes(reader.ReadBytes(4));
ColorBottomLeft = STColor8.FromBytes(reader.ReadBytes(4));
ColorBottomRight = STColor8.FromBytes(reader.ReadBytes(4));
MaterialIndex = reader.ReadUInt16();
byte numUVs = reader.ReadByte();
reader.Seek(1); //padding
}
public override void Write(FileWriter writer, Header header)
{
base.Write(writer, header);
writer.Write(ColorTopLeft.ToBytes());
writer.Write(ColorTopRight.ToBytes());
writer.Write(ColorBottomLeft.ToBytes());
writer.Write(ColorBottomRight.ToBytes());
writer.Write(MaterialIndex);
writer.Write(TexCoords != null ? TexCoords.Length : 0);
}
}
public class PAN1 : BasePane
{
private byte _flags1;
private byte _flags2;
public bool Visible
{
get { return (_flags1 & 0x1) == 0x1; }
set {
if (value)
_flags1 |= 0x1;
else
_flags1 &= 0xFE;
}
}
public bool InfluenceAlpha
{
get { return (_flags1 & 0x2) == 0x2; }
set
{
if (value)
_flags1 |= 0x2;
else
_flags1 &= 0xFD;
}
}
public OriginX originX
{
get => (OriginX)((_flags2 & 0xC0) >> 6);
set
{
_flags2 &= unchecked((byte)(~0xC0));
_flags2 |= (byte)((byte)value << 6);
}
}
public OriginY originY
{
get => (OriginY)((_flags2 & 0x30) >> 4);
set
{
_flags2 &= unchecked((byte)(~0x30));
_flags2 |= (byte)((byte)value << 4);
}
}
public OriginX ParentOriginX
{
get => (OriginX)((_flags2 & 0xC) >> 2);
set
{
_flags2 &= unchecked((byte)(~0xC));
_flags2 |= (byte)((byte)value << 2);
}
}
public OriginY ParentOriginY
{
get => (OriginY)((_flags2 & 0x3));
set
{
_flags2 &= unchecked((byte)(~0x3));
_flags2 |= (byte)value;
}
}
public byte Alpha { get; set; }
public byte Unknown { get; set; }
public string Name { get; set; }
public string UserDataInfo { get; set; }
public Vector3F Translate;
public Vector3F Rotate;
public Vector2F Scale;
public float Width;
public float Height;
public PAN1() : base()
{
}
public PAN1(FileReader reader) : base()
{
_flags1 = reader.ReadByte();
_flags2 = reader.ReadByte();
Alpha = reader.ReadByte();
Unknown = reader.ReadByte();
Name = reader.ReadString(0x18).Replace("\0", string.Empty);
UserDataInfo = reader.ReadString(0x18).Replace("\0", string.Empty);
Translate = reader.ReadVec3SY();
Rotate = reader.ReadVec3SY();
Scale = reader.ReadVec2SY();
Width = reader.ReadSingle();
Height = reader.ReadSingle();
}
public override void Write(FileWriter writer, Header header)
{
writer.Write(_flags1);
writer.Write(_flags2);
writer.Write(Alpha);
writer.Write(Unknown);
writer.WriteString(Name, 0x18);
writer.WriteString(UserDataInfo, 0x18);
writer.Write(Translate);
writer.Write(Rotate);
writer.Write(Scale);
writer.Write(Width);
writer.Write(Height);
}
public enum OriginX : byte
{
Center = 0,
Left = 1,
Right = 2
};
public enum OriginY : byte
{
Center = 0,
Top = 1,
Bottom = 2
};
}
public class MAT1 : SectionCommon
{
public List<Material> Materials { get; set; }
public MAT1() {
Materials = new List<Material>();
}
public MAT1(FileReader reader, Header header) : base()
{
Materials = new List<Material>();
long pos = reader.Position;
ushort numMats = reader.ReadUInt16();
reader.Seek(2); //padding
uint[] offsets = reader.ReadUInt32s(numMats);
for (int i = 0; i < numMats; i++)
{
reader.SeekBegin(pos + offsets[i] - 8);
Materials.Add(new Material(reader, header));
}
}
public override void Write(FileWriter writer, Header header)
{
writer.Write((ushort)Materials.Count);
writer.Seek(2);
}
}
public class Material
{
public string Name { get; set; }
public STColor8 ForeColor { get; set; }
public STColor8 BackColor { get; set; }
public List<TextureRef> TextureMaps { get; set; }
public List<TextureTransform> TextureTransforms { get; set; }
private int flags;
private int unknown;
public Material()
{
TextureMaps = new List<TextureRef>();
TextureTransforms = new List<TextureTransform>();
}
public Material(FileReader reader, Header header) : base()
{
TextureMaps = new List<TextureRef>();
TextureTransforms = new List<TextureTransform>();
Name = reader.ReadString(0x1C).Replace("\0", string.Empty);
if (header.Version == 0x8030000)
{
flags = reader.ReadInt32();
unknown = reader.ReadInt32();
ForeColor = STColor8.FromBytes(reader.ReadBytes(4));
BackColor = STColor8.FromBytes(reader.ReadBytes(4));
}
else
{
ForeColor = STColor8.FromBytes(reader.ReadBytes(4));
BackColor = STColor8.FromBytes(reader.ReadBytes(4));
flags = reader.ReadInt32();
}
int texCount = flags & 3;
int mtxCount = (flags & 0xC) >> 2;
for (int i = 0; i < texCount; i++)
TextureMaps.Add(new TextureRef(reader));
for (int i = 0; i < mtxCount; i++)
TextureTransforms.Add(new TextureTransform(reader));
}
public void Write(FileWriter writer, Header header)
{
writer.WriteString(Name, 0x1C);
if (header.Version == 0x8030000)
{
writer.Write(flags);
writer.Write(unknown);
writer.Write(ForeColor);
writer.Write(BackColor);
}
else
{
writer.Write(ForeColor);
writer.Write(BackColor);
writer.Write(flags);
}
for (int i = 0; i < TextureMaps.Count; i++)
TextureMaps[i].Write(writer);
for (int i = 0; i < TextureTransforms.Count; i++)
TextureTransforms[i].Write(writer);
}
}
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);
}
}
public class TextureRef
{
public ushort ID;
public byte WrapS;
public byte WrapT;
public TextureRef() {}
public TextureRef(FileReader reader) {
ID = reader.ReadUInt16();
WrapS = reader.ReadByte();
WrapT = reader.ReadByte();
}
public void Write(FileWriter writer)
{
writer.Write(ID);
writer.Write(WrapS);
writer.Write(WrapT);
}
}
public class FNL1 : SectionCommon
{
public List<string> Fonts { get; set; }
public FNL1()
{
Fonts = new List<string>();
}
public FNL1(FileReader reader) : base()
{
Fonts = new List<string>();
ushort numFonts = reader.ReadUInt16();
reader.Seek(2); //padding
long pos = reader.Position;
uint[] offsets = reader.ReadUInt32s(numFonts);
for (int i = 0; i < offsets.Length; i++)
{
reader.SeekBegin(offsets[i] + pos);
}
}
public override void Write(FileWriter writer, Header header)
{
writer.Write((ushort)Fonts.Count);
writer.Seek(2);
//Fill empty spaces for offsets later
long pos = writer.Position;
writer.Write(new uint[Fonts.Count]);
//Save offsets and strings
for (int i = 0; i < Fonts.Count; i++)
{
writer.WriteUint32Offset(pos + (i * 4), pos);
writer.WriteString(Fonts[i]);
}
}
}
public class TXL1 : SectionCommon
{
public List<string> Textures { get; set; }
public TXL1()
{
Textures = new List<string>();
}
public TXL1(FileReader reader) : base()
{
Textures = new List<string>();
ushort numTextures = reader.ReadUInt16();
reader.Seek(2); //padding
long pos = reader.Position;
uint[] offsets = reader.ReadUInt32s(numTextures);
for (int i = 0; i < offsets.Length; i++)
{
reader.SeekBegin(offsets[i] + pos);
}
}
public override void Write(FileWriter writer, Header header)
{
writer.Write((ushort)Textures.Count);
writer.Seek(2);
//Fill empty spaces for offsets later
long pos = writer.Position;
writer.Write(new uint[Textures.Count]);
//Save offsets and strings
for (int i = 0; i < Textures.Count; i++)
{
writer.WriteUint32Offset(pos + (i * 4), pos);
writer.WriteString(Textures[i]);
}
}
}
public class LYT1 : SectionCommon
{
public bool DrawFromCenter { get; set; }
public float Width { get; set; }
public float Height { get; set; }
public float MaxPartsWidth { get; set; }
public float MaxPartsHeight { get; set; }
public string Name { get; set; }
public LYT1()
{
DrawFromCenter = false;
Width = 0;
Height = 0;
MaxPartsWidth = 0;
MaxPartsHeight = 0;
Name = "";
}
public LYT1(FileReader reader)
{
DrawFromCenter = reader.ReadBoolean();
reader.Seek(3); //padding
Width = reader.ReadSingle();
Height = reader.ReadSingle();
MaxPartsWidth = reader.ReadSingle();
MaxPartsHeight = reader.ReadSingle();
Name = reader.ReadZeroTerminatedString();
}
public override void Write(FileWriter writer, Header header)
{
writer.Write(DrawFromCenter);
writer.Seek(3);
writer.Write(Width);
writer.Write(Height);
writer.Write(MaxPartsWidth);
writer.Write(MaxPartsHeight);
writer.Write(Name);
}
}
public class SectionCommon
@ -128,7 +1011,7 @@ namespace FirstPlugin
internal byte[] Data { get; set; }
public void Write(FileWriter writer)
public virtual void Write(FileWriter writer, Header header)
{
writer.WriteSignature(Signature);
if (Data != null)

View File

@ -307,6 +307,12 @@
<Compile Include="GL\GXToOpenGL.cs" />
<Compile Include="GL\KCL_Render.cs" />
<Compile Include="GL\LM2_Render.cs" />
<Compile Include="GUI\BFLYT\LayoutViewer.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GUI\BFLYT\LayoutViewer.Designer.cs">
<DependentUpon>LayoutViewer.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BotwActorEditorControl.cs">
<SubType>UserControl</SubType>
</Compile>
@ -1069,6 +1075,9 @@
<EmbeddedResource Include="GUI\BFLYT\LayoutEditor.resx">
<DependentUpon>LayoutEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFLYT\LayoutViewer.resx">
<DependentUpon>LayoutViewer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFRES\BatchEditBaseAnimDataForm.resx">
<DependentUpon>BatchEditBaseAnimDataForm.cs</DependentUpon>
</EmbeddedResource>

View File

@ -1,4 +1,4 @@
namespace FirstPlugin.LayoutEditor
namespace FirstPlugin.Forms
{
partial class LayoutEditor
{
@ -28,9 +28,13 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LayoutEditor));
this.stMenuStrip1 = new Toolbox.Library.Forms.STMenuStrip();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.stToolStrip1 = new Toolbox.Library.Forms.STToolStrip();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.stMenuStrip1.SuspendLayout();
this.stToolStrip1.SuspendLayout();
this.SuspendLayout();
//
// stMenuStrip1
@ -49,15 +53,37 @@
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
this.editToolStripMenuItem.Text = "Edit";
//
// stToolStrip1
//
this.stToolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripButton1});
this.stToolStrip1.Location = new System.Drawing.Point(0, 24);
this.stToolStrip1.Name = "stToolStrip1";
this.stToolStrip1.Size = new System.Drawing.Size(836, 25);
this.stToolStrip1.TabIndex = 3;
this.stToolStrip1.Text = "stToolStrip1";
//
// toolStripButton1
//
this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton1.Name = "toolStripButton1";
this.toolStripButton1.Size = new System.Drawing.Size(23, 22);
this.toolStripButton1.Text = "toolStripButton1";
//
// LayoutEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stToolStrip1);
this.Controls.Add(this.stMenuStrip1);
this.Name = "LayoutEditor";
this.Size = new System.Drawing.Size(836, 518);
this.stMenuStrip1.ResumeLayout(false);
this.stMenuStrip1.PerformLayout();
this.stToolStrip1.ResumeLayout(false);
this.stToolStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -67,5 +93,7 @@
private Toolbox.Library.Forms.STMenuStrip stMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private Toolbox.Library.Forms.STToolStrip stToolStrip1;
private System.Windows.Forms.ToolStripButton toolStripButton1;
}
}

View File

@ -8,13 +8,37 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FirstPlugin.LayoutEditor
namespace FirstPlugin.Forms
{
public partial class LayoutEditor : UserControl
{
public List<BFLYT.Header> LayoutFiles = new List<BFLYT.Header>();
public enum DockLayout
{
Default,
Animation,
}
public LayoutEditor()
{
InitializeComponent();
}
public void LoadBflyt(BFLYT.Header header, string fileName)
{
LayoutViewer viewer = new LayoutViewer();
this.Controls.Add(viewer);
}
public void LoadBflan()
{
}
public void InitalizeEditors()
{
}
}
}

View File

@ -120,4 +120,23 @@
<metadata name="stMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="stToolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>141, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="toolStripButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
</root>

View File

@ -0,0 +1,45 @@
namespace FirstPlugin.Forms
{
partial class LayoutViewer
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// LayoutViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "LayoutViewer";
this.Size = new System.Drawing.Size(625, 414);
this.ResumeLayout(false);
}
#endregion
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FirstPlugin.Forms
{
public partial class LayoutViewer : UserControl
{
public LayoutViewer()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -378,8 +378,9 @@ namespace FirstPlugin
Formats.Add(typeof(CTR.NCCH.RomFS));
Formats.Add(typeof(DKCTF.MSBT));
Formats.Add(typeof(DKCTF.PAK));
// Formats.Add(typeof(MSBP));
// Formats.Add(typeof(BFGRP));
// Formats.Add(typeof(MSBP));
// Formats.Add(typeof(BFGRP));
//Unfinished wip formats not ready for use
if (Runtime.DEVELOPER_DEBUG_MODE)

View File

@ -50,6 +50,14 @@ namespace Toolbox.Library.IO
Write(v.W);
}
public void Write(STColor color) {
Write(color.ToBytes());
}
public void Write(STColor8 color) {
Write(color.ToBytes());
}
public void WriteStruct<T>(T item) => Write(item.StructToBytes(ByteOrder == ByteOrder.BigEndian));
public void WriteSignature(string value)

View File

@ -57,6 +57,25 @@ namespace Toolbox.Library
A = 1;
}
public STColor(float r, float g, float b, float a)
{
R = r;
G = g;
B = b;
A = a;
}
public byte[] ToBytes()
{
return new byte[]
{
(byte)Utils.FloatToIntClamp(R),
(byte)Utils.FloatToIntClamp(G),
(byte)Utils.FloatToIntClamp(B),
(byte)Utils.FloatToIntClamp(A),
};
}
public override string ToString()
{
return String.Format("R:{0} G:{1} B:{2} A:{3}", R, G, B, A);
@ -66,5 +85,10 @@ namespace Toolbox.Library
{
return String.Format("R:{0:X2} G:{1:X2} B:{2:X2} A:{3:X2}", R, G, B, A);
}
public static STColor White
{
get { return new STColor(1, 1, 1, 1); }
}
}
}

View File

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Toolbox.Library
{
//Class that contains colors and useful color related methods
public class STColor8
{
public byte R { get; set; }
public byte G { get; set; }
public byte B { get; set; }
public byte A { get; set; }
public Color Color
{
get
{
return Color.FromArgb(A, R, G, B);
}
set
{
var color = value;
R = color.R;
G = color.G;
B = color.B;
A = color.A;
}
}
public static STColor8 FromBytes(byte[] color)
{
STColor8 col = new STColor8();
col.R = color[0];
col.G = color[1];
col.B = color[2];
col.A = color[3];
return col;
}
public STColor8()
{
R = 255;
G = 255;
B = 255;
A = 255;
}
public STColor8(byte r, byte g, byte b, byte a)
{
R = r;
G = g;
B = b;
A = a;
}
public byte[] ToBytes()
{
return new byte[] { R, G, B, A, };
}
public override string ToString()
{
return String.Format("R:{0} G:{1} B:{2} A:{3}", R, G, B, A);
}
public string ToHexString()
{
return String.Format("R:{0:X2} G:{1:X2} B:{2:X2} A:{3:X2}", R, G, B, A);
}
public static STColor8 White
{
get { return new STColor8(255, 255, 255, 255); }
}
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.Forms;
using System.Windows.Forms;
namespace Toolbox.Library
{
/// <summary>
/// Represets a form to load from a <see cref="Form"/> for an <see cref="IFileFormat"/>.
/// </summary>
public interface IEditorForm<T> where T : Form
{
T OpenForm();
void FillEditor(Form Editor);
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Toolbox.Library
{
public interface IEnableMdiContainer
{
}
}

View File

@ -292,7 +292,9 @@
<Compile Include="Interfaces\FileFormatting\ILeaveOpenOnLoad.cs" />
<Compile Include="Interfaces\FileFormatting\IPropertyContainer.cs" />
<Compile Include="Interfaces\FileFormatting\ISaveOpenedFileStream.cs" />
<Compile Include="Interfaces\Forms\IEditorForm.cs" />
<Compile Include="Interfaces\IMainForm.cs" />
<Compile Include="Interfaces\IMdiContainer.cs" />
<Compile Include="Interfaces\Textures\ITextureIconLoader.cs" />
<Compile Include="Interfaces\Utility\ICloneableNode.cs" />
<Compile Include="Interfaces\ModelData\IMeshContainer.cs" />
@ -305,6 +307,7 @@
<Compile Include="IO\HSVPixel.cs" />
<Compile Include="IO\IOComoon.cs" />
<Compile Include="IO\STColor.cs" />
<Compile Include="IO\STColor8.cs" />
<Compile Include="IO\SubStream.cs" />
<Compile Include="Rendering\GenericModelRenderer\GenericModelRenderer.cs" />
<Compile Include="Rendering\GenericModelRenderer\GenericRenderedObject.cs" />

Binary file not shown.

View File

@ -300,6 +300,17 @@ namespace Toolbox
form.MdiParent = this;
form.Show();
HasEditorActive = true;
}
else if (inter.IsGenericType && inter.GetGenericTypeDefinition() == typeof(IEditorForm<>))
{
MethodInfo method = objectType.GetMethod("OpenForm");
var form = (Form)method.Invoke(file, new object[0]);
TabDupeIndex = 0;
form.Text = CheckTabDupes(((IFileFormat)file).FileName);
form.MdiParent = this;
form.Show();
HasEditorActive = true;
}
}

View File

@ -500,6 +500,9 @@
<Content Include="Lib\VGAudio.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\WeifenLuo.WinFormsUI.Docking.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="LZ4.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>