Add all the newest changes.
Add support for bayonetta/astral chain dat. Add support for darc archives. Support previewing window panes for bflyt (1 frame atm with around kind) Add bflan reading. Saving needs more testing and will be enabled soon. Bflyt editor will keep the editor open within an archive when saved. A custom dialog will be added soon to customize saving parameters. Bflims will be loaded if in the same folder as the bflyt when opened.
This commit is contained in:
parent
0a3fada53a
commit
32fb5444e7
157
File_Format_Library/FileFormats/Archives/DARC.cs
Normal file
157
File_Format_Library/FileFormats/Archives/DARC.cs
Normal file
@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using Toolbox;
|
||||
using System.Windows.Forms;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.IO;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class DARC : IArchiveFile, IFileFormat, ILeaveOpenOnLoad
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Archive;
|
||||
|
||||
public bool CanSave { get; set; }
|
||||
public string[] Description { get; set; } = new string[] { "DARC" };
|
||||
public string[] Extension { get; set; } = new string[] { "*.arc", "*.darc" };
|
||||
public string FileName { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
public IFileInfo IFileInfo { get; set; }
|
||||
|
||||
public bool CanAddFiles { get; set; }
|
||||
public bool CanRenameFiles { get; set; }
|
||||
public bool CanReplaceFiles { get; set; }
|
||||
public bool CanDeleteFiles { get; set; }
|
||||
|
||||
public bool Identify(System.IO.Stream stream)
|
||||
{
|
||||
using (var reader = new Toolbox.Library.IO.FileReader(stream, true))
|
||||
{
|
||||
return reader.CheckSignature(4, "darc");
|
||||
}
|
||||
}
|
||||
|
||||
public Type[] Types
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Type> types = new List<Type>();
|
||||
return types.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public List<FileEntry> files = new List<FileEntry>();
|
||||
|
||||
public IEnumerable<ArchiveFileInfo> Files => files;
|
||||
|
||||
public void ClearFiles() { files.Clear(); }
|
||||
|
||||
public uint Version;
|
||||
public ushort Bom;
|
||||
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
using (var reader = new FileReader(stream, true))
|
||||
{
|
||||
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
|
||||
reader.ReadSignature(4, "darc");
|
||||
Bom = reader.ReadUInt16();
|
||||
reader.CheckByteOrderMark(Bom);
|
||||
ushort headerLength = reader.ReadUInt16();
|
||||
|
||||
Version = reader.ReadUInt32();
|
||||
uint FileSize = reader.ReadUInt32();
|
||||
uint FileTableOffset = reader.ReadUInt32();
|
||||
uint FileTableLength = reader.ReadUInt32();
|
||||
uint FileDataOffset = reader.ReadUInt32();
|
||||
|
||||
Console.WriteLine("Version " + Version);
|
||||
Console.WriteLine("FileTableOffset " + FileTableOffset);
|
||||
Console.WriteLine("FileTableLength " + FileTableLength);
|
||||
Console.WriteLine("FileDataOffset " + FileDataOffset);
|
||||
|
||||
uint endOfTable = FileDataOffset + FileTableLength;
|
||||
|
||||
List<NodeEntry> entries = new List<NodeEntry>();
|
||||
reader.SeekBegin(FileTableOffset);
|
||||
entries.Add(new NodeEntry(reader));
|
||||
for (int i = 0; i < entries[0].Size - 1; i++)
|
||||
entries.Add(new NodeEntry(reader));
|
||||
|
||||
for (int i = 0; i < entries.Count; i++)
|
||||
entries[i].Name = ReadCStringW(reader);
|
||||
|
||||
for (int i = 0; i < entries.Count; i++)
|
||||
{
|
||||
string Name = entries[i].Name;
|
||||
if (entries[i].IsFolder)
|
||||
{
|
||||
for (int s = 0; s < entries[i].Size; s++)
|
||||
entries[i].FullName += $"{Name}/";
|
||||
}
|
||||
else
|
||||
entries[i].FullName = Name;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entries.Count; i++)
|
||||
{
|
||||
if (!entries[i].IsFolder)
|
||||
{
|
||||
var file = new FileEntry();
|
||||
file.FileName = entries[i].FullName;
|
||||
file.FileDataStream = new SubStream(reader.BaseStream, entries[i].Offset, entries[i].Size);
|
||||
files.Add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ReadCStringW(FileReader reader) => string.Concat(Enumerable.Range(0, 999).Select(_ => (char)reader.ReadInt16()).TakeWhile(c => c != 0));
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Save(System.IO.Stream stream)
|
||||
{
|
||||
}
|
||||
|
||||
public bool AddFile(ArchiveFileInfo archiveFileInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DeleteFile(ArchiveFileInfo archiveFileInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public class NodeEntry
|
||||
{
|
||||
public uint NameOffset;
|
||||
public uint Size;
|
||||
public uint Offset;
|
||||
|
||||
public bool IsFolder => (NameOffset >> 24) == 1;
|
||||
|
||||
public string Name;
|
||||
|
||||
public string FullName;
|
||||
|
||||
public NodeEntry(FileReader reader)
|
||||
{
|
||||
NameOffset = reader.ReadUInt32();
|
||||
Offset = reader.ReadUInt32();
|
||||
Size = reader.ReadUInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public class FileEntry : ArchiveFileInfo
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
132
File_Format_Library/FileFormats/Archives/DAT_Bayonetta.cs
Normal file
132
File_Format_Library/FileFormats/Archives/DAT_Bayonetta.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.IO;
|
||||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class DAT_Bayonetta : IArchiveFile, IFileFormat, ILeaveOpenOnLoad
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Archive;
|
||||
|
||||
public bool CanSave { get; set; }
|
||||
public string[] Description { get; set; } = new string[] { "Platinum Games Archive" };
|
||||
public string[] Extension { get; set; } = new string[] { "*.pkz" };
|
||||
public string FileName { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
public IFileInfo IFileInfo { get; set; }
|
||||
|
||||
public bool CanAddFiles { get; set; }
|
||||
public bool CanRenameFiles { get; set; }
|
||||
public bool CanReplaceFiles { get; set; }
|
||||
public bool CanDeleteFiles { get; set; }
|
||||
|
||||
public bool Identify(System.IO.Stream stream)
|
||||
{
|
||||
using (var reader = new Toolbox.Library.IO.FileReader(stream, true))
|
||||
{
|
||||
return reader.CheckSignature(3, "DAT");
|
||||
}
|
||||
}
|
||||
|
||||
public Type[] Types
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Type> types = new List<Type>();
|
||||
return types.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public List<FileEntry> files = new List<FileEntry>();
|
||||
|
||||
public IEnumerable<ArchiveFileInfo> Files => files;
|
||||
|
||||
public void ClearFiles() { files.Clear(); }
|
||||
|
||||
private System.IO.Stream _stream;
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
_stream = stream;
|
||||
using (var reader = new FileReader(stream, true))
|
||||
{
|
||||
reader.SetByteOrder(false);
|
||||
uint magic = reader.ReadUInt32();
|
||||
uint fileCount = reader.ReadUInt32();
|
||||
uint offsetFileOffsetTbl= reader.ReadUInt32();
|
||||
uint offsetFileExtTbl = reader.ReadUInt32();
|
||||
uint offsetFileNameTbl = reader.ReadUInt32();
|
||||
uint offsetFileSizeTbl = reader.ReadUInt32();
|
||||
|
||||
reader.SeekBegin(offsetFileOffsetTbl);
|
||||
var offsets = reader.ReadUInt32s((int)fileCount);
|
||||
|
||||
reader.SeekBegin(offsetFileExtTbl);
|
||||
string[] extensions = new string[fileCount];
|
||||
for (int i = 0; i < fileCount; i++)
|
||||
extensions[i] = reader.ReadString(4, true);
|
||||
|
||||
reader.SeekBegin(offsetFileNameTbl);
|
||||
uint strSize = reader.ReadUInt32();
|
||||
|
||||
string[] names = new string[fileCount];
|
||||
for (int i = 0; i < fileCount; i++)
|
||||
names[i] = reader.ReadString((int)strSize, true);
|
||||
|
||||
reader.SeekBegin(offsetFileSizeTbl);
|
||||
var sizes = reader.ReadUInt32s((int)fileCount);
|
||||
|
||||
for (int i = 0; i < fileCount; i++)
|
||||
{
|
||||
var file = new FileEntry();
|
||||
file.FileName = $"{names[i]}";
|
||||
file.FileDataStream = new SubStream(reader.BaseStream, (long)offsets[i], (long)sizes[i]);
|
||||
files.Add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Save(System.IO.Stream stream)
|
||||
{
|
||||
}
|
||||
|
||||
public bool AddFile(ArchiveFileInfo archiveFileInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DeleteFile(ArchiveFileInfo archiveFileInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public class FileEntry : ArchiveFileInfo
|
||||
{
|
||||
public ulong fileSize;
|
||||
public ulong fileOffset;
|
||||
public ulong compressedSize;
|
||||
|
||||
protected Stream stream;
|
||||
public override Stream FileDataStream
|
||||
{
|
||||
get
|
||||
{
|
||||
if (compressedSize != fileSize)
|
||||
return new MemoryStream(STLibraryCompression.ZSTD.Decompress(stream.ToBytes()));
|
||||
else
|
||||
return stream;
|
||||
}
|
||||
set
|
||||
{
|
||||
stream = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -193,6 +193,249 @@ namespace LayoutBXLYT
|
||||
BxlytToGL.DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
}
|
||||
|
||||
public static void DrawWindowPane(BasePane pane, byte effectiveAlpha, Dictionary<string, STGenericTexture> Textures)
|
||||
{
|
||||
uint sizeX = (uint)pane.Width;
|
||||
uint sizeY = (uint)pane.Height;
|
||||
|
||||
var window = (IWindowPane)pane;
|
||||
switch (window.WindowKind)
|
||||
{
|
||||
case WindowKind.Around:
|
||||
if (window.FrameCount == 1) //1 texture for all
|
||||
{
|
||||
var mat = window.WindowFrames[0].Material;
|
||||
|
||||
if (mat.TextureMaps.Length == 0)
|
||||
RenderWindowContent(pane, sizeX, sizeY, window.Content, effectiveAlpha, Textures);
|
||||
else
|
||||
{
|
||||
var texture = mat.TextureMaps[0].Name;
|
||||
if (!Textures.ContainsKey(texture))
|
||||
{
|
||||
RenderWindowContent(pane, sizeX, sizeY, window.Content, effectiveAlpha, Textures);
|
||||
break;
|
||||
}
|
||||
|
||||
var image = Textures[texture];
|
||||
|
||||
uint contentWidth = sizeX - (uint)window.FrameElementRight - (uint)window.FrameElementLeft;
|
||||
uint contentHeight = sizeY - (uint)window.FrameElementTop - (uint)window.FrameElementBottm;
|
||||
|
||||
RenderWindowContent(pane,
|
||||
contentWidth,
|
||||
contentHeight,
|
||||
window.Content, effectiveAlpha, Textures);
|
||||
|
||||
// _________
|
||||
//|______| |
|
||||
//| | | |
|
||||
//| |___|__|
|
||||
//|__|______|
|
||||
|
||||
|
||||
//Top Left
|
||||
SetupShaders(mat, Textures);
|
||||
mat.Shader.SetInt("flipTexture", (int)window.WindowFrames[0].TextureFlip);
|
||||
|
||||
CustomRectangle rect;
|
||||
|
||||
GL.PushMatrix();
|
||||
{
|
||||
uint pieceWidth = sizeX - window.FrameElementRight;
|
||||
uint pieceHeight = window.FrameElementTop;
|
||||
int pieceX = (int)-(window.FrameElementRight / 2);
|
||||
int pieceY = (int)((sizeY / 2) - (pieceHeight / 2));
|
||||
|
||||
GL.Translate(pieceX, pieceY, 0);
|
||||
rect = pane.CreateRectangle(pieceWidth, pieceHeight);
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / window.FrameElementRight, 1);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / window.FrameElementRight, 0);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.End();
|
||||
}
|
||||
GL.PopMatrix();
|
||||
|
||||
//Top Right
|
||||
GL.PushMatrix();
|
||||
{
|
||||
uint pieceWidth = window.FrameElementRight;
|
||||
uint pieceHeight = sizeY - window.FrameElementBottm;
|
||||
int pieceX = (int)((contentWidth / 2) + (pieceWidth / 2));
|
||||
int pieceY = (int)(window.FrameElementBottm / 2);
|
||||
|
||||
GL.Translate(pieceX, pieceY, 0);
|
||||
rect = pane.CreateRectangle(pieceWidth, pieceHeight);
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, pieceHeight / window.FrameElementBottm);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 1, pieceHeight / window.FrameElementBottm);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 1, 0);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.End();
|
||||
}
|
||||
GL.PopMatrix();
|
||||
|
||||
//Bottom Right
|
||||
GL.PushMatrix();
|
||||
{
|
||||
uint pieceWidth = window.FrameElementLeft;
|
||||
uint pieceHeight = sizeY - window.FrameElementTop;
|
||||
int pieceX = (int)-((contentWidth / 2) + (pieceWidth / 2));
|
||||
int pieceY = (int)-(window.FrameElementTop / 2);
|
||||
|
||||
GL.Translate(pieceX, pieceY, 0);
|
||||
rect = pane.CreateRectangle(pieceWidth, pieceHeight);
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 1, 0);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 1, pieceHeight / window.FrameElementTop);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, pieceHeight / window.FrameElementTop);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.End();
|
||||
}
|
||||
GL.PopMatrix();
|
||||
|
||||
//Bottom Right
|
||||
GL.PushMatrix();
|
||||
{
|
||||
uint pieceWidth = sizeX - window.FrameElementLeft;
|
||||
uint pieceHeight = window.FrameElementBottm;
|
||||
int pieceX = (int)(window.FrameElementLeft / 2);
|
||||
int pieceY = (int)(-(sizeY / 2) + (pieceHeight / 2));
|
||||
|
||||
GL.Translate(pieceX, pieceY, 0);
|
||||
rect = pane.CreateRectangle(pieceWidth, pieceHeight);
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / window.FrameElementLeft, 1);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 1);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, 0, 0);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, pieceWidth / window.FrameElementLeft, 0);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.End();
|
||||
}
|
||||
GL.PopMatrix();
|
||||
}
|
||||
}
|
||||
else if (window.FrameCount == 4)
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
case WindowKind.Horizontal:
|
||||
break;
|
||||
case WindowKind.HorizontalNoContent:
|
||||
break;
|
||||
}
|
||||
|
||||
GL.UseProgram(0);
|
||||
}
|
||||
|
||||
enum FrameType
|
||||
{
|
||||
LeftTop,
|
||||
Left,
|
||||
LeftBottom,
|
||||
Top,
|
||||
Bottom,
|
||||
RightTop,
|
||||
Right,
|
||||
RightBottom,
|
||||
}
|
||||
|
||||
private static Vector2 GetFramePosition(uint paneWidth, uint paneHeight, IWindowPane window, FrameType type)
|
||||
{
|
||||
|
||||
|
||||
Vector2 pos = new Vector2();
|
||||
switch (type)
|
||||
{
|
||||
case FrameType.LeftTop:
|
||||
|
||||
break;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
private static void SetupShaders(BxlytMaterial mat, Dictionary<string, STGenericTexture> textures)
|
||||
{
|
||||
if (mat.Shader == null)
|
||||
{
|
||||
if (mat is Cafe.BFLYT.Material)
|
||||
{
|
||||
mat.Shader = new BflytShader((Cafe.BFLYT.Material)mat);
|
||||
mat.Shader.Compile();
|
||||
}
|
||||
}
|
||||
|
||||
mat.Shader.Enable();
|
||||
if (mat is Cafe.BFLYT.Material)
|
||||
((BflytShader)mat.Shader).SetMaterials(textures);
|
||||
}
|
||||
|
||||
private static void RenderWindowContent(BasePane pane, uint sizeX, uint sizeY, BxlytWindowContent content,
|
||||
byte effectiveAlpha, Dictionary<string, STGenericTexture> Textures)
|
||||
{
|
||||
var mat = content.Material;
|
||||
var rect = pane.CreateRectangle(sizeX, sizeY);
|
||||
|
||||
SetupShaders(mat, Textures);
|
||||
|
||||
Vector2[] texCoords = new Vector2[] {
|
||||
new Vector2(1,1),
|
||||
new Vector2(0,1),
|
||||
new Vector2(0,0),
|
||||
new Vector2(1,0)
|
||||
};
|
||||
|
||||
Color[] colors = new Color[] {
|
||||
content.ColorTopLeft.Color,
|
||||
content.ColorTopRight.Color,
|
||||
content.ColorBottomRight.Color,
|
||||
content.ColorBottomLeft.Color,
|
||||
};
|
||||
|
||||
if (content.TexCoords.Count > 0)
|
||||
{
|
||||
texCoords = new Vector2[] {
|
||||
content.TexCoords[0].TopLeft.ToTKVector2(),
|
||||
content.TexCoords[0].TopRight.ToTKVector2(),
|
||||
content.TexCoords[0].BottomRight.ToTKVector2(),
|
||||
content.TexCoords[0].BottomLeft.ToTKVector2(),
|
||||
};
|
||||
}
|
||||
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.Color4(colors[0]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[0].X, texCoords[0].Y);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.Color4(colors[1]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[1].X, texCoords[1].Y);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.Color4(colors[2]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[2].X, texCoords[2].Y);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.Color4(colors[3]);
|
||||
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[3].X, texCoords[3].Y);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.End();
|
||||
}
|
||||
|
||||
public static bool BindGLTexture(BxlytTextureRef tex, STGenericTexture texture)
|
||||
{
|
||||
if (texture.RenderableTex == null || !texture.RenderableTex.GLInitialized)
|
||||
@ -240,7 +483,7 @@ namespace LayoutBXLYT
|
||||
}
|
||||
|
||||
public static void DrawRectangle(CustomRectangle rect, Vector2[] texCoords,
|
||||
Color[] colors, bool useLines = true, byte alpha = 255)
|
||||
Color[] colors, bool useLines = true, byte alpha = 255)
|
||||
{
|
||||
for (int i = 0; i < colors.Length; i++)
|
||||
{
|
||||
|
@ -2,14 +2,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel;
|
||||
using Toolbox;
|
||||
using System.Windows.Forms;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.IO;
|
||||
|
||||
namespace LayoutBXLYT
|
||||
{
|
||||
public class BFLAN : IFileFormat
|
||||
public class BFLAN : IEditorForm<LayoutEditor>, IFileFormat
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Layout;
|
||||
|
||||
@ -37,16 +38,582 @@ namespace LayoutBXLYT
|
||||
}
|
||||
}
|
||||
|
||||
Header header;
|
||||
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
CanSave = false;
|
||||
|
||||
header = new Header();
|
||||
header.Read(new FileReader(stream),this);
|
||||
}
|
||||
public void Unload()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Save(System.IO.Stream stream)
|
||||
public void Save(System.IO.Stream stream) {
|
||||
header.Write(new FileWriter(stream));
|
||||
}
|
||||
|
||||
public LayoutEditor OpenForm()
|
||||
{
|
||||
LayoutEditor editor = new LayoutEditor();
|
||||
editor.Dock = DockStyle.Fill;
|
||||
editor.LoadBxlan(header);
|
||||
return editor;
|
||||
}
|
||||
|
||||
public void FillEditor(Form control)
|
||||
{
|
||||
((LayoutEditor)control).LoadBxlan(header);
|
||||
}
|
||||
|
||||
public class Header : BxlanHeader
|
||||
{
|
||||
private const string Magic = "FLAN";
|
||||
private ushort ByteOrderMark;
|
||||
private ushort HeaderSize;
|
||||
|
||||
//As of now this should be empty but just for future proofing
|
||||
private List<SectionCommon> UnknownSections = new List<SectionCommon>();
|
||||
|
||||
public PAT1 AnimationTag;
|
||||
public PAI1 AnimationInfo;
|
||||
|
||||
public void Read(FileReader reader, BFLAN bflan)
|
||||
{
|
||||
AnimationTag = new PAT1();
|
||||
AnimationInfo = new PAI1();
|
||||
|
||||
reader.SetByteOrder(true);
|
||||
reader.ReadSignature(4, Magic);
|
||||
ByteOrderMark = reader.ReadUInt16();
|
||||
reader.CheckByteOrderMark(ByteOrderMark);
|
||||
HeaderSize = reader.ReadUInt16();
|
||||
Version = reader.ReadUInt32();
|
||||
SetVersionInfo();
|
||||
uint FileSize = reader.ReadUInt32();
|
||||
ushort sectionCount = reader.ReadUInt16();
|
||||
reader.ReadUInt16(); //Padding
|
||||
|
||||
FileInfo = bflan;
|
||||
IsBigEndian = reader.ByteOrder == Syroot.BinaryData.ByteOrder.BigEndian;
|
||||
|
||||
reader.SeekBegin(HeaderSize);
|
||||
for (int i = 0; i < sectionCount; i++)
|
||||
{
|
||||
long pos = reader.Position;
|
||||
string Signature = reader.ReadString(4, Encoding.ASCII);
|
||||
uint SectionSize = reader.ReadUInt32();
|
||||
|
||||
SectionCommon section = new SectionCommon(Signature);
|
||||
switch (Signature)
|
||||
{
|
||||
case "pat1":
|
||||
AnimationTag = new PAT1(reader, this);
|
||||
break;
|
||||
case "pai1":
|
||||
AnimationInfo = new PAI1(reader, this);
|
||||
break;
|
||||
default:
|
||||
section.Data = reader.ReadBytes((int)SectionSize - 8);
|
||||
UnknownSections.Add(section);
|
||||
break;
|
||||
}
|
||||
|
||||
section.SectionSize = SectionSize;
|
||||
reader.SeekBegin(pos + SectionSize);
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
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, "pat1", AnimationTag, () => AnimationTag.Write(writer, this));
|
||||
sectionCount++;
|
||||
|
||||
WriteSection(writer, "pai1", AnimationInfo, () => AnimationInfo.Write(writer, this));
|
||||
sectionCount++;
|
||||
|
||||
foreach (var section in UnknownSections)
|
||||
{
|
||||
WriteSection(writer, section.Signature, section, () => section.Write(writer, this));
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PAT1 : SectionCommon
|
||||
{
|
||||
[DisplayName("Name"), CategoryAttribute("Animation")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Groups"), CategoryAttribute("Animation")]
|
||||
public List<string> Groups { get; set; }
|
||||
|
||||
[DisplayName("Start"), CategoryAttribute("Frames")]
|
||||
public ushort StartFrame { get; set; }
|
||||
|
||||
[DisplayName("End"), CategoryAttribute("Frames")]
|
||||
public ushort EndFrame { get; set; }
|
||||
|
||||
[DisplayName("Animation Order"), CategoryAttribute("Parameters")]
|
||||
public ushort AnimationOrder { get; set; }
|
||||
|
||||
[DisplayName("Child Binding"), CategoryAttribute("Parameters")]
|
||||
public bool ChildBinding { get; set; }
|
||||
|
||||
private byte[] UnknownData;
|
||||
|
||||
public PAT1()
|
||||
{
|
||||
AnimationOrder = 2;
|
||||
Name = "";
|
||||
EndFrame = 0;
|
||||
StartFrame = 0;
|
||||
ChildBinding = false;
|
||||
Groups = new List<string>();
|
||||
}
|
||||
|
||||
public PAT1(FileReader reader, Header header)
|
||||
{
|
||||
long startPos = reader.Position - 8;
|
||||
|
||||
Groups = new List<string>();
|
||||
|
||||
AnimationOrder = reader.ReadUInt16();
|
||||
ushort groupCount = reader.ReadUInt16();
|
||||
if (groupCount != 1)
|
||||
throw new Exception("Unexpected group count! Expected 1!");
|
||||
uint animNameOffset = reader.ReadUInt32();
|
||||
uint groupNamesOffset = reader.ReadUInt32();
|
||||
StartFrame = reader.ReadUInt16();
|
||||
EndFrame = reader.ReadUInt16();
|
||||
ChildBinding = reader.ReadBoolean();
|
||||
UnknownData = reader.ReadBytes((int)(startPos + animNameOffset - reader.Position));
|
||||
|
||||
reader.SeekBegin(startPos + animNameOffset);
|
||||
Name = reader.ReadZeroTerminatedString();
|
||||
|
||||
reader.SeekBegin(startPos + groupNamesOffset);
|
||||
for (int i = 0; i < groupCount; i++)
|
||||
Groups.Add(reader.ReadString(0x24, true));
|
||||
}
|
||||
|
||||
public override void Write(FileWriter writer, LayoutHeader header)
|
||||
{
|
||||
long startPos = writer.Position - 8;
|
||||
|
||||
writer.Write(AnimationOrder);
|
||||
writer.Write((ushort)Groups.Count);
|
||||
writer.Write(uint.MaxValue); //animNameOffset
|
||||
writer.Write(uint.MaxValue); //groupNamesOffset
|
||||
writer.Write(StartFrame);
|
||||
writer.Write(EndFrame);
|
||||
writer.Write(ChildBinding);
|
||||
writer.Write(UnknownData);
|
||||
|
||||
writer.WriteUint32Offset(4, startPos);
|
||||
writer.WriteString(Name);
|
||||
writer.Align(4);
|
||||
|
||||
writer.WriteUint32Offset(8, startPos);
|
||||
for (int i = 0; i < Groups.Count; i++)
|
||||
writer.WriteString(Groups[i], 0x24);
|
||||
}
|
||||
}
|
||||
|
||||
public class PAI1 : SectionCommon
|
||||
{
|
||||
public ushort FrameSize;
|
||||
|
||||
private byte flags;
|
||||
|
||||
public List<string> Textures { get; set; }
|
||||
|
||||
public List<PaiEntry> Entries = new List<PaiEntry>();
|
||||
|
||||
public PAI1()
|
||||
{
|
||||
Textures = new List<string>();
|
||||
}
|
||||
|
||||
public PAI1(FileReader reader, Header header)
|
||||
{
|
||||
long startPos = reader.Position - 8;
|
||||
|
||||
Textures = new List<string>();
|
||||
|
||||
FrameSize = reader.ReadUInt16();
|
||||
flags = reader.ReadByte();
|
||||
reader.ReadByte(); //padding
|
||||
var numTextures = reader.ReadUInt16();
|
||||
var numEntries = reader.ReadUInt16();
|
||||
var entryOffsetTbl = reader.ReadUInt32();
|
||||
|
||||
var texOffsets = reader.ReadUInt32s(numTextures);
|
||||
for (int i = 0; i < numTextures; i++)
|
||||
{
|
||||
reader.SeekBegin(startPos + texOffsets[i]);
|
||||
Textures.Add(reader.ReadZeroTerminatedString());
|
||||
}
|
||||
|
||||
reader.SeekBegin(startPos + entryOffsetTbl);
|
||||
var entryOffsets = reader.ReadUInt32s(numEntries);
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
reader.SeekBegin(startPos + entryOffsets[i]);
|
||||
Entries.Add(new PaiEntry(reader, header));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(FileWriter writer, LayoutHeader header)
|
||||
{
|
||||
long startPos = writer.Position;
|
||||
|
||||
writer.Write(FrameSize);
|
||||
writer.Write(flags);
|
||||
writer.Write((byte)0);
|
||||
writer.Write((ushort)Textures.Count);
|
||||
writer.Write((ushort)Entries.Count);
|
||||
|
||||
if (Textures.Count > 0)
|
||||
{
|
||||
writer.Write(new uint[Textures.Count]);
|
||||
for (int i = 0; i < Textures.Count; i++)
|
||||
{
|
||||
writer.WriteUint32Offset(4 + (i * 4), startPos);
|
||||
writer.WriteString(Textures[i]);
|
||||
}
|
||||
}
|
||||
if (Entries.Count > 0)
|
||||
{
|
||||
writer.Write(new uint[Entries.Count]);
|
||||
for (int i = 0; i < Textures.Count; i++)
|
||||
{
|
||||
writer.WriteUint32Offset(4 + (i * 4), startPos);
|
||||
Entries[i].Write(writer, header);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PaiEntry
|
||||
{
|
||||
[DisplayName("Name"), CategoryAttribute("Animation")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Target"), CategoryAttribute("Animation")]
|
||||
public AnimationTarget Target { get; set; }
|
||||
|
||||
public List<PaiTag> Tags = new List<PaiTag>();
|
||||
|
||||
public PaiEntry(FileReader reader, Header header)
|
||||
{
|
||||
long startPos = reader.Position;
|
||||
|
||||
Name = reader.ReadString(28);
|
||||
var numTags = reader.ReadByte();
|
||||
Target = reader.ReadEnum<AnimationTarget>(false);
|
||||
reader.ReadUInt16(); //padding
|
||||
|
||||
var offsets = reader.ReadUInt32s(numTags);
|
||||
for (int i = 0; i < numTags; i++)
|
||||
{
|
||||
reader.SeekBegin(startPos + offsets[i]);
|
||||
Tags.Add(new PaiTag(reader, header));
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer, LayoutHeader header)
|
||||
{
|
||||
long startPos = writer.Position;
|
||||
|
||||
writer.WriteString(Name, 28);
|
||||
writer.Write((byte)Tags.Count);
|
||||
writer.Write(Target, true);
|
||||
writer.Write((byte)0);
|
||||
if (Tags.Count > 0)
|
||||
{
|
||||
writer.Write(new uint[Tags.Count]);
|
||||
for (int i = 0; i < Tags.Count; i++)
|
||||
{
|
||||
writer.WriteUint32Offset(4 + (i * 4), startPos);
|
||||
Tags[i].Write(writer, header);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PaiTag
|
||||
{
|
||||
public List<PaiTagEntry> Entries = new List<PaiTagEntry>();
|
||||
|
||||
private string Tag;
|
||||
|
||||
public string Type
|
||||
{
|
||||
get { return TypeDefine.ContainsKey(Tag) ? TypeDefine[Tag] : Tag; }
|
||||
}
|
||||
|
||||
public Dictionary<string, string> TypeDefine = new Dictionary<string, string>()
|
||||
{
|
||||
{"FLPA","Pane" },
|
||||
{"FLTS","Pane Texture SRT" },
|
||||
{"FLVI","Pane Visibilty" },
|
||||
{"FLVC","Vertex Colors" },
|
||||
{"FLMC","Material Colors" },
|
||||
{"FLTP","Texture Pattern" },
|
||||
};
|
||||
|
||||
public PaiTag(FileReader reader, Header header)
|
||||
{
|
||||
long startPos = reader.Position;
|
||||
|
||||
Tag = reader.ReadString(4, Encoding.ASCII);
|
||||
var numEntries = reader.ReadByte();
|
||||
reader.Seek(3);
|
||||
var offsets = reader.ReadUInt32s((int)numEntries);
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
reader.SeekBegin(startPos + offsets[i]);
|
||||
switch (Tag)
|
||||
{
|
||||
case "FLPA":
|
||||
Entries.Add(new FLPATagEntry(reader, header));
|
||||
break;
|
||||
case "FLTS":
|
||||
Entries.Add(new FLTSTagEntry(reader, header));
|
||||
break;
|
||||
case "FLVI":
|
||||
Entries.Add(new FLVITagEntry(reader, header));
|
||||
break;
|
||||
case "FLVC":
|
||||
Entries.Add(new FLVCTagEntry(reader, header));
|
||||
break;
|
||||
case "FLMC":
|
||||
Entries.Add(new FLMCTagEntry(reader, header));
|
||||
break;
|
||||
case "FLTP":
|
||||
Entries.Add(new FLTPTagEntry(reader, header));
|
||||
break;
|
||||
default:
|
||||
Entries.Add(new PaiTagEntry(reader, header));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer, LayoutHeader header)
|
||||
{
|
||||
long startPos = writer.Position;
|
||||
|
||||
writer.WriteSignature(Tag);
|
||||
writer.Write((byte)Entries.Count);
|
||||
writer.Seek(3);
|
||||
writer.Write(new uint[Entries.Count]);
|
||||
for (int i = 0; i < Entries.Count; i++)
|
||||
{
|
||||
writer.WriteUint32Offset(8 + (i * 4), startPos);
|
||||
Entries[i].Write(writer, header);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PaiTagEntry
|
||||
{
|
||||
[Browsable(false)]
|
||||
public virtual string TargetName
|
||||
{
|
||||
get { return AnimationTarget.ToString(); }
|
||||
}
|
||||
|
||||
public byte AnimationTarget;
|
||||
|
||||
[DisplayName("Index"), CategoryAttribute("Tag")]
|
||||
public byte Index { get; private set; }
|
||||
|
||||
[DisplayName("Data Type"), CategoryAttribute("Tag")]
|
||||
public KeyType DataType { get; private set; }
|
||||
|
||||
public byte Unknown;
|
||||
|
||||
public List<KeyFrame> KeyFrames = new List<KeyFrame>();
|
||||
|
||||
public PaiTagEntry(FileReader reader, Header header)
|
||||
{
|
||||
long startPos = reader.Position;
|
||||
Index = reader.ReadByte();
|
||||
AnimationTarget = reader.ReadByte();
|
||||
DataType = reader.ReadEnum<KeyType>(true);
|
||||
Unknown = reader.ReadByte();
|
||||
var KeyFrameCount = reader.ReadUInt16();
|
||||
reader.ReadUInt16(); //Padding
|
||||
uint keyFrameOffset = reader.ReadUInt32();
|
||||
|
||||
|
||||
reader.SeekBegin(startPos + keyFrameOffset);
|
||||
for (int i = 0; i < KeyFrameCount; i++)
|
||||
KeyFrames.Add(new KeyFrame(reader, DataType));
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer, LayoutHeader header)
|
||||
{
|
||||
long startPos = writer.Position;
|
||||
|
||||
writer.Write(Index);
|
||||
writer.Write(AnimationTarget);
|
||||
writer.Write(DataType, true);
|
||||
writer.Write(Unknown);
|
||||
writer.Write((ushort)KeyFrames.Count);
|
||||
writer.Write((ushort)0); //padding
|
||||
writer.Write(0); //key offset
|
||||
|
||||
if (KeyFrames.Count > 0)
|
||||
{
|
||||
writer.WriteUint32Offset(8, startPos);
|
||||
for (int i = 0; i < KeyFrames.Count; i++)
|
||||
KeyFrames[i].Write(writer, DataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class KeyFrame
|
||||
{
|
||||
[DisplayName("Blend"), CategoryAttribute("Key Frame")]
|
||||
public float Blend { get; set; }
|
||||
[DisplayName("Frame"), CategoryAttribute("Key Frame")]
|
||||
public float Frame { get; set; }
|
||||
[DisplayName("Value"), CategoryAttribute("Key Frame")]
|
||||
public float Value { get; set; }
|
||||
|
||||
public KeyFrame(FileReader reader, KeyType DataType)
|
||||
{
|
||||
Frame = reader.ReadSingle();
|
||||
switch (DataType)
|
||||
{
|
||||
case KeyType.Float:
|
||||
Value = reader.ReadSingle();
|
||||
Blend = reader.ReadSingle();
|
||||
break;
|
||||
case KeyType.Uin16:
|
||||
Value = (float)reader.ReadInt16();
|
||||
Blend = (float)reader.ReadInt16();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer, KeyType DataType)
|
||||
{
|
||||
writer.Write(Frame);
|
||||
switch (DataType)
|
||||
{
|
||||
case KeyType.Float:
|
||||
writer.Write(Value);
|
||||
writer.Write(Blend);
|
||||
break;
|
||||
case KeyType.Uin16:
|
||||
writer.Write((ushort)Value);
|
||||
writer.Write((ushort)Blend);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FLPATagEntry : PaiTagEntry
|
||||
{
|
||||
public override string TargetName => Target.ToString();
|
||||
[DisplayName("Target"), CategoryAttribute("Tag")]
|
||||
public LPATarget Target
|
||||
{
|
||||
get { return (LPATarget)AnimationTarget; }
|
||||
set { AnimationTarget = (byte)value; }
|
||||
}
|
||||
public FLPATagEntry(FileReader reader, Header header) : base(reader, header) { }
|
||||
}
|
||||
|
||||
public class FLTSTagEntry : PaiTagEntry
|
||||
{
|
||||
public override string TargetName => Target.ToString();
|
||||
[DisplayName("Target"), CategoryAttribute("Tag")]
|
||||
public LTSTarget Target
|
||||
{
|
||||
get { return (LTSTarget)AnimationTarget; }
|
||||
set { AnimationTarget = (byte)value; }
|
||||
}
|
||||
public FLTSTagEntry(FileReader reader, Header header) : base(reader, header) { }
|
||||
}
|
||||
|
||||
public class FLVITagEntry : PaiTagEntry
|
||||
{
|
||||
public override string TargetName => Target.ToString();
|
||||
[DisplayName("Target"), CategoryAttribute("Tag")]
|
||||
public LVITarget Target
|
||||
{
|
||||
get { return (LVITarget)AnimationTarget; }
|
||||
set { AnimationTarget = (byte)value; }
|
||||
}
|
||||
public FLVITagEntry(FileReader reader, Header header) : base(reader, header) { }
|
||||
}
|
||||
|
||||
public class FLVCTagEntry : PaiTagEntry
|
||||
{
|
||||
public override string TargetName => Target.ToString();
|
||||
[DisplayName("Target"), CategoryAttribute("Tag")]
|
||||
public LVCTarget Target
|
||||
{
|
||||
get { return (LVCTarget)AnimationTarget; }
|
||||
set { AnimationTarget = (byte)value; }
|
||||
}
|
||||
public FLVCTagEntry(FileReader reader, Header header) : base(reader, header) { }
|
||||
}
|
||||
|
||||
public class FLMCTagEntry : PaiTagEntry
|
||||
{
|
||||
public override string TargetName => Target.ToString();
|
||||
[DisplayName("Target"), CategoryAttribute("Tag")]
|
||||
public LMCTarget Target
|
||||
{
|
||||
get { return (LMCTarget)AnimationTarget; }
|
||||
set { AnimationTarget = (byte)value; }
|
||||
}
|
||||
public FLMCTagEntry(FileReader reader, Header header) : base(reader, header) { }
|
||||
}
|
||||
|
||||
public class FLTPTagEntry : PaiTagEntry
|
||||
{
|
||||
public override string TargetName => Target.ToString();
|
||||
[DisplayName("Target"), CategoryAttribute("Tag")]
|
||||
public LTPTarget Target
|
||||
{
|
||||
get { return (LTPTarget)AnimationTarget; }
|
||||
set { AnimationTarget = (byte)value; }
|
||||
}
|
||||
public FLTPTagEntry(FileReader reader, Header header) : base(reader, header) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,6 +199,20 @@ namespace LayoutBXLYT.Cafe
|
||||
BFLIM test = new BFLIM();
|
||||
Dictionary<string, STGenericTexture> textures = new Dictionary<string, STGenericTexture>();
|
||||
|
||||
if (File.Exists(FilePath))
|
||||
{
|
||||
string folder = Path.GetDirectoryName(FilePath);
|
||||
foreach (var file in Directory.GetFiles(folder))
|
||||
{
|
||||
if (Utils.GetExtension(file) == ".bflim")
|
||||
{
|
||||
BFLIM bflim = (BFLIM)STFileLoader.OpenFileFormat(file);
|
||||
if (!textures.ContainsKey(bflim.FileName))
|
||||
textures.Add(bflim.FileName, bflim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var archive in PluginRuntime.SarcArchives)
|
||||
{
|
||||
foreach (var file in archive.Files)
|
||||
@ -516,9 +530,13 @@ namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
Version = VersionMajor << 24 | VersionMinor << 16 | VersionMicro << 8 | VersionMicro2;
|
||||
|
||||
writer.SetByteOrder(IsBigEndian);
|
||||
writer.SetByteOrder(true);
|
||||
writer.WriteSignature(Magic);
|
||||
writer.Write(ByteOrderMark);
|
||||
if (!IsBigEndian)
|
||||
writer.Write((ushort)0xFFFE);
|
||||
else
|
||||
writer.Write((ushort)0xFEFF);
|
||||
writer.SetByteOrder(IsBigEndian);
|
||||
writer.Write(HeaderSize);
|
||||
writer.Write(Version);
|
||||
writer.Write(uint.MaxValue); //Reserve space for file size later
|
||||
@ -655,22 +673,6 @@ namespace LayoutBXLYT.Cafe
|
||||
}
|
||||
}
|
||||
|
||||
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 override string Signature { get; } = "txt1";
|
||||
@ -863,7 +865,7 @@ namespace LayoutBXLYT.Cafe
|
||||
};
|
||||
}
|
||||
|
||||
public class WND1 : PAN1
|
||||
public class WND1 : PAN1, IWindowPane
|
||||
{
|
||||
public override string Signature { get; } = "wnd1";
|
||||
|
||||
@ -875,44 +877,48 @@ namespace LayoutBXLYT.Cafe
|
||||
public bool UseOneMaterialForAll
|
||||
{
|
||||
get { return Convert.ToBoolean(_flag & 1); }
|
||||
set { }
|
||||
}
|
||||
|
||||
public bool UseVertexColorForAll
|
||||
{
|
||||
get { return Convert.ToBoolean((_flag >> 1) & 1); }
|
||||
set { }
|
||||
}
|
||||
|
||||
public bool WindowKind
|
||||
public WindowKind WindowKind
|
||||
{
|
||||
get { return Convert.ToBoolean((_flag >> 2) & 3); }
|
||||
get { return (WindowKind)((_flag >> 2) & 3); }
|
||||
set { }
|
||||
}
|
||||
|
||||
public bool NotDrawnContent
|
||||
{
|
||||
get { return Convert.ToBoolean((_flag >> 4) & 1); }
|
||||
set { }
|
||||
}
|
||||
|
||||
public ushort StretchLeft;
|
||||
public ushort StretchRight;
|
||||
public ushort StretchTop;
|
||||
public ushort StretchBottm;
|
||||
public ushort FrameElementLeft;
|
||||
public ushort FrameElementRight;
|
||||
public ushort FrameElementTop;
|
||||
public ushort FrameElementBottm;
|
||||
public byte FrameCount;
|
||||
public ushort StretchLeft { get; set; }
|
||||
public ushort StretchRight { get; set; }
|
||||
public ushort StretchTop { get; set; }
|
||||
public ushort StretchBottm { get; set; }
|
||||
public ushort FrameElementLeft { get; set; }
|
||||
public ushort FrameElementRight { get; set; }
|
||||
public ushort FrameElementTop { get; set; }
|
||||
public ushort FrameElementBottm { get; set; }
|
||||
public byte FrameCount { get; set; }
|
||||
private byte _flag;
|
||||
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public WindowContent Content { get; set; }
|
||||
public BxlytWindowContent Content { get; set; }
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public List<WindowFrame> WindowFrames { get; set; }
|
||||
public List<BxlytWindowFrame> WindowFrames { get; set; }
|
||||
|
||||
public WND1(FileReader reader, Header header) : base(reader)
|
||||
{
|
||||
WindowFrames = new List<WindowFrame>();
|
||||
WindowFrames = new List<BxlytWindowFrame>();
|
||||
|
||||
long pos = reader.Position - 0x54;
|
||||
|
||||
@ -965,7 +971,7 @@ namespace LayoutBXLYT.Cafe
|
||||
writer.Write(0);
|
||||
|
||||
writer.WriteUint32Offset(_ofsContentPos, pos);
|
||||
Content.Write(writer);
|
||||
((WindowContent)Content).Write(writer);
|
||||
|
||||
if (WindowFrames.Count > 0)
|
||||
{
|
||||
@ -976,30 +982,15 @@ namespace LayoutBXLYT.Cafe
|
||||
for (int i = 0; i < WindowFrames.Count; i++)
|
||||
{
|
||||
writer.WriteUint32Offset(_ofsFramePos + (i * 4), pos);
|
||||
WindowFrames[i].Write(writer);
|
||||
((WindowFrame)WindowFrames[i]).Write(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class WindowContent
|
||||
public class WindowContent : BxlytWindowContent
|
||||
{
|
||||
private Header LayoutFile;
|
||||
|
||||
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 List<TexCoord> TexCoords = new List<TexCoord>();
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public Material Material
|
||||
{
|
||||
get { return LayoutFile.MaterialList.Materials[MaterialIndex]; }
|
||||
}
|
||||
|
||||
public WindowContent(FileReader reader, Header header)
|
||||
{
|
||||
LayoutFile = header;
|
||||
@ -1020,6 +1011,8 @@ namespace LayoutBXLYT.Cafe
|
||||
BottomLeft = reader.ReadVec2SY(),
|
||||
BottomRight = reader.ReadVec2SY(),
|
||||
});
|
||||
|
||||
Material = LayoutFile.MaterialList.Materials[MaterialIndex];
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
@ -1041,26 +1034,21 @@ namespace LayoutBXLYT.Cafe
|
||||
}
|
||||
}
|
||||
|
||||
public class WindowFrame
|
||||
public class WindowFrame : BxlytWindowFrame
|
||||
{
|
||||
public Material material { get; set; }
|
||||
|
||||
public ushort MaterialIndex;
|
||||
public byte TextureFlip;
|
||||
|
||||
public WindowFrame(FileReader reader, Header header)
|
||||
{
|
||||
MaterialIndex = reader.ReadUInt16();
|
||||
TextureFlip = reader.ReadByte();
|
||||
TextureFlip = (WindowFrameTexFlip)reader.ReadByte();
|
||||
reader.ReadByte(); //padding
|
||||
|
||||
material = header.MaterialList.Materials[MaterialIndex];
|
||||
Material = header.MaterialList.Materials[MaterialIndex];
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer)
|
||||
{
|
||||
writer.Write(MaterialIndex);
|
||||
writer.Write(TextureFlip);
|
||||
writer.Write(TextureFlip, false);
|
||||
writer.Write((byte)0);
|
||||
}
|
||||
}
|
||||
@ -1236,16 +1224,19 @@ namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
if (file.Contains(LayoutFile))
|
||||
{
|
||||
var openedFile = STFileLoader.OpenFileFormat(file);
|
||||
if (openedFile is IArchiveFile)
|
||||
if (Utils.GetExtension(file) == ".szs")
|
||||
{
|
||||
var openedFile = STFileLoader.OpenFileFormat(file);
|
||||
|
||||
BFLYT bflyt = null;
|
||||
SearchArchive((IArchiveFile)openedFile, ref bflyt);
|
||||
if (bflyt != null)
|
||||
return bflyt;
|
||||
}
|
||||
else if (openedFile is BFLYT)
|
||||
else if (Utils.GetExtension(file) == ".bflyt")
|
||||
{
|
||||
var openedFile = STFileLoader.OpenFileFormat(file);
|
||||
|
||||
openedFile.IFileInfo = new IFileInfo();
|
||||
openedFile.IFileInfo.ArchiveParent = fileFormat.IFileInfo.ArchiveParent;
|
||||
return (BFLYT)openedFile;
|
||||
@ -1846,9 +1837,6 @@ namespace LayoutBXLYT.Cafe
|
||||
[DisplayName("White Color"), CategoryAttribute("Color")]
|
||||
public STColor8 WhiteColor { get; set; }
|
||||
|
||||
[DisplayName("Texture Maps"), CategoryAttribute("Texture")]
|
||||
public TextureRef[] TextureMaps { get; set; }
|
||||
|
||||
[DisplayName("Texture Transforms"), CategoryAttribute("Texture")]
|
||||
public TextureTransform[] TextureTransforms { get; set; }
|
||||
|
||||
@ -1981,7 +1969,7 @@ namespace LayoutBXLYT.Cafe
|
||||
}
|
||||
|
||||
for (int i = 0; i < TextureMaps.Length; i++)
|
||||
TextureMaps[i].Write(writer);
|
||||
((TextureRef)TextureMaps[i]).Write(writer);
|
||||
|
||||
for (int i = 0; i < TextureTransforms.Length; i++)
|
||||
TextureTransforms[i].Write(writer);
|
||||
|
@ -27,6 +27,7 @@ namespace LayoutBXLYT
|
||||
SetInt("debugShading", 0);
|
||||
SetInt("hasTexture0", 0);
|
||||
SetInt("numTextureMaps", 0);
|
||||
SetInt("flipTexture", 0);
|
||||
|
||||
SetVec2("uvScale0", new Vector2(1,1));
|
||||
SetFloat("uvRotate0", 0);
|
||||
@ -42,6 +43,9 @@ namespace LayoutBXLYT
|
||||
SetVec2("uvScale0", new Vector2(1, 1));
|
||||
SetFloat("uvRotate0", 0);
|
||||
SetVec2("uvTranslate0", new Vector2(0, 0));
|
||||
SetInt("flipTexture", 0);
|
||||
|
||||
Console.WriteLine("debugShading " + (int)Runtime.LayoutEditor.Shading);
|
||||
|
||||
BindTextureUniforms();
|
||||
|
||||
|
@ -4,7 +4,6 @@ namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
public class TextureRef : BxlytTextureRef
|
||||
{
|
||||
public short ID;
|
||||
byte flag1;
|
||||
byte flag2;
|
||||
|
||||
|
@ -382,22 +382,6 @@ namespace LayoutBXLYT
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
@ -38,6 +38,9 @@ namespace LayoutBXLYT
|
||||
SetColor("blackColor", Color.FromArgb(0, 0, 0, 0));
|
||||
SetInt("debugShading", (int)Runtime.LayoutEditor.Shading);
|
||||
SetInt("numTextureMaps", material.TextureMaps.Count);
|
||||
SetVec2("uvScale0", new Vector2(1, 1));
|
||||
SetFloat("uvRotate0", 0);
|
||||
SetVec2("uvTranslate0", new Vector2(0, 0));
|
||||
|
||||
BindTextureUniforms();
|
||||
|
||||
@ -64,9 +67,9 @@ namespace LayoutBXLYT
|
||||
if (transform.Scale.Y < 0)
|
||||
shiftY = 1;
|
||||
|
||||
SetVec2("uvScale0",new Vector2(transform.Scale.X, transform.Scale.Y));
|
||||
SetFloat("uvRotate0", transform.Rotate);
|
||||
SetVec2("uvTranslate0",new Vector2(shiftX + transform.Translate.X, shiftY + transform.Translate.Y));
|
||||
//SetVec2("uvScale0",new Vector2(transform.Scale.X, transform.Scale.Y));
|
||||
// SetFloat("uvRotate0", transform.Rotate);
|
||||
// SetVec2("uvTranslate0",new Vector2(shiftX + transform.Translate.X, shiftY + transform.Translate.Y));
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +95,19 @@ namespace LayoutBXLYT
|
||||
rectangle = CreateRectangle();
|
||||
}
|
||||
|
||||
public CustomRectangle CreateRectangle(uint width, uint height)
|
||||
{
|
||||
//Do origin transforms
|
||||
var transformed = TransformOrientation((int)width, (int)height, originX, originY);
|
||||
var parentTransform = ParentOriginTransform(transformed);
|
||||
|
||||
return new CustomRectangle(
|
||||
parentTransform.X,
|
||||
parentTransform.Y,
|
||||
parentTransform.Z,
|
||||
parentTransform.W);
|
||||
}
|
||||
|
||||
public CustomRectangle CreateRectangle()
|
||||
{
|
||||
//Do origin transforms
|
||||
@ -225,6 +238,8 @@ namespace LayoutBXLYT
|
||||
|
||||
public class BxlytTextureRef
|
||||
{
|
||||
public short ID { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public virtual WrapMode WrapModeU { get; set; }
|
||||
@ -373,6 +388,84 @@ namespace LayoutBXLYT
|
||||
|
||||
}
|
||||
|
||||
public enum WindowKind
|
||||
{
|
||||
Around = 0,
|
||||
Horizontal = 1,
|
||||
HorizontalNoContent = 2
|
||||
}
|
||||
|
||||
public enum WindowFrameTexFlip : byte
|
||||
{
|
||||
None = 0,
|
||||
FlipH = 1,
|
||||
FlipV = 2,
|
||||
Rotate90 = 3,
|
||||
Rotate180 = 4,
|
||||
Rotate270 = 5
|
||||
}
|
||||
|
||||
public interface IWindowPane
|
||||
{
|
||||
bool UseOneMaterialForAll { get; set; }
|
||||
bool UseVertexColorForAll { get; set; }
|
||||
WindowKind WindowKind { get; set; }
|
||||
bool NotDrawnContent { get; set; }
|
||||
ushort StretchLeft { get; set; }
|
||||
ushort StretchRight { get; set; }
|
||||
ushort StretchTop { get; set; }
|
||||
ushort StretchBottm { get; set; }
|
||||
ushort FrameElementLeft { get; set; }
|
||||
ushort FrameElementRight { get; set; }
|
||||
ushort FrameElementTop { get; set; }
|
||||
ushort FrameElementBottm { get; set; }
|
||||
byte FrameCount { get; set; }
|
||||
|
||||
BxlytWindowContent Content { get; set; }
|
||||
|
||||
List<BxlytWindowFrame> WindowFrames { get; set; }
|
||||
}
|
||||
|
||||
public class BxlytWindowContent
|
||||
{
|
||||
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; }
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public virtual BxlytMaterial Material { get; set; }
|
||||
|
||||
public List<TexCoord> TexCoords = new List<TexCoord>();
|
||||
}
|
||||
|
||||
public class BxlytWindowFrame
|
||||
{
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public BxlytMaterial Material { get; set; }
|
||||
|
||||
public ushort MaterialIndex;
|
||||
public WindowFrameTexFlip TextureFlip;
|
||||
}
|
||||
|
||||
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 LayoutHeader : IDisposable
|
||||
{
|
||||
[Browsable(false)]
|
||||
@ -479,6 +572,9 @@ namespace LayoutBXLYT
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual BxlytShader Shader { get; set; }
|
||||
|
||||
[DisplayName("Texture Maps"), CategoryAttribute("Texture")]
|
||||
public BxlytTextureRef[] TextureMaps { get; set; }
|
||||
}
|
||||
|
||||
public class SectionCommon
|
||||
|
@ -385,22 +385,6 @@ namespace LayoutBXLYT
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
@ -212,6 +212,8 @@
|
||||
<Compile Include="FileFormats\AAMP\AAMP.cs" />
|
||||
<Compile Include="FileFormats\Archives\APAK.cs" />
|
||||
<Compile Include="FileFormats\Archives\ARC.cs" />
|
||||
<Compile Include="FileFormats\Archives\DARC.cs" />
|
||||
<Compile Include="FileFormats\Archives\DAT_Bayonetta.cs" />
|
||||
<Compile Include="FileFormats\Archives\GFA.cs" />
|
||||
<Compile Include="FileFormats\Archives\LM2\LM2_Material.cs" />
|
||||
<Compile Include="FileFormats\Archives\PKZ.cs" />
|
||||
@ -307,7 +309,7 @@
|
||||
<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\CTR\BrlytShader.cs" />
|
||||
<Compile Include="FileFormats\Layout\CTR\BclytShader.cs" />
|
||||
<Compile Include="FileFormats\Layout\LayoutTextureLoader.cs" />
|
||||
<Compile Include="FileFormats\Layout\PaneTreeWrapper.cs" />
|
||||
<Compile Include="FileFormats\Layout\Common.cs" />
|
||||
@ -359,6 +361,12 @@
|
||||
<Compile Include="GUI\BFLYT\LayoutProperties.Designer.cs">
|
||||
<DependentUpon>LayoutProperties.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GUI\BFLYT\LayoutSaveDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GUI\BFLYT\LayoutSaveDialog.Designer.cs">
|
||||
<DependentUpon>LayoutSaveDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GUI\BFLYT\LayoutTextDocked.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -1165,6 +1173,9 @@
|
||||
<EmbeddedResource Include="GUI\BFLYT\LayoutProperties.resx">
|
||||
<DependentUpon>LayoutProperties.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GUI\BFLYT\LayoutSaveDialog.resx">
|
||||
<DependentUpon>LayoutSaveDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GUI\BFLYT\LayoutTextDocked.resx">
|
||||
<DependentUpon>LayoutTextDocked.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
@ -899,7 +899,7 @@ namespace FirstPlugin
|
||||
{
|
||||
foreach (var tex in bntx.Textures)
|
||||
{
|
||||
if (!tex.Value.RenderableTex.GLInitialized)
|
||||
if (tex.Value.RenderableTex != null && !tex.Value.RenderableTex.GLInitialized)
|
||||
tex.Value.LoadOpenGLTexture();
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,7 @@
|
||||
this.textureListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.textConverterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.orthographicViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveAnimationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.backColorDisplay)).BeginInit();
|
||||
this.stToolStrip1.SuspendLayout();
|
||||
this.stMenuStrip1.SuspendLayout();
|
||||
@ -156,6 +157,7 @@
|
||||
this.openToolStripMenuItem,
|
||||
this.clearWorkspaceToolStripMenuItem,
|
||||
this.saveToolStripMenuItem1,
|
||||
this.saveAnimationToolStripMenuItem,
|
||||
this.saveToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
@ -179,7 +181,7 @@
|
||||
//
|
||||
this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1";
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveToolStripMenuItem1.Text = "Save";
|
||||
this.saveToolStripMenuItem1.Text = "Save Layout";
|
||||
this.saveToolStripMenuItem1.Click += new System.EventHandler(this.saveToolStripMenuItem1_Click);
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
@ -227,6 +229,13 @@
|
||||
this.orthographicViewToolStripMenuItem.Text = "Orthographic View";
|
||||
this.orthographicViewToolStripMenuItem.Click += new System.EventHandler(this.orthographicViewToolStripMenuItem_Click);
|
||||
//
|
||||
// saveAnimationToolStripMenuItem
|
||||
//
|
||||
this.saveAnimationToolStripMenuItem.Name = "saveAnimationToolStripMenuItem";
|
||||
this.saveAnimationToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveAnimationToolStripMenuItem.Text = "Save Animation";
|
||||
this.saveAnimationToolStripMenuItem.Click += new System.EventHandler(this.saveAnimationToolStripMenuItem_Click);
|
||||
//
|
||||
// LayoutEditor
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
@ -277,5 +286,6 @@
|
||||
private Toolbox.Library.Forms.STLabel stLabel1;
|
||||
private System.Windows.Forms.ToolStripMenuItem orthographicViewToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripButton toolstripOrthoBtn;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveAnimationToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,13 @@ namespace LayoutBXLYT
|
||||
{
|
||||
public partial class LayoutEditor : Form
|
||||
{
|
||||
public static bool IsSaving = false;
|
||||
|
||||
private Dictionary<string, STGenericTexture> Textures;
|
||||
|
||||
public List<BxlytHeader> LayoutFiles = new List<BxlytHeader>();
|
||||
public List<BxlanHeader> AnimationFiles = new List<BxlanHeader>();
|
||||
|
||||
private BxlytHeader ActiveLayout;
|
||||
private BxlanHeader ActiveAnimation;
|
||||
|
||||
public enum DockLayout
|
||||
{
|
||||
@ -38,8 +38,6 @@ namespace LayoutBXLYT
|
||||
|
||||
public LayoutEditor()
|
||||
{
|
||||
IsSaving = false;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
Textures = new Dictionary<string, STGenericTexture>();
|
||||
@ -72,7 +70,7 @@ namespace LayoutBXLYT
|
||||
private LayoutPartsEditor LayoutPartsEditor;
|
||||
|
||||
private bool isLoaded = false;
|
||||
public void LoadBxlyt(BxlytHeader header, string fileName)
|
||||
public void LoadBxlyt(BxlytHeader header)
|
||||
{
|
||||
LayoutFiles.Add(header);
|
||||
ActiveLayout = header;
|
||||
@ -91,7 +89,18 @@ namespace LayoutBXLYT
|
||||
isLoaded = true;
|
||||
}
|
||||
|
||||
private void InitializeDockPanels()
|
||||
public void LoadBxlan(BxlanHeader header)
|
||||
{
|
||||
AnimationFiles.Add(header);
|
||||
ActiveAnimation = header;
|
||||
|
||||
ShowAnimationHierarchy();
|
||||
ShowPropertiesPanel();
|
||||
|
||||
isLoaded = true;
|
||||
}
|
||||
|
||||
private void InitializeDockPanels(bool isAnimation = false)
|
||||
{
|
||||
ShowTextureList();
|
||||
ShowPartsEditor();
|
||||
@ -152,7 +161,7 @@ namespace LayoutBXLYT
|
||||
|
||||
if (LayoutProperties != null && (string)sender == "Select")
|
||||
{
|
||||
ActiveViewport.SelectedPanes.Clear();
|
||||
ActiveViewport?.SelectedPanes.Clear();
|
||||
|
||||
if (e is TreeViewEventArgs) {
|
||||
var node = ((TreeViewEventArgs)e).Node;
|
||||
@ -161,7 +170,7 @@ namespace LayoutBXLYT
|
||||
{
|
||||
var pane = node.Tag as BasePane;
|
||||
LayoutProperties.LoadProperties(pane, OnProperyChanged);
|
||||
ActiveViewport.SelectedPanes.Add(pane);
|
||||
ActiveViewport?.SelectedPanes.Add(pane);
|
||||
}
|
||||
else
|
||||
LayoutProperties.LoadProperties(node.Tag, OnProperyChanged);
|
||||
@ -190,11 +199,6 @@ namespace LayoutBXLYT
|
||||
ToggleChildern(child, isChecked);
|
||||
}
|
||||
|
||||
public void LoadBflan()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void InitalizeEditors()
|
||||
{
|
||||
|
||||
@ -226,6 +230,14 @@ namespace LayoutBXLYT
|
||||
LayoutProperties.Show(dockPanel1, DockState.DockRight);
|
||||
}
|
||||
|
||||
public void ShowAnimationHierarchy()
|
||||
{
|
||||
LayoutHierarchy = new LayoutHierarchy();
|
||||
LayoutHierarchy.Text = "Animation Hierarchy";
|
||||
LayoutHierarchy.LoadAnimation(ActiveAnimation, ObjectSelected);
|
||||
LayoutHierarchy.Show(dockPanel1, DockState.DockLeft);
|
||||
}
|
||||
|
||||
private void ShowPaneHierarchy()
|
||||
{
|
||||
LayoutHierarchy = new LayoutHierarchy();
|
||||
@ -323,11 +335,11 @@ namespace LayoutBXLYT
|
||||
if (file == null) return;
|
||||
|
||||
if (file is BFLYT)
|
||||
LoadBxlyt(((BFLYT)file).header, file.FileName);
|
||||
LoadBxlyt(((BFLYT)file).header);
|
||||
else if (file is BCLYT)
|
||||
LoadBxlyt(((BCLYT)file).header, file.FileName);
|
||||
LoadBxlyt(((BCLYT)file).header);
|
||||
else if (file is BRLYT)
|
||||
LoadBxlyt(((BRLYT)file).header, file.FileName);
|
||||
LoadBxlyt(((BRLYT)file).header);
|
||||
else if (file is IArchiveFile)
|
||||
{
|
||||
var layouts = SearchLayoutFiles((IArchiveFile)file);
|
||||
@ -340,22 +352,22 @@ namespace LayoutBXLYT
|
||||
foreach (var layout in form.SelectedLayouts())
|
||||
{
|
||||
if (layout is BFLYT)
|
||||
LoadBxlyt(((BFLYT)layout).header, file.FileName);
|
||||
LoadBxlyt(((BFLYT)layout).header);
|
||||
if (layout is BCLYT)
|
||||
LoadBxlyt(((BCLYT)layout).header, file.FileName);
|
||||
LoadBxlyt(((BCLYT)layout).header);
|
||||
if (layout is BRLYT)
|
||||
LoadBxlyt(((BRLYT)layout).header, file.FileName);
|
||||
LoadBxlyt(((BRLYT)layout).header);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (layouts.Count > 0)
|
||||
{
|
||||
if (layouts[0] is BFLYT)
|
||||
LoadBxlyt(((BFLYT)layouts[0]).header, file.FileName);
|
||||
LoadBxlyt(((BFLYT)layouts[0]).header);
|
||||
if (layouts[0] is BCLYT)
|
||||
LoadBxlyt(((BCLYT)layouts[0]).header, file.FileName);
|
||||
LoadBxlyt(((BCLYT)layouts[0]).header);
|
||||
if (layouts[0] is BRLYT)
|
||||
LoadBxlyt(((BRLYT)layouts[0]).header, file.FileName);
|
||||
LoadBxlyt(((BRLYT)layouts[0]).header);
|
||||
}
|
||||
}
|
||||
else if (file is BFLAN)
|
||||
@ -492,23 +504,30 @@ namespace LayoutBXLYT
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem1_Click(object sender, EventArgs e) {
|
||||
SaveActiveFile();
|
||||
if (ActiveLayout != null)
|
||||
SaveActiveFile(ActiveLayout.FileInfo);
|
||||
}
|
||||
|
||||
private void SaveActiveFile(bool ForceDialog = false)
|
||||
private void saveAnimationToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
if (ActiveAnimation != null)
|
||||
SaveActiveFile(ActiveAnimation.FileInfo);
|
||||
}
|
||||
|
||||
private void SaveActiveFile(IFileFormat fileFormat, bool ForceDialog = false)
|
||||
{
|
||||
if (ActiveLayout != null && ActiveLayout.FileInfo.CanSave)
|
||||
if (fileFormat.CanSave)
|
||||
{
|
||||
var fileFormat = ActiveLayout.FileInfo;
|
||||
if (fileFormat.IFileInfo.ArchiveParent != null && !ForceDialog)
|
||||
if (fileFormat.IFileInfo != null &&
|
||||
fileFormat.IFileInfo.ArchiveParent != null && !ForceDialog)
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
IsSaving = true;
|
||||
this.Close();
|
||||
if (fileFormat is IEditorFormParameters)
|
||||
((IEditorFormParameters)fileFormat).OnSave.Invoke(fileFormat, new EventArgs());
|
||||
|
||||
MessageBox.Show($"Saved {fileFormat.FileName} to archive!");
|
||||
}
|
||||
else
|
||||
{
|
||||
STFileSaver.SaveFileFormat(ActiveLayout.FileInfo, fileFormat.FilePath);
|
||||
STFileSaver.SaveFileFormat(fileFormat, fileFormat.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -518,12 +537,18 @@ namespace LayoutBXLYT
|
||||
if (e.Control && e.Alt && e.KeyCode == Keys.S) // Ctrl + Alt + S Save As
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
SaveActiveFile(true);
|
||||
if (ActiveLayout != null)
|
||||
SaveActiveFile(ActiveLayout.FileInfo, true);
|
||||
if (ActiveAnimation != null)
|
||||
SaveActiveFile(ActiveAnimation.FileInfo, true);
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.S) // Ctrl + S Save
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
SaveActiveFile(false);
|
||||
if (ActiveLayout != null)
|
||||
SaveActiveFile(ActiveLayout.FileInfo, false);
|
||||
if (ActiveAnimation != null)
|
||||
SaveActiveFile(ActiveAnimation.FileInfo, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -565,7 +590,10 @@ namespace LayoutBXLYT
|
||||
}
|
||||
|
||||
private void toolStripButton1_Click(object sender, EventArgs e) {
|
||||
SaveActiveFile(false);
|
||||
if (ActiveLayout != null)
|
||||
SaveActiveFile(ActiveLayout.FileInfo, false);
|
||||
if (ActiveAnimation != null)
|
||||
SaveActiveFile(ActiveAnimation.FileInfo, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,11 +50,14 @@ namespace LayoutBXLYT
|
||||
|
||||
private bool isLoaded = false;
|
||||
private EventHandler OnProperySelected;
|
||||
private BxlytHeader ActiveLayout;
|
||||
public void LoadLayout(BxlytHeader bxlyt, EventHandler onPropertySelected)
|
||||
{
|
||||
isLoaded = false;
|
||||
OnProperySelected = onPropertySelected;
|
||||
|
||||
ActiveLayout = bxlyt;
|
||||
|
||||
treeView1.BeginUpdate();
|
||||
treeView1.Nodes.Clear();
|
||||
|
||||
@ -71,12 +74,67 @@ namespace LayoutBXLYT
|
||||
isLoaded = true;
|
||||
}
|
||||
|
||||
public void LoadAnimation(BxlanHeader bxlan, EventHandler onPropertySelected)
|
||||
{
|
||||
isLoaded = false;
|
||||
OnProperySelected = onPropertySelected;
|
||||
|
||||
treeView1.BeginUpdate();
|
||||
treeView1.Nodes.Clear();
|
||||
LoadAnimations(bxlan,new TreeNode(bxlan.FileName) { Tag = bxlan });
|
||||
treeView1.EndUpdate();
|
||||
isLoaded = true;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
treeView1.Nodes.Clear();
|
||||
isLoaded = false;
|
||||
}
|
||||
|
||||
private void LoadAnimations(BxlanHeader bxlan, TreeNode root)
|
||||
{
|
||||
treeView1.Nodes.Add(root);
|
||||
if (bxlan is BFLAN.Header)
|
||||
{
|
||||
var header = bxlan as BFLAN.Header;
|
||||
var pat1 = new TreeNode("Tag Info") { Tag = header.AnimationTag };
|
||||
var pai1 = new TreeNode("Animation Info") { Tag = header.AnimationInfo };
|
||||
|
||||
for (int i = 0; i < header.AnimationInfo.Entries.Count; i++)
|
||||
LoadAnimationEntry(header.AnimationInfo.Entries[i], pai1);
|
||||
|
||||
root.Nodes.Add(pat1);
|
||||
root.Nodes.Add(pai1);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadAnimationEntry(BFLAN.PaiEntry entry, TreeNode root)
|
||||
{
|
||||
var nodeEntry = new TreeNode(entry.Name) { Tag = entry };
|
||||
root.Nodes.Add(nodeEntry);
|
||||
|
||||
for (int i = 0;i < entry.Tags.Count; i++)
|
||||
{
|
||||
var nodeTag = new TreeNode(entry.Tags[i].Type) { Tag = entry.Tags[i] };
|
||||
nodeEntry.Nodes.Add(nodeTag);
|
||||
for (int j = 0; j < entry.Tags[i].Entries.Count; j++)
|
||||
LoadTagEntry(entry.Tags[i].Entries[j], nodeTag, j);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadTagEntry(BFLAN.PaiTagEntry entry, TreeNode root, int index)
|
||||
{
|
||||
var nodeEntry = new TreeNode(entry.TargetName) { Tag = entry };
|
||||
root.Nodes.Add(nodeEntry);
|
||||
|
||||
for (int i = 0; i < entry.KeyFrames.Count; i++)
|
||||
{
|
||||
var keyNode = new TreeNode($"Key Frame {i}") { Tag = entry.KeyFrames[i] };
|
||||
nodeEntry.Nodes.Add(keyNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadTextures(List<string> textures)
|
||||
{
|
||||
TreeNode node = new TreeNode("Textures");
|
||||
@ -84,12 +142,35 @@ namespace LayoutBXLYT
|
||||
for (int i = 0; i < textures.Count; i++)
|
||||
{
|
||||
TreeNode matNode = new TreeNode(textures[i]);
|
||||
matNode.Tag = i;
|
||||
matNode.ContextMenuStrip = new ContextMenuStrip();
|
||||
var menu = new STToolStipMenuItem("Rename");
|
||||
menu.Click += RenameTextureAction;
|
||||
matNode.ContextMenuStrip.Items.Add(menu);
|
||||
matNode.ImageKey = "texture";
|
||||
matNode.SelectedImageKey = "texture";
|
||||
node.Nodes.Add(matNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void RenameTextureAction(object sender, EventArgs e)
|
||||
{
|
||||
var selectedNode = treeView1.SelectedNode;
|
||||
if (selectedNode == null) return;
|
||||
|
||||
int index = (int)selectedNode.Tag;
|
||||
string activeTex = ActiveLayout.Textures[index];
|
||||
|
||||
RenameDialog dlg = new RenameDialog();
|
||||
dlg.SetString(activeTex);
|
||||
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
ActiveLayout.Textures[index] = dlg.textBox1.Text;
|
||||
selectedNode.Text = dlg.textBox1.Text;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadFonts(List<string> fonts)
|
||||
{
|
||||
TreeNode node = new TreeNode("Fonts");
|
||||
|
191
File_Format_Library/GUI/BFLYT/LayoutSaveDialog.Designer.cs
generated
Normal file
191
File_Format_Library/GUI/BFLYT/LayoutSaveDialog.Designer.cs
generated
Normal file
@ -0,0 +1,191 @@
|
||||
namespace FirstPlugin.Forms
|
||||
{
|
||||
partial class LayoutSaveDialog
|
||||
{
|
||||
/// <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 Windows Form 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()
|
||||
{
|
||||
System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Animations");
|
||||
System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Layouts");
|
||||
System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("Textures");
|
||||
System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("Fonts");
|
||||
System.Windows.Forms.TreeNode treeNode5 = new System.Windows.Forms.TreeNode("Shaders");
|
||||
this.stButton1 = new Toolbox.Library.Forms.STButton();
|
||||
this.treeView1 = new System.Windows.Forms.TreeView();
|
||||
this.radioButton1 = new System.Windows.Forms.RadioButton();
|
||||
this.radioButton2 = new System.Windows.Forms.RadioButton();
|
||||
this.radioButton3 = new System.Windows.Forms.RadioButton();
|
||||
this.radioButton4 = new System.Windows.Forms.RadioButton();
|
||||
this.radioButton5 = new System.Windows.Forms.RadioButton();
|
||||
this.radioButton6 = new System.Windows.Forms.RadioButton();
|
||||
this.contentContainer.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// contentContainer
|
||||
//
|
||||
this.contentContainer.Controls.Add(this.radioButton6);
|
||||
this.contentContainer.Controls.Add(this.radioButton5);
|
||||
this.contentContainer.Controls.Add(this.radioButton4);
|
||||
this.contentContainer.Controls.Add(this.radioButton3);
|
||||
this.contentContainer.Controls.Add(this.radioButton2);
|
||||
this.contentContainer.Controls.Add(this.radioButton1);
|
||||
this.contentContainer.Controls.Add(this.treeView1);
|
||||
this.contentContainer.Controls.Add(this.stButton1);
|
||||
this.contentContainer.Size = new System.Drawing.Size(389, 337);
|
||||
this.contentContainer.Controls.SetChildIndex(this.stButton1, 0);
|
||||
this.contentContainer.Controls.SetChildIndex(this.treeView1, 0);
|
||||
this.contentContainer.Controls.SetChildIndex(this.radioButton1, 0);
|
||||
this.contentContainer.Controls.SetChildIndex(this.radioButton2, 0);
|
||||
this.contentContainer.Controls.SetChildIndex(this.radioButton3, 0);
|
||||
this.contentContainer.Controls.SetChildIndex(this.radioButton4, 0);
|
||||
this.contentContainer.Controls.SetChildIndex(this.radioButton5, 0);
|
||||
this.contentContainer.Controls.SetChildIndex(this.radioButton6, 0);
|
||||
//
|
||||
// stButton1
|
||||
//
|
||||
this.stButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.stButton1.Location = new System.Drawing.Point(305, 305);
|
||||
this.stButton1.Name = "stButton1";
|
||||
this.stButton1.Size = new System.Drawing.Size(75, 23);
|
||||
this.stButton1.TabIndex = 0;
|
||||
this.stButton1.Text = "Save";
|
||||
this.stButton1.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// treeView1
|
||||
//
|
||||
this.treeView1.Location = new System.Drawing.Point(3, 31);
|
||||
this.treeView1.Name = "treeView1";
|
||||
treeNode1.Name = "Node5";
|
||||
treeNode1.Text = "Animations";
|
||||
treeNode2.Name = "Node6";
|
||||
treeNode2.Text = "Layouts";
|
||||
treeNode3.Name = "Node7";
|
||||
treeNode3.Text = "Textures";
|
||||
treeNode4.Name = "Node8";
|
||||
treeNode4.Text = "Fonts";
|
||||
treeNode5.Name = "Node9";
|
||||
treeNode5.Text = "Shaders";
|
||||
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
|
||||
treeNode1,
|
||||
treeNode2,
|
||||
treeNode3,
|
||||
treeNode4,
|
||||
treeNode5});
|
||||
this.treeView1.Size = new System.Drawing.Size(248, 271);
|
||||
this.treeView1.TabIndex = 1;
|
||||
//
|
||||
// radioButton1
|
||||
//
|
||||
this.radioButton1.AutoSize = true;
|
||||
this.radioButton1.Location = new System.Drawing.Point(257, 37);
|
||||
this.radioButton1.Name = "radioButton1";
|
||||
this.radioButton1.Size = new System.Drawing.Size(105, 17);
|
||||
this.radioButton1.TabIndex = 2;
|
||||
this.radioButton1.TabStop = true;
|
||||
this.radioButton1.Text = "Save To Archive";
|
||||
this.radioButton1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// radioButton2
|
||||
//
|
||||
this.radioButton2.AutoSize = true;
|
||||
this.radioButton2.Location = new System.Drawing.Point(257, 60);
|
||||
this.radioButton2.Name = "radioButton2";
|
||||
this.radioButton2.Size = new System.Drawing.Size(129, 17);
|
||||
this.radioButton2.TabIndex = 3;
|
||||
this.radioButton2.TabStop = true;
|
||||
this.radioButton2.Text = "Save As New Archive";
|
||||
this.radioButton2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// radioButton3
|
||||
//
|
||||
this.radioButton3.AutoSize = true;
|
||||
this.radioButton3.Location = new System.Drawing.Point(257, 83);
|
||||
this.radioButton3.Name = "radioButton3";
|
||||
this.radioButton3.Size = new System.Drawing.Size(119, 17);
|
||||
this.radioButton3.TabIndex = 4;
|
||||
this.radioButton3.TabStop = true;
|
||||
this.radioButton3.Text = "Save To File/Folder";
|
||||
this.radioButton3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// radioButton4
|
||||
//
|
||||
this.radioButton4.AutoSize = true;
|
||||
this.radioButton4.Location = new System.Drawing.Point(257, 203);
|
||||
this.radioButton4.Name = "radioButton4";
|
||||
this.radioButton4.Size = new System.Drawing.Size(90, 17);
|
||||
this.radioButton4.TabIndex = 5;
|
||||
this.radioButton4.TabStop = true;
|
||||
this.radioButton4.Text = "Save As XML";
|
||||
this.radioButton4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// radioButton5
|
||||
//
|
||||
this.radioButton5.AutoSize = true;
|
||||
this.radioButton5.Location = new System.Drawing.Point(257, 226);
|
||||
this.radioButton5.Name = "radioButton5";
|
||||
this.radioButton5.Size = new System.Drawing.Size(97, 17);
|
||||
this.radioButton5.TabIndex = 6;
|
||||
this.radioButton5.TabStop = true;
|
||||
this.radioButton5.Text = "Save As YAML";
|
||||
this.radioButton5.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// radioButton6
|
||||
//
|
||||
this.radioButton6.AutoSize = true;
|
||||
this.radioButton6.Location = new System.Drawing.Point(257, 180);
|
||||
this.radioButton6.Name = "radioButton6";
|
||||
this.radioButton6.Size = new System.Drawing.Size(97, 17);
|
||||
this.radioButton6.TabIndex = 11;
|
||||
this.radioButton6.TabStop = true;
|
||||
this.radioButton6.Text = "Save As Binary";
|
||||
this.radioButton6.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// LayoutSaveDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(395, 342);
|
||||
this.Name = "LayoutSaveDialog";
|
||||
this.Text = "Layout Save Dialog";
|
||||
this.contentContainer.ResumeLayout(false);
|
||||
this.contentContainer.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Toolbox.Library.Forms.STButton stButton1;
|
||||
private System.Windows.Forms.TreeView treeView1;
|
||||
private System.Windows.Forms.RadioButton radioButton1;
|
||||
private System.Windows.Forms.RadioButton radioButton2;
|
||||
private System.Windows.Forms.RadioButton radioButton3;
|
||||
private System.Windows.Forms.RadioButton radioButton4;
|
||||
private System.Windows.Forms.RadioButton radioButton5;
|
||||
private System.Windows.Forms.RadioButton radioButton6;
|
||||
}
|
||||
}
|
21
File_Format_Library/GUI/BFLYT/LayoutSaveDialog.cs
Normal file
21
File_Format_Library/GUI/BFLYT/LayoutSaveDialog.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Toolbox.Library.Forms;
|
||||
|
||||
namespace FirstPlugin.Forms
|
||||
{
|
||||
public partial class LayoutSaveDialog : STForm
|
||||
{
|
||||
public LayoutSaveDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
120
File_Format_Library/GUI/BFLYT/LayoutSaveDialog.resx
Normal file
120
File_Format_Library/GUI/BFLYT/LayoutSaveDialog.resx
Normal 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>
|
@ -85,6 +85,13 @@ namespace LayoutBXLYT
|
||||
{
|
||||
if (textureList.ContainsKey(texture))
|
||||
{
|
||||
if (header is BCLYT.Header)
|
||||
{
|
||||
//Skip certain formats like bcn ones
|
||||
if (STGenericTexture.IsCompressed(textureList[texture].Format))
|
||||
continue;
|
||||
}
|
||||
|
||||
LoadTextureIcon(index, textureList[texture]);
|
||||
}
|
||||
index++;
|
||||
|
@ -62,11 +62,8 @@ namespace LayoutBXLYT
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
if (LayoutEditor.IsSaving)
|
||||
{
|
||||
base.OnFormClosing(e);
|
||||
return;
|
||||
}
|
||||
base.OnFormClosing(e);
|
||||
return;
|
||||
|
||||
var result = MessageBox.Show("Are you sure you want to close this file? You will lose any unsaved progress!", "Layout Editor", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result != DialogResult.Yes)
|
||||
@ -206,10 +203,10 @@ namespace LayoutBXLYT
|
||||
{
|
||||
if (pane is BFLYT.PIC1 || pane is BCLYT.PIC1 || pane is BRLYT.PIC1)
|
||||
BxlytToGL.DrawPictureBox(pane, effectiveAlpha, Textures);
|
||||
else if (pane is IWindowPane)
|
||||
BxlytToGL.DrawWindowPane(pane, effectiveAlpha, Textures);
|
||||
else if (pane is BFLYT.BND1 || pane is BCLYT.BND1 || pane is BRLYT.BND1)
|
||||
BxlytToGL.DrawBoundryPane(pane, effectiveAlpha, SelectedPanes);
|
||||
else if (pane is BFLYT.WND1)
|
||||
DrawWindowPane((BFLYT.WND1)pane, effectiveAlpha);
|
||||
else if (pane is BFLYT.PRT1)
|
||||
DrawPartsPane((BFLYT.PRT1)pane, effectiveAlpha, parentAlphaInfluence);
|
||||
else
|
||||
@ -298,66 +295,6 @@ namespace LayoutBXLYT
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawWindowPane(BFLYT.WND1 pane, byte effectiveAlpha)
|
||||
{
|
||||
Vector2[] TexCoords = new Vector2[] {
|
||||
new Vector2(1,1),
|
||||
new Vector2(0,1),
|
||||
new Vector2(0,0),
|
||||
new Vector2(1,0)
|
||||
};
|
||||
|
||||
Color[] Colors = new Color[] {
|
||||
pane.Content.ColorTopLeft.Color,
|
||||
pane.Content.ColorTopRight.Color,
|
||||
pane.Content.ColorBottomRight.Color,
|
||||
pane.Content.ColorBottomLeft.Color,
|
||||
};
|
||||
|
||||
|
||||
float frameLeft = 0;
|
||||
float frameTop = 0;
|
||||
float frameRight = 0;
|
||||
float frameBottom = 0;
|
||||
if (pane.FrameCount == 1)
|
||||
{
|
||||
}
|
||||
else if (pane.FrameCount == 4)
|
||||
{
|
||||
|
||||
}
|
||||
else if (pane.FrameCount == 8)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
var mat = pane.Content.Material;
|
||||
if (mat.Shader == null)
|
||||
{
|
||||
mat.Shader = new BflytShader(mat);
|
||||
mat.Shader.Compile();
|
||||
}
|
||||
|
||||
mat.Shader.Enable();
|
||||
((BflytShader)mat.Shader).SetMaterials(Textures);
|
||||
if (pane.Content.TexCoords.Count > 0)
|
||||
{
|
||||
TexCoords = new Vector2[] {
|
||||
pane.Content.TexCoords[0].TopLeft.ToTKVector2(),
|
||||
pane.Content.TexCoords[0].TopRight.ToTKVector2(),
|
||||
pane.Content.TexCoords[0].BottomRight.ToTKVector2(),
|
||||
pane.Content.TexCoords[0].BottomLeft.ToTKVector2(),
|
||||
};
|
||||
}
|
||||
|
||||
BxlytToGL.DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
|
||||
mat.Shader.Disable();
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
GL.PopAttrib();
|
||||
}
|
||||
|
||||
private void DrawPicturePane(BCLYT.PIC1 pane, byte effectiveAlpha)
|
||||
{
|
||||
Vector2[] TexCoords = new Vector2[] {
|
||||
|
@ -318,8 +318,6 @@ namespace FirstPlugin
|
||||
Formats.Add(typeof(NSP));
|
||||
Formats.Add(typeof(BNSH));
|
||||
Formats.Add(typeof(BFSHA));
|
||||
Formats.Add(typeof(BFLIM));
|
||||
Formats.Add(typeof(BCLIM));
|
||||
Formats.Add(typeof(BFSTM));
|
||||
Formats.Add(typeof(BCSTM));
|
||||
Formats.Add(typeof(BRSTM));
|
||||
@ -382,6 +380,11 @@ namespace FirstPlugin
|
||||
Formats.Add(typeof(DKCTF.PAK));
|
||||
Formats.Add(typeof(WTB));
|
||||
Formats.Add(typeof(PKZ));
|
||||
Formats.Add(typeof(DARC));
|
||||
Formats.Add(typeof(BFLIM));
|
||||
Formats.Add(typeof(BCLIM));
|
||||
Formats.Add(typeof(LayoutBXLYT.BFLAN));
|
||||
Formats.Add(typeof(DAT_Bayonetta));
|
||||
|
||||
// Formats.Add(typeof(MSBP));
|
||||
// Formats.Add(typeof(BFGRP));
|
||||
@ -390,7 +393,6 @@ namespace FirstPlugin
|
||||
if (Runtime.DEVELOPER_DEBUG_MODE)
|
||||
{
|
||||
Formats.Add(typeof(XCI));
|
||||
Formats.Add(typeof(LayoutBXLYT.BFLAN));
|
||||
Formats.Add(typeof(XLINK));
|
||||
Formats.Add(typeof(BFSAR));
|
||||
Formats.Add(typeof(GFA));
|
||||
|
@ -292,7 +292,12 @@ namespace Toolbox.Library.Forms
|
||||
|
||||
foreach (var node in TreeViewExtensions.Collect(treeViewCustom1.Nodes))
|
||||
{
|
||||
if (node is IFileFormat)
|
||||
if (node is ArchiveRootNodeWrapper)
|
||||
{
|
||||
var file = ((ArchiveRootNodeWrapper)node).ArchiveFile;
|
||||
((IFileFormat)file).Unload();
|
||||
}
|
||||
else if (node is IFileFormat)
|
||||
{
|
||||
((IFileFormat)node).Unload();
|
||||
}
|
||||
|
@ -142,6 +142,14 @@ namespace Toolbox.Library.IO
|
||||
return ReadString(BinaryStringFormat.ZeroTerminated, encoding ?? Encoding);
|
||||
}
|
||||
|
||||
public string[] ReadZeroTerminatedStrings(uint count, Encoding encoding = null)
|
||||
{
|
||||
string[] str = new string[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
str[i] = ReadString(BinaryStringFormat.ZeroTerminated, encoding ?? Encoding);
|
||||
return str;
|
||||
}
|
||||
|
||||
public string ReadUTF16String()
|
||||
{
|
||||
List<byte> chars = new List<byte>();
|
||||
|
@ -224,10 +224,7 @@ namespace Toolbox.Library.IO
|
||||
|
||||
if (Magic == "Yaz0")
|
||||
{
|
||||
if (data != null)
|
||||
data = EveryFileExplorer.YAZ0.Decompress(data);
|
||||
else
|
||||
data = EveryFileExplorer.YAZ0.Decompress(FileName);
|
||||
data = EveryFileExplorer.YAZ0.Decompress(stream.ToArray());
|
||||
|
||||
return OpenFileFormat(FileName, data, LeaveStreamOpen, InArchive, archiveNode, true,
|
||||
CompressionType.Yaz0, DecompressedFileSize, CompressedFileSize);
|
||||
|
@ -949,11 +949,28 @@ namespace Toolbox.Library
|
||||
{
|
||||
activeForm = GetEditorForm(fileFormat);
|
||||
activeForm.Text = (((IFileFormat)fileFormat).FileName);
|
||||
activeForm.FormClosed += OnFormClosed;
|
||||
if (fileFormat is IEditorFormParameters)
|
||||
{
|
||||
((IEditorFormParameters)fileFormat).OnSave += OnFormSaved;
|
||||
}
|
||||
activeForm.Show();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFormSaved(object sender, EventArgs args)
|
||||
{
|
||||
if (ArchiveFileInfo.FileFormat == null) return;
|
||||
|
||||
Console.WriteLine("OnFormSaved");
|
||||
if (ArchiveFileInfo.FileFormat.CanSave)
|
||||
{
|
||||
Console.WriteLine("SaveFileFormat");
|
||||
|
||||
ArchiveFileInfo.SaveFileFormat();
|
||||
UpdateEditor();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFormClosed(object sender, EventArgs args)
|
||||
{
|
||||
if (ArchiveFileInfo.FileFormat == null) return;
|
||||
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Toolbox.Library
|
||||
{
|
||||
public interface IEditorFormParameters
|
||||
{
|
||||
bool KeepOpen { get; }
|
||||
EventHandler OnSave { get; set; }
|
||||
}
|
||||
}
|
@ -301,6 +301,7 @@
|
||||
<Compile Include="Helpers\ArchiveNodeMenuHelper.cs" />
|
||||
<Compile Include="Helpers\DirectoryHelper.cs" />
|
||||
<Compile Include="Helpers\DragHelper.cs" />
|
||||
<Compile Include="Interfaces\FileFormatting\IFormEditorParameters.cs" />
|
||||
<Compile Include="Interfaces\FileFormatting\ILeaveOpenOnLoad.cs" />
|
||||
<Compile Include="Interfaces\FileFormatting\IPropertyContainer.cs" />
|
||||
<Compile Include="Interfaces\FileFormatting\ISaveOpenedFileStream.cs" />
|
||||
|
Binary file not shown.
@ -3,29 +3,36 @@ uniform vec4 whiteColor;
|
||||
uniform int hasTexture0;
|
||||
uniform int debugShading;
|
||||
uniform int numTextureMaps;
|
||||
|
||||
uniform sampler2D textures0;
|
||||
uniform sampler2D uvTestPattern;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 textureMap0 = vec4(1);
|
||||
vec4 textureMap1 = vec4(1);
|
||||
vec4 textureMap2 = vec4(1);
|
||||
|
||||
if (numTextureMaps > 0)
|
||||
{
|
||||
if (hasTexture0 == 1)
|
||||
textureMap0 = texture2D(textures0, gl_TexCoord[0].st);;
|
||||
textureMap0 = texture2D(textures0, gl_TexCoord[0].st);
|
||||
}
|
||||
|
||||
if (debugShading == 0)
|
||||
{
|
||||
vec4 colorFrag = gl_Color * textureMap0;
|
||||
vec4 colorBlend = colorFrag * whiteColor;
|
||||
gl_FragColor = colorBlend;
|
||||
vec4 colorBlend = textureMap0 * whiteColor;
|
||||
vec3 blackBlend = (vec3(1) - textureMap0.rgb) + blackColor.rgb;
|
||||
gl_FragColor = gl_Color * colorBlend;
|
||||
}
|
||||
if (debugShading == 1)
|
||||
else if (debugShading == 5)
|
||||
gl_FragColor = vec4(textureMap0.rgb, 1);
|
||||
if (debugShading == 2)
|
||||
else if (debugShading == 1)
|
||||
gl_FragColor = gl_Color;
|
||||
else if (debugShading == 2)
|
||||
gl_FragColor = whiteColor;
|
||||
if (debugShading == 3)
|
||||
else if (debugShading == 3)
|
||||
gl_FragColor = blackColor;
|
||||
if (debugShading == 4)
|
||||
else if (debugShading == 4)
|
||||
gl_FragColor = texture2D(uvTestPattern, gl_TexCoord[0].st);
|
||||
}
|
@ -1,11 +1,39 @@
|
||||
uniform vec2 uvScale0;
|
||||
uniform vec2 uvRotate0;
|
||||
uniform vec2 uvTranslate0;
|
||||
uniform int flipTexture;
|
||||
|
||||
vec2 rotateUV(vec2 uv, float rotation)
|
||||
{
|
||||
float mid = 0.5;
|
||||
return vec2(
|
||||
cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid,
|
||||
cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid
|
||||
);
|
||||
}
|
||||
|
||||
vec2 SetFlip(vec2 tex)
|
||||
{
|
||||
vec2 outTexCoord = tex;
|
||||
|
||||
if (flipTexture == 1) //FlipH
|
||||
return vec2(-1, 1) * tex + vec2(1, 0);
|
||||
else if (flipTexture == 2) //FlipV
|
||||
return vec2(1, -1) * tex + vec2(0, 1);
|
||||
else if (flipTexture == 3) //Rotate90
|
||||
return rotateUV(tex, 90.0);
|
||||
else if (flipTexture == 4) //Rotate180
|
||||
return rotateUV(tex, 180.0);
|
||||
else if (flipTexture == 5) //Rotate270
|
||||
return rotateUV(tex, 270.0);
|
||||
|
||||
return outTexCoord;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FrontColor = gl_Color;
|
||||
vec2 texCoord0 = uvScale0 * gl_MultiTexCoord0.xy + uvTranslate0;
|
||||
gl_TexCoord[0].st = texCoord0;
|
||||
gl_TexCoord[0].st = SetFlip(texCoord0);
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user