mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-10 07:04:36 +00:00
Finish bflan saving and more editor improvements.
This commit is contained in:
parent
7344b04d2c
commit
c38ae37562
17 changed files with 788 additions and 267 deletions
|
@ -31,9 +31,7 @@ namespace HedgehogLibrary
|
|||
{
|
||||
using (var reader = new Toolbox.Library.IO.FileReader(stream, true))
|
||||
{
|
||||
return reader.CheckSignature(8, "PACx301L") ||
|
||||
reader.CheckSignature(8, "PACx302L") ||
|
||||
reader.CheckSignature(8, "PACx402L");
|
||||
return reader.CheckSignature(4, "PACx");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,13 +56,29 @@ namespace HedgehogLibrary
|
|||
|
||||
public static bool IsVersion4;
|
||||
|
||||
public bool IsBigEndian = false;
|
||||
|
||||
public ushort Version = 301;
|
||||
|
||||
public List<SplitEntry> SplitEntries = new List<SplitEntry>();
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
using (var reader = new FileReader(stream))
|
||||
{
|
||||
reader.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
|
||||
IsVersion4 = reader.CheckSignature(8, "PACx402L");
|
||||
string signature = reader.ReadString(4, Encoding.ASCII);
|
||||
string version = reader.ReadString(3, Encoding.ASCII);
|
||||
if (!ushort.TryParse(version, out Version)) {
|
||||
}
|
||||
|
||||
|
||||
char bom = reader.ReadChar();
|
||||
IsBigEndian = bom == 'B';
|
||||
|
||||
reader.SetByteOrder(IsBigEndian);
|
||||
|
||||
reader.Position = 0;
|
||||
IsVersion4 = Version > 400;
|
||||
if (IsVersion4)
|
||||
{
|
||||
var header = reader.ReadStruct<HeaderV4>();
|
||||
|
@ -84,13 +98,42 @@ namespace HedgehogLibrary
|
|||
}
|
||||
else
|
||||
{
|
||||
var header3 = reader.ReadStruct<HeaderV3>();
|
||||
if (Version > 300)
|
||||
{
|
||||
var header3 = reader.ReadStruct<HeaderV3>();
|
||||
|
||||
PacNodeTree tree = new PacNodeTree();
|
||||
tree.Read(reader, header3);
|
||||
PacNodeTree tree = new PacNodeTree();
|
||||
tree.Read(reader, header3);
|
||||
|
||||
var rootNode = tree.RootNode;
|
||||
LoadTree(rootNode);
|
||||
var rootNode = tree.RootNode;
|
||||
LoadTree(rootNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
var header2 = reader.ReadStruct<HeaderV2>();
|
||||
|
||||
for (int i = 0; i < header2.FileExtensions; i++)
|
||||
{
|
||||
reader.SeekBegin(header2.FileExtensionsTblOffset + (i * 8));
|
||||
uint offset = reader.ReadUInt32();
|
||||
|
||||
if (offset != 0)
|
||||
{
|
||||
reader.SeekBegin(offset);
|
||||
uint fileExtOffset = reader.ReadUInt32();
|
||||
uint fileTblOffset = reader.ReadUInt32();
|
||||
|
||||
reader.SeekBegin(fileExtOffset);
|
||||
string ext = reader.ReadZeroTerminatedString();
|
||||
|
||||
reader.SeekBegin(fileTblOffset);
|
||||
uint fileCount = reader.ReadUInt32();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
reader.SeekBegin(header2.OffsetTableSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,6 +260,24 @@ namespace HedgehogLibrary
|
|||
public uint SplitCount;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public class HeaderV2
|
||||
{
|
||||
public Magic8 Magic;
|
||||
public uint FileSize;
|
||||
public uint Unknown;
|
||||
public Magic DataMagic;
|
||||
public uint NodesSize;
|
||||
public uint DataEntriesSize;
|
||||
public uint ExtensionTableSize;
|
||||
public uint StringOffsetTableSize;
|
||||
public uint StringTableSize;
|
||||
public uint OffsetTableSize;
|
||||
public uint Flag;
|
||||
public uint FileExtensions;
|
||||
public uint FileExtensionsTblOffset;
|
||||
}
|
||||
|
||||
public class SplitEntry
|
||||
{
|
||||
public ulong SplitNameOffset;
|
||||
|
|
|
@ -7,6 +7,7 @@ using OpenTK.Graphics.OpenGL;
|
|||
using Toolbox.Library;
|
||||
using Toolbox.Library.IO;
|
||||
using OpenTK;
|
||||
using LayoutBXLYT.Cafe;
|
||||
|
||||
namespace LayoutBXLYT
|
||||
{
|
||||
|
@ -86,7 +87,7 @@ namespace LayoutBXLYT
|
|||
};
|
||||
}
|
||||
|
||||
DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
DrawRectangle(pane, pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
|
||||
mat.Shader.Disable();
|
||||
|
||||
|
@ -124,7 +125,7 @@ namespace LayoutBXLYT
|
|||
};
|
||||
}
|
||||
|
||||
DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
DrawRectangle(pane, pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
|
||||
mat.Shader.Disable();
|
||||
|
||||
|
@ -162,7 +163,7 @@ namespace LayoutBXLYT
|
|||
};
|
||||
}
|
||||
|
||||
DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
DrawRectangle(pane, pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
|
||||
mat.Shader.Disable();
|
||||
|
||||
|
@ -170,7 +171,7 @@ namespace LayoutBXLYT
|
|||
GL.PopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void DrawBoundryPane(BasePane pane, byte effectiveAlpha, List<BasePane> SelectedPanes)
|
||||
{
|
||||
if (!Runtime.LayoutEditor.DisplayBoundryPane)
|
||||
|
@ -196,7 +197,7 @@ namespace LayoutBXLYT
|
|||
color,
|
||||
};
|
||||
|
||||
BxlytToGL.DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
BxlytToGL.DrawRectangle(pane, pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,7 +227,7 @@ namespace LayoutBXLYT
|
|||
color,
|
||||
};
|
||||
|
||||
BxlytToGL.DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
BxlytToGL.DrawRectangle(pane, pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
}
|
||||
|
||||
public static void DrawScissorPane(BasePane pane, byte effectiveAlpha, List<BasePane> SelectedPanes)
|
||||
|
@ -254,7 +255,7 @@ namespace LayoutBXLYT
|
|||
color,
|
||||
};
|
||||
|
||||
BxlytToGL.DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
BxlytToGL.DrawRectangle(pane, pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
}
|
||||
|
||||
public static void DrawWindowPane(BasePane pane, byte effectiveAlpha, Dictionary<string, STGenericTexture> Textures)
|
||||
|
@ -571,6 +572,66 @@ namespace LayoutBXLYT
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static BlendingFactor ConvertBlendFactor(BlendMode.GX2BlendFactor blendFactor)
|
||||
{
|
||||
switch (blendFactor)
|
||||
{
|
||||
case BlendMode.GX2BlendFactor.DestAlpha: return BlendingFactor.DstAlpha;
|
||||
case BlendMode.GX2BlendFactor.DestColor: return BlendingFactor.DstColor;
|
||||
case BlendMode.GX2BlendFactor.DestInvAlpha: return BlendingFactor.OneMinusDstAlpha;
|
||||
case BlendMode.GX2BlendFactor.DestInvColor: return BlendingFactor.OneMinusDstColor;
|
||||
case BlendMode.GX2BlendFactor.Factor0: return BlendingFactor.Zero;
|
||||
case BlendMode.GX2BlendFactor.Factor1: return BlendingFactor.One;
|
||||
case BlendMode.GX2BlendFactor.SourceAlpha: return BlendingFactor.SrcAlpha;
|
||||
case BlendMode.GX2BlendFactor.SourceColor: return BlendingFactor.SrcColor;
|
||||
case BlendMode.GX2BlendFactor.SourceInvAlpha: return BlendingFactor.OneMinusSrcAlpha;
|
||||
case BlendMode.GX2BlendFactor.SourceInvColor: return BlendingFactor.OneMinusSrcColor;
|
||||
default: return BlendingFactor.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
private static LogicOp ConvertLogicOperation(BlendMode.GX2LogicOp blendOp)
|
||||
{
|
||||
switch (blendOp)
|
||||
{
|
||||
case BlendMode.GX2LogicOp.And: return LogicOp.And;
|
||||
case BlendMode.GX2LogicOp.Clear: return LogicOp.Clear;
|
||||
case BlendMode.GX2LogicOp.Copy: return LogicOp.Copy;
|
||||
case BlendMode.GX2LogicOp.Equiv: return LogicOp.Equiv;
|
||||
case BlendMode.GX2LogicOp.Inv: return LogicOp.Invert;
|
||||
case BlendMode.GX2LogicOp.Nand: return LogicOp.Nand;
|
||||
case BlendMode.GX2LogicOp.NoOp: return LogicOp.Noop;
|
||||
case BlendMode.GX2LogicOp.Nor: return LogicOp.Nor;
|
||||
case BlendMode.GX2LogicOp.Or: return LogicOp.Or;
|
||||
case BlendMode.GX2LogicOp.RevAnd: return LogicOp.AndReverse;
|
||||
case BlendMode.GX2LogicOp.RevOr: return LogicOp.OrReverse;
|
||||
case BlendMode.GX2LogicOp.Set: return LogicOp.Set;
|
||||
case BlendMode.GX2LogicOp.Xor: return LogicOp.Xor;
|
||||
case BlendMode.GX2LogicOp.Disable:
|
||||
GL.Disable(EnableCap.ColorLogicOp);
|
||||
return LogicOp.Noop;
|
||||
default: return LogicOp.Noop;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static BlendEquationMode ConvertBlendOperation(BlendMode.GX2BlendOp blendOp)
|
||||
{
|
||||
switch (blendOp)
|
||||
{
|
||||
case BlendMode.GX2BlendOp.Add: return BlendEquationMode.FuncAdd;
|
||||
case BlendMode.GX2BlendOp.ReverseSubtract: return BlendEquationMode.FuncReverseSubtract;
|
||||
case BlendMode.GX2BlendOp.SelectMax: return BlendEquationMode.Max;
|
||||
case BlendMode.GX2BlendOp.SelectMin: return BlendEquationMode.Min;
|
||||
case BlendMode.GX2BlendOp.Subtract: return BlendEquationMode.FuncSubtract;
|
||||
case BlendMode.GX2BlendOp.Disable:
|
||||
GL.Disable(EnableCap.Blend);
|
||||
return BlendEquationMode.FuncAdd;
|
||||
default: return BlendEquationMode.FuncAdd;
|
||||
}
|
||||
}
|
||||
|
||||
enum TextureSwizzle
|
||||
{
|
||||
Zero = All.Zero,
|
||||
|
@ -581,7 +642,7 @@ namespace LayoutBXLYT
|
|||
Alpha = All.Alpha,
|
||||
}
|
||||
|
||||
public static void DrawRectangle(CustomRectangle rect, Vector2[] texCoords,
|
||||
public static void DrawRectangle(BasePane pane, CustomRectangle rect, Vector2[] texCoords,
|
||||
Color[] colors, bool useLines = true, byte alpha = 255)
|
||||
{
|
||||
for (int i = 0; i < colors.Length; i++)
|
||||
|
@ -590,42 +651,65 @@ namespace LayoutBXLYT
|
|||
colors[i] = Color.FromArgb((int)setalpha, colors[i]);
|
||||
}
|
||||
|
||||
if (useLines)
|
||||
if (LayoutEditor.UseLegacyGL)
|
||||
{
|
||||
GL.Begin(PrimitiveType.LineLoop);
|
||||
GL.Color4(colors[0]);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.End();
|
||||
if (useLines)
|
||||
{
|
||||
GL.Begin(PrimitiveType.LineLoop);
|
||||
GL.Color4(colors[0]);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.End();
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
|
||||
GL.Enable(EnableCap.LineSmooth);
|
||||
GL.LineWidth(1f);
|
||||
GL.PolygonOffset(1f, 1f);
|
||||
|
||||
GL.Begin(PrimitiveType.Quads);
|
||||
GL.Color4(Color.Green);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.End();
|
||||
|
||||
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
|
||||
GL.PolygonOffset(0f, 0f);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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();
|
||||
if (pane.renderablePane == null)
|
||||
pane.renderablePane = new RenderablePane();
|
||||
|
||||
//Draw outline
|
||||
GL.Begin(PrimitiveType.LineLoop);
|
||||
GL.LineWidth(3);
|
||||
GL.Color4(colors[0]);
|
||||
GL.Vertex2(rect.LeftPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.BottomPoint);
|
||||
GL.Vertex2(rect.RightPoint, rect.TopPoint);
|
||||
GL.Vertex2(rect.LeftPoint, rect.TopPoint);
|
||||
GL.End();
|
||||
Vector3[] vertices = new Vector3[4];
|
||||
vertices[0] = new Vector3(rect.LeftPoint, rect.BottomPoint, 0);
|
||||
vertices[1] = new Vector3(rect.RightPoint, rect.BottomPoint, 0);
|
||||
vertices[2] = new Vector3(rect.RightPoint, rect.TopPoint, 0);
|
||||
vertices[3] = new Vector3(rect.LeftPoint, rect.TopPoint, 0);
|
||||
Vector4[] vertexColors = new Vector4[4];
|
||||
|
||||
pane.renderablePane.Render(vertices, vertexColors, texCoords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,11 @@ using Toolbox;
|
|||
using System.Windows.Forms;
|
||||
using Toolbox.Library;
|
||||
using Toolbox.Library.IO;
|
||||
using SharpYaml.Serialization;
|
||||
|
||||
namespace LayoutBXLYT
|
||||
{
|
||||
public class BFLAN : IEditorForm<LayoutEditor>, IFileFormat
|
||||
public class BFLAN : IEditorForm<LayoutEditor>, IFileFormat, IConvertableTextFormat
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Layout;
|
||||
|
||||
|
@ -38,11 +39,41 @@ namespace LayoutBXLYT
|
|||
}
|
||||
}
|
||||
|
||||
#region Text Converter Interface
|
||||
public TextFileType TextFileType => TextFileType.Xml;
|
||||
public bool CanConvertBack => true;
|
||||
|
||||
public string ConvertToString()
|
||||
{
|
||||
var serializerSettings = new SerializerSettings()
|
||||
{
|
||||
// EmitTags = false
|
||||
};
|
||||
|
||||
serializerSettings.DefaultStyle = SharpYaml.YamlStyle.Any;
|
||||
serializerSettings.ComparerForKeySorting = null;
|
||||
serializerSettings.RegisterTagMapping("Header", typeof(Header));
|
||||
|
||||
return FLAN.ToXml(header);
|
||||
|
||||
var serializer = new Serializer(serializerSettings);
|
||||
string yaml = serializer.Serialize(header, typeof(Header));
|
||||
return yaml;
|
||||
}
|
||||
|
||||
public void ConvertFromString(string text)
|
||||
{
|
||||
header = FLAN.FromXml(text);
|
||||
header.FileInfo = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Header header;
|
||||
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
CanSave = false;
|
||||
CanSave = true;
|
||||
|
||||
header = new Header();
|
||||
header.Read(new FileReader(stream),this);
|
||||
|
@ -142,7 +173,7 @@ namespace LayoutBXLYT
|
|||
writer.Write(ushort.MaxValue); //Reserve space for section count later
|
||||
writer.Seek(2); //padding
|
||||
|
||||
int sectionCount = 1;
|
||||
int sectionCount = 0;
|
||||
|
||||
WriteSection(writer, "pat1", AnimationTag, () => AnimationTag.Write(writer, this));
|
||||
sectionCount++;
|
||||
|
@ -192,6 +223,8 @@ namespace LayoutBXLYT
|
|||
|
||||
private byte[] UnknownData;
|
||||
|
||||
private byte flags;
|
||||
|
||||
public PAT1()
|
||||
{
|
||||
AnimationOrder = 2;
|
||||
|
@ -222,7 +255,7 @@ namespace LayoutBXLYT
|
|||
|
||||
reader.SeekBegin(startPos + groupNamesOffset);
|
||||
for (int i = 0; i < groupCount; i++)
|
||||
Groups.Add(reader.ReadString(0x24, true));
|
||||
Groups.Add(reader.ReadString(28, true));
|
||||
}
|
||||
|
||||
public override void Write(FileWriter writer, LayoutHeader header)
|
||||
|
@ -244,7 +277,7 @@ namespace LayoutBXLYT
|
|||
|
||||
writer.WriteUint32Offset(startPos + 16, startPos);
|
||||
for (int i = 0; i < Groups.Count; i++)
|
||||
writer.WriteString(Groups[i], 0x24);
|
||||
writer.WriteString(Groups[i], 28);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,10 +285,9 @@ namespace LayoutBXLYT
|
|||
{
|
||||
public ushort FrameSize;
|
||||
|
||||
private byte flags;
|
||||
public bool Loop;
|
||||
|
||||
public List<string> Textures { get; set; }
|
||||
|
||||
public List<PaiEntry> Entries = new List<PaiEntry>();
|
||||
|
||||
public PAI1()
|
||||
|
@ -270,7 +302,7 @@ namespace LayoutBXLYT
|
|||
Textures = new List<string>();
|
||||
|
||||
FrameSize = reader.ReadUInt16();
|
||||
flags = reader.ReadByte();
|
||||
Loop = reader.ReadBoolean();
|
||||
reader.ReadByte(); //padding
|
||||
var numTextures = reader.ReadUInt16();
|
||||
var numEntries = reader.ReadUInt16();
|
||||
|
@ -297,10 +329,11 @@ namespace LayoutBXLYT
|
|||
long startPos = writer.Position - 8;
|
||||
|
||||
writer.Write(FrameSize);
|
||||
writer.Write(flags);
|
||||
writer.Write(Loop);
|
||||
writer.Write((byte)0);
|
||||
writer.Write((ushort)Textures.Count);
|
||||
writer.Write((ushort)Entries.Count);
|
||||
long entryOfsTblPos = writer.Position;
|
||||
writer.Write(0);
|
||||
|
||||
if (Textures.Count > 0)
|
||||
|
@ -315,7 +348,7 @@ namespace LayoutBXLYT
|
|||
}
|
||||
if (Entries.Count > 0)
|
||||
{
|
||||
writer.WriteUint32Offset(startPos + 8, startPos);
|
||||
writer.WriteUint32Offset(entryOfsTblPos, startPos);
|
||||
|
||||
long startOfsPos = writer.Position;
|
||||
writer.Write(new uint[Entries.Count]);
|
||||
|
@ -368,7 +401,7 @@ namespace LayoutBXLYT
|
|||
writer.Write(new uint[Tags.Count]);
|
||||
for (int i = 0; i < Tags.Count; i++)
|
||||
{
|
||||
writer.WriteUint32Offset(startPos + 4 + (i * 4), startPos);
|
||||
writer.WriteUint32Offset(startPos + 32 + (i * 4), startPos);
|
||||
Tags[i].Write(writer, header, Target);
|
||||
}
|
||||
}
|
||||
|
@ -388,12 +421,16 @@ namespace LayoutBXLYT
|
|||
|
||||
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" },
|
||||
{"FLPA","PaneSRT" },
|
||||
{"FLVI","Visibility" },
|
||||
{"FLTS","TextureSRT" },
|
||||
{"FLVC","VertexColor" },
|
||||
{"FLMC","MaterialColor" },
|
||||
{"FLTP","TexturePattern" },
|
||||
{"FLIM","IndTextureSRT" },
|
||||
{"FLAC","AlphaTest" },
|
||||
{"FLCT","FontShadow" },
|
||||
{"FLCC","PerCharacterTransformCurve" },
|
||||
};
|
||||
|
||||
private uint Unknown {get;set;}
|
||||
|
|
|
@ -98,7 +98,12 @@ namespace LayoutBXLYT
|
|||
get
|
||||
{
|
||||
string path = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Bflyt.vert");
|
||||
return System.IO.File.ReadAllText(path);
|
||||
string legacyPath = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Legacy", "Bflyt.vert");
|
||||
|
||||
if (LayoutEditor.UseLegacyGL)
|
||||
return System.IO.File.ReadAllText(legacyPath);
|
||||
else
|
||||
return System.IO.File.ReadAllText(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +112,12 @@ namespace LayoutBXLYT
|
|||
get
|
||||
{
|
||||
string path = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Bflyt.frag");
|
||||
return System.IO.File.ReadAllText(path);
|
||||
string legacyPath = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Legacy", "Bflyt.frag");
|
||||
|
||||
if (LayoutEditor.UseLegacyGL)
|
||||
return System.IO.File.ReadAllText(legacyPath);
|
||||
else
|
||||
return System.IO.File.ReadAllText(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
256
File_Format_Library/FileFormats/Layout/CAFE/FLAN.cs
Normal file
256
File_Format_Library/FileFormats/Layout/CAFE/FLAN.cs
Normal file
|
@ -0,0 +1,256 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using LayoutBXLYT.Cafe;
|
||||
|
||||
namespace LayoutBXLYT
|
||||
{
|
||||
public class FLAN
|
||||
{
|
||||
public static BFLAN.Header FromXml(string text)
|
||||
{
|
||||
BFLAN.Header header = new BFLAN.Header();
|
||||
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(XmlRoot));
|
||||
XmlRoot flyt = (XmlRoot)serializer.Deserialize(new StringReader(text));
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
public static string ToXml(BFLAN.Header header)
|
||||
{
|
||||
XmlRoot root = new XmlRoot();
|
||||
root.head = new Head();
|
||||
root.body = new Body();
|
||||
|
||||
var generator = new Generator();
|
||||
root.head.generator = generator;
|
||||
generator.name = "ST";
|
||||
generator.version = "1.0"
|
||||
;
|
||||
var create = new Create();
|
||||
root.head.create = create;
|
||||
create.date = DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss");
|
||||
|
||||
BinaryInfo info = new BinaryInfo();
|
||||
info.layout.name = header.AnimationTag.Name;
|
||||
info.version.major = (byte)header.VersionMajor;
|
||||
info.version.minor = (byte)header.VersionMinor;
|
||||
info.version.micro = (byte)header.VersionMicro;
|
||||
info.version.micro2 = (byte)header.VersionMicro2;
|
||||
root.head.binaryInfo = info;
|
||||
|
||||
AnimTag tag = new AnimTag();
|
||||
AnimInfo animInfo = new AnimInfo();
|
||||
|
||||
if (header.AnimationInfo.Loop)
|
||||
tag.animLoop = AnimLoopType.Loop;
|
||||
|
||||
tag.descendingBind = header.AnimationTag.ChildBinding;
|
||||
tag.name = header.AnimationTag.Name;
|
||||
tag.fileName = header.AnimationTag.Name;
|
||||
tag.startFrame = header.AnimationTag.StartFrame;
|
||||
tag.endFrame = header.AnimationTag.EndFrame;
|
||||
tag.group = new Group[header.AnimationTag.Groups.Count];
|
||||
for (int i =0; i < header.AnimationTag.Groups.Count; i++) {
|
||||
tag.group[i] = new Group();
|
||||
tag.group[i].name = header.AnimationTag.Groups[i];
|
||||
}
|
||||
|
||||
root.body.animTag[0] = tag;
|
||||
root.body.lan[0] = animInfo;
|
||||
|
||||
var bflanInfo = header.AnimationInfo;
|
||||
var animContent = new AnimContent();
|
||||
animInfo.animContent[0] = animContent;
|
||||
animInfo.startFrame = bflanInfo.FrameSize;
|
||||
|
||||
|
||||
|
||||
XmlWriterSettings settings = new XmlWriterSettings
|
||||
{
|
||||
Encoding = Encoding.UTF8,
|
||||
Indent = true,
|
||||
IndentChars = " ",
|
||||
};
|
||||
|
||||
|
||||
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
|
||||
ns.Add("", "");
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", null, null);
|
||||
xmldecl.Encoding = "UTF-8";
|
||||
xmldecl.Standalone = "yes";
|
||||
|
||||
var stringWriter = new StringWriter();
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(XmlRoot));
|
||||
XmlWriter output = XmlWriter.Create(stringWriter, settings);
|
||||
serializer.Serialize(output, root, ns);
|
||||
return stringWriter.ToString();
|
||||
}
|
||||
|
||||
[XmlRootAttribute("nw4f_layout")]
|
||||
public class XmlRoot
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string version = "1.5.16";
|
||||
|
||||
public Head head = new Head();
|
||||
public Body body = new Body();
|
||||
}
|
||||
|
||||
public class BinaryInfo
|
||||
{
|
||||
public BinaryLayout layout = new BinaryLayout();
|
||||
public BinaryVersion version = new BinaryVersion();
|
||||
}
|
||||
|
||||
public class BinaryLayout
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string name = "";
|
||||
}
|
||||
|
||||
public class BinaryVersion
|
||||
{
|
||||
[XmlAttribute]
|
||||
public byte major;
|
||||
|
||||
[XmlAttribute]
|
||||
public byte minor;
|
||||
|
||||
[XmlAttribute]
|
||||
public byte micro;
|
||||
|
||||
[XmlAttribute]
|
||||
public byte micro2;
|
||||
}
|
||||
|
||||
public class Head
|
||||
{
|
||||
public Create create = new Create();
|
||||
public Title title = new Title();
|
||||
public Comment comment = new Comment();
|
||||
public Generator generator = new Generator();
|
||||
public BinaryInfo binaryInfo = new BinaryInfo();
|
||||
}
|
||||
|
||||
public class Comment
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class Title
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class Create
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string user = "";
|
||||
|
||||
[XmlAttribute]
|
||||
public string host = "";
|
||||
|
||||
[XmlAttribute]
|
||||
public string date = "";
|
||||
|
||||
[XmlAttribute]
|
||||
public string source = "";
|
||||
}
|
||||
|
||||
public class Generator
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string name = "";
|
||||
|
||||
[XmlAttribute]
|
||||
public string version = "";
|
||||
}
|
||||
|
||||
public class Body
|
||||
{
|
||||
[XmlArrayItem]
|
||||
public AnimTag[] animTag = new AnimTag[1];
|
||||
|
||||
[XmlArrayItem]
|
||||
public AnimInfo[] lan = new AnimInfo[1];
|
||||
}
|
||||
|
||||
public class AnimTag
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string name = "";
|
||||
|
||||
[XmlAttribute]
|
||||
public int startFrame = 0;
|
||||
|
||||
[XmlAttribute]
|
||||
public int endFrame = 0;
|
||||
|
||||
public AnimLoopType animLoop = AnimLoopType.OneTime;
|
||||
|
||||
[XmlAttribute]
|
||||
public string fileName = "";
|
||||
|
||||
[XmlAttribute]
|
||||
public bool descendingBind = false;
|
||||
|
||||
[XmlArrayItem]
|
||||
public Group[] group;
|
||||
}
|
||||
|
||||
public enum AnimLoopType
|
||||
{
|
||||
Loop,
|
||||
OneTime,
|
||||
}
|
||||
|
||||
public class Group
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string name = "";
|
||||
}
|
||||
|
||||
public class AnimInfo
|
||||
{
|
||||
[XmlAttribute]
|
||||
public AnimType animType;
|
||||
|
||||
[XmlAttribute]
|
||||
public int startFrame = 0;
|
||||
|
||||
[XmlAttribute]
|
||||
public int endFrame = 0;
|
||||
|
||||
[XmlAttribute]
|
||||
public int convertStartFrame = 0;
|
||||
|
||||
[XmlAttribute]
|
||||
public int convertEndFrame = 0;
|
||||
|
||||
[XmlArrayItem]
|
||||
public AnimContent[] animContent;
|
||||
}
|
||||
|
||||
public enum AnimType
|
||||
{
|
||||
PaneSRT,
|
||||
VertexColor,
|
||||
MaterialColor,
|
||||
TextureSRT,
|
||||
}
|
||||
|
||||
public class AnimContent
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string name = "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -95,7 +95,12 @@ namespace LayoutBXLYT
|
|||
get
|
||||
{
|
||||
string path = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Bflyt.vert");
|
||||
return System.IO.File.ReadAllText(path);
|
||||
string legacyPath = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Legacy", "Bflyt.vert");
|
||||
|
||||
if (LayoutEditor.UseLegacyGL)
|
||||
return System.IO.File.ReadAllText(legacyPath);
|
||||
else
|
||||
return System.IO.File.ReadAllText(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +109,12 @@ namespace LayoutBXLYT
|
|||
get
|
||||
{
|
||||
string path = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Bflyt.frag");
|
||||
return System.IO.File.ReadAllText(path);
|
||||
string legacyPath = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Legacy", "Bflyt.frag");
|
||||
|
||||
if (LayoutEditor.UseLegacyGL)
|
||||
return System.IO.File.ReadAllText(legacyPath);
|
||||
else
|
||||
return System.IO.File.ReadAllText(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ namespace LayoutBXLYT
|
|||
get { return Parent != null && Parent.IsRoot; }
|
||||
}
|
||||
|
||||
internal RenderablePane renderablePane;
|
||||
|
||||
[DisplayName("Alpha"), CategoryAttribute("Alpha")]
|
||||
public byte Alpha { get; set; }
|
||||
|
||||
|
@ -385,7 +387,38 @@ namespace LayoutBXLYT
|
|||
|
||||
public enum LMCTarget : byte
|
||||
{
|
||||
BlackColorRed,
|
||||
BlackColorGreen,
|
||||
BlackColorBlue,
|
||||
BlackColorAlpha,
|
||||
WhiteColorRed,
|
||||
WhiteColorGreen,
|
||||
WhiteColorBlue,
|
||||
WhiteColorAlpha,
|
||||
}
|
||||
|
||||
public enum LFSTarget : byte
|
||||
{
|
||||
FontShadowBlackColorRed,
|
||||
FontShadowBlackColorGreen,
|
||||
FontShadowBlackColorBlue,
|
||||
FontShadowBlackColorAlpha,
|
||||
FontShadowWhiteColorRed,
|
||||
FontShadowWhiteColorGreen,
|
||||
FontShadowWhiteColorBlue,
|
||||
FontShadowWhiteColorAlpha,
|
||||
}
|
||||
|
||||
public enum LCTTarget : byte
|
||||
{
|
||||
FontShadowBlackColorRed,
|
||||
FontShadowBlackColorGreen,
|
||||
FontShadowBlackColorBlue,
|
||||
FontShadowBlackColorAlpha,
|
||||
FontShadowWhiteColorRed,
|
||||
FontShadowWhiteColorGreen,
|
||||
FontShadowWhiteColorBlue,
|
||||
FontShadowWhiteColorAlpha,
|
||||
}
|
||||
|
||||
public enum WindowKind
|
||||
|
|
77
File_Format_Library/FileFormats/Layout/RenderablePane.cs
Normal file
77
File_Format_Library/FileFormats/Layout/RenderablePane.cs
Normal file
|
@ -0,0 +1,77 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace LayoutBXLYT
|
||||
{
|
||||
public class RenderablePane
|
||||
{
|
||||
int vbo_position;
|
||||
|
||||
public struct Vertex
|
||||
{
|
||||
public Vector3 Position;
|
||||
public Vector4 Color;
|
||||
public Vector2 TexCoord0;
|
||||
public Vector2 TexCoord1;
|
||||
public Vector2 TexCoord2;
|
||||
|
||||
public static int SizeInBytes = 4 * (3 + 4 + 2 + 2 + 2);
|
||||
}
|
||||
|
||||
private void GenerateBuffers(Vector3[] positions, Vector4[] colors, Vector2[] texCoords0)
|
||||
{
|
||||
GL.GenBuffers(1, out vbo_position);
|
||||
UpdateVertexData(positions, colors, texCoords0);
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
bool buffersWereInitialized = vbo_position != 0;
|
||||
if (!buffersWereInitialized)
|
||||
return;
|
||||
|
||||
GL.DeleteBuffer(vbo_position);
|
||||
}
|
||||
|
||||
public Vertex[] Vertices;
|
||||
|
||||
public void Render(Vector3[] positions, Vector4[] colors, Vector2[] texCoords0)
|
||||
{
|
||||
bool buffersWereInitialized = vbo_position != 0;
|
||||
if (!buffersWereInitialized)
|
||||
GenerateBuffers(positions, colors, texCoords0);
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
|
||||
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 0);
|
||||
GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 12);
|
||||
GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 28);
|
||||
GL.VertexAttribPointer(3, 2, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 36);
|
||||
GL.VertexAttribPointer(4, 2, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 44);
|
||||
|
||||
GL.DrawArrays(PrimitiveType.Triangles, 0, 3);
|
||||
}
|
||||
|
||||
public void UpdateVertexData(Vector3[] positions, Vector4[] colors, Vector2[] texCoords0)
|
||||
{
|
||||
Vertices = new Vertex[positions.Length];
|
||||
for (int v = 0; v < Vertices.Length; v++)
|
||||
{
|
||||
Vertices[v] = new Vertex();
|
||||
Vertices[v].Position = positions[v];
|
||||
Vertices[v].Color = colors[v];
|
||||
Vertices[v].TexCoord0 = texCoords0[v];
|
||||
}
|
||||
|
||||
GL.GenBuffers(1, out vbo_position);
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
|
||||
GL.BufferData<Vertex>(BufferTarget.ArrayBuffer,
|
||||
new IntPtr(Vertices.Length * Vertex.SizeInBytes),
|
||||
Vertices, BufferUsageHint.StaticDraw);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -92,7 +92,12 @@ namespace LayoutBXLYT
|
|||
get
|
||||
{
|
||||
string path = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Bflyt.vert");
|
||||
return System.IO.File.ReadAllText(path);
|
||||
string legacyPath = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Legacy", "Bflyt.vert");
|
||||
|
||||
if (LayoutEditor.UseLegacyGL)
|
||||
return System.IO.File.ReadAllText(legacyPath);
|
||||
else
|
||||
return System.IO.File.ReadAllText(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +106,12 @@ namespace LayoutBXLYT
|
|||
get
|
||||
{
|
||||
string path = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Bflyt.frag");
|
||||
return System.IO.File.ReadAllText(path);
|
||||
string legacyPath = System.IO.Path.Combine(Runtime.ExecutableDir, "Shader", "Layout", "Legacy", "Bflyt.frag");
|
||||
|
||||
if (LayoutEditor.UseLegacyGL)
|
||||
return System.IO.File.ReadAllText(legacyPath);
|
||||
else
|
||||
return System.IO.File.ReadAllText(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -298,6 +298,7 @@
|
|||
<Compile Include="FileFormats\HyruleWarriors\LINKDATA.cs" />
|
||||
<Compile Include="FileFormats\Layout\BxlytShader.cs" />
|
||||
<Compile Include="FileFormats\Layout\BxlytToGL.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\FLAN.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\AlphaCompare.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\BlendMode.cs" />
|
||||
<Compile Include="FileFormats\Layout\CAFE\Materials\FontShadowParameter.cs" />
|
||||
|
@ -313,6 +314,7 @@
|
|||
<Compile Include="FileFormats\Layout\LayoutTextureLoader.cs" />
|
||||
<Compile Include="FileFormats\Layout\PaneTreeWrapper.cs" />
|
||||
<Compile Include="FileFormats\Layout\Common.cs" />
|
||||
<Compile Include="FileFormats\Layout\RenderablePane.cs" />
|
||||
<Compile Include="FileFormats\Layout\Rev\BrlytShader.cs" />
|
||||
<Compile Include="FileFormats\Layout\Rev\BRLYT.cs" />
|
||||
<Compile Include="FileFormats\Message\MSBP.cs" />
|
||||
|
|
|
@ -19,6 +19,12 @@ namespace LayoutBXLYT
|
|||
{
|
||||
public partial class LayoutEditor : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Enables or disables legacy opengl support
|
||||
/// Modern support is not quite finished yet so keep enabled!
|
||||
/// </summary>
|
||||
public static bool UseLegacyGL = true;
|
||||
|
||||
private Dictionary<string, STGenericTexture> Textures;
|
||||
|
||||
public List<BxlytHeader> LayoutFiles = new List<BxlytHeader>();
|
||||
|
@ -49,7 +55,6 @@ namespace LayoutBXLYT
|
|||
|
||||
viewportBackColorCB.Items.Add("Back Color : Default");
|
||||
viewportBackColorCB.Items.Add("Back Color : Custom");
|
||||
viewportBackColorCB.SelectedIndex = 0;
|
||||
orthographicViewToolStripMenuItem.Checked = true;
|
||||
|
||||
foreach (var type in Enum.GetValues(typeof(Runtime.LayoutEditor.DebugShading)).Cast<Runtime.LayoutEditor.DebugShading>())
|
||||
|
@ -63,6 +68,11 @@ namespace LayoutBXLYT
|
|||
|
||||
ObjectSelected += OnObjectSelected;
|
||||
ObjectChanged += OnObjectChanged;
|
||||
|
||||
if (Runtime.LayoutEditor.BackgroundColor != Color.FromArgb(130, 130, 130))
|
||||
viewportBackColorCB.SelectedIndex = 1;
|
||||
else
|
||||
viewportBackColorCB.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private List<LayoutViewer> Viewports = new List<LayoutViewer>();
|
||||
|
@ -277,6 +287,11 @@ namespace LayoutBXLYT
|
|||
ActiveViewport.UpdateBackgroundColor(Color.FromArgb(130, 130, 130));
|
||||
backColorDisplay.BackColor = Color.FromArgb(130, 130, 130);
|
||||
}
|
||||
else if (!isLoaded)
|
||||
{
|
||||
ActiveViewport.UpdateBackgroundColor(Runtime.LayoutEditor.BackgroundColor);
|
||||
backColorDisplay.BackColor = Runtime.LayoutEditor.BackgroundColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorDialog dlg = new ColorDialog();
|
||||
|
|
|
@ -207,6 +207,10 @@ namespace LayoutBXLYT
|
|||
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.SCR1)
|
||||
BxlytToGL.DrawScissorPane(pane, effectiveAlpha, SelectedPanes);
|
||||
else if (pane is BFLYT.ALI1)
|
||||
BxlytToGL.DrawAlignmentPane(pane, effectiveAlpha, SelectedPanes);
|
||||
else if (pane is BFLYT.PRT1)
|
||||
DrawPartsPane((BFLYT.PRT1)pane, effectiveAlpha, parentAlphaInfluence);
|
||||
else
|
||||
|
@ -253,6 +257,9 @@ namespace LayoutBXLYT
|
|||
|
||||
private void DrawDefaultPane(BasePane pane)
|
||||
{
|
||||
if (!Runtime.LayoutEditor.DisplayNullPane)
|
||||
return;
|
||||
|
||||
Vector2[] TexCoords = new Vector2[] {
|
||||
new Vector2(1,1),
|
||||
new Vector2(0,1),
|
||||
|
@ -271,7 +278,7 @@ namespace LayoutBXLYT
|
|||
color,
|
||||
};
|
||||
|
||||
BxlytToGL.DrawRectangle(pane.Rectangle, TexCoords, Colors);
|
||||
BxlytToGL.DrawRectangle(pane, pane.Rectangle, TexCoords, Colors);
|
||||
}
|
||||
|
||||
private void DrawPartsPane(BFLYT.PRT1 pane, byte effectiveAlpha, bool parentInfluenceAlpha)
|
||||
|
@ -295,187 +302,6 @@ namespace LayoutBXLYT
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawPicturePane(BCLYT.PIC1 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.ColorTopLeft.Color,
|
||||
pane.ColorTopRight.Color,
|
||||
pane.ColorBottomRight.Color,
|
||||
pane.ColorBottomLeft.Color,
|
||||
};
|
||||
|
||||
var mat = pane.Material;
|
||||
if (pane.TexCoords.Length > 0)
|
||||
{
|
||||
string textureMap0 = "";
|
||||
if (mat.TextureMaps.Count > 0)
|
||||
textureMap0 = mat.GetTexture(0);
|
||||
|
||||
// if (Textures.ContainsKey(textureMap0))
|
||||
// BindGLTexture(mat.TextureMaps[0], Textures[textureMap0]);
|
||||
|
||||
TexCoords = new Vector2[] {
|
||||
pane.TexCoords[0].TopLeft.ToTKVector2(),
|
||||
pane.TexCoords[0].TopRight.ToTKVector2(),
|
||||
pane.TexCoords[0].BottomRight.ToTKVector2(),
|
||||
pane.TexCoords[0].BottomLeft.ToTKVector2(),
|
||||
};
|
||||
}
|
||||
|
||||
BxlytToGL.DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
|
||||
private void DrawPicturePane(BRLYT.PIC1 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.ColorTopLeft.Color,
|
||||
pane.ColorTopRight.Color,
|
||||
pane.ColorBottomRight.Color,
|
||||
pane.ColorBottomLeft.Color,
|
||||
};
|
||||
|
||||
if (pane.TexCoords.Length > 0)
|
||||
{
|
||||
var mat = pane.GetMaterial();
|
||||
string textureMap0 = "";
|
||||
if (mat.TextureMaps.Count > 0)
|
||||
textureMap0 = mat.GetTexture(0);
|
||||
|
||||
// if (Textures.ContainsKey(textureMap0))
|
||||
// BindGLTexture(mat.TextureMaps[0], Textures[textureMap0]);
|
||||
if (Runtime.LayoutEditor.Shading == Runtime.LayoutEditor.DebugShading.UVTestPattern)
|
||||
GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.RenderableTex.TexID);
|
||||
|
||||
TexCoords = new Vector2[] {
|
||||
pane.TexCoords[0].TopLeft.ToTKVector2(),
|
||||
pane.TexCoords[0].TopRight.ToTKVector2(),
|
||||
pane.TexCoords[0].BottomRight.ToTKVector2(),
|
||||
pane.TexCoords[0].BottomLeft.ToTKVector2(),
|
||||
};
|
||||
}
|
||||
|
||||
BxlytToGL.DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
|
||||
private void DrawPicturePane(BFLYT.PIC1 pane, byte effectiveAlpha, int stage = 0)
|
||||
{
|
||||
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.ColorTopLeft.Color,
|
||||
pane.ColorTopRight.Color,
|
||||
pane.ColorBottomRight.Color,
|
||||
pane.ColorBottomLeft.Color,
|
||||
};
|
||||
|
||||
var mat = pane.Material;
|
||||
if (mat.Shader == null)
|
||||
{
|
||||
mat.Shader = new BflytShader(mat);
|
||||
mat.Shader.Compile();
|
||||
}
|
||||
|
||||
mat.Shader.Enable();
|
||||
((BflytShader)mat.Shader).SetMaterials(Textures);
|
||||
|
||||
if (pane.TexCoords.Length > 0)
|
||||
{
|
||||
TexCoords = new Vector2[] {
|
||||
pane.TexCoords[0].TopLeft.ToTKVector2(),
|
||||
pane.TexCoords[0].TopRight.ToTKVector2(),
|
||||
pane.TexCoords[0].BottomRight.ToTKVector2(),
|
||||
pane.TexCoords[0].BottomLeft.ToTKVector2(),
|
||||
};
|
||||
}
|
||||
|
||||
BxlytToGL.DrawRectangle(pane.Rectangle, TexCoords, Colors, false, effectiveAlpha);
|
||||
|
||||
mat.Shader.Disable();
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
GL.PopAttrib();
|
||||
}
|
||||
|
||||
private static BlendingFactor ConvertBlendFactor(BlendMode.GX2BlendFactor blendFactor)
|
||||
{
|
||||
switch (blendFactor)
|
||||
{
|
||||
case BlendMode.GX2BlendFactor.DestAlpha: return BlendingFactor.DstAlpha;
|
||||
case BlendMode.GX2BlendFactor.DestColor: return BlendingFactor.DstColor;
|
||||
case BlendMode.GX2BlendFactor.DestInvAlpha: return BlendingFactor.OneMinusDstAlpha;
|
||||
case BlendMode.GX2BlendFactor.DestInvColor: return BlendingFactor.OneMinusDstColor;
|
||||
case BlendMode.GX2BlendFactor.Factor0: return BlendingFactor.Zero;
|
||||
case BlendMode.GX2BlendFactor.Factor1: return BlendingFactor.One;
|
||||
case BlendMode.GX2BlendFactor.SourceAlpha: return BlendingFactor.SrcAlpha;
|
||||
case BlendMode.GX2BlendFactor.SourceColor: return BlendingFactor.SrcColor;
|
||||
case BlendMode.GX2BlendFactor.SourceInvAlpha: return BlendingFactor.OneMinusSrcAlpha;
|
||||
case BlendMode.GX2BlendFactor.SourceInvColor: return BlendingFactor.OneMinusSrcColor;
|
||||
default: return BlendingFactor.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
private static LogicOp ConvertLogicOperation(BlendMode.GX2LogicOp blendOp)
|
||||
{
|
||||
switch (blendOp)
|
||||
{
|
||||
case BlendMode.GX2LogicOp.And: return LogicOp.And;
|
||||
case BlendMode.GX2LogicOp.Clear: return LogicOp.Clear;
|
||||
case BlendMode.GX2LogicOp.Copy: return LogicOp.Copy;
|
||||
case BlendMode.GX2LogicOp.Equiv: return LogicOp.Equiv;
|
||||
case BlendMode.GX2LogicOp.Inv: return LogicOp.Invert;
|
||||
case BlendMode.GX2LogicOp.Nand: return LogicOp.Nand;
|
||||
case BlendMode.GX2LogicOp.NoOp: return LogicOp.Noop;
|
||||
case BlendMode.GX2LogicOp.Nor: return LogicOp.Nor;
|
||||
case BlendMode.GX2LogicOp.Or: return LogicOp.Or;
|
||||
case BlendMode.GX2LogicOp.RevAnd: return LogicOp.AndReverse;
|
||||
case BlendMode.GX2LogicOp.RevOr: return LogicOp.OrReverse;
|
||||
case BlendMode.GX2LogicOp.Set: return LogicOp.Set;
|
||||
case BlendMode.GX2LogicOp.Xor: return LogicOp.Xor;
|
||||
case BlendMode.GX2LogicOp.Disable:
|
||||
GL.Disable(EnableCap.ColorLogicOp);
|
||||
return LogicOp.Noop;
|
||||
default: return LogicOp.Noop;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static BlendEquationMode ConvertBlendOperation(BlendMode.GX2BlendOp blendOp)
|
||||
{
|
||||
switch (blendOp)
|
||||
{
|
||||
case BlendMode.GX2BlendOp.Add: return BlendEquationMode.FuncAdd;
|
||||
case BlendMode.GX2BlendOp.ReverseSubtract: return BlendEquationMode.FuncReverseSubtract;
|
||||
case BlendMode.GX2BlendOp.SelectMax: return BlendEquationMode.Max;
|
||||
case BlendMode.GX2BlendOp.SelectMin: return BlendEquationMode.Min;
|
||||
case BlendMode.GX2BlendOp.Subtract: return BlendEquationMode.FuncSubtract;
|
||||
case BlendMode.GX2BlendOp.Disable:
|
||||
GL.Disable(EnableCap.Blend);
|
||||
return BlendEquationMode.FuncAdd;
|
||||
default: return BlendEquationMode.FuncAdd;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawBackground()
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
uniform vec4 blackColor;
|
||||
#version 330
|
||||
|
||||
uniform vec4 blackColor;
|
||||
uniform vec4 whiteColor;
|
||||
uniform int hasTexture0;
|
||||
uniform int debugShading;
|
||||
|
@ -7,6 +9,11 @@ uniform int numTextureMaps;
|
|||
uniform sampler2D textures0;
|
||||
uniform sampler2D uvTestPattern;
|
||||
|
||||
in vec2 uv0;
|
||||
in vec4 vertexColor0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 textureMap0 = vec4(1);
|
||||
|
@ -16,23 +23,23 @@ void main()
|
|||
if (numTextureMaps > 0)
|
||||
{
|
||||
if (hasTexture0 == 1)
|
||||
textureMap0 = texture2D(textures0, gl_TexCoord[0].st);
|
||||
textureMap0 = texture2D(textures0, uv0);
|
||||
}
|
||||
|
||||
if (debugShading == 0)
|
||||
{
|
||||
vec4 colorBlend = textureMap0 * whiteColor;
|
||||
vec3 blackBlend = (vec3(1) - textureMap0.rgb) + blackColor.rgb;
|
||||
gl_FragColor = gl_Color * colorBlend;
|
||||
fragColor = vertexColor0 * colorBlend;
|
||||
}
|
||||
else if (debugShading == 5)
|
||||
gl_FragColor = vec4(textureMap0.rgb, 1);
|
||||
fragColor = vec4(textureMap0.rgb, 1);
|
||||
else if (debugShading == 1)
|
||||
gl_FragColor = gl_Color;
|
||||
fragColor = vertexColor0;
|
||||
else if (debugShading == 2)
|
||||
gl_FragColor = whiteColor;
|
||||
fragColor = whiteColor;
|
||||
else if (debugShading == 3)
|
||||
gl_FragColor = blackColor;
|
||||
fragColor = blackColor;
|
||||
else if (debugShading == 4)
|
||||
gl_FragColor = texture2D(uvTestPattern, gl_TexCoord[0].st);
|
||||
fragColor = texture2D(uvTestPattern, uv0);
|
||||
}
|
|
@ -1,8 +1,19 @@
|
|||
uniform vec2 uvScale0;
|
||||
#version 330
|
||||
|
||||
layout(location = 0) in vec3 position;
|
||||
layout(location = 1) in vec4 color;
|
||||
layout(location = 2) in vec2 texCoord0;
|
||||
layout(location = 3) in vec2 texCoord1;
|
||||
layout(location = 4) in vec2 texCoord2;
|
||||
|
||||
uniform mat4 modelViewMatrix;
|
||||
uniform vec2 uvScale0;
|
||||
uniform vec2 uvRotate0;
|
||||
uniform vec2 uvTranslate0;
|
||||
uniform int flipTexture;
|
||||
|
||||
out vec2 uv0;
|
||||
|
||||
vec2 rotateUV(vec2 uv, float rotation)
|
||||
{
|
||||
float mid = 0.5;
|
||||
|
@ -32,8 +43,7 @@ vec2 SetFlip(vec2 tex)
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_FrontColor = gl_Color;
|
||||
vec2 texCoord0 = uvScale0 * gl_MultiTexCoord0.xy + uvTranslate0;
|
||||
gl_TexCoord[0].st = SetFlip(texCoord0);
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
vec2 texCoord0Transformed = uvScale0 * texCoord0.xy + uvTranslate0;
|
||||
uv0 = SetFlip(texCoord0Transformed);
|
||||
gl_Position = modelViewMatrix * vec4(position,1);
|
||||
}
|
38
Toolbox/Shader/Layout/Legacy/Bflyt.frag
Normal file
38
Toolbox/Shader/Layout/Legacy/Bflyt.frag
Normal file
|
@ -0,0 +1,38 @@
|
|||
uniform vec4 blackColor;
|
||||
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);
|
||||
}
|
||||
|
||||
if (debugShading == 0)
|
||||
{
|
||||
vec4 colorBlend = textureMap0 * whiteColor;
|
||||
vec3 blackBlend = (vec3(1) - textureMap0.rgb) + blackColor.rgb;
|
||||
gl_FragColor = gl_Color * colorBlend;
|
||||
}
|
||||
else if (debugShading == 5)
|
||||
gl_FragColor = vec4(textureMap0.rgb, 1);
|
||||
else if (debugShading == 1)
|
||||
gl_FragColor = gl_Color;
|
||||
else if (debugShading == 2)
|
||||
gl_FragColor = whiteColor;
|
||||
else if (debugShading == 3)
|
||||
gl_FragColor = blackColor;
|
||||
else if (debugShading == 4)
|
||||
gl_FragColor = texture2D(uvTestPattern, gl_TexCoord[0].st);
|
||||
}
|
39
Toolbox/Shader/Layout/Legacy/Bflyt.vert
Normal file
39
Toolbox/Shader/Layout/Legacy/Bflyt.vert
Normal file
|
@ -0,0 +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 = SetFlip(texCoord0);
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
}
|
|
@ -251,6 +251,12 @@
|
|||
<None Include="Shader\Layout\Bflyt.vert">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Shader\Layout\Legacy\Bflyt.frag">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Shader\Layout\Legacy\Bflyt.vert">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Shader\Legacy\BFRES.frag" />
|
||||
<None Include="Shader\Legacy\BFRES.vert" />
|
||||
<None Include="Shader\Legacy\KCL.frag">
|
||||
|
|
Loading…
Reference in a new issue