1
0
mirror of synced 2024-09-23 19:18:21 +02:00

Giant layout update. Support BRLYT and BCLYT files!

BRLYT can now be edited and saved.
BCLYT can now be edited and saved.
BRLYT shaders greatly improved using ported shaders from WiiLayoutEditor. Plan to expand upon it for more accuacte shader rendering.
Add support for saving per character transforms.
Add support for BNR files.
Fixed flags so orientation can be edited properly.
Fix issues decoding some gamecube textures.
Fix animation timeline breaking at times for multi selecting animations.
This commit is contained in:
KillzXGaming 2020-02-11 19:19:23 -05:00
parent 9918b811a8
commit 89d5b621b2
115 changed files with 13906 additions and 5195 deletions

View File

@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox;
using System.Windows.Forms;
using Toolbox.Library;
using Toolbox.Library.IO;
namespace FirstPlugin
{
public class BNR : IArchiveFile, IFileFormat
{
public FileType FileType { get; set; } = FileType.Archive;
public bool CanSave { get; set; }
public string[] Description { get; set; } = new string[] { "Wii Opening Banner" };
public string[] Extension { get; set; } = new string[] { "*.bnr" };
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)
{
if (stream.Length < 68) return false;
using (var reader = new Toolbox.Library.IO.FileReader(stream, true)) {
return reader.CheckSignature(4, "IMET", 64);
}
}
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public List<U8.FileEntry> files = new List<U8.FileEntry>();
public IEnumerable<ArchiveFileInfo> Files => files;
public void ClearFiles() { files.Clear(); }
public void Load(System.IO.Stream stream)
{
using (var reader = new FileReader(stream))
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
reader.SeekBegin(64);
reader.ReadSignature(4, "IMET");
reader.SeekBegin(1536);
U8 u8 = new U8();
u8.Load(new SubStream(reader.BaseStream, reader.Position, reader.BaseStream.Length - 1536));
foreach (var file in u8.files) {
file.FileData = ParseFileData(file.FileData);
files.Add(file);
}
}
}
private byte[] ParseFileData(byte[] data) {
using (var reader = new FileReader(data))
{
reader.SetByteOrder(true);
string magic = reader.ReadString(4, Encoding.ASCII);
if (magic == "IMD5")
{
uint fileSize = reader.ReadUInt32();
reader.Seek(8); //padding
byte[] md5Hash = reader.ReadBytes(16);
string compMagic = reader.ReadString(4, Encoding.ASCII);
reader.Position -= 4;
if (compMagic == "LZ77")
return LZ77_WII.Decompress(reader.ReadBytes((int)fileSize));
else
reader.ReadBytes((int)fileSize);
}
if (magic == "IMET")
{
}
if (magic == "BNS")
{
}
}
return data;
}
public void Unload()
{
}
public void Save(System.IO.Stream stream)
{
}
public bool AddFile(ArchiveFileInfo archiveFileInfo)
{
return false;
}
public bool DeleteFile(ArchiveFileInfo archiveFileInfo)
{
return false;
}
}
}

View File

@ -120,6 +120,8 @@ namespace LayoutBXLYT
continue;
var targetGroup = ((IAnimationTarget)group).GetTrack(keyGroup.AnimationTarget);
if (group is LytMaterialColorGroup)
Console.WriteLine($"targetGroup {(RevLMCTarget)keyGroup.AnimationTarget} {targetGroup != null}");
if (targetGroup != null)
{
targetGroup.LoadKeyFrames(keyGroup.KeyFrames);
@ -342,6 +344,13 @@ namespace LayoutBXLYT
public class LytMaterialColorGroup : SubAnimGroup, IAnimationTarget
{
public bool IsRLAN = false;
public LytAnimTrack MatColorR = new LytAnimTrack();
public LytAnimTrack MatColorG = new LytAnimTrack();
public LytAnimTrack MatColorB = new LytAnimTrack();
public LytAnimTrack MatColorA = new LytAnimTrack();
public LytAnimTrack BlackColorR = new LytAnimTrack();
public LytAnimTrack BlackColorG = new LytAnimTrack();
public LytAnimTrack BlackColorB = new LytAnimTrack();
@ -352,33 +361,96 @@ namespace LayoutBXLYT
public LytAnimTrack WhiteColorB = new LytAnimTrack();
public LytAnimTrack WhiteColorA = new LytAnimTrack();
public LytAnimTrack ColorReg3R = new LytAnimTrack();
public LytAnimTrack ColorReg3G = new LytAnimTrack();
public LytAnimTrack ColorReg3B = new LytAnimTrack();
public LytAnimTrack ColorReg3A = new LytAnimTrack();
public LytAnimTrack TevColor1R = new LytAnimTrack();
public LytAnimTrack TevColor1G = new LytAnimTrack();
public LytAnimTrack TevColor1B = new LytAnimTrack();
public LytAnimTrack TevColor1A = new LytAnimTrack();
public LytAnimTrack TevColor2R = new LytAnimTrack();
public LytAnimTrack TevColor2G = new LytAnimTrack();
public LytAnimTrack TevColor2B = new LytAnimTrack();
public LytAnimTrack TevColor2A = new LytAnimTrack();
public LytAnimTrack TevColor3R = new LytAnimTrack();
public LytAnimTrack TevColor3G = new LytAnimTrack();
public LytAnimTrack TevColor3B = new LytAnimTrack();
public LytAnimTrack TevColor3A = new LytAnimTrack();
public LytAnimTrack TevColor4R = new LytAnimTrack();
public LytAnimTrack TevColor4G = new LytAnimTrack();
public LytAnimTrack TevColor4B = new LytAnimTrack();
public LytAnimTrack TevColor4A = new LytAnimTrack();
public override List<STAnimationTrack> GetTracks()
{
List<STAnimationTrack> tracks = new List<STAnimationTrack>();
for (int i = 0; i < 8; i++)
for (int i = 0; i < (IsRLAN ? 30 : 8); i++)
tracks.Add(GetTrack(i));
return tracks;
}
public LytAnimTrack GetTrack(int target)
{
switch (target)
if (!IsRLAN)
{
case 0: return BlackColorR;
case 1: return BlackColorG;
case 2: return BlackColorB;
case 3: return BlackColorA;
case 4: return WhiteColorR;
case 5: return WhiteColorG;
case 6: return WhiteColorB;
case 7: return WhiteColorA;
default: return null;
switch (target)
{
case 0: return BlackColorR;
case 1: return BlackColorG;
case 2: return BlackColorB;
case 3: return BlackColorA;
case 4: return WhiteColorR;
case 5: return WhiteColorG;
case 6: return WhiteColorB;
case 7: return WhiteColorA;
default: return null;
}
}
else
{
switch (target)
{
case 0: return MatColorR;
case 1: return MatColorG;
case 2: return MatColorB;
case 3: return MatColorA;
case 4: return BlackColorR;
case 5: return BlackColorG;
case 6: return BlackColorB;
case 7: return BlackColorA;
case 8: return WhiteColorR;
case 9: return WhiteColorG;
case 10: return WhiteColorB;
case 11: return WhiteColorA;
case 12: return ColorReg3R;
case 13: return ColorReg3G;
case 14: return ColorReg3B;
case 15: return ColorReg3A;
case 16: return TevColor1R;
case 17: return TevColor1G;
case 18: return TevColor1B;
case 19: return TevColor1A;
case 20: return TevColor2R;
case 21: return TevColor2G;
case 22: return TevColor2B;
case 23: return TevColor2A;
case 24: return TevColor3R;
case 25: return TevColor3G;
case 26: return TevColor3B;
case 27: return TevColor3A;
case 28: return TevColor4R;
case 29: return TevColor4G;
case 30: return TevColor4B;
case 31: return TevColor4A;
default: return null;
}
}
}
public LytMaterialColorGroup(BxlanPaiTag entry) : base(entry)
{
public LytMaterialColorGroup(BxlanPaiTag entry) : base(entry) {
IsRLAN = entry is BRLAN.PaiTag;
}
}

View File

@ -29,6 +29,21 @@ namespace LayoutBXLYT
FrameCount = BxlanAnimation.AnimationTag.EndFrame;
StartFrame = BxlanAnimation.AnimationTag.StartFrame;
if (StartFrame == 0 && FrameCount == 0)
{
foreach (var tag in BxlanAnimation.AnimationInfo.Entries)
{
foreach (var tagEntry in tag.Tags)
{
foreach (var subEntry in tagEntry.Entries)
{
StartFrame = Math.Min(FrameCount, subEntry.KeyFrames.Min(x => x.Frame));
FrameCount = Math.Max(FrameCount, subEntry.KeyFrames.Max(x => x.Frame));
}
}
}
}
Textures.Clear();
AnimGroups.Clear();
foreach (var tex in BxlanAnimation.AnimationInfo.Textures)
@ -45,7 +60,7 @@ namespace LayoutBXLYT
foreach (var pane in parentLayout.PaneLookup.Values)
pane.animController.ResetAnim();
foreach (var mat in parentLayout.GetMaterials())
foreach (var mat in parentLayout.Materials)
mat.animController.ResetAnim();
}
@ -58,6 +73,23 @@ namespace LayoutBXLYT
FrameCount = (uint)header.AnimationTag.EndFrame;
StartFrame = (uint)header.AnimationTag.StartFrame;
if (StartFrame == 0 && FrameCount == 0)
{
foreach (var tag in header.AnimationInfo.Entries)
{
foreach (var tagEntry in tag.Tags)
{
foreach (var subEntry in tagEntry.Entries)
{
StartFrame = Math.Min(FrameCount, subEntry.KeyFrames.Min(x => x.Frame));
FrameCount = Math.Max(FrameCount, subEntry.KeyFrames.Max(x => x.Frame));
}
}
}
}
Console.WriteLine($"FrameSize {BxlanAnimation.AnimationInfo.FrameSize}");
Console.WriteLine($"FrameCount {FrameCount}");
Textures.Clear();
AnimGroups.Clear();
foreach (var tex in header.AnimationInfo.Textures)
@ -200,7 +232,7 @@ namespace LayoutBXLYT
private void LoadMaterialColorGroup(BxlytMaterial mat, LytMaterialColorGroup group)
{
for (int i = 0; i < 8; i++)
for (int i = 0; i < (group.IsRLAN ? 30 : 8); i++)
{
if (group.GetTrack(i).HasKeys)
{

View File

@ -8,7 +8,6 @@ using Toolbox.Library;
using Toolbox.Library.IO;
using Toolbox.Library.Rendering;
using OpenTK;
using LayoutBXLYT.Cafe;
namespace LayoutBXLYT
{
@ -57,9 +56,9 @@ namespace LayoutBXLYT
new Vector2(1,0)
};
if (pane is Cafe.BFLYT.PIC1)
if (pane is Cafe.PIC1)
{
var pic1Pane = pane as Cafe.BFLYT.PIC1;
var pic1Pane = pane as Cafe.PIC1;
STColor8[] stColors = SetupVertexColors(pane,
pic1Pane.ColorBottomRight, pic1Pane.ColorBottomLeft,
@ -72,7 +71,7 @@ namespace LayoutBXLYT
stColors[3].Color,
};
var mat = pic1Pane.Material as BFLYT.Material;
var mat = pic1Pane.Material as Cafe.Material;
var mvp = camera.ModelViewMatrix;
@ -94,9 +93,9 @@ namespace LayoutBXLYT
ShaderLoader.CafeShader.Disable();
}
else if (pane is BCLYT.PIC1)
else if (pane is CTR.PIC1)
{
var pic1Pane = pane as BCLYT.PIC1;
var pic1Pane = pane as CTR.PIC1;
Color[] Colors = new Color[] {
pic1Pane.ColorBottomLeft.Color,
@ -105,10 +104,10 @@ namespace LayoutBXLYT
pic1Pane.ColorTopLeft.Color,
};
var mat = pic1Pane.Material as BCLYT.Material;
var mat = pic1Pane.Material as CTR.Material;
ShaderLoader.CtrShader.Enable();
BclytShader.SetMaterials(ShaderLoader.CtrShader, (BCLYT.Material)mat, pane, Textures);
BclytShader.SetMaterials(ShaderLoader.CtrShader, (CTR.Material)mat, pane, Textures);
if (pic1Pane.TexCoords.Length > 0)
{
@ -124,9 +123,9 @@ namespace LayoutBXLYT
ShaderLoader.CtrShader.Disable();
}
else if (pane is BRLYT.PIC1)
else if (pane is Revolution.PIC1)
{
var pic1Pane = pane as BRLYT.PIC1;
var pic1Pane = pane as Revolution.PIC1;
Color[] Colors = new Color[] {
pic1Pane.ColorBottomLeft.Color,
@ -135,29 +134,193 @@ namespace LayoutBXLYT
pic1Pane.ColorTopLeft.Color,
};
var mat = pic1Pane.Material as BRLYT.Material;
ShaderLoader.RevShader.Enable();
BrlytShader.SetMaterials(ShaderLoader.RevShader, (BRLYT.Material)mat, pane, Textures);
var mat = pic1Pane.Material as Revolution.Material;
RenderBRLYTMaterial(pic1Pane, mat, Textures);
if (pic1Pane.TexCoords.Length > 0)
{
TexCoords = new Vector2[] {
pic1Pane.TexCoords[0].BottomLeft.ToTKVector2(),
pic1Pane.TexCoords[0].BottomRight.ToTKVector2(),
pic1Pane.TexCoords[0].TopRight.ToTKVector2(),
pic1Pane.TexCoords[0].TopLeft.ToTKVector2(),
};
List<Vector2> texCoords = new List<Vector2>();
if (mat.TexCoordGens.Count > 0) {
for (int i = 0; i < mat.TexCoordGens.Count; i++)
{
var texCoord = pic1Pane.TexCoords[(int)mat.TexCoordGens[i].Source - 4];
texCoords.Add(texCoord.BottomLeft.ToTKVector2());
texCoords.Add(texCoord.BottomRight.ToTKVector2());
texCoords.Add(texCoord.TopRight.ToTKVector2());
texCoords.Add(texCoord.TopLeft.ToTKVector2());
}
TexCoords = texCoords.ToArray();
}
else if (pic1Pane.TexCoords.Length > 0)
{
var texCoord = pic1Pane.TexCoords[0];
texCoords.Add(texCoord.BottomLeft.ToTKVector2());
texCoords.Add(texCoord.BottomRight.ToTKVector2());
texCoords.Add(texCoord.TopRight.ToTKVector2());
texCoords.Add(texCoord.TopLeft.ToTKVector2());
TexCoords = texCoords.ToArray();
}
}
DrawRectangle(pane, gameWindow, pane.Rectangle, TexCoords, Colors, false, effectiveAlpha, isSelected);
ShaderLoader.RevShader.Disable();
mat.Shader.Disable();
GL.BindTexture(TextureTarget.Texture2D, 0);
GL.Disable(EnableCap.Texture2D);
// ShaderLoader.RevShader.Disable();
}
// GL.BindTexture(TextureTarget.Texture2D, 0);
// GL.Disable(EnableCap.Texture2D);
// GL.UseProgram(0);
// GL.BindTexture(TextureTarget.Texture2D, 0);
// GL.Disable(EnableCap.Texture2D);
// GL.UseProgram(0);
}
public static void RenderBRLYTMaterial(BasePane pane, Revolution.Material mat, Dictionary<string, STGenericTexture> textures)
{
// ShaderLoader.RevShader.Enable();
if (mat.Shader == null)
{
List<int> texIds = new List<int>();
if (mat.TextureMaps.Length > 0)
{
for (int i = 0; i < mat.TextureMaps.Length; i++)
{
string TexName = mat.TextureMaps[i].Name;
if (mat.animController.TexturePatterns.ContainsKey((LTPTarget)i))
TexName = mat.animController.TexturePatterns[(LTPTarget)i];
if (textures.ContainsKey(TexName))
{
bool binded = BindGLTexture(mat.TextureMaps[i], textures[TexName]);
if (binded)
texIds.Add(textures[TexName].RenderableTex.TexID);
}
}
}
mat.Shader = new Revolution.Shader(mat, (uint)mat.TextureMaps.Length);
mat.Shader.Compile();
}
var alphaCompare = (Revolution.AlphaCompare)mat.AlphaCompare;
var alphaFunc = BxlytToGL.ConvertAlphaFunc(alphaCompare.Comp0);
var alphaFunc2 = BxlytToGL.ConvertAlphaFunc(alphaCompare.Comp1);
var srcFactor = BxlytToGL.ConvertBlendFactor(mat.BlendMode.SourceFactor);
var destFactor = BxlytToGL.ConvertBlendFactor(mat.BlendMode.DestFactor);
var blendOp = BxlytToGL.ConvertBlendOperation(mat.BlendMode.BlendOp);
var logicOp = BxlytToGL.ConvertLogicOperation(mat.BlendMode.LogicOp);
GL.Enable(EnableCap.AlphaTest);
GL.AlphaFunc(alphaFunc, alphaCompare.Ref0 / 255f);
GL.AlphaFunc(alphaFunc2, alphaCompare.Ref1 / 255f);
if (mat.BlendMode.BlendOp != 0)
{
GL.Enable(EnableCap.Blend);
GL.BlendEquation(blendOp);
}
else
{
GL.Disable(EnableCap.Blend);
}
GL.BlendFunc(srcFactor, destFactor);
GL.LogicOp(logicOp);
for (int i = 0; i < 3; i++) {
Matrix4 matTransform = Matrix4.Identity;
mat.Shader.SetMatrix4(String.Format("textureTransforms[{0}]", i), ref matTransform);
}
mat.Shader.Enable();
mat.Shader.SetInt("debugShading", (int)Runtime.LayoutEditor.Shading);
var paneRotate = pane.Rotate;
if (pane.animController.PaneSRT?.Count > 0)
{
foreach (var animItem in pane.animController.PaneSRT)
{
switch (animItem.Key)
{
case LPATarget.RotateX:
paneRotate.X = animItem.Value; break;
case LPATarget.RotateY:
paneRotate.Y = animItem.Value; break;
case LPATarget.RotateZ:
paneRotate.Z = animItem.Value; break;
}
}
}
Matrix4 rotationX = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(paneRotate.X));
Matrix4 rotationY = Matrix4.CreateRotationY(MathHelper.DegreesToRadians(paneRotate.Y));
Matrix4 rotationZ = Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(paneRotate.Z));
var rotationMatrix = rotationX * rotationY * rotationZ;
mat.Shader.SetMatrix4("rotationMatrix", ref rotationMatrix);
//Do uv test pattern
GL.ActiveTexture(TextureUnit.Texture10);
mat.Shader.SetInt("uvTestPattern", 10);
GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.RenderableTex.TexID);
if (mat.TextureMaps.Length > 0 || Runtime.LayoutEditor.Shading == Runtime.LayoutEditor.DebugShading.UVTestPattern)
GL.Enable(EnableCap.Texture2D);
int id = 1;
for (int i = 0; i < mat.TextureMaps.Length; i++)
{
string TexName = mat.TextureMaps[i].Name;
if (mat.animController.TexturePatterns.ContainsKey((LTPTarget)i))
TexName = mat.animController.TexturePatterns[(LTPTarget)i];
mat.Shader.SetInt($"hasTexture{i}", 0);
if (textures.ContainsKey(TexName))
{
GL.ActiveTexture(TextureUnit.Texture0 + id);
mat.Shader.SetInt($"textures{i}", id);
bool binded = BindGLTexture(mat.TextureMaps[i], textures[TexName]);
mat.Shader.SetInt($"hasTexture{i}", 1);
var scale = new Syroot.Maths.Vector2F(1, 1);
float rotate = 0;
var translate = new Syroot.Maths.Vector2F(0, 0);
int index = (int)mat.TexCoordGens[i].MatrixSource / 3 - 10;
if (mat.TextureTransforms.Length > index)
{
var transform = mat.TextureTransforms[index];
scale = transform.Scale;
rotate = transform.Rotate;
translate = transform.Translate;
foreach (var animItem in mat.animController.TextureSRTS)
{
switch (animItem.Key)
{
case LTSTarget.ScaleS: scale.X = animItem.Value; break;
case LTSTarget.ScaleT: scale.Y = animItem.Value; break;
case LTSTarget.Rotate: rotate = animItem.Value; break;
case LTSTarget.TranslateS: translate.X = animItem.Value; break;
case LTSTarget.TranslateT: translate.Y = animItem.Value; break;
}
}
}
Matrix4 matTransform = Matrix4.Identity;
var matScale = Matrix4.CreateScale(scale.X, scale.Y, 1.0f);
var matRotate = Matrix4.CreateFromAxisAngle(new Vector3(0, 0, 1), MathHelper.DegreesToRadians(rotate));
var matTranslate = Matrix4.CreateTranslation(
translate.X / scale.X - 0.5f,
translate.Y / scale.Y - 0.5f,0);
matTransform = matRotate * matTranslate * matScale;
mat.Shader.SetMatrix4(String.Format("textureTransforms[{0}]", i), ref matTransform);
id++;
}
}
mat.Shader.RefreshColors(mat);
}
public static void DrawBoundryPane(BasePane pane, bool gameWindow, byte effectiveAlpha, bool isSelected)
@ -256,7 +419,7 @@ namespace LayoutBXLYT
if (updateBitmap)
BindFontBitmap(pane, fontBitmap);
var mat = textBox.Material as BFLYT.Material;
var mat = textBox.Material as Cafe.Material;
BxlytShader shader = ShaderLoader.CafeShader;
@ -407,11 +570,11 @@ namespace LayoutBXLYT
return;
BxlytShader shader = null;
if (pane is BFLYT.PAN1)
if (pane is Cafe.PAN1)
shader = ShaderLoader.CafeShader;
if (pane is BCLYT.PAN1)
if (pane is CTR.PAN1)
shader = ShaderLoader.CtrShader;
if (pane is BRLYT.PAN1)
if (pane is Revolution.PAN1)
shader = ShaderLoader.RevShader;
var window = (IWindowPane)pane;
@ -522,9 +685,7 @@ namespace LayoutBXLYT
{
var windowFrame = window.WindowFrames[0];
SetupShaders(pane, windowFrame.Material, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[0].TextureFlip);
SetWindowTextureFlip(shader, windowFrame.Material, window.WindowFrames[0].TextureFlip);
hasTextures = windowFrame.Material.TextureMaps?.Length > 0;
@ -557,7 +718,6 @@ namespace LayoutBXLYT
hasTextures = windowFrame.Material.TextureMaps?.Length > 0;
}
texCoords = new Vector2[]
{
new Vector2(1, 0),
@ -725,8 +885,7 @@ namespace LayoutBXLYT
if (matTL.TextureMaps.Length > 0)
{
SetupShaders(pane, matTL, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[0].TextureFlip);
SetWindowTextureFlip(shader, matTL, window.WindowFrames[0].TextureFlip);
float pieceWidth = pane.Width - frameRight;
float pieceHeight = frameTop;
@ -744,8 +903,7 @@ namespace LayoutBXLYT
if (matTR.TextureMaps.Length > 0)
{
SetupShaders(pane, matTR, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[1].TextureFlip);
SetWindowTextureFlip(shader, matTR, window.WindowFrames[1].TextureFlip);
float pieceWidth = frameRight;
float pieceHeight = pane.Height - frameBottom;
@ -763,8 +921,7 @@ namespace LayoutBXLYT
if (matBL.TextureMaps.Length > 0)
{
SetupShaders(pane, matBL, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[2].TextureFlip);
SetWindowTextureFlip(shader, matBL, window.WindowFrames[2].TextureFlip);
float pieceWidth = frameLeft;
float pieceHeight = pane.Height - frameTop;
@ -782,8 +939,7 @@ namespace LayoutBXLYT
if (matBR.TextureMaps.Length > 0)
{
SetupShaders(pane, matBR, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[3].TextureFlip);
SetWindowTextureFlip(shader, matBR, window.WindowFrames[3].TextureFlip);
float pieceWidth = pane.Width - frameLeft;
float pieceHeight = frameBottom;
@ -827,7 +983,7 @@ namespace LayoutBXLYT
if (matTL.TextureMaps.Length > 0)
{
SetupShaders(pane, matTL, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[0].TextureFlip);
SetWindowTextureFlip(shader, matTL, window.WindowFrames[0].TextureFlip);
texCoords = new Vector2[]
{
@ -843,7 +999,7 @@ namespace LayoutBXLYT
if (matTR.TextureMaps.Length > 0)
{
SetupShaders(pane, matTR, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[1].TextureFlip);
SetWindowTextureFlip(shader, matTR, window.WindowFrames[1].TextureFlip);
texCoords = new Vector2[]
{
@ -859,7 +1015,7 @@ namespace LayoutBXLYT
if (matBL.TextureMaps.Length > 0)
{
SetupShaders(pane, matBL, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[2].TextureFlip);
SetWindowTextureFlip(shader, matBL, window.WindowFrames[2].TextureFlip);
texCoords = new Vector2[]
{
@ -875,7 +1031,7 @@ namespace LayoutBXLYT
if (matBR.TextureMaps.Length > 0)
{
SetupShaders(pane, matBR, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[3].TextureFlip);
SetWindowTextureFlip(shader, matBR, window.WindowFrames[3].TextureFlip);
texCoords = new Vector2[]
{
@ -891,7 +1047,7 @@ namespace LayoutBXLYT
if (matT.TextureMaps.Length > 0)
{
SetupShaders(pane, matT, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[4].TextureFlip);
SetWindowTextureFlip(shader, matT, window.WindowFrames[4].TextureFlip);
texCoords = new Vector2[]
{
@ -907,7 +1063,7 @@ namespace LayoutBXLYT
if (matB.TextureMaps.Length > 0)
{
SetupShaders(pane, matB, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[5].TextureFlip);
SetWindowTextureFlip(shader, matB, window.WindowFrames[5].TextureFlip);
texCoords = new Vector2[]
{
@ -923,7 +1079,7 @@ namespace LayoutBXLYT
if (matL.TextureMaps.Length > 0)
{
SetupShaders(pane, matL, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[6].TextureFlip);
SetWindowTextureFlip(shader, matL, window.WindowFrames[6].TextureFlip);
texCoords = new Vector2[]
{
@ -939,7 +1095,7 @@ namespace LayoutBXLYT
if (matR.TextureMaps.Length > 0)
{
SetupShaders(pane, matR, Textures);
shader.SetInt("flipTexture", (int)window.WindowFrames[7].TextureFlip);
SetWindowTextureFlip(shader, matR, window.WindowFrames[7].TextureFlip);
texCoords = new Vector2[]
{
@ -960,6 +1116,14 @@ namespace LayoutBXLYT
GL.UseProgram(0);
}
private static void SetWindowTextureFlip(BxlytShader shader, BxlytMaterial mat, WindowFrameTexFlip flip)
{
if (mat is Revolution.Material)
((Revolution.Material)mat).Shader.SetInt("flipTexture", (int)flip);
else
shader.SetInt("flipTexture", (int)flip);
}
private static void GetTextureSize(BxlytMaterial pane, Dictionary<string, STGenericTexture> Textures, out float width, out float height)
{
width = 0;
@ -1074,20 +1238,19 @@ namespace LayoutBXLYT
private static void SetupShaders(BasePane pane, BxlytMaterial mat, Dictionary<string, STGenericTexture> textures)
{
if (mat is Cafe.BFLYT.Material)
if (mat is Cafe.Material)
{
ShaderLoader.CafeShader.Enable();
BflytShader.SetMaterials(ShaderLoader.CafeShader, (Cafe.BFLYT.Material)mat, pane, textures);
BflytShader.SetMaterials(ShaderLoader.CafeShader, (Cafe.Material)mat, pane, textures);
}
else if (mat is BRLYT.Material)
else if (mat is Revolution.Material)
{
ShaderLoader.RevShader.Enable();
BrlytShader.SetMaterials(ShaderLoader.RevShader, (BRLYT.Material)mat, pane, textures);
RenderBRLYTMaterial(pane, (Revolution.Material)mat, textures);
}
else if (mat is BCLYT.Material)
else if (mat is CTR.Material)
{
ShaderLoader.CtrShader.Enable();
BclytShader.SetMaterials(ShaderLoader.CtrShader, (BCLYT.Material)mat, pane, textures);
BclytShader.SetMaterials(ShaderLoader.CtrShader, (CTR.Material)mat, pane, textures);
}
}
@ -1302,7 +1465,7 @@ namespace LayoutBXLYT
{
for (int i = 0; i < colors.Length; i++)
{
float outAlpha = BasePane.MixColors(colors[i].A, alpha);
float outAlpha = BasePane.MixColors(colors[i].A, (float)(alpha * (float)alpha) / 255f);
colors[i] = Color.FromArgb(Utils.FloatToIntClamp(outAlpha), colors[i]);
}
@ -1320,18 +1483,24 @@ namespace LayoutBXLYT
}
else
{
int numTexCoord = texCoords.Length >= 4 ? 4 / texCoords.Length : 0;
GL.Begin(PrimitiveType.Quads);
GL.Color4(colors[0]);
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[0].X, texCoords[0].Y);
for (int i = 0; i < numTexCoord; i++)
GL.MultiTexCoord2(TextureUnit.Texture0 + i, texCoords[0 + (i * 4)].X, texCoords[0 + (i * 4)].Y);
GL.Vertex2(rect.BottomLeftPoint);
GL.Color4(colors[1]);
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[1].X, texCoords[1].Y);
for (int i = 0; i < numTexCoord; i++)
GL.MultiTexCoord2(TextureUnit.Texture0 + i, texCoords[1 + (i * 4)].X, texCoords[1 + (i * 4)].Y);
GL.Vertex2(rect.BottomRightPoint);
GL.Color4(colors[2]);
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[2].X, texCoords[2].Y);
for (int i = 0; i < numTexCoord; i++)
GL.MultiTexCoord2(TextureUnit.Texture0 + i, texCoords[2 + (i * 4)].X, texCoords[2 + (i * 4)].Y);
GL.Vertex2(rect.TopRightPoint);
GL.Color4(colors[3]);
GL.MultiTexCoord2(TextureUnit.Texture0, texCoords[3].X, texCoords[3].Y);
for (int i = 0; i < numTexCoord; i++)
GL.MultiTexCoord2(TextureUnit.Texture0 + i, texCoords[3 + (i * 4)].X, texCoords[3 + (i * 4)].Y);
GL.Vertex2(rect.TopLeftPoint);
GL.End();
}

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,6 @@ using System.Text;
using System.Threading.Tasks;
using OpenTK.Graphics.OpenGL;
using OpenTK;
using LayoutBXLYT.Cafe;
using Toolbox.Library;
namespace LayoutBXLYT
@ -41,7 +40,7 @@ namespace LayoutBXLYT
SetInt($"texCoords0Source", 0);
}
public static void SetMaterials(BxlytShader shader, BFLYT.Material material, BasePane pane, Dictionary<string, STGenericTexture> textures)
public static void SetMaterials(BxlytShader shader, Cafe.Material material, BasePane pane, Dictionary<string, STGenericTexture> textures)
{
var rotationMatrix = pane.GetRotationMatrix();
shader.SetMatrix("rotationMatrix", ref rotationMatrix);
@ -119,10 +118,10 @@ namespace LayoutBXLYT
}
}
for (int i = 0; i < material.TexCoords?.Length; i++)
for (int i = 0; i < material.TexCoordGens?.Length; i++)
{
shader.SetInt($"texCoords{i}GenType", (int)material.TexCoords[i].GenType);
shader.SetInt($"texCoords{i}Source", (int)material.TexCoords[i].Source);
shader.SetInt($"texCoords{i}GenType", (int)material.TexCoordGens[i].GenType);
shader.SetInt($"texCoords{i}Source", (int)material.TexCoordGens[i].Source);
}
for (int i = 0; i < material.TevStages?.Length; i++)

View File

@ -1,257 +0,0 @@
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 = new AnimContent[1];
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 = "";
}
}
}

View File

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Cafe
{
public class GRP1 : GroupPane
{
public GRP1() { }
public GRP1(FileReader reader, BxlytHeader header)
{
LayoutFile = header;
ushort numNodes = 0;
if (header.VersionMajor >= 5)
{
Name = reader.ReadString(34, true);
numNodes = reader.ReadUInt16();
}
else
{
Name = reader.ReadString(24, true); ;
numNodes = reader.ReadUInt16();
reader.Seek(2); //padding
}
for (int i = 0; i < numNodes; i++)
Panes.Add(reader.ReadString(24, true));
}
public override void Write(FileWriter writer, LayoutHeader header)
{
if (header.Version >= 0x05020000)
{
writer.WriteString(Name, 34);
writer.Write((ushort)Panes.Count);
}
else
{
writer.WriteString(Name, 24);
writer.Write((ushort)Panes.Count);
writer.Seek(2);
}
for (int i = 0; i < Panes.Count; i++)
writer.WriteString(Panes[i], 24);
}
}
}

View File

@ -0,0 +1,559 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using Toolbox.Library;
using Toolbox.Library.IO;
using System.ComponentModel;
namespace LayoutBXLYT.Cafe
{
//Thanks to SwitchThemes for flags, and enums
//https://github.com/FuryBaguette/SwitchLayoutEditor/tree/master/SwitchThemesCommon
public class Header : BxlytHeader, IDisposable
{
private const string Magic = "FLYT";
private ushort ByteOrderMark;
private ushort HeaderSize;
[Browsable(false)]
public LYT1 LayoutInfo { get; set; }
[Browsable(false)]
public TXL1 TextureList { get; set; }
[Browsable(false)]
public MAT1 MaterialList { get; set; }
[Browsable(false)]
public FNL1 FontList { get; set; }
[Browsable(false)]
public CNT1 Container { get; set; }
public USD1 UserData { get; set; }
public override short AddMaterial(BxlytMaterial material, ushort index)
{
if (material == null) return -1;
if (MaterialList.Materials.Count > index)
MaterialList.Materials.Insert(index, (Material)material);
else
MaterialList.Materials.Add((Material)material);
if (material.NodeWrapper == null)
material.NodeWrapper = new MatWrapper(material.Name)
{
Tag = material,
ImageKey = "material",
SelectedImageKey = "material",
};
MaterialFolder.Nodes.Insert(index, material.NodeWrapper);
return (short)MaterialList.Materials.IndexOf((Material)material);
}
public override BasePane CreateNewNullPane(string name) {
return new PAN1(this, name);
}
public override BasePane CreateNewTextPane(string name) {
return new TXT1(this, name);
}
public override BasePane CreateNewPicturePane(string name) {
return new PIC1(this, name);
}
public override BasePane CreateNewWindowPane(string name) {
return new WND1(this, name);
}
public override BasePane CreateNewBoundryPane(string name) {
return new BND1(this, name);
}
public override BasePane CreateNewPartPane(string name) {
return new PRT1(this, name);
}
public override int AddFont(string name)
{
if (!FontList.Fonts.Contains(name))
FontList.Fonts.Add(name);
return FontList.Fonts.IndexOf(name);
}
/// <summary>
/// Adds the given texture if not found. Returns the index of the texture
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public override int AddTexture(string name)
{
if (!TextureList.Textures.Contains(name))
TextureList.Textures.Add(name);
return TextureList.Textures.IndexOf(name);
}
public override void RemoveTexture(string name)
{
if (TextureList.Textures.Contains(name))
TextureList.Textures.Remove(name);
RemoveTextureReferences(name);
}
public override short AddMaterial(BxlytMaterial material)
{
if (material == null) return -1;
if (!MaterialList.Materials.Contains(material))
MaterialList.Materials.Add(material);
if (material.NodeWrapper == null)
material.NodeWrapper = new MatWrapper(material.Name)
{
Tag = material,
ImageKey = "material",
SelectedImageKey = "material",
};
if (!MaterialFolder.Nodes.Contains(material.NodeWrapper))
MaterialFolder.Nodes.Add(material.NodeWrapper);
return (short)MaterialList.Materials.IndexOf(material);
}
public override List<int> AddMaterial(List<BxlytMaterial> materials)
{
List<int> indices = new List<int>();
foreach (var material in materials)
indices.Add(AddMaterial(material));
return indices;
}
public override void TryRemoveMaterial(BxlytMaterial material)
{
if (material == null) return;
material.RemoveNodeWrapper();
if (MaterialList.Materials.Contains(material))
MaterialList.Materials.Remove(material);
}
public override void TryRemoveMaterial(List<BxlytMaterial> materials)
{
foreach (var material in materials)
{
if (material == null) continue;
material.RemoveNodeWrapper();
if (MaterialList.Materials.Contains(material))
MaterialList.Materials.Remove(material);
}
}
//As of now this should be empty but just for future proofing
private List<SectionCommon> UnknownSections = new List<SectionCommon>();
[Browsable(false)]
public int TotalPaneCount()
{
int panes = GetPanes().Count;
int grpPanes = GetGroupPanes().Count;
return panes + grpPanes;
}
[Browsable(false)]
public override List<string> Textures
{
get { return TextureList.Textures; }
}
[Browsable(false)]
public override List<BxlytMaterial> Materials
{
get { return MaterialList.Materials; }
}
[Browsable(false)]
public override List<string> Fonts
{
get { return FontList.Fonts; }
}
[Browsable(false)]
public override Dictionary<string, STGenericTexture> GetTextures
{
get { return ((BFLYT)FileInfo).GetTextures(); }
}
[Browsable(false)]
public List<PAN1> GetPanes()
{
List<PAN1> panes = new List<PAN1>();
GetPaneChildren(panes, (PAN1)RootPane);
return panes;
}
[Browsable(false)]
public List<GRP1> GetGroupPanes()
{
List<GRP1> panes = new List<GRP1>();
GetGroupChildren(panes, (GRP1)RootGroup);
return panes;
}
public override BxlytMaterial GetMaterial(ushort index)
{
return MaterialList.Materials[index];
}
public override BxlytMaterial CreateNewMaterial(string name)
{
return new Material(name, this);
}
private void GetPaneChildren(List<PAN1> panes, PAN1 root)
{
panes.Add(root);
foreach (var pane in root.Childern)
GetPaneChildren(panes, (PAN1)pane);
}
private void GetGroupChildren(List<GRP1> panes, GRP1 root)
{
panes.Add(root);
foreach (var pane in root.Childern)
GetGroupChildren(panes, (GRP1)pane);
}
public Header()
{
LayoutInfo = new LYT1();
TextureList = new TXL1();
MaterialList = new MAT1();
FontList = new FNL1();
RootPane = new PAN1();
RootGroup = new GRP1();
VersionMajor = 8;
VersionMinor = 0;
VersionMicro = 0;
VersionMicro2 = 0;
}
public void Read(FileReader reader, BFLYT bflyt)
{
PaneLookup.Clear();
LayoutInfo = new LYT1();
TextureList = new TXL1();
MaterialList = new MAT1();
FontList = new FNL1();
RootPane = new PAN1();
RootGroup = new GRP1();
UserData = new USD1();
FileInfo = bflyt;
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
IsBigEndian = reader.ByteOrder == Syroot.BinaryData.ByteOrder.BigEndian;
if (!IsBigEndian)
{
if (VersionMajor == 3)
TextureManager.Platform = TextureManager.PlatformType.ThreeDS;
else
TextureManager.Platform = TextureManager.PlatformType.Switch;
}
else
TextureManager.Platform = TextureManager.PlatformType.WiiU;
TextureManager.LayoutFile = this;
bool setRoot = false;
bool setGroupRoot = false;
BasePane currentPane = null;
BasePane parentPane = null;
BasePane currentGroupPane = null;
BasePane parentGroupPane = null;
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 "lyt1":
LayoutInfo = new LYT1(reader);
break;
case "txl1":
TextureList = new TXL1(reader, this);
break;
case "fnl1":
FontList = new FNL1(reader, this);
break;
case "mat1":
MaterialList = new MAT1(reader, this);
break;
case "pan1":
var panel = new PAN1(reader, this);
AddPaneToTable(panel);
if (!setRoot)
{
RootPane = panel;
setRoot = true;
}
SetPane(panel, parentPane);
currentPane = panel;
break;
case "pic1":
var picturePanel = new PIC1(reader, this);
AddPaneToTable(picturePanel);
SetPane(picturePanel, parentPane);
currentPane = picturePanel;
break;
case "txt1":
var textPanel = new TXT1(reader, this);
AddPaneToTable(textPanel);
SetPane(textPanel, parentPane);
currentPane = textPanel;
break;
case "bnd1":
var boundsPanel = new BND1(reader, this);
AddPaneToTable(boundsPanel);
SetPane(boundsPanel, parentPane);
currentPane = boundsPanel;
break;
case "prt1":
var partsPanel = new PRT1(reader, this);
AddPaneToTable(partsPanel);
SetPane(partsPanel, parentPane);
currentPane = partsPanel;
break;
case "wnd1":
var windowPanel = new WND1(reader, this);
AddPaneToTable(windowPanel);
SetPane(windowPanel, parentPane);
currentPane = windowPanel;
break;
case "scr1":
var scissorPane = new SCR1(reader, this);
AddPaneToTable(scissorPane);
SetPane(scissorPane, parentPane);
currentPane = scissorPane;
break;
case "ali1":
var alignmentPane = new ALI1(reader, this);
AddPaneToTable(alignmentPane);
SetPane(alignmentPane, parentPane);
currentPane = alignmentPane;
break;
case "pas1":
if (currentPane != null)
parentPane = currentPane;
break;
case "pae1":
if (parentPane != null)
currentPane = parentPane;
parentPane = currentPane.Parent;
break;
case "grp1":
var groupPanel = new GRP1(reader, this);
if (!setGroupRoot)
{
RootGroup = groupPanel;
setGroupRoot = true;
}
SetPane(groupPanel, parentGroupPane);
currentGroupPane = groupPanel;
break;
case "grs1":
if (currentGroupPane != null)
parentGroupPane = currentGroupPane;
break;
case "gre1":
currentGroupPane = parentGroupPane;
parentGroupPane = currentGroupPane.Parent;
break;
/* case "cnt1":
Container = new CNT1(reader, this);
break;*/
case "usd1":
long dataPos = reader.Position;
if (currentPane != null)
((PAN1)currentPane).UserData = new USD1(reader, this);
else
{
//User data before panes
UserData = new USD1(reader, this);
}
reader.SeekBegin(dataPos);
UserData.Data = reader.ReadBytes((int)SectionSize - 8);
break;
//If the section is not supported store the raw bytes
default:
section.Data = reader.ReadBytes((int)SectionSize - 8);
UnknownSections.Add(section);
Console.WriteLine("Unknown section!" + Signature);
break;
}
section.SectionSize = SectionSize;
reader.SeekBegin(pos + SectionSize);
}
}
private void SetPane(BasePane pane, BasePane parentPane)
{
if (parentPane != null)
{
parentPane.Childern.Add(pane);
pane.Parent = parentPane;
}
}
public void Write(FileWriter writer)
{
Version = VersionMajor << 24 | VersionMinor << 16 | VersionMicro << 8 | VersionMicro2;
writer.SetByteOrder(true);
writer.WriteSignature(Magic);
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
writer.Write(ushort.MaxValue); //Reserve space for section count later
writer.Seek(2); //padding
int sectionCount = 1;
WriteSection(writer, "lyt1", LayoutInfo, () => LayoutInfo.Write(writer, this));
if (UserData != null && UserData.Entries?.Count > 0)
{
WriteSection(writer, "usd1", UserData, () => UserData.Write(writer, this));
sectionCount++;
}
if (TextureList != null && TextureList.Textures.Count > 0)
{
WriteSection(writer, "txl1", TextureList, () => TextureList.Write(writer, this));
sectionCount++;
}
if (FontList != null && FontList.Fonts.Count > 0)
{
WriteSection(writer, "fnl1", FontList, () => FontList.Write(writer, this));
sectionCount++;
}
if (MaterialList != null && MaterialList.Materials.Count > 0)
{
WriteSection(writer, "mat1", MaterialList, () => MaterialList.Write(writer, this));
sectionCount++;
}
WritePanes(writer, RootPane, this, ref sectionCount);
WriteGroupPanes(writer, RootGroup, this, ref sectionCount);
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);
}
}
private void WritePanes(FileWriter writer, BasePane pane, LayoutHeader header, ref int sectionCount)
{
WriteSection(writer, pane.Signature, pane, () => pane.Write(writer, header));
sectionCount++;
if (pane is IUserDataContainer && ((IUserDataContainer)pane).UserData != null)
{
var userData = ((IUserDataContainer)pane).UserData;
WriteSection(writer, "usd1", userData, () => userData.Write(writer, this));
sectionCount++;
}
if (pane.HasChildern)
{
sectionCount += 2;
//Write start of children section
WriteSection(writer, "pas1", null);
foreach (var child in pane.Childern)
WritePanes(writer, child, header, ref sectionCount);
//Write pae1 of children section
WriteSection(writer, "pae1", null);
}
}
private void WriteGroupPanes(FileWriter writer, BasePane pane, LayoutHeader header, ref int sectionCount)
{
WriteSection(writer, pane.Signature, pane, () => pane.Write(writer, header));
sectionCount++;
if (pane.HasChildern)
{
sectionCount += 2;
//Write start of children section
WriteSection(writer, "grs1", null);
foreach (var child in pane.Childern)
WriteGroupPanes(writer, child, header, ref sectionCount);
//Write pae1 of children section
WriteSection(writer, "gre1", null);
}
}
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Cafe
{
public class LYT1 : LayoutInfo
{
[DisplayName("Max Parts Width"), CategoryAttribute("Layout")]
public float MaxPartsWidth { get; set; }
[DisplayName("Max Parts Height"), CategoryAttribute("Layout")]
public float MaxPartsHeight { get; set; }
public LYT1()
{
DrawFromCenter = false;
Width = 0;
Height = 0;
MaxPartsWidth = 0;
MaxPartsHeight = 0;
Name = "";
}
public LYT1(FileReader reader)
{
DrawFromCenter = reader.ReadBoolean();
reader.Seek(3); //padding
Width = reader.ReadSingle();
Height = reader.ReadSingle();
MaxPartsWidth = reader.ReadSingle();
MaxPartsHeight = reader.ReadSingle();
Name = reader.ReadZeroTerminatedString();
}
public override void Write(FileWriter writer, LayoutHeader header)
{
writer.Write(DrawFromCenter);
writer.Seek(3);
writer.Write(Width);
writer.Write(Height);
writer.Write(MaxPartsWidth);
writer.Write(MaxPartsHeight);
writer.WriteString(Name);
}
}
}

View File

@ -0,0 +1,322 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using Toolbox.Library.IO;
using Toolbox.Library;
namespace LayoutBXLYT.Cafe
{
public class MAT1 : SectionCommon
{
public List<BxlytMaterial> Materials { get; set; }
public MAT1()
{
Materials = new List<BxlytMaterial>();
}
public MAT1(FileReader reader, Header header) : base()
{
Materials = new List<BxlytMaterial>();
long pos = reader.Position;
ushort numMats = reader.ReadUInt16();
reader.Seek(2); //padding
uint[] offsets = reader.ReadUInt32s(numMats);
for (int i = 0; i < numMats; i++)
{
reader.SeekBegin(pos + offsets[i] - 8);
Materials.Add(new Material(reader, header));
}
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long pos = writer.Position - 8;
writer.Write((ushort)Materials.Count);
writer.Seek(2);
long _ofsPos = writer.Position;
//Fill empty spaces for offsets later
writer.Write(new uint[Materials.Count]);
//Save offsets and strings
for (int i = 0; i < Materials.Count; i++)
{
writer.WriteUint32Offset(_ofsPos + (i * 4), pos);
((Material)Materials[i]).Write(writer, header);
writer.Align(4);
}
}
}
//Thanks to shibbs for the material info
//https://github.com/shibbo/flyte/blob/master/flyte/lyt/common/MAT1.cs
public class Material : BxlytMaterial
{
private string name;
[DisplayName("Name"), CategoryAttribute("General")]
public override string Name
{
get { return name; }
set
{
name = value;
if (NodeWrapper != null)
NodeWrapper.Text = name;
}
}
public override void AddTexture(string texture)
{
Console.WriteLine("TextureMaps AddTexture");
int index = ParentLayout.AddTexture(texture);
TextureRef textureRef = new TextureRef();
textureRef.ID = (short)index;
textureRef.Name = texture;
TextureMaps = TextureMaps.AddToArray(textureRef);
TextureTransforms = TextureTransforms.AddToArray(new BxlytTextureTransform());
}
[DisplayName("Black Color"), CategoryAttribute("Color")]
public override STColor8 BlackColor { get; set; }
[DisplayName("White Color"), CategoryAttribute("Color")]
public override STColor8 WhiteColor { get; set; }
[DisplayName("Texture Coordinate Params"), CategoryAttribute("Texture")]
public TexCoordGen[] TexCoordGens { get; set; }
[DisplayName("Indirect Parameter"), CategoryAttribute("Texture")]
[TypeConverter(typeof(ExpandableObjectConverter))]
public IndirectParameter IndParameter { get; set; }
[DisplayName("Projection Texture Coord Parameters"), CategoryAttribute("Texture")]
public ProjectionTexGenParam[] ProjTexGenParams { get; set; }
[DisplayName("Font Shadow Parameters"), CategoryAttribute("Font")]
[TypeConverter(typeof(ExpandableObjectConverter))]
public FontShadowParameter FontShadowParameter { get; set; }
private uint flags;
private int unknown;
public string GetTexture(int index)
{
if (TextureMaps[index].ID != -1)
return ((Header)ParentLayout).TextureList.Textures[TextureMaps[index].ID];
else
return "";
}
public override BxlytMaterial Clone()
{
Material mat = new Material();
return mat;
}
public Material()
{
TextureMaps = new TextureRef[0];
TextureTransforms = new BxlytTextureTransform[0];
TexCoordGens = new TexCoordGen[0];
TevStages = new TevStage[0];
ProjTexGenParams = new ProjectionTexGenParam[0];
BlackColor = new STColor8(0, 0, 0, 0);
WhiteColor = STColor8.White;
}
public Material(string name, BxlytHeader header)
{
ParentLayout = header;
Name = name;
TextureMaps = new TextureRef[0];
TextureTransforms = new BxlytTextureTransform[0];
TexCoordGens = new TexCoordGen[0];
TevStages = new TevStage[0];
ProjTexGenParams = new ProjectionTexGenParam[0];
BlackColor = new STColor8(0, 0, 0, 0);
WhiteColor = STColor8.White;
}
public Material(FileReader reader, Header header) : base()
{
ParentLayout = header;
Name = reader.ReadString(0x1C, true);
Name = Name.Replace("\x01", string.Empty);
Name = Name.Replace("\x04", string.Empty);
if (header.VersionMajor >= 8)
{
flags = reader.ReadUInt32();
unknown = reader.ReadInt32();
BlackColor = STColor8.FromBytes(reader.ReadBytes(4));
WhiteColor = STColor8.FromBytes(reader.ReadBytes(4));
}
else
{
BlackColor = STColor8.FromBytes(reader.ReadBytes(4));
WhiteColor = STColor8.FromBytes(reader.ReadBytes(4));
flags = reader.ReadUInt32();
}
uint texCount = Convert.ToUInt32(flags & 3);
uint mtxCount = Convert.ToUInt32(flags >> 2) & 3;
uint texCoordGenCount = Convert.ToUInt32(flags >> 4) & 3;
uint tevStageCount = Convert.ToUInt32(flags >> 6) & 0x7;
EnableAlphaCompare = Convert.ToBoolean((flags >> 9) & 0x1);
EnableBlend = Convert.ToBoolean((flags >> 10) & 0x1);
var useTextureOnly = Convert.ToBoolean((flags >> 11) & 0x1);
EnableBlendLogic = Convert.ToBoolean((flags >> 12) & 0x1);
EnableIndParams = Convert.ToBoolean((flags >> 14) & 0x1);
var projTexGenParamCount = Convert.ToUInt32((flags >> 15) & 0x3);
EnableFontShadowParams = Convert.ToBoolean((flags >> 17) & 0x1);
AlphaInterpolation = Convert.ToBoolean((flags >> 18) & 0x1);
Console.WriteLine($"MAT1 {Name}");
Console.WriteLine($"texCount {texCount}");
Console.WriteLine($"mtxCount {mtxCount}");
Console.WriteLine($"texCoordGenCount {texCoordGenCount}");
Console.WriteLine($"tevStageCount {tevStageCount}");
Console.WriteLine($"hasAlphaCompare {EnableAlphaCompare}");
Console.WriteLine($"hasBlendMode {EnableBlend}");
Console.WriteLine($"useTextureOnly {useTextureOnly}");
Console.WriteLine($"seperateBlendMode {EnableBlendLogic}");
Console.WriteLine($"hasIndParam {EnableIndParams}");
Console.WriteLine($"projTexGenParamCount {projTexGenParamCount}");
Console.WriteLine($"hasFontShadowParam {EnableFontShadowParams}");
Console.WriteLine($"AlphaInterpolation {AlphaInterpolation}");
TextureMaps = new TextureRef[texCount];
TextureTransforms = new BxlytTextureTransform[mtxCount];
TexCoordGens = new TexCoordGen[texCoordGenCount];
TevStages = new TevStage[tevStageCount];
ProjTexGenParams = new ProjectionTexGenParam[projTexGenParamCount];
for (int i = 0; i < texCount; i++)
TextureMaps[i] = new TextureRef(reader, header);
for (int i = 0; i < mtxCount; i++)
TextureTransforms[i] = new BxlytTextureTransform(reader);
for (int i = 0; i < texCoordGenCount; i++)
TexCoordGens[i] = new TexCoordGen(reader, header);
for (int i = 0; i < tevStageCount; i++)
TevStages[i] = new TevStage(reader, header);
if (EnableAlphaCompare)
AlphaCompare = new BxlytAlphaCompare(reader, header);
if (EnableBlend)
BlendMode = new BxlytBlendMode(reader, header);
if (EnableBlendLogic)
BlendModeLogic = new BxlytBlendMode(reader, header);
if (EnableIndParams)
IndParameter = new IndirectParameter(reader, header);
for (int i = 0; i < projTexGenParamCount; i++)
ProjTexGenParams[i] = new ProjectionTexGenParam(reader, header);
if (EnableFontShadowParams)
FontShadowParameter = new FontShadowParameter(reader, header);
}
public void Write(FileWriter writer, LayoutHeader header)
{
long flagPos = 0;
writer.WriteString(Name, 0x1C);
if (header.VersionMajor >= 8)
{
flagPos = writer.Position;
writer.Write(flags);
writer.Write(unknown);
writer.Write(BlackColor);
writer.Write(WhiteColor);
}
else
{
writer.Write(BlackColor);
writer.Write(WhiteColor);
flagPos = writer.Position;
writer.Write(flags);
}
flags = 0;
for (int i = 0; i < TextureMaps.Length; i++)
{
flags += Bit.BitInsert(1, 1, 2, 30);
((TextureRef)TextureMaps[i]).Write(writer);
}
for (int i = 0; i < TextureTransforms.Length; i++)
{
flags += Bit.BitInsert(1, 1, 2, 28);
((BxlytTextureTransform)TextureTransforms[i]).Write(writer);
}
for (int i = 0; i < TexCoordGens.Length; i++)
{
flags += Bit.BitInsert(1, 1, 2, 26);
TexCoordGens[i].Write(writer);
}
for (int i = 0; i < TevStages.Length; i++)
{
flags += Bit.BitInsert(1, 1, 2, 24);
((TevStage)TevStages[i]).Write(writer);
}
if (AlphaCompare != null && EnableAlphaCompare)
{
flags += Bit.BitInsert(1, 1, 1, 22);
AlphaCompare.Write(writer);
}
if (BlendMode != null && EnableBlend)
{
flags += Bit.BitInsert(1, 1, 2, 20);
BlendMode.Write(writer);
}
if (BlendModeLogic != null && EnableBlendLogic)
{
flags += Bit.BitInsert(1, 1, 2, 18);
BlendModeLogic.Write(writer);
}
if (IndParameter != null && EnableIndParams)
{
flags += Bit.BitInsert(1, 1, 1, 17);
IndParameter.Write(writer);
}
for (int i = 0; i < ProjTexGenParams.Length; i++)
{
flags += Bit.BitInsert(1, 1, 2, 15);
ProjTexGenParams[i].Write(writer);
}
if (FontShadowParameter != null && EnableFontShadowParams)
{
flags += Bit.BitInsert(1, 1, 1, 14);
FontShadowParameter.Write(writer);
}
if (AlphaInterpolation)
flags += Bit.BitInsert(1, 1, 1, 13);
using (writer.TemporarySeek(flagPos, SeekOrigin.Begin))
{
writer.Write(flags);
}
}
}
}

View File

@ -7,7 +7,7 @@ namespace LayoutBXLYT.Cafe
private byte colorFlags;
private byte alphaFlags;
public TevStage(FileReader reader, BFLYT.Header header)
public TevStage(FileReader reader, Header header)
{
colorFlags = reader.ReadByte();
alphaFlags = reader.ReadByte();

View File

@ -9,7 +9,7 @@ namespace LayoutBXLYT.Cafe
byte[] unkData;
public TexCoordGen(FileReader reader, BFLYT.Header header)
public TexCoordGen(FileReader reader, BxlytHeader header)
{
GenType = reader.ReadEnum<MatrixType>(false);
Source = reader.ReadEnum<TextureGenerationType>(false);

View File

@ -39,7 +39,7 @@ namespace LayoutBXLYT.Cafe
{
}
public TextureRef(FileReader reader, BFLYT.Header header)
public TextureRef(FileReader reader, Header header)
{
ID = reader.ReadInt16();
flag1 = reader.ReadByte();

View File

@ -1,25 +0,0 @@
using Toolbox.Library.IO;
using Syroot.Maths;
namespace LayoutBXLYT.Cafe
{
public class TextureTransform : BxlytTextureTransform
{
public TextureTransform() : base()
{ }
public TextureTransform(FileReader reader)
{
Translate = reader.ReadVec2SY();
Rotate = reader.ReadSingle();
Scale = reader.ReadVec2SY();
}
public void Write(FileWriter writer)
{
writer.Write(Translate);
writer.Write(Rotate);
writer.Write(Scale);
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Cafe
{
public class ALI1 : PAN1
{
public override string Signature { get; } = "ali1";
public ALI1() : base()
{
}
public ALI1(FileReader reader, Header header) : base(reader, header)
{
}
public override void Write(FileWriter writer, LayoutHeader header)
{
base.Write(writer, header);
}
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Cafe
{
public class BND1 : PAN1, IBoundryPane
{
public override string Signature { get; } = "bnd1";
public BND1() : base()
{
LoadDefaults();
}
public BND1(Header header, string name) : base()
{
LoadDefaults();
Name = name;
}
public BND1(FileReader reader, Header header) : base(reader, header)
{
}
public override void Write(FileWriter writer, LayoutHeader header)
{
base.Write(writer, header);
}
}
}

View File

@ -0,0 +1,164 @@
using System;
using System.Linq;
using System.ComponentModel;
using Syroot.Maths;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Cafe
{
public class PAN1 : BasePane, IUserDataContainer
{
public override string Signature { get; } = "pan1";
private byte _flags1;
[DisplayName("Is Visible"), CategoryAttribute("Flags")]
public override bool Visible
{
get { return (_flags1 & 0x1) == 0x1; }
set
{
if (value)
_flags1 |= 0x1;
else
_flags1 &= 0xFE;
}
}
[DisplayName("Parts Flag"), CategoryAttribute("Flags")]
public byte PaneMagFlags { get; set; }
[DisplayName("Influence Alpha"), CategoryAttribute("Alpha")]
public override bool InfluenceAlpha
{
get { return (_flags1 & 0x2) == 0x2; }
set
{
if (value)
_flags1 |= 0x2;
else
_flags1 &= 0xFD;
}
}
[DisplayName("User Data Info"), CategoryAttribute("User Data")]
public string UserDataInfo { get; set; }
[DisplayName("User Data"), CategoryAttribute("User Data")]
public UserData UserData { get; set; }
public PAN1() : base()
{
LoadDefaults();
}
public PAN1(BxlytHeader header, string name) : base()
{
LoadDefaults();
Name = name;
}
public override BasePane Copy()
{
PAN1 pan1 = new PAN1();
pan1.Alpha = Alpha;
pan1.DisplayInEditor = DisplayInEditor;
pan1.Childern = Childern;
pan1.Parent = Parent;
pan1.Name = Name;
pan1.LayoutFile = LayoutFile;
pan1.NodeWrapper = NodeWrapper;
pan1.originX = originX;
pan1.originY = originY;
pan1.ParentOriginX = ParentOriginX;
pan1.ParentOriginY = ParentOriginY;
pan1.Rotate = Rotate;
pan1.Scale = Scale;
pan1.Translate = Translate;
pan1.Visible = Visible;
pan1.Height = Height;
pan1.Width = Width;
pan1.UserData = UserData;
pan1.UserDataInfo = UserDataInfo;
pan1._flags1 = _flags1;
return pan1;
}
public override UserData CreateUserData()
{
return new USD1();
}
public override void LoadDefaults()
{
base.LoadDefaults();
UserDataInfo = "";
UserData = null;
PaneMagFlags = 0;
}
public PAN1(FileReader reader, BxlytHeader header) : base()
{
LayoutFile = header;
_flags1 = reader.ReadByte();
byte origin = reader.ReadByte();
Alpha = reader.ReadByte();
PaneMagFlags = reader.ReadByte();
Name = reader.ReadString(0x18, true);
UserDataInfo = reader.ReadString(0x8, true);
Translate = reader.ReadVec3SY();
Rotate = reader.ReadVec3SY();
Scale = reader.ReadVec2SY();
Width = reader.ReadSingle();
Height = reader.ReadSingle();
int mainorigin = origin % 16;
int parentorigin = origin / 16;
originX = (OriginX)(mainorigin % 4);
originY = (OriginY)(mainorigin / 4);
ParentOriginX = (OriginX)(parentorigin % 4);
ParentOriginY = (OriginY)(parentorigin / 4);
}
public override void Write(FileWriter writer, LayoutHeader header)
{
int originL = (int)originX;
int originH = (int)originY * 4;
int originPL = (int)ParentOriginX;
int originPH = (int)ParentOriginY * 4;
byte parentorigin = (byte)((originPL + originPH) * 16);
byte origin = (byte)(originL + originH + parentorigin);
writer.Write(_flags1);
writer.Write(origin);
writer.Write(Alpha);
writer.Write(PaneMagFlags);
writer.WriteString(Name, 0x18);
writer.WriteString(UserDataInfo, 0x8);
writer.Write(Translate);
writer.Write(Rotate);
writer.Write(Scale);
writer.Write(Width);
writer.Write(Height);
}
[Browsable(false)]
public bool ParentVisibility
{
get
{
if (Scale.X == 0 || Scale.Y == 0)
return false;
if (!Visible)
return false;
if (Parent != null && Parent is PAN1)
{
return ((PAN1)Parent).ParentVisibility && Visible;
}
return true;
}
}
}
}

View File

@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library;
using System.ComponentModel;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Cafe
{
public class PIC1 : PAN1, IPicturePane
{
public override string Signature { get; } = "pic1";
[DisplayName("Texture Coordinates"), CategoryAttribute("Texture")]
public TexCoord[] TexCoords { get; set; }
[DisplayName("Vertex Color (Top Left)"), CategoryAttribute("Color")]
public STColor8 ColorTopLeft { get; set; }
[DisplayName("Vertex Color (Top Right)"), CategoryAttribute("Color")]
public STColor8 ColorTopRight { get; set; }
[DisplayName("Vertex Color (Bottom Left)"), CategoryAttribute("Color")]
public STColor8 ColorBottomLeft { get; set; }
[DisplayName("Vertex Color (Bottom Right)"), CategoryAttribute("Color")]
public STColor8 ColorBottomRight { get; set; }
public System.Drawing.Color[] GetVertexColors()
{
return new System.Drawing.Color[4]
{
ColorTopLeft.Color,
ColorTopRight.Color,
ColorBottomLeft.Color,
ColorBottomRight.Color,
};
}
[Browsable(false)]
public ushort MaterialIndex { get; set; }
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytMaterial Material { get; set; }
[Browsable(false)]
public string GetTexture(int index)
{
return ParentLayout.Textures[Material.TextureMaps[index].ID];
}
private Header ParentLayout;
public PIC1() : base()
{
LoadDefaults();
}
public PIC1(Header header, string name) : base()
{
LoadDefaults();
Name = name;
ParentLayout = header;
ColorTopLeft = STColor8.White;
ColorTopRight = STColor8.White;
ColorBottomLeft = STColor8.White;
ColorBottomRight = STColor8.White;
TexCoords = new TexCoord[1];
TexCoords[0] = new TexCoord();
Material = new Material(name, header);
}
public void CopyMaterial()
{
Material = Material.Clone();
}
public PIC1(FileReader reader, Header header) : base(reader, header)
{
ParentLayout = header;
ColorTopLeft = reader.ReadColor8RGBA();
ColorTopRight = reader.ReadColor8RGBA();
ColorBottomLeft = reader.ReadColor8RGBA();
ColorBottomRight = reader.ReadColor8RGBA();
MaterialIndex = reader.ReadUInt16();
byte numUVs = reader.ReadByte();
reader.Seek(1); //padding
TexCoords = new TexCoord[numUVs];
for (int i = 0; i < numUVs; i++)
{
TexCoords[i] = new TexCoord()
{
TopLeft = reader.ReadVec2SY(),
TopRight = reader.ReadVec2SY(),
BottomLeft = reader.ReadVec2SY(),
BottomRight = reader.ReadVec2SY(),
};
}
Material = header.MaterialList.Materials[MaterialIndex];
}
public override void Write(FileWriter writer, LayoutHeader header)
{
base.Write(writer, header);
writer.Write(ColorTopLeft);
writer.Write(ColorTopRight);
writer.Write(ColorBottomLeft);
writer.Write(ColorBottomRight);
writer.Write(MaterialIndex);
writer.Write((byte)TexCoords.Length);
writer.Write((byte)0);
for (int i = 0; i < TexCoords.Length; i++)
{
writer.Write(TexCoords[i].TopLeft);
writer.Write(TexCoords[i].TopRight);
writer.Write(TexCoords[i].BottomLeft);
writer.Write(TexCoords[i].BottomRight);
}
}
}
}

View File

@ -0,0 +1,393 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using Toolbox.Library;
using System.IO;
using Toolbox.Library.IO;
using FirstPlugin;
namespace LayoutBXLYT.Cafe
{
public class PRT1 : PAN1, IPartPane
{
public override string Signature { get; } = "prt1";
private bool hasSearchedParts = false;
public PRT1() : base()
{
}
public PRT1(Header header, string name) : base()
{
LoadDefaults();
Name = name;
layoutFile = header;
MagnifyX = 1;
MagnifyY = 1;
LayoutFileName = "";
Properties = new List<PartProperty>();
}
[DisplayName("Magnify X"), CategoryAttribute("Parts")]
public float MagnifyX { get; set; }
[DisplayName("Magnify Y"), CategoryAttribute("Parts")]
public float MagnifyY { get; set; }
[DisplayName("Properties"), CategoryAttribute("Parts")]
public List<PartProperty> Properties { get; set; }
private string layoutFilename;
[DisplayName("External Layout File"), CategoryAttribute("Parts")]
public string LayoutFileName
{
get { return layoutFilename; }
set
{
layoutFilename = value;
ExternalLayout = null;
hasSearchedParts = false;
}
}
private BFLYT ExternalLayout;
public BasePane GetExternalPane()
{
if (hasSearchedParts || LayoutFileName == string.Empty) return null;
ExternalLayout = layoutFile.PartsManager.TryGetLayout($"{LayoutFileName}.bflyt") as BFLYT;
if (ExternalLayout == null)
ExternalLayout = SearchExternalFile();
if (ExternalLayout == null)
return null;
//Load all the part panes to the lookup table
foreach (var pane in ExternalLayout.header.PaneLookup)
if (!layoutFile.PaneLookup.ContainsKey(pane.Key))
layoutFile.PaneLookup.Add(pane.Key, pane.Value);
layoutFile.PartsManager.AddLayout(ExternalLayout.header);
return ExternalLayout.header.RootPane;
}
//Get textures if possible from the external parts file
public void UpdateTextureData(Dictionary<string, STGenericTexture> textures)
{
if (hasSearchedParts) return;
if (ExternalLayout == null)
{
ExternalLayout = SearchExternalFile();
if (ExternalLayout == null)
return;
ExternalLayout.header.TextureManager = layoutFile.TextureManager;
var textureList = ExternalLayout.GetTextures();
foreach (var tex in textureList)
if (!textures.ContainsKey(tex.Key))
textures.Add(tex.Key, tex.Value);
textureList.Clear();
}
}
private BFLYT SearchExternalFile()
{
hasSearchedParts = false;
var fileFormat = layoutFile.FileInfo;
string path = FileManager.GetSourcePath(fileFormat);
//File is outside an archive so check the contents it is in
if (File.Exists(path))
{
string folder = Path.GetDirectoryName(path);
foreach (var file in Directory.GetFiles(folder))
{
if (file.Contains(LayoutFileName))
{
if (Utils.GetExtension(file) == ".szs")
{
var openedFile = STFileLoader.OpenFileFormat(file);
if (openedFile == null)
continue;
layoutFile.PartsManager.AddArchive((IArchiveFile)openedFile);
BFLYT bflyt = null;
SearchArchive((IArchiveFile)openedFile, ref bflyt);
if (bflyt != null)
return bflyt;
}
else if (Utils.GetExtension(file) == ".bflan")
{
try
{
var openedFile = STFileLoader.OpenFileFormat(file);
if (openedFile == null)
continue;
openedFile.CanSave = false;
var bflan = openedFile as BXLAN;
layoutFile.PartsManager.AddAnimation(bflan.BxlanHeader);
}
catch
{
}
}
else if (Utils.GetExtension(file) == ".bflyt")
{
var openedFile = STFileLoader.OpenFileFormat(file);
if (openedFile == null) continue;
openedFile.CanSave = false;
openedFile.IFileInfo = new IFileInfo();
openedFile.IFileInfo.ArchiveParent = fileFormat.IFileInfo.ArchiveParent;
return (BFLYT)openedFile;
}
}
}
}
for (int i = 0; i < PluginRuntime.SarcArchives.Count; i++)
{
BFLYT bflyt = null;
SearchArchive(PluginRuntime.SarcArchives[i], ref bflyt);
if (bflyt != null)
return bflyt;
}
return null;
}
private void SearchArchive(IArchiveFile archiveFile, ref BFLYT layoutFile)
{
layoutFile = null;
if (archiveFile is SARC)
{
if (((SARC)archiveFile).FileLookup.ContainsKey($"blyt/{LayoutFileName}.bflyt"))
{
var entry = ((SARC)archiveFile).FileLookup[$"blyt/{LayoutFileName}.bflyt"];
var openedFile = entry.OpenFile();
if (openedFile is BFLYT)
{
layoutFile = openedFile as BFLYT;
layoutFile.IFileInfo = new IFileInfo();
layoutFile.IFileInfo.ArchiveParent = layoutFile.IFileInfo.ArchiveParent;
return;
}
}
}
foreach (var file in archiveFile.Files)
{
if (file.FileName.Contains(".lyarc"))
{
var openedFile = file.OpenFile();
if (openedFile is IArchiveFile)
SearchArchive((IArchiveFile)openedFile, ref layoutFile);
}
else if (file.FileName.Contains(LayoutFileName))
{
try
{
var openedFile = file.OpenFile();
if (openedFile is IArchiveFile)
SearchArchive((IArchiveFile)openedFile, ref layoutFile);
else if (openedFile is BFLYT)
{
Console.WriteLine("Part found! " + file.FileName);
layoutFile = openedFile as BFLYT;
layoutFile.IFileInfo = new IFileInfo();
layoutFile.IFileInfo.ArchiveParent = layoutFile.IFileInfo.ArchiveParent;
return;
}
}
catch
{
}
}
}
}
private Header layoutFile;
public PRT1(FileReader reader, Header header) : base(reader, header)
{
layoutFile = header;
Properties = new List<PartProperty>();
StartPosition = reader.Position - 84;
uint properyCount = reader.ReadUInt32();
MagnifyX = reader.ReadSingle();
MagnifyY = reader.ReadSingle();
for (int i = 0; i < properyCount; i++)
Properties.Add(new PartProperty(reader, header, StartPosition));
LayoutFileName = reader.ReadZeroTerminatedString();
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long startPos = writer.Position - 8;
base.Write(writer, header);
writer.Write(Properties.Count);
writer.Write(MagnifyX);
writer.Write(MagnifyY);
for (int i = 0; i < Properties.Count; i++)
Properties[i].Write(writer, header, startPos);
writer.WriteString(LayoutFileName);
writer.Align(4);
// for (int i = 0; i < Properties.Count; i++)
// Properties[i].WriteProperties(writer, header, startPos);
// for (int i = 0; i < Properties.Count; i++)
// Properties[i].WriteUserData(writer, header, startPos);
for (int i = 0; i < Properties.Count; i++)
{
Properties[i].WriteProperties(writer, header, startPos);
Properties[i].WriteUserData(writer, header, startPos);
Properties[i].WritePaneInfo(writer, header, startPos);
}
}
}
public class PartProperty
{
public string Name { get; set; }
public byte UsageFlag { get; set; }
public byte BasicUsageFlag { get; set; }
public byte MaterialUsageFlag { get; set; }
public BasePane Property { get; set; }
public USD1 UserData { get; set; }
public byte[] PaneInfo { get; set; }
public PartProperty(FileReader reader, Header header, long StartPosition)
{
Name = reader.ReadString(0x18, true);
UsageFlag = reader.ReadByte();
BasicUsageFlag = reader.ReadByte();
MaterialUsageFlag = reader.ReadByte();
reader.ReadByte(); //padding
uint propertyOffset = reader.ReadUInt32();
uint userDataOffset = reader.ReadUInt32();
uint panelInfoOffset = reader.ReadUInt32();
long pos = reader.Position;
if (propertyOffset != 0)
{
reader.SeekBegin(StartPosition + propertyOffset);
long startPos = reader.Position;
string signtature = reader.ReadString(4, Encoding.ASCII);
uint sectionSize = reader.ReadUInt32();
Console.WriteLine($"signtature " + signtature);
switch (signtature)
{
case "pic1":
Property = new PIC1(reader, header);
break;
case "txt1":
Property = new TXT1(reader, header);
break;
case "wnd1":
Property = new WND1(reader, header);
break;
case "bnd1":
Property = new BND1(reader, header);
break;
case "prt1":
Property = new PRT1(reader, header);
break;
default:
Console.WriteLine("Unknown section! " + signtature);
break;
}
}
if (userDataOffset != 0)
{
reader.SeekBegin(StartPosition + userDataOffset);
UserData = new USD1(reader, header);
}
if (panelInfoOffset != 0)
{
reader.SeekBegin(StartPosition + panelInfoOffset);
PaneInfo = reader.ReadBytes(52);
}
reader.SeekBegin(pos);
}
private long _ofsPos;
public void Write(FileWriter writer, LayoutHeader header, long startPos)
{
writer.WriteString(Name, 0x18);
writer.Write(UsageFlag);
writer.Write(BasicUsageFlag);
writer.Write(MaterialUsageFlag);
writer.Write((byte)0);
//Reserve offset spaces
_ofsPos = writer.Position;
writer.Write(0); //Property Offset
writer.Write(0); //External User Data
writer.Write(0); //Panel Info Offset
}
public void WriteProperties(FileWriter writer, LayoutHeader header, long startPos)
{
if (Property != null)
{
writer.WriteUint32Offset(_ofsPos, startPos);
Header.WriteSection(writer, Property.Signature, Property, () => Property.Write(writer, header));
}
}
public void WriteUserData(FileWriter writer, LayoutHeader header, long startPos)
{
if (UserData != null)
{
writer.WriteUint32Offset(_ofsPos + 4, startPos);
UserData.Write(writer, header);
}
}
public void WritePaneInfo(FileWriter writer, LayoutHeader header, long startPos)
{
if (PaneInfo != null)
{
writer.WriteUint32Offset(_ofsPos + 8, startPos);
writer.Write(PaneInfo);
}
}
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Cafe
{
public class SCR1 : PAN1
{
public override string Signature { get; } = "scr1";
public SCR1() : base()
{
}
public SCR1(FileReader reader, Header header) : base(reader, header)
{
}
public override void Write(FileWriter writer, LayoutHeader header)
{
base.Write(writer, header);
}
}
}

View File

@ -0,0 +1,389 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using Syroot.Maths;
using Toolbox.Library.IO;
using Toolbox.Library;
namespace LayoutBXLYT.Cafe
{
public class TXT1 : PAN1, ITextPane
{
private Header layoutFile;
public override string Signature { get; } = "txt1";
public List<string> GetFonts
{
get { return layoutFile.Fonts; }
}
public override BasePane Copy()
{
TXT1 pane = new TXT1();
pane.Material = Material;
pane.MaterialIndex = MaterialIndex;
pane.FontIndex = FontIndex;
pane.FontName = FontName;
pane.FontTopColor = FontTopColor;
pane.FontBottomColor = FontBottomColor;
pane.FontSize = FontSize;
pane.LineSpace = LineSpace;
pane.CharacterSpace = CharacterSpace;
pane.ShadowXY = ShadowXY;
pane.ShadowXYSize = ShadowXYSize;
pane.ShadowForeColor = ShadowForeColor;
pane.ShadowBackColor = ShadowBackColor;
pane.ShadowItalic = ShadowItalic;
pane.LineAlignment = LineAlignment;
pane.TextAlignment = TextAlignment;
pane.MaxTextLength = MaxTextLength;
pane.ItalicTilt = ItalicTilt;
pane._flags = _flags;
return pane;
}
public TXT1() : base()
{
}
public TXT1(Header header, string name)
{
LoadDefaults();
Name = name;
layoutFile = header;
//Add new material
var mat = new Material(this.Name, header);
header.MaterialList.Materials.Add(mat);
MaterialIndex = (ushort)header.MaterialList.Materials.IndexOf(mat);
Material = mat;
Text = Encoding.Unicode.GetString(new byte[0]);
FontIndex = 0;
FontName = "";
TextLength = 4;
MaxTextLength = 4;
TextAlignment = 0;
LineAlignment = LineAlign.Unspecified;
ItalicTilt = 0;
FontTopColor = STColor8.White;
FontBottomColor = STColor8.White;
FontSize = new Vector2F(92, 101);
CharacterSpace = 0;
LineSpace = 0;
ShadowXY = new Vector2F(1, -1);
ShadowXYSize = new Vector2F(1, 1);
ShadowBackColor = STColor8.Black;
ShadowForeColor = STColor8.Black;
ShadowItalic = 0;
}
public void LoadFontData(FirstPlugin.FFNT bffnt)
{
FontSize = new Vector2F(
bffnt.FontSection.Width,
bffnt.FontSection.Height);
}
[Browsable(false)]
public Toolbox.Library.Rendering.RenderableTex RenderableFont { get; set; }
[DisplayName("Horizontal Alignment"), CategoryAttribute("Font")]
public OriginX HorizontalAlignment
{
get { return (OriginX)((TextAlignment >> 2) & 0x3); }
set
{
TextAlignment &= unchecked((byte)(~0xC));
TextAlignment |= (byte)((byte)(value) << 2);
}
}
[DisplayName("Vertical Alignment"), CategoryAttribute("Font")]
public OriginY VerticalAlignment
{
get { return (OriginY)((TextAlignment) & 0x3); }
set
{
TextAlignment &= unchecked((byte)(~0x3));
TextAlignment |= (byte)(value);
}
}
[Browsable(false)]
public ushort RestrictedLength
{
get
{ //Divide by 2 due to 2 characters taking up 2 bytes
//Subtract 1 due to padding
return (ushort)((TextLength / 2) - 1);
}
set
{
TextLength = (ushort)((value * 2) + 1);
}
}
[Browsable(false)]
public ushort TextLength { get; set; }
[Browsable(false)]
public ushort MaxTextLength { get; set; }
[Browsable(false)]
public ushort MaterialIndex { get; set; }
[Browsable(false)]
public ushort FontIndex { get; set; }
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytMaterial Material { get; set; }
[DisplayName("Text Alignment"), CategoryAttribute("Font")]
public byte TextAlignment { get; set; }
[DisplayName("Line Alignment"), CategoryAttribute("Font")]
public LineAlign LineAlignment { get; set; }
[DisplayName("Italic Tilt"), CategoryAttribute("Font")]
public float ItalicTilt { get; set; }
[DisplayName("Top Color"), CategoryAttribute("Font")]
public STColor8 FontTopColor { get; set; }
[DisplayName("Bottom Color"), CategoryAttribute("Font")]
public STColor8 FontBottomColor { get; set; }
[DisplayName("Font Size"), CategoryAttribute("Font")]
public Vector2F FontSize { get; set; }
[DisplayName("Character Space"), CategoryAttribute("Font")]
public float CharacterSpace { get; set; }
[DisplayName("Line Space"), CategoryAttribute("Font")]
public float LineSpace { get; set; }
[DisplayName("Shadow Position"), CategoryAttribute("Shadows")]
public Vector2F ShadowXY { get; set; }
[DisplayName("Shadow Size"), CategoryAttribute("Shadows")]
public Vector2F ShadowXYSize { get; set; }
[DisplayName("Shadow Fore Color"), CategoryAttribute("Shadows")]
public STColor8 ShadowForeColor { get; set; }
[DisplayName("Shadow Back Color"), CategoryAttribute("Shadows")]
public STColor8 ShadowBackColor { get; set; }
[DisplayName("Shadow Italic"), CategoryAttribute("Shadows")]
public float ShadowItalic { get; set; }
[DisplayName("Text Box Name"), CategoryAttribute("Text Box")]
public string TextBoxName { get; set; }
private string text;
[DisplayName("Text"), CategoryAttribute("Text Box")]
public string Text
{
get { return text; }
set
{
text = value;
TextLength = (ushort)((text.Length * 2) + 2);
UpdateTextRender();
}
}
[DisplayName("Per Character Transform"), CategoryAttribute("Font")]
public bool PerCharTransformEnabled
{
get { return (_flags & 0x10) != 0; }
set { _flags = value ? (byte)(_flags | 0x10) : unchecked((byte)(_flags & (~0x10))); }
}
[DisplayName("Restricted Text Length"), CategoryAttribute("Font")]
public bool RestrictedTextLengthEnabled
{
get { return (_flags & 0x2) != 0; }
set { _flags = value ? (byte)(_flags | 0x2) : unchecked((byte)(_flags & (~0x2))); }
}
[DisplayName("Enable Shadows"), CategoryAttribute("Font")]
public bool ShadowEnabled
{
get { return (_flags & 1) != 0; }
set { _flags = value ? (byte)(_flags | 1) : unchecked((byte)(_flags & (~1))); }
}
[DisplayName("Font Name"), CategoryAttribute("Font")]
public string FontName { get; set; }
private byte _flags;
private float Unknown1 { get; set; }
private float Unknown2 { get; set; }
public void CopyMaterial()
{
Material = Material.Clone();
}
public PerCharacterTransform PerCharacterTransform;
public void UpdateTextRender()
{
if (RenderableFont == null) return;
System.Drawing.Bitmap bitmap = null;
foreach (var fontFile in FirstPlugin.PluginRuntime.BxfntFiles)
{
if (Utils.CompareNoExtension(fontFile.Name, FontName))
bitmap = fontFile.GetBitmap(Text, false, this);
}
if (bitmap != null)
RenderableFont.UpdateFromBitmap(bitmap);
}
public TXT1(FileReader reader, Header header) : base(reader, header)
{
layoutFile = header;
long startPos = reader.Position - 84;
TextLength = reader.ReadUInt16();
MaxTextLength = reader.ReadUInt16();
MaterialIndex = reader.ReadUInt16();
FontIndex = reader.ReadUInt16();
TextAlignment = reader.ReadByte();
LineAlignment = (LineAlign)reader.ReadByte();
_flags = reader.ReadByte();
reader.Seek(1); //padding
ItalicTilt = reader.ReadSingle();
uint textOffset = reader.ReadUInt32();
FontTopColor = STColor8.FromBytes(reader.ReadBytes(4));
FontBottomColor = STColor8.FromBytes(reader.ReadBytes(4));
FontSize = reader.ReadVec2SY();
CharacterSpace = reader.ReadSingle();
LineSpace = reader.ReadSingle();
uint nameOffset = reader.ReadUInt32();
ShadowXY = reader.ReadVec2SY();
ShadowXYSize = reader.ReadVec2SY();
ShadowForeColor = STColor8.FromBytes(reader.ReadBytes(4));
ShadowBackColor = STColor8.FromBytes(reader.ReadBytes(4));
ShadowItalic = reader.ReadSingle();
uint perCharTransformOffset = reader.ReadUInt32();
if (header.VersionMajor >= 8)
{
Unknown2 = reader.ReadSingle();
}
if (MaterialIndex != ushort.MaxValue && header.MaterialList.Materials.Count > 0)
Material = header.MaterialList.Materials[MaterialIndex];
if (FontIndex != ushort.MaxValue && header.FontList.Fonts.Count > 0)
FontName = header.FontList.Fonts[FontIndex];
if (textOffset != 0)
{
reader.SeekBegin(startPos + textOffset);
if (RestrictedTextLengthEnabled)
text = reader.ReadZeroTerminatedString(Encoding.Unicode);
else
text = reader.ReadZeroTerminatedString(Encoding.Unicode);
}
if (nameOffset != 0)
{
reader.SeekBegin(startPos + nameOffset);
TextBoxName = reader.ReadZeroTerminatedString();
}
if (header.VersionMajor > 2 && PerCharTransformEnabled)
{
reader.SeekBegin(startPos + perCharTransformOffset);
PerCharacterTransform = new PerCharacterTransform();
PerCharacterTransform.Read(reader, header);
}
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long pos = writer.Position - 8;
var textLength = TextLength;
base.Write(writer, header);
writer.Write(textLength);
if (!RestrictedTextLengthEnabled)
writer.Write(textLength);
else
writer.Write(MaxTextLength);
writer.Write(MaterialIndex);
writer.Write(FontIndex);
writer.Write(TextAlignment);
writer.Write(LineAlignment, false);
writer.Write(_flags);
writer.Seek(1);
writer.Write(ItalicTilt);
long _ofsTextPos = writer.Position;
writer.Write(0); //text offset
writer.Write(FontTopColor.ToBytes());
writer.Write(FontBottomColor.ToBytes());
writer.Write(FontSize);
writer.Write(CharacterSpace);
writer.Write(LineSpace);
long _ofsNamePos = writer.Position;
writer.Write(0);
writer.Write(ShadowXY);
writer.Write(ShadowXYSize);
writer.Write(ShadowForeColor.ToBytes());
writer.Write(ShadowBackColor.ToBytes());
writer.Write(ShadowItalic);
long _ofsPerCharTransform = writer.Position;
if (header.VersionMajor > 2)
writer.Write(0); //per character transform offset
if (header.VersionMajor >= 8)
{
writer.Write(Unknown2);
}
if (Text != null)
{
Encoding encoding = Encoding.Unicode;
if (writer.ByteOrder == Syroot.BinaryData.ByteOrder.BigEndian)
encoding = Encoding.BigEndianUnicode;
writer.WriteUint32Offset(_ofsTextPos, pos);
if (RestrictedTextLengthEnabled)
writer.WriteString(Text, MaxTextLength, encoding);
else
writer.WriteString(Text, TextLength, encoding);
writer.Align(4);
}
if (TextBoxName != null)
{
writer.WriteUint32Offset(_ofsNamePos, pos);
writer.WriteString(TextBoxName);
writer.Align(4);
}
if (header.VersionMajor > 2 && PerCharTransformEnabled)
{
writer.WriteUint32Offset(_ofsPerCharTransform, pos);
PerCharacterTransform.Write(writer, header);
writer.Align(4);
}
}
}
}

View File

@ -0,0 +1,300 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using Syroot.Maths;
using Toolbox.Library.IO;
using Toolbox.Library;
namespace LayoutBXLYT.Cafe
{
public class WND1 : PAN1, IWindowPane
{
private Header layoutHeader;
public override string Signature { get; } = "wnd1";
public WND1() : base()
{
}
public void CopyWindows()
{
Content = (BxlytWindowContent)Content.Clone();
for (int f = 0; f < WindowFrames.Count; f++)
WindowFrames[f] = (BxlytWindowFrame)WindowFrames[f].Clone();
}
public WND1(Header header, string name)
{
layoutHeader = header;
LoadDefaults();
Name = name;
Content = new BxlytWindowContent(header, this.Name);
UseOneMaterialForAll = true;
UseVertexColorForAll = true;
WindowKind = WindowKind.Around;
NotDrawnContent = false;
StretchLeft = 0;
StretchRight = 0;
StretchTop = 0;
StretchBottm = 0;
Width = 70;
Height = 80;
FrameElementLeft = 16;
FrameElementRight = 16;
FrameElementTop = 16;
FrameElementBottm = 16;
FrameCount = 1;
WindowFrames = new List<BxlytWindowFrame>();
SetFrames(header);
}
public void ReloadFrames()
{
SetFrames(layoutHeader);
}
public void SetFrames(Header header)
{
if (WindowFrames == null)
WindowFrames = new List<BxlytWindowFrame>();
switch (FrameCount)
{
case 1:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LT"));
break;
case 2:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_L"));
if (WindowFrames.Count == 1)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_R"));
break;
case 4:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LT"));
if (WindowFrames.Count == 1)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RT"));
if (WindowFrames.Count == 2)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LB"));
if (WindowFrames.Count == 3)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RB"));
break;
case 8:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LT"));
if (WindowFrames.Count == 1)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RT"));
if (WindowFrames.Count == 2)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LB"));
if (WindowFrames.Count == 3)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RB"));
if (WindowFrames.Count == 4)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_T"));
if (WindowFrames.Count == 5)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_B"));
if (WindowFrames.Count == 6)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_R"));
if (WindowFrames.Count == 7)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_L"));
break;
}
//Now search for invalid unused materials and remove them
for (int i = 0; i < WindowFrames.Count; i++)
{
if (i >= FrameCount)
layoutHeader.TryRemoveMaterial(WindowFrames[i].Material);
else if (!layoutHeader.Materials.Contains(WindowFrames[i].Material))
layoutHeader.AddMaterial(WindowFrames[i].Material);
}
}
public bool UseOneMaterialForAll
{
get { return Convert.ToBoolean(_flag & 1); }
set { }
}
public bool UseVertexColorForAll
{
get { return Convert.ToBoolean((_flag >> 1) & 1); }
set { }
}
public WindowKind WindowKind { get; set; }
public bool NotDrawnContent
{
get { return (_flag & 8) == 16; }
set { }
}
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; }
private byte _flag;
private byte frameCount;
public byte FrameCount
{
get { return frameCount; }
set
{
frameCount = value;
}
}
public System.Drawing.Color[] GetVertexColors()
{
return new System.Drawing.Color[4]
{
Content.ColorTopLeft.Color,
Content.ColorTopRight.Color,
Content.ColorBottomLeft.Color,
Content.ColorBottomRight.Color,
};
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowContent Content { get; set; }
[Browsable(false)]
public List<BxlytWindowFrame> WindowFrames { get; set; }
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame TopLeftFrame
{
get { return WindowFrames.Count >= 1 ? WindowFrames[0] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame TopRightFrame
{
get { return WindowFrames.Count >= 2 ? WindowFrames[1] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame BottomLeftFrame
{
get { return WindowFrames.Count >= 3 ? WindowFrames[2] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame BottomRightFrame
{
get { return WindowFrames.Count >= 4 ? WindowFrames[3] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame TopFrame
{
get { return WindowFrames.Count >= 5 ? WindowFrames[4] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame BottomFrame
{
get { return WindowFrames.Count >= 6 ? WindowFrames[5] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame LeftFrame
{
get { return WindowFrames.Count >= 7 ? WindowFrames[6] : null; }
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowFrame RightFrame
{
get { return WindowFrames.Count >= 8 ? WindowFrames[7] : null; }
}
public WND1(FileReader reader, Header header) : base(reader, header)
{
layoutHeader = header;
WindowFrames = new List<BxlytWindowFrame>();
long pos = reader.Position - 0x54;
StretchLeft = reader.ReadUInt16();
StretchRight = reader.ReadUInt16();
StretchTop = reader.ReadUInt16();
StretchBottm = reader.ReadUInt16();
FrameElementLeft = reader.ReadUInt16();
FrameElementRight = reader.ReadUInt16();
FrameElementTop = reader.ReadUInt16();
FrameElementBottm = reader.ReadUInt16();
FrameCount = reader.ReadByte();
_flag = reader.ReadByte();
reader.ReadUInt16();//padding
uint contentOffset = reader.ReadUInt32();
uint frameOffsetTbl = reader.ReadUInt32();
WindowKind = (WindowKind)((_flag >> 2) & 3);
reader.SeekBegin(pos + contentOffset);
Content = new BxlytWindowContent(reader, header);
reader.SeekBegin(pos + frameOffsetTbl);
var offsets = reader.ReadUInt32s(FrameCount);
foreach (int offset in offsets)
{
reader.SeekBegin(pos + offset);
WindowFrames.Add(new BxlytWindowFrame(reader, header));
}
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long pos = writer.Position - 8;
base.Write(writer, header);
writer.Write(StretchLeft);
writer.Write(StretchRight);
writer.Write(StretchTop);
writer.Write(StretchBottm);
writer.Write(FrameElementLeft);
writer.Write(FrameElementRight);
writer.Write(FrameElementTop);
writer.Write(FrameElementBottm);
writer.Write(FrameCount);
writer.Write(_flag);
writer.Write((ushort)0);
long _ofsContentPos = writer.Position;
writer.Write(0);
writer.Write(0);
writer.WriteUint32Offset(_ofsContentPos, pos);
Content.Write(writer);
if (WindowFrames.Count > 0)
{
writer.WriteUint32Offset(_ofsContentPos + 4, pos);
//Reserve space for frame offsets
long _ofsFramePos = writer.Position;
writer.Write(new uint[FrameCount]);
for (int i = 0; i < FrameCount; i++)
{
writer.WriteUint32Offset(_ofsFramePos + (i * 4), pos);
WindowFrames[i].Write(writer);
}
}
}
}
}

View File

@ -0,0 +1,25 @@
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();
return header;
}
public static string ToXml(BFLAN.Header header)
{
return "";
}
}
}

View File

@ -11,15 +11,14 @@ namespace LayoutBXLYT
{
public class FLYT
{
public static BFLYT.Header FromXml(string text)
public static Header FromXml(string text)
{
BFLYT.Header header = new BFLYT.Header();
Header header = new Header();
return header;
}
public static string ToXml(BFLYT.Header header)
public static string ToXml(Header header)
{
return "";
}
}

View File

@ -0,0 +1,142 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using Syroot.Maths;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Cafe
{
public class USD1 : UserData
{
public USD1()
{
Entries = new List<UserDataEntry>();
}
public USD1(FileReader reader, Header header) : base()
{
long startPos = reader.Position - 8;
ushort numEntries = reader.ReadUInt16();
reader.ReadUInt16(); //padding
for (int i = 0; i < numEntries; i++)
Entries.Add(new USD1Entry(reader, startPos, header));
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long startPos = writer.Position - 8;
writer.Write((ushort)Entries.Count);
writer.Write((ushort)0);
long enryPos = writer.Position;
for (int i = 0; i < Entries.Count; i++)
((USD1Entry)Entries[i]).Write(writer, header);
for (int i = 0; i < Entries.Count; i++)
{
writer.WriteUint32Offset(Entries[i]._pos + 4, Entries[i]._pos);
switch (Entries[i].Type)
{
case UserDataType.String:
writer.WriteString(Entries[i].GetString());
break;
case UserDataType.Int:
writer.Write(Entries[i].GetInts());
break;
case UserDataType.Float:
writer.Write(Entries[i].GetFloats());
break;
case UserDataType.StructData:
foreach (UserDataStruct structure in Entries[i].GetStructs())
structure.Write(writer, header);
break;
}
}
//Write strings after
for (int i = 0; i < Entries.Count; i++)
{
writer.WriteUint32Offset(Entries[i]._pos, Entries[i]._pos);
writer.WriteString(Entries[i].Name);
}
}
}
public class USD1Entry : UserDataEntry
{
public USD1Entry(FileReader reader, long startPos, Header header)
{
long pos = reader.Position;
uint nameOffset = reader.ReadUInt32();
uint dataOffset = reader.ReadUInt32();
ushort dataLength = reader.ReadUInt16();
Type = reader.ReadEnum<UserDataType>(false);
Unknown = reader.ReadByte();
long datapos = reader.Position;
if (nameOffset != 0)
{
reader.SeekBegin(pos + nameOffset);
Name = reader.ReadZeroTerminatedString();
}
if (dataOffset != 0)
{
reader.SeekBegin(pos + dataOffset);
switch (Type)
{
case UserDataType.String:
if (dataLength != 0)
data = reader.ReadString((int)dataLength);
else
data = reader.ReadZeroTerminatedString();
break;
case UserDataType.Int:
data = reader.ReadInt32s((int)dataLength);
break;
case UserDataType.Float:
data = reader.ReadSingles((int)dataLength);
break;
case UserDataType.StructData:
var structs = new List<UserDataStruct>();
for (int i = 0; i < dataLength; i++)
structs.Add(new UserDataStruct(reader, header));
data = structs;
break;
}
}
reader.SeekBegin(datapos);
}
public void Write(FileWriter writer, LayoutHeader header)
{
_pos = writer.Position;
writer.Write(0); //nameOffset
writer.Write(0); //dataOffset
writer.Write((ushort)GetDataLength());
writer.Write(Type, false);
writer.Write(Unknown);
}
private int GetDataLength()
{
if (data is string)
return ((string)data).Length;
else if (data is int[])
return ((int[])data).Length;
else if (data is float[])
return ((float[])data).Length;
else if (data is List<UserDataStruct>)
return ((List<UserDataStruct>)data).Count;
return 0;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -39,7 +39,7 @@ namespace LayoutBXLYT
SetInt($"texCoords0Source", 0);
}
public static void SetMaterials(BxlytShader shader, BCLYT.Material material, BasePane pane, Dictionary<string, STGenericTexture> textures)
public static void SetMaterials(BxlytShader shader, CTR.Material material, BasePane pane, Dictionary<string, STGenericTexture> textures)
{
Matrix4 rotationX = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(pane.Rotate.X));
Matrix4 rotationY = Matrix4.CreateRotationY(MathHelper.DegreesToRadians(pane.Rotate.Y));
@ -48,8 +48,8 @@ namespace LayoutBXLYT
shader.SetMatrix("rotationMatrix", ref rotationMatrix);
shader.SetColor("whiteColor", material.TevConstantColors[0].Color);
shader.SetColor("blackColor", material.TevColor.Color);
shader.SetColor("whiteColor", material.WhiteColor.Color);
shader.SetColor("blackColor", material.BlackColor.Color);
shader.SetInt("debugShading", (int)Runtime.LayoutEditor.Shading);
shader.SetInt("numTextureMaps", material.TextureMaps.Length);
shader.SetVec2("uvScale0", new Vector2(1, 1));

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.CTR
{
public class GRP1 : GroupPane
{
public GRP1() : base()
{
}
public GRP1(FileReader reader, BxlytHeader header)
{
LayoutFile = header;
Name = reader.ReadString(0x10, true); ;
int numNodes = reader.ReadUInt16();
reader.Seek(2); //padding
for (int i = 0; i < numNodes; i++)
Panes.Add(reader.ReadString(0x10, true));
}
public override void Write(FileWriter writer, LayoutHeader header)
{
writer.WriteString(Name, 0x10);
writer.Write((ushort)Panes.Count);
writer.Seek(2);
for (int i = 0; i < Panes.Count; i++)
writer.WriteString(Panes[i], 0x10);
}
}
}

View File

@ -0,0 +1,269 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
using Toolbox.Library;
using System.ComponentModel;
namespace LayoutBXLYT.CTR
{
public class MAT1 : SectionCommon
{
public List<BxlytMaterial> Materials { get; set; }
public MAT1()
{
Materials = new List<BxlytMaterial>();
}
public MAT1(FileReader reader, BxlytHeader header) : base()
{
Materials = new List<BxlytMaterial>();
long pos = reader.Position;
ushort numMats = reader.ReadUInt16();
reader.Seek(2); //padding
uint[] offsets = reader.ReadUInt32s(numMats);
for (int i = 0; i < numMats; i++)
{
reader.SeekBegin(pos + offsets[i] - 8);
Materials.Add(new Material(reader, header));
}
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long pos = writer.Position - 8;
writer.Write((ushort)Materials.Count);
writer.Seek(2);
long _ofsPos = writer.Position;
//Fill empty spaces for offsets later
writer.Write(new uint[Materials.Count]);
//Save offsets and strings
for (int i = 0; i < Materials.Count; i++)
{
writer.WriteUint32Offset(_ofsPos + (i * 4), pos);
((Material)Materials[i]).Write(writer, header);
writer.Align(4);
}
}
}
public class Material : BxlytMaterial
{
public STColor8[] TevConstantColors { get; set; }
[DisplayName("Texture Coordinate Params"), CategoryAttribute("Texture")]
public TexCoordGen[] TexCoordGens { get; set; }
[DisplayName("Indirect Parameter"), CategoryAttribute("Texture")]
[TypeConverter(typeof(ExpandableObjectConverter))]
public IndirectParameter IndParameter { get; set; }
[DisplayName("Projection Texture Coord Parameters"), CategoryAttribute("Texture")]
public ProjectionTexGenParam[] ProjTexGenParams { get; set; }
[DisplayName("Font Shadow Parameters"), CategoryAttribute("Font")]
[TypeConverter(typeof(ExpandableObjectConverter))]
public FontShadowParameter FontShadowParameter { get; set; }
private uint flags;
public string GetTexture(int index)
{
if (TextureMaps[index].ID != -1)
return ParentLayout.Textures[TextureMaps[index].ID];
else
return "";
}
public Material()
{
TextureMaps = new TextureRef[0];
TextureTransforms = new BxlytTextureTransform[0];
TextureMaps = new TextureRef[0];
TextureTransforms = new BxlytTextureTransform[0];
ProjTexGenParams = new ProjectionTexGenParam[0];
TevStages = new TevStage[0];
TexCoordGens = new TexCoordGen[0];
TevConstantColors = new STColor8[5];
for (int i = 0; i < 5; i++)
TevConstantColors[i] = STColor8.White;
BlackColor = new STColor8(0, 0, 0, 0);
WhiteColor = STColor8.White;
}
public Material(string name, BxlytHeader header)
{
ParentLayout = header;
Name = name;
TextureMaps = new TextureRef[0];
TextureTransforms = new BxlytTextureTransform[0];
ProjTexGenParams = new ProjectionTexGenParam[0];
TevStages = new TevStage[0];
TexCoordGens = new TexCoordGen[0];
TevConstantColors = new STColor8[5];
for (int i = 0; i < 5; i++)
TevConstantColors[i] = STColor8.White;
BlackColor = new STColor8(0, 0, 0, 0);
WhiteColor = STColor8.White;
}
public Material(FileReader reader, BxlytHeader header) : base()
{
ParentLayout = header;
Name = reader.ReadString(20, true);
BlackColor = reader.ReadColor8RGBA();
WhiteColor = reader.ReadColor8RGBA();
TevConstantColors = reader.ReadColor8sRGBA(5);
flags = reader.ReadUInt32();
uint texCount = Convert.ToUInt32(flags & 3);
uint mtxCount = Convert.ToUInt32(flags >> 2) & 3;
uint texCoordGenCount = Convert.ToUInt32(flags >> 4) & 3;
uint tevStageCount = Convert.ToUInt32(flags >> 6) & 0x7;
EnableAlphaCompare = Convert.ToBoolean((flags >> 9) & 0x1);
EnableBlend = Convert.ToBoolean((flags >> 10) & 0x1);
var useTextureOnly = Convert.ToBoolean((flags >> 11) & 0x1);
EnableBlendLogic = Convert.ToBoolean((flags >> 12) & 0x1);
EnableIndParams = Convert.ToBoolean((flags >> 14) & 0x1);
var projTexGenParamCount = Convert.ToUInt32((flags >> 15) & 0x3);
EnableFontShadowParams = Convert.ToBoolean((flags >> 17) & 0x1);
AlphaInterpolation = Convert.ToBoolean((flags >> 18) & 0x1);
Console.WriteLine($"MAT1 {Name}");
Console.WriteLine($"texCount {texCount}");
Console.WriteLine($"mtxCount {mtxCount}");
Console.WriteLine($"texCoordGenCount {texCoordGenCount}");
Console.WriteLine($"tevStageCount {tevStageCount}");
Console.WriteLine($"hasAlphaCompare {EnableAlphaCompare}");
Console.WriteLine($"hasBlendMode {EnableBlend}");
Console.WriteLine($"useTextureOnly {useTextureOnly}");
Console.WriteLine($"seperateBlendMode {EnableBlendLogic}");
Console.WriteLine($"hasIndParam {EnableIndParams}");
Console.WriteLine($"projTexGenParamCount {projTexGenParamCount}");
Console.WriteLine($"hasFontShadowParam {EnableFontShadowParams}");
Console.WriteLine($"AlphaInterpolation {AlphaInterpolation}");
TextureMaps = new TextureRef[texCount];
TextureTransforms = new BxlytTextureTransform[mtxCount];
TexCoordGens = new TexCoordGen[texCoordGenCount];
TevStages = new TevStage[tevStageCount];
ProjTexGenParams = new ProjectionTexGenParam[projTexGenParamCount];
for (int i = 0; i < texCount; i++)
TextureMaps[i] = new TextureRef(reader, header);
for (int i = 0; i < mtxCount; i++)
TextureTransforms[i] = new BxlytTextureTransform(reader);
for (int i = 0; i < texCoordGenCount; i++)
TexCoordGens[i] = new TexCoordGen(reader, header);
for (int i = 0; i < tevStageCount; i++)
TevStages[i] = new TevStage(reader, header);
if (EnableAlphaCompare)
AlphaCompare = new BxlytAlphaCompare(reader, header);
if (EnableBlend)
BlendMode = new BxlytBlendMode(reader, header);
if (EnableBlendLogic)
BlendModeLogic = new BxlytBlendMode(reader, header);
if (EnableIndParams)
IndParameter = new IndirectParameter(reader, header);
for (int i = 0; i < projTexGenParamCount; i++)
ProjTexGenParams[i] = new ProjectionTexGenParam(reader, header);
if (EnableFontShadowParams)
FontShadowParameter = new FontShadowParameter(reader, header);
}
public void Write(FileWriter writer, LayoutHeader header)
{
writer.WriteString(Name, 20);
writer.Write(BlackColor);
writer.Write(WhiteColor);
writer.Write(TevConstantColors);
long flagPos = writer.Position;
writer.Write(flags);
flags = 0;
for (int i = 0; i < TextureMaps?.Length; i++)
{
flags += Bit.BitInsert(1, 1, 2, 30);
((TextureRef)TextureMaps[i]).Write(writer);
}
for (int i = 0; i < TextureTransforms?.Length; i++)
{
flags += Bit.BitInsert(1, 1, 2, 28);
((BxlytTextureTransform)TextureTransforms[i]).Write(writer);
}
for (int i = 0; i < TexCoordGens?.Length; i++)
{
flags += Bit.BitInsert(1, 1, 2, 26);
TexCoordGens[i].Write(writer);
}
for (int i = 0; i < TevStages?.Length; i++)
{
flags += Bit.BitInsert(1, 1, 2, 24);
((TevStage)TevStages[i]).Write(writer);
}
if (AlphaCompare != null && EnableAlphaCompare)
{
flags += Bit.BitInsert(1, 1, 1, 22);
AlphaCompare.Write(writer);
}
if (BlendMode != null && EnableBlend)
{
flags += Bit.BitInsert(1, 1, 2, 20);
BlendMode.Write(writer);
}
if (BlendModeLogic != null && EnableBlendLogic)
{
flags += Bit.BitInsert(1, 1, 2, 18);
BlendModeLogic.Write(writer);
}
if (IndParameter != null && EnableIndParams)
{
flags += Bit.BitInsert(1, 1, 1, 17);
IndParameter.Write(writer);
}
for (int i = 0; i < ProjTexGenParams.Length; i++)
{
flags += Bit.BitInsert(1, 1, 2, 15);
ProjTexGenParams[i].Write(writer);
}
if (FontShadowParameter != null && EnableFontShadowParams)
{
flags += Bit.BitInsert(1, 1, 1, 14);
FontShadowParameter.Write(writer);
}
if (AlphaInterpolation)
flags += Bit.BitInsert(1, 1, 1, 13);
using (writer.TemporarySeek(flagPos, System.IO.SeekOrigin.Begin)) {
writer.Write(flags);
}
}
}
}

View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.CTR
{
public class TevStage : BxlytTevStage
{
public TevSource[] ColorSources;
public TevColorOp[] ColorOperators;
public TevScale ColorScale;
public Boolean ColorSavePrevReg;
public byte ColorUnknown;
public TevSource[] AlphaSources;
public TevAlphaOp[] AlphaOperators;
public TevScale AlphaScale;
public Boolean AlphaSavePrevReg;
public uint ConstColors;
private uint flags1;
private uint flags2;
public TevStage() { }
public TevStage(FileReader reader, BxlytHeader header)
{
flags1 = reader.ReadUInt32();
ColorSources = new TevSource[] { (TevSource)(flags1 & 0xF), (TevSource)((flags1 >> 4) & 0xF), (TevSource)((flags1 >> 8) & 0xF) };
ColorOperators = new TevColorOp[] { (TevColorOp)((flags1 >> 12) & 0xF), (TevColorOp)((flags1 >> 16) & 0xF), (TevColorOp)((flags1 >> 20) & 0xF) };
ColorMode = (TevMode)((flags1 >> 24) & 0xF);
ColorScale = (TevScale)((flags1 >> 28) & 0x3);
ColorSavePrevReg = ((flags1 >> 30) & 0x1) == 1;
flags2 = reader.ReadUInt32();
AlphaSources = new TevSource[] { (TevSource)(flags2 & 0xF), (TevSource)((flags2 >> 4) & 0xF), (TevSource)((flags2 >> 8) & 0xF) };
AlphaOperators = new TevAlphaOp[] { (TevAlphaOp)((flags2 >> 12) & 0xF), (TevAlphaOp)((flags2 >> 16) & 0xF), (TevAlphaOp)((flags2 >> 20) & 0xF) };
AlphaMode = (TevMode)((flags2 >> 24) & 0xF);
AlphaScale = (TevScale)((flags2 >> 28) & 0x3);
AlphaSavePrevReg = ((flags2 >> 30) & 0x1) == 1;
ConstColors = reader.ReadUInt32();
}
public void Write(FileWriter writer)
{
writer.Write(flags1);
writer.Write(flags2);
}
}
}

View File

@ -0,0 +1,41 @@
using Toolbox.Library.IO;
namespace LayoutBXLYT.CTR
{
public class TexCoordGen
{
public MatrixType GenType { get; set; }
public TextureGenerationType Source { get; set; }
ushort Unknown { get; set; }
public TexCoordGen(FileReader reader, BxlytHeader header)
{
GenType = (MatrixType)reader.ReadByte();
Source = (TextureGenerationType)reader.ReadByte();
Unknown = reader.ReadUInt16();
}
public void Write(FileWriter writer)
{
writer.Write((byte)GenType);
writer.Write((byte)Source);
writer.Write(Unknown);
}
public enum MatrixType : byte
{
Matrix2x4 = 0
}
public enum TextureGenerationType : byte
{
Tex0 = 0,
Tex1 = 1,
Tex2 = 2,
Ortho = 3,
PaneBased = 4,
PerspectiveProj = 5
}
}
}

View File

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.CTR
{
public class TextureRef : BxlytTextureRef
{
public short ID;
byte flag1;
byte flag2;
public override WrapMode WrapModeU
{
get { return (WrapMode)(flag1 & 0x3); }
}
public override WrapMode WrapModeV
{
get { return (WrapMode)(flag2 & 0x3); }
}
public override FilterMode MinFilterMode
{
get { return (FilterMode)((flag1 >> 2) & 0x3); }
}
public override FilterMode MaxFilterMode
{
get { return (FilterMode)((flag2 >> 2) & 0x3); }
}
public TextureRef() { }
public TextureRef(FileReader reader, BxlytHeader header)
{
ID = reader.ReadInt16();
flag1 = reader.ReadByte();
flag2 = reader.ReadByte();
if (header.Textures.Count > 0)
Name = header.Textures[ID];
}
public void Write(FileWriter writer)
{
writer.Write(ID);
writer.Write(flag1);
writer.Write(flag2);
}
}
}

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.CTR
{
public class BND1 : PAN1, IBoundryPane
{
public override string Signature { get; } = "bnd1";
public BND1() : base() {
LoadDefaults();
}
public BND1(BxlytHeader header, string name) : base()
{
LoadDefaults();
Name = name;
}
public BND1(FileReader reader, BxlytHeader header) : base(reader, header)
{
}
public override void Write(FileWriter writer, LayoutHeader header)
{
base.Write(writer, header);
}
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.CTR
{
public class LYT1 : LayoutInfo
{
public LYT1()
{
DrawFromCenter = false;
Width = 0;
Height = 0;
}
public LYT1(FileReader reader)
{
DrawFromCenter = reader.ReadBoolean();
reader.Seek(3); //padding
Width = reader.ReadSingle();
Height = reader.ReadSingle();
}
public override void Write(FileWriter writer, LayoutHeader header)
{
writer.Write(DrawFromCenter);
writer.Seek(3);
writer.Write(Width);
writer.Write(Height);
}
}
}

View File

@ -0,0 +1,131 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
using System.ComponentModel;
namespace LayoutBXLYT.CTR
{
public class PAN1 : BasePane, IUserDataContainer
{
public override string Signature { get; } = "pan1";
private byte _flags1;
public override bool Visible
{
get { return (_flags1 & 0x1) == 0x1; }
set
{
if (value)
_flags1 |= 0x1;
else
_flags1 &= 0xFE;
}
}
public override bool InfluenceAlpha
{
get { return (_flags1 & 0x2) == 0x2; }
set
{
if (value)
_flags1 |= 0x2;
else
_flags1 &= 0xFD;
}
}
public byte PartsScale { get; set; }
public byte PaneMagFlags { get; set; }
[DisplayName("User Data"), CategoryAttribute("User Data")]
public UserData UserData { get; set; }
public PAN1() : base()
{
}
public PAN1(BxlytHeader header, string name) : base() {
LoadDefaults();
Name = name;
}
public override UserData CreateUserData()
{
return new USD1();
}
public override void LoadDefaults()
{
base.LoadDefaults();
UserData = null;
PaneMagFlags = 0;
}
public PAN1(FileReader reader, BxlytHeader header) : base()
{
_flags1 = reader.ReadByte();
byte origin = reader.ReadByte();
Alpha = reader.ReadByte();
PaneMagFlags = reader.ReadByte();
Name = reader.ReadString(0x18, true);
Translate = reader.ReadVec3SY();
Rotate = reader.ReadVec3SY();
Scale = reader.ReadVec2SY();
Width = reader.ReadSingle();
Height = reader.ReadSingle();
int mainorigin = origin % 16;
int parentorigin = origin / 16;
originX = (OriginX)(mainorigin % 4);
originY = (OriginY)(mainorigin / 4);
ParentOriginX = (OriginX)(parentorigin % 4);
ParentOriginY = (OriginY)(parentorigin / 4);
}
public override void Write(FileWriter writer, LayoutHeader header)
{
int originL = (int)originX;
int originH = (int)originY * 4;
int originPL = (int)ParentOriginX;
int originPH = (int)ParentOriginY * 4;
byte parentorigin = (byte)((originPL + originPH) * 16);
byte origin = (byte)(originL + originH + parentorigin);
writer.Write(_flags1);
writer.Write(origin);
writer.Write(Alpha);
writer.Write(PaneMagFlags);
writer.WriteString(Name, 0x18);
writer.Write(Translate);
writer.Write(Rotate);
writer.Write(Scale);
writer.Write(Width);
writer.Write(Height);
}
public bool ParentVisibility
{
get
{
if (Scale.X == 0 || Scale.Y == 0)
return false;
if (!Visible)
return false;
if (Parent != null && Parent is PAN1)
{
return ((PAN1)Parent).ParentVisibility && Visible;
}
return true;
}
}
}
}

View File

@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library;
using Toolbox.Library.IO;
using System.ComponentModel;
namespace LayoutBXLYT.CTR
{
public class PIC1 : PAN1, IPicturePane
{
public override string Signature { get; } = "pic1";
public TexCoord[] TexCoords { get; set; }
public STColor8 ColorTopLeft { get; set; }
public STColor8 ColorTopRight { get; set; }
public STColor8 ColorBottomLeft { get; set; }
public STColor8 ColorBottomRight { get; set; }
public System.Drawing.Color[] GetVertexColors()
{
return new System.Drawing.Color[4]
{
ColorTopLeft.Color,
ColorTopRight.Color,
ColorBottomLeft.Color,
ColorBottomRight.Color,
};
}
public ushort MaterialIndex { get; set; }
public string GetTexture(int index)
{
return ParentLayout.Textures[Material.TextureMaps[index].ID];
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytMaterial Material { get; set; }
private BxlytHeader ParentLayout;
public PIC1() : base()
{
LoadDefaults();
}
public PIC1(BxlytHeader header, string name) : base()
{
LoadDefaults();
Name = name;
ParentLayout = header;
ColorTopLeft = STColor8.White;
ColorTopRight = STColor8.White;
ColorBottomLeft = STColor8.White;
ColorBottomRight = STColor8.White;
TexCoords = new TexCoord[1];
TexCoords[0] = new TexCoord();
Material = new Material(name, header);
}
public void CopyMaterial()
{
Material = (BxlytMaterial)Material.Clone();
}
public PIC1(FileReader reader, BCLYT.Header header) : base(reader, header)
{
ParentLayout = header;
ColorTopLeft = STColor8.FromBytes(reader.ReadBytes(4));
ColorTopRight = STColor8.FromBytes(reader.ReadBytes(4));
ColorBottomLeft = STColor8.FromBytes(reader.ReadBytes(4));
ColorBottomRight = STColor8.FromBytes(reader.ReadBytes(4));
MaterialIndex = reader.ReadUInt16();
byte numUVs = reader.ReadByte();
reader.Seek(1); //padding
TexCoords = new TexCoord[numUVs];
for (int i = 0; i < numUVs; i++)
{
TexCoords[i] = new TexCoord()
{
TopLeft = reader.ReadVec2SY(),
TopRight = reader.ReadVec2SY(),
BottomLeft = reader.ReadVec2SY(),
BottomRight = reader.ReadVec2SY(),
};
}
Material = header.MaterialList.Materials[MaterialIndex];
}
public override void Write(FileWriter writer, LayoutHeader header)
{
base.Write(writer, header);
writer.Write(ColorTopLeft.ToBytes());
writer.Write(ColorTopRight.ToBytes());
writer.Write(ColorBottomLeft.ToBytes());
writer.Write(ColorBottomRight.ToBytes());
writer.Write(MaterialIndex);
writer.Write(TexCoords != null ? (byte)TexCoords.Length : (byte)0);
writer.Write((byte)0);
for (int i = 0; i < TexCoords.Length; i++)
{
writer.Write(TexCoords[i].TopLeft);
writer.Write(TexCoords[i].TopRight);
writer.Write(TexCoords[i].BottomLeft);
writer.Write(TexCoords[i].BottomRight);
}
}
}
}

View File

@ -0,0 +1,393 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using Toolbox.Library;
using System.IO;
using Toolbox.Library.IO;
using FirstPlugin;
namespace LayoutBXLYT.CTR
{
public class PRT1 : PAN1, IPartPane
{
public override string Signature { get; } = "prt1";
private bool hasSearchedParts = false;
public PRT1() : base()
{
}
public PRT1(BxlytHeader header, string name) : base()
{
LoadDefaults();
Name = name;
layoutFile = (BCLYT.Header)header;
MagnifyX = 1;
MagnifyY = 1;
LayoutFileName = "";
Properties = new List<PartProperty>();
}
[DisplayName("Magnify X"), CategoryAttribute("Parts")]
public float MagnifyX { get; set; }
[DisplayName("Magnify Y"), CategoryAttribute("Parts")]
public float MagnifyY { get; set; }
[DisplayName("Properties"), CategoryAttribute("Parts")]
public List<PartProperty> Properties { get; set; }
private string layoutFilename;
[DisplayName("External Layout File"), CategoryAttribute("Parts")]
public string LayoutFileName
{
get { return layoutFilename; }
set
{
layoutFilename = value;
ExternalLayout = null;
hasSearchedParts = false;
}
}
private BCLYT ExternalLayout;
public BasePane GetExternalPane()
{
if (hasSearchedParts || LayoutFileName == string.Empty) return null;
ExternalLayout = layoutFile.PartsManager.TryGetLayout($"{LayoutFileName}.bClyt") as BCLYT;
if (ExternalLayout == null)
ExternalLayout = SearchExternalFile();
if (ExternalLayout == null)
return null;
//Load all the part panes to the lookup table
foreach (var pane in ExternalLayout.header.PaneLookup)
if (!layoutFile.PaneLookup.ContainsKey(pane.Key))
layoutFile.PaneLookup.Add(pane.Key, pane.Value);
layoutFile.PartsManager.AddLayout(ExternalLayout.header);
return ExternalLayout.header.RootPane;
}
//Get textures if possible from the external parts file
public void UpdateTextureData(Dictionary<string, STGenericTexture> textures)
{
if (hasSearchedParts) return;
if (ExternalLayout == null)
{
ExternalLayout = SearchExternalFile();
if (ExternalLayout == null)
return;
ExternalLayout.header.TextureManager = layoutFile.TextureManager;
var textureList = ExternalLayout.GetTextures();
foreach (var tex in textureList)
if (!textures.ContainsKey(tex.Key))
textures.Add(tex.Key, tex.Value);
textureList.Clear();
}
}
private BCLYT SearchExternalFile()
{
hasSearchedParts = false;
var fileFormat = layoutFile.FileInfo;
string path = FileManager.GetSourcePath(fileFormat);
//File is outside an archive so check the contents it is in
if (File.Exists(path))
{
string folder = Path.GetDirectoryName(path);
foreach (var file in Directory.GetFiles(folder))
{
if (file.Contains(LayoutFileName))
{
if (Utils.GetExtension(file) == ".szs")
{
var openedFile = STFileLoader.OpenFileFormat(file);
if (openedFile == null)
continue;
layoutFile.PartsManager.AddArchive((IArchiveFile)openedFile);
BCLYT bclyt = null;
SearchArchive((IArchiveFile)openedFile, ref bclyt);
if (bclyt != null)
return bclyt;
}
else if (Utils.GetExtension(file) == ".bclan")
{
try
{
var openedFile = STFileLoader.OpenFileFormat(file);
if (openedFile == null)
continue;
openedFile.CanSave = false;
var bflan = openedFile as BXLAN;
layoutFile.PartsManager.AddAnimation(bflan.BxlanHeader);
}
catch
{
}
}
else if (Utils.GetExtension(file) == ".bclyt")
{
var openedFile = STFileLoader.OpenFileFormat(file);
if (openedFile == null) continue;
openedFile.CanSave = false;
openedFile.IFileInfo = new IFileInfo();
openedFile.IFileInfo.ArchiveParent = fileFormat.IFileInfo.ArchiveParent;
return (BCLYT)openedFile;
}
}
}
}
for (int i = 0; i < PluginRuntime.SarcArchives.Count; i++)
{
BCLYT bclyt = null;
SearchArchive(PluginRuntime.SarcArchives[i], ref bclyt);
if (bclyt != null)
return bclyt;
}
return null;
}
private void SearchArchive(IArchiveFile archiveFile, ref BCLYT layoutFile)
{
layoutFile = null;
if (archiveFile is SARC)
{
if (((SARC)archiveFile).FileLookup.ContainsKey($"blyt/{LayoutFileName}.bclyt"))
{
var entry = ((SARC)archiveFile).FileLookup[$"blyt/{LayoutFileName}.bclyt"];
var openedFile = entry.OpenFile();
if (openedFile is BCLYT)
{
layoutFile = openedFile as BCLYT;
layoutFile.IFileInfo = new IFileInfo();
layoutFile.IFileInfo.ArchiveParent = layoutFile.IFileInfo.ArchiveParent;
return;
}
}
}
foreach (var file in archiveFile.Files)
{
if (file.FileName.Contains(".lyarc"))
{
var openedFile = file.OpenFile();
if (openedFile is IArchiveFile)
SearchArchive((IArchiveFile)openedFile, ref layoutFile);
}
else if (file.FileName.Contains(LayoutFileName))
{
try
{
var openedFile = file.OpenFile();
if (openedFile is IArchiveFile)
SearchArchive((IArchiveFile)openedFile, ref layoutFile);
else if (openedFile is BCLYT)
{
Console.WriteLine("Part found! " + file.FileName);
layoutFile = openedFile as BCLYT;
layoutFile.IFileInfo = new IFileInfo();
layoutFile.IFileInfo.ArchiveParent = layoutFile.IFileInfo.ArchiveParent;
return;
}
}
catch
{
}
}
}
}
private BCLYT.Header layoutFile;
public PRT1(FileReader reader, BCLYT.Header header) : base(reader, header)
{
layoutFile = header;
Properties = new List<PartProperty>();
StartPosition = reader.Position - 84;
uint properyCount = reader.ReadUInt32();
MagnifyX = reader.ReadSingle();
MagnifyY = reader.ReadSingle();
for (int i = 0; i < properyCount; i++)
Properties.Add(new PartProperty(reader, header, StartPosition));
LayoutFileName = reader.ReadZeroTerminatedString();
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long startPos = writer.Position - 8;
base.Write(writer, header);
writer.Write(Properties.Count);
writer.Write(MagnifyX);
writer.Write(MagnifyY);
for (int i = 0; i < Properties.Count; i++)
Properties[i].Write(writer, header, startPos);
writer.WriteString(LayoutFileName);
writer.Align(4);
// for (int i = 0; i < Properties.Count; i++)
// Properties[i].WriteProperties(writer, header, startPos);
// for (int i = 0; i < Properties.Count; i++)
// Properties[i].WriteUserData(writer, header, startPos);
for (int i = 0; i < Properties.Count; i++)
{
Properties[i].WriteProperties(writer, header, startPos);
Properties[i].WriteUserData(writer, header, startPos);
Properties[i].WritePaneInfo(writer, header, startPos);
}
}
}
public class PartProperty
{
public string Name { get; set; }
public byte UsageFlag { get; set; }
public byte BasicUsageFlag { get; set; }
public byte MaterialUsageFlag { get; set; }
public BasePane Property { get; set; }
public USD1 UserData { get; set; }
public byte[] PaneInfo { get; set; }
public PartProperty(FileReader reader, BCLYT.Header header, long StartPosition)
{
Name = reader.ReadString(0x18, true);
UsageFlag = reader.ReadByte();
BasicUsageFlag = reader.ReadByte();
MaterialUsageFlag = reader.ReadByte();
reader.ReadByte(); //padding
uint propertyOffset = reader.ReadUInt32();
uint userDataOffset = reader.ReadUInt32();
uint panelInfoOffset = reader.ReadUInt32();
long pos = reader.Position;
if (propertyOffset != 0)
{
reader.SeekBegin(StartPosition + propertyOffset);
long startPos = reader.Position;
string signtature = reader.ReadString(4, Encoding.ASCII);
uint sectionSize = reader.ReadUInt32();
Console.WriteLine($"signtature " + signtature);
switch (signtature)
{
case "pic1":
Property = new PIC1(reader, header);
break;
case "txt1":
Property = new TXT1(reader, header);
break;
case "wnd1":
Property = new WND1(reader, header);
break;
case "bnd1":
Property = new BND1(reader, header);
break;
case "prt1":
Property = new PRT1(reader, header);
break;
default:
Console.WriteLine("Unknown section! " + signtature);
break;
}
}
if (userDataOffset != 0)
{
reader.SeekBegin(StartPosition + userDataOffset);
UserData = new USD1(reader, header);
}
if (panelInfoOffset != 0)
{
reader.SeekBegin(StartPosition + panelInfoOffset);
PaneInfo = reader.ReadBytes(52);
}
reader.SeekBegin(pos);
}
private long _ofsPos;
public void Write(FileWriter writer, LayoutHeader header, long startPos)
{
writer.WriteString(Name, 0x18);
writer.Write(UsageFlag);
writer.Write(BasicUsageFlag);
writer.Write(MaterialUsageFlag);
writer.Write((byte)0);
//Reserve offset spaces
_ofsPos = writer.Position;
writer.Write(0); //Property Offset
writer.Write(0); //External User Data
writer.Write(0); //Panel Info Offset
}
public void WriteProperties(FileWriter writer, LayoutHeader header, long startPos)
{
if (Property != null)
{
writer.WriteUint32Offset(_ofsPos, startPos);
BCLYT.Header.WriteSection(writer, Property.Signature, Property, () => Property.Write(writer, header));
}
}
public void WriteUserData(FileWriter writer, LayoutHeader header, long startPos)
{
if (UserData != null)
{
writer.WriteUint32Offset(_ofsPos + 4, startPos);
UserData.Write(writer, header);
}
}
public void WritePaneInfo(FileWriter writer, LayoutHeader header, long startPos)
{
if (PaneInfo != null)
{
writer.WriteUint32Offset(_ofsPos + 8, startPos);
writer.Write(PaneInfo);
}
}
}
}

View File

@ -0,0 +1,267 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
using Toolbox.Library;
using System.ComponentModel;
using Syroot.Maths;
namespace LayoutBXLYT.CTR
{
public class TXT1 : PAN1, ITextPane
{
public override string Signature { get; } = "txt1";
public TXT1() : base()
{
}
public List<string> GetFonts
{
get { return layoutFile.Fonts; }
}
[Browsable(false)]
public Toolbox.Library.Rendering.RenderableTex RenderableFont { get; set; }
[DisplayName("Horizontal Alignment"), CategoryAttribute("Font")]
public OriginX HorizontalAlignment
{
get { return (OriginX)((TextAlignment >> 2) & 0x3); }
set
{
TextAlignment &= unchecked((byte)(~0xC));
TextAlignment |= (byte)((byte)(value) << 2);
}
}
[DisplayName("Vertical Alignment"), CategoryAttribute("Font")]
public OriginY VerticalAlignment
{
get { return (OriginY)((TextAlignment) & 0x3); }
set
{
TextAlignment &= unchecked((byte)(~0x3));
TextAlignment |= (byte)(value);
}
}
[Browsable(false)]
public ushort RestrictedLength
{
get
{ //Divide by 2 due to 2 characters taking up 2 bytes
//Subtract 1 due to padding
return (ushort)((TextLength / 2) - 1);
}
set
{
TextLength = (ushort)((value * 2) + 1);
}
}
[Browsable(false)]
public ushort TextLength { get; set; }
[Browsable(false)]
public ushort MaxTextLength { get; set; }
[Browsable(false)]
public ushort MaterialIndex { get; set; }
[Browsable(false)]
public ushort FontIndex { get; set; }
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytMaterial Material { get; set; }
[DisplayName("Text Alignment"), CategoryAttribute("Font")]
public byte TextAlignment { get; set; }
[DisplayName("Line Alignment"), CategoryAttribute("Font")]
public LineAlign LineAlignment { get; set; }
[DisplayName("Italic Tilt"), CategoryAttribute("Font")]
public float ItalicTilt { get; set; }
[DisplayName("Top Color"), CategoryAttribute("Font")]
public STColor8 FontTopColor { get; set; }
[DisplayName("Bottom Color"), CategoryAttribute("Font")]
public STColor8 FontBottomColor { get; set; }
[DisplayName("Font Size"), CategoryAttribute("Font")]
public Vector2F FontSize { get; set; }
[DisplayName("Character Space"), CategoryAttribute("Font")]
public float CharacterSpace { get; set; }
[DisplayName("Line Space"), CategoryAttribute("Font")]
public float LineSpace { get; set; }
[DisplayName("Shadow Position"), CategoryAttribute("Shadows")]
public Vector2F ShadowXY { get; set; }
[DisplayName("Shadow Size"), CategoryAttribute("Shadows")]
public Vector2F ShadowXYSize { get; set; }
[DisplayName("Shadow Fore Color"), CategoryAttribute("Shadows")]
public STColor8 ShadowForeColor { get; set; }
[DisplayName("Shadow Back Color"), CategoryAttribute("Shadows")]
public STColor8 ShadowBackColor { get; set; }
[DisplayName("Shadow Italic"), CategoryAttribute("Shadows")]
public float ShadowItalic { get; set; }
[DisplayName("Text Box Name"), CategoryAttribute("Text Box")]
public string TextBoxName { get; set; }
private string text;
[DisplayName("Text"), CategoryAttribute("Text Box")]
public string Text
{
get { return text; }
set
{
text = value;
TextLength = (ushort)((text.Length * 2) + 2);
UpdateTextRender();
}
}
[DisplayName("Restricted Text Length"), CategoryAttribute("Font")]
public bool RestrictedTextLengthEnabled
{
get { return (_flags & 0x2) != 0; }
set { _flags = value ? (byte)(_flags | 0x2) : unchecked((byte)(_flags & (~0x2))); }
}
[DisplayName("Enable Shadows"), CategoryAttribute("Font")]
public bool ShadowEnabled { get; set; } = false;
[DisplayName("Font Name"), CategoryAttribute("Font")]
public string FontName { get; set; }
private byte _flags;
private BxlytHeader layoutFile;
public void UpdateTextRender()
{
}
public void CopyMaterial()
{
Material = Material.Clone();
}
public TXT1(BCLYT.Header header, string name)
{
LoadDefaults();
Name = name;
layoutFile = header;
//Add new material
var mat = new Material(this.Name, header);
header.MaterialList.Materials.Add(mat);
MaterialIndex = (ushort)header.MaterialList.Materials.IndexOf(mat);
Material = mat;
Text = Encoding.Unicode.GetString(new byte[0]);
FontIndex = 0;
FontName = "";
TextLength = 4;
MaxTextLength = 4;
TextAlignment = 0;
LineAlignment = LineAlign.Unspecified;
ItalicTilt = 0;
FontTopColor = STColor8.White;
FontBottomColor = STColor8.White;
FontSize = new Vector2F(92, 101);
CharacterSpace = 0;
LineSpace = 0;
ShadowXY = new Vector2F(1, -1);
ShadowXYSize = new Vector2F(1, 1);
ShadowBackColor = STColor8.Black;
ShadowForeColor = STColor8.Black;
ShadowItalic = 0;
}
public TXT1(FileReader reader, BxlytHeader header) : base(reader,header)
{
layoutFile = header;
TextLength = reader.ReadUInt16();
MaxTextLength = reader.ReadUInt16();
MaterialIndex = reader.ReadUInt16();
FontIndex = reader.ReadUInt16();
TextAlignment = reader.ReadByte();
LineAlignment = (LineAlign)reader.ReadByte();
_flags = reader.ReadByte();
reader.Seek(1); //padding
uint textOffset = reader.ReadUInt32();
FontTopColor = STColor8.FromBytes(reader.ReadBytes(4));
FontBottomColor = STColor8.FromBytes(reader.ReadBytes(4));
FontSize = reader.ReadVec2SY();
CharacterSpace = reader.ReadSingle();
LineSpace = reader.ReadSingle();
if (MaterialIndex != ushort.MaxValue && header.Materials.Count > 0)
Material = header.Materials[MaterialIndex];
if (FontIndex != ushort.MaxValue && header.Fonts.Count > 0)
FontName = header.Fonts[FontIndex];
if (RestrictedTextLengthEnabled)
text = reader.ReadZeroTerminatedString(Encoding.Unicode);
else
text = reader.ReadZeroTerminatedString(Encoding.Unicode);
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long pos = writer.Position - 8;
base.Write(writer, header);
writer.Write(TextLength);
writer.Write(MaxTextLength);
writer.Write(MaterialIndex);
writer.Write(FontIndex);
writer.Write(TextAlignment);
writer.Write(LineAlignment, false);
writer.Write(_flags);
writer.Seek(1);
long _ofsTextPos = writer.Position;
writer.Write(0); //text offset
writer.Write(FontTopColor.ToBytes());
writer.Write(FontBottomColor.ToBytes());
writer.Write(FontSize);
writer.Write(CharacterSpace);
writer.Write(LineSpace);
if (Text != null)
{
Encoding encoding = Encoding.Unicode;
if (writer.ByteOrder == Syroot.BinaryData.ByteOrder.BigEndian)
encoding = Encoding.BigEndianUnicode;
writer.WriteUint32Offset(_ofsTextPos, pos);
writer.WriteString(Text, encoding);
// if (RestrictedTextLengthEnabled)
// writer.WriteString(Text, MaxTextLength, encoding);
// else
// writer.WriteString(Text, TextLength, encoding);
}
}
public enum BorderType : byte
{
Standard = 0,
DeleteBorder = 1,
RenderTwoCycles = 2,
};
}
}

View File

@ -0,0 +1,252 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
using System.ComponentModel;
namespace LayoutBXLYT.CTR
{
public class WND1 : PAN1, IWindowPane
{
public override string Signature { get; } = "wnd1";
public BxlytHeader layoutHeader;
public bool UseOneMaterialForAll
{
get { return Convert.ToBoolean(_flag & 1); }
set { }
}
public bool UseVertexColorForAll
{
get { return Convert.ToBoolean((_flag >> 1) & 1); }
set { }
}
public WindowKind WindowKind { get; set; }
public bool NotDrawnContent
{
get { return (_flag & 8) == 16; }
set { }
}
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; }
private byte _flag;
private byte frameCount;
public byte FrameCount
{
get { return frameCount; }
set
{
frameCount = value;
}
}
public System.Drawing.Color[] GetVertexColors()
{
return new System.Drawing.Color[4]
{
Content.ColorTopLeft.Color,
Content.ColorTopRight.Color,
Content.ColorBottomLeft.Color,
Content.ColorBottomRight.Color,
};
}
public void ReloadFrames()
{
SetFrames(layoutHeader);
}
public void SetFrames(BxlytHeader header)
{
if (WindowFrames == null)
WindowFrames = new List<BxlytWindowFrame>();
switch (FrameCount)
{
case 1:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LT"));
break;
case 2:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_L"));
if (WindowFrames.Count == 1)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_R"));
break;
case 4:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LT"));
if (WindowFrames.Count == 1)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RT"));
if (WindowFrames.Count == 2)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LB"));
if (WindowFrames.Count == 3)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RB"));
break;
case 8:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LT"));
if (WindowFrames.Count == 1)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RT"));
if (WindowFrames.Count == 2)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LB"));
if (WindowFrames.Count == 3)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RB"));
if (WindowFrames.Count == 4)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_T"));
if (WindowFrames.Count == 5)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_B"));
if (WindowFrames.Count == 6)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_R"));
if (WindowFrames.Count == 7)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_L"));
break;
}
//Now search for invalid unused materials and remove them
for (int i = 0; i < WindowFrames.Count; i++)
{
if (i >= FrameCount)
header.TryRemoveMaterial(WindowFrames[i].Material);
else if (!header.Materials.Contains(WindowFrames[i].Material))
header.AddMaterial(WindowFrames[i].Material);
}
}
public void CopyWindows()
{
Content = (BxlytWindowContent)Content.Clone();
for (int f = 0; f < WindowFrames.Count; f++)
WindowFrames[f] = (BxlytWindowFrame)WindowFrames[f].Clone();
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowContent Content { get; set; }
[Browsable(false)]
public List<BxlytWindowFrame> WindowFrames { get; set; }
public WND1() : base()
{
}
public WND1(BxlytHeader header, string name)
{
layoutHeader = header;
LoadDefaults();
Name = name;
Content = new BxlytWindowContent(header, this.Name);
UseOneMaterialForAll = true;
UseVertexColorForAll = true;
WindowKind = WindowKind.Around;
NotDrawnContent = false;
StretchLeft = 0;
StretchRight = 0;
StretchTop = 0;
StretchBottm = 0;
Width = 70;
Height = 80;
FrameElementLeft = 16;
FrameElementRight = 16;
FrameElementTop = 16;
FrameElementBottm = 16;
FrameCount = 1;
WindowFrames = new List<BxlytWindowFrame>();
SetFrames(header);
}
public WND1( FileReader reader, BxlytHeader header) : base(reader, header)
{
layoutHeader = header;
WindowFrames = new List<BxlytWindowFrame>();
long pos = reader.Position - 0x4C;
StretchLeft = reader.ReadUInt16();
StretchRight = reader.ReadUInt16();
StretchTop = reader.ReadUInt16();
StretchBottm = reader.ReadUInt16();
FrameElementLeft = reader.ReadUInt16();
FrameElementRight = reader.ReadUInt16();
FrameElementTop = reader.ReadUInt16();
FrameElementBottm = reader.ReadUInt16();
FrameCount = reader.ReadByte();
_flag = reader.ReadByte();
reader.ReadUInt16();//padding
uint contentOffset = reader.ReadUInt32();
uint frameOffsetTbl = reader.ReadUInt32();
WindowKind = (WindowKind)((_flag >> 2) & 3);
reader.SeekBegin(pos + contentOffset);
Content = new BxlytWindowContent(reader, header);
reader.SeekBegin(pos + frameOffsetTbl);
var offsets = reader.ReadUInt32s(FrameCount);
foreach (int offset in offsets)
{
reader.SeekBegin(pos + offset);
WindowFrames.Add(new BxlytWindowFrame(reader, header));
}
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long pos = writer.Position - 8;
base.Write(writer, header);
writer.Write(StretchLeft);
writer.Write(StretchRight);
writer.Write(StretchTop);
writer.Write(StretchBottm);
writer.Write(FrameElementLeft);
writer.Write(FrameElementRight);
writer.Write(FrameElementTop);
writer.Write(FrameElementBottm);
writer.Write(FrameCount);
writer.Write(_flag);
writer.Write((ushort)0);
long _ofsContentPos = writer.Position;
writer.Write(0);
writer.Write(0);
writer.WriteUint32Offset(_ofsContentPos, pos);
Content.Write(writer);
if (WindowFrames.Count > 0)
{
writer.WriteUint32Offset(_ofsContentPos + 4, pos);
//Reserve space for frame offsets
long _ofsFramePos = writer.Position;
writer.Write(new uint[FrameCount]);
for (int i = 0; i < FrameCount; i++)
{
writer.WriteUint32Offset(_ofsFramePos + (i * 4), pos);
WindowFrames[i].Write(writer);
}
}
}
}
}

View File

@ -0,0 +1,130 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using Syroot.Maths;
using Toolbox.Library.IO;
namespace LayoutBXLYT.CTR
{
public class USD1 : UserData
{
public USD1()
{
Entries = new List<UserDataEntry>();
}
public USD1(FileReader reader, BxlytHeader header) : base()
{
long startPos = reader.Position - 8;
ushort numEntries = reader.ReadUInt16();
reader.ReadUInt16(); //padding
for (int i = 0; i < numEntries; i++)
Entries.Add(new USD1Entry(reader, startPos, header));
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long startPos = writer.Position - 8;
writer.Write((ushort)Entries.Count);
writer.Write((ushort)0);
long enryPos = writer.Position;
for (int i = 0; i < Entries.Count; i++)
((USD1Entry)Entries[i]).Write(writer, header);
for (int i = 0; i < Entries.Count; i++)
{
writer.WriteUint32Offset(Entries[i]._pos + 4, Entries[i]._pos);
switch (Entries[i].Type)
{
case UserDataType.String:
writer.WriteString(Entries[i].GetString());
break;
case UserDataType.Int:
writer.Write(Entries[i].GetInts());
break;
case UserDataType.Float:
writer.Write(Entries[i].GetFloats());
break;
}
}
//Write strings after
for (int i = 0; i < Entries.Count; i++)
{
writer.WriteUint32Offset(Entries[i]._pos, Entries[i]._pos);
writer.WriteString(Entries[i].Name);
}
}
}
public class USD1Entry : UserDataEntry
{
public USD1Entry(FileReader reader, long startPos, BxlytHeader header)
{
long pos = reader.Position;
uint nameOffset = reader.ReadUInt32();
uint dataOffset = reader.ReadUInt32();
ushort dataLength = reader.ReadUInt16();
Type = reader.ReadEnum<UserDataType>(false);
Unknown = reader.ReadByte();
long datapos = reader.Position;
if (nameOffset != 0)
{
reader.SeekBegin(pos + nameOffset);
Name = reader.ReadZeroTerminatedString();
}
if (dataOffset != 0)
{
reader.SeekBegin(pos + dataOffset);
switch (Type)
{
case UserDataType.String:
if (dataLength != 0)
data = reader.ReadString((int)dataLength);
else
data = reader.ReadZeroTerminatedString();
break;
case UserDataType.Int:
data = reader.ReadInt32s((int)dataLength);
break;
case UserDataType.Float:
data = reader.ReadSingles((int)dataLength);
break;
}
}
reader.SeekBegin(datapos);
}
public void Write(FileWriter writer, LayoutHeader header)
{
_pos = writer.Position;
writer.Write(0); //nameOffset
writer.Write(0); //dataOffset
writer.Write((ushort)GetDataLength());
writer.Write(Type, false);
writer.Write(Unknown);
}
private int GetDataLength()
{
if (data is string)
return ((string)data).Length;
else if (data is int[])
return ((int[])data).Length;
else if (data is float[])
return ((float[])data).Length;
return 0;
}
}
}

View File

@ -12,45 +12,44 @@ using System.ComponentModel;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using SharpYaml.Serialization;
namespace LayoutBXLYT
{
public class BasePane : SectionCommon, ICloneable
{
[Browsable(false)]
public BxlytHeader LayoutFile;
[YamlIgnore]
internal BxlytHeader LayoutFile;
[Browsable(false)]
public PaneAnimController animController = new PaneAnimController();
[YamlIgnore]
internal PaneAnimController animController = new PaneAnimController();
[Browsable(false)]
public TreeNodeCustom NodeWrapper;
[DisplayName("Is Visible"), CategoryAttribute("Flags")]
public virtual bool Visible { get; set; }
[YamlIgnore]
internal TreeNodeCustom NodeWrapper;
[Browsable(false)]
public bool IsRoot
[YamlIgnore]
internal bool IsRoot
{
get { return Parent == null; }
}
[Browsable(false)]
public bool ParentIsRoot
[YamlIgnore]
internal bool ParentIsRoot
{
get { return Parent != null && Parent.IsRoot; }
}
[YamlIgnore]
internal RenderablePane renderablePane;
[DisplayName("Alpha"), CategoryAttribute("Alpha")]
public byte Alpha { get; set; }
[DisplayName("Influence Alpha"), CategoryAttribute("Alpha")]
public virtual bool InfluenceAlpha { get; set; }
[Browsable(false)]
public virtual bool DisplayInEditor { get; set; } = true;
[YamlIgnore]
internal virtual bool DisplayInEditor { get; set; } = true;
private string name;
@ -95,6 +94,9 @@ namespace LayoutBXLYT
}
}
[DisplayName("Is Visible"), CategoryAttribute("Flags")]
public virtual bool Visible { get; set; }
public BxlytMaterial TryGetActiveMaterial()
{
if (this is IPicturePane)
@ -130,14 +132,22 @@ namespace LayoutBXLYT
[DisplayName("Parent Origin Y"), CategoryAttribute("Origin")]
public virtual OriginY ParentOriginY { get; set; }
[DisplayName("Alpha"), CategoryAttribute("Alpha")]
public byte Alpha { get; set; }
[DisplayName("Influence Alpha"), CategoryAttribute("Alpha")]
public virtual bool InfluenceAlpha { get; set; }
[Browsable(false)]
[YamlIgnore]
public BasePane Parent { get; set; }
[Browsable(false)]
public List<BasePane> Childern { get; set; } = new List<BasePane>();
[Browsable(false)]
public bool HasChildern
[YamlIgnore]
internal bool HasChildern
{
get { return Childern.Count > 0; }
}
@ -213,6 +223,24 @@ namespace LayoutBXLYT
ParentOriginY = OriginY.Center;
}
public virtual void LoadDefaults()
{
Alpha = 255;
Name = "";
Translate = new Vector3F(0, 0, 0);
Rotate = new Vector3F(0, 0, 0);
Scale = new Vector2F(1, 1);
Width = 30;
Height = 40;
originX = OriginX.Center;
originY = OriginY.Center;
ParentOriginX = OriginX.Center;
ParentOriginY = OriginY.Center;
InfluenceAlpha = false;
Visible = true;
}
public virtual BasePane Copy()
{
return new BasePane();
@ -305,6 +333,7 @@ namespace LayoutBXLYT
private CustomRectangle rectangle;
[Browsable(false)]
[YamlIgnore]
public CustomRectangle Rectangle
{
get
@ -714,7 +743,7 @@ namespace LayoutBXLYT
Value = reader.ReadSingle();
}
public void Write(FileWriter writer)
public virtual void Write(FileWriter writer)
{
writer.Write(CompareMode, false);
writer.Seek(3);
@ -734,7 +763,7 @@ namespace LayoutBXLYT
BlendOp = GX2BlendOp.Add;
SourceFactor = GX2BlendFactor.SourceAlpha;
DestFactor = GX2BlendFactor.SourceInvAlpha;
LogicOp = GX2LogicOp.Disable;
LogicOp = GX2LogicOp.Set;
}
public BxlytBlendMode(FileReader reader, BxlytHeader header)
@ -1047,6 +1076,42 @@ namespace LayoutBXLYT
Image3 = 0x02,
}
public enum RevLMCTarget : byte
{
MatColorRed,
MatColorGreen,
MatColorBlue,
MatColorAlpha,
BlackColorRed,
BlackColorGreen,
BlackColorBlue,
BlackColorAlpha,
WhiteColorRed,
WhiteColorGreen,
WhiteColorBlue,
WhiteColorAlpha,
ColorReg3Red,
ColorReg3Green,
ColorReg3Blue,
ColorReg3Alpha,
TevColor1Red,
TevColor1Green,
TevColor1Blue,
TevColor1Alpha,
TevColor2Red,
TevColor2Green,
TevColor2Blue,
TevColor2Alpha,
TevColor3Red,
TevColor3Green,
TevColor3Blue,
TevColor3Alpha,
TevColor4Red,
TevColor4Green,
TevColor4Blue,
TevColor4Alpha,
}
public enum LMCTarget : byte
{
BlackColorRed,
@ -1144,6 +1209,14 @@ namespace LayoutBXLYT
Always = 7,
}
public enum GfxAlphaOp : byte
{
And = 0,
Or = 1,
Xor = 2,
Nor = 3,
}
public enum TevMode : byte
{
Replace,
@ -1265,7 +1338,6 @@ namespace LayoutBXLYT
string TextBoxName { get; set; }
bool PerCharTransform { get; set; }
bool RestrictedTextLengthEnabled { get; set; }
bool ShadowEnabled { get; set; }
string FontName { get; set; }
@ -1325,6 +1397,7 @@ namespace LayoutBXLYT
public List<TexCoord> TexCoords = new List<TexCoord>();
[YamlIgnore]
private BxlytHeader LayoutFile;
public object Clone()
@ -1514,6 +1587,36 @@ namespace LayoutBXLYT
}
}
public virtual BasePane CreateNewNullPane(string name)
{
return null;
}
public virtual BasePane CreateNewTextPane(string name)
{
return null;
}
public virtual BasePane CreateNewPicturePane(string name)
{
return null;
}
public virtual BasePane CreateNewWindowPane(string name)
{
return null;
}
public virtual BasePane CreateNewBoundryPane(string name)
{
return null;
}
public virtual BasePane CreateNewPartPane(string name)
{
return null;
}
public void Dispose()
{
PartsManager?.Dispose();
@ -1855,6 +1958,20 @@ namespace LayoutBXLYT
public LMCTagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { }
}
public class RevLMCTagEntry : BxlanPaiTagEntry
{
public override string TargetName => Target.ToString();
[DisplayName("Target"), CategoryAttribute("Tag")]
public RevLMCTarget Target
{
get { return (RevLMCTarget)AnimationTarget; }
set { AnimationTarget = (byte)value; }
}
public RevLMCTagEntry(byte target, byte curveType) : base(target, curveType) { }
public RevLMCTagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { }
}
public class LTPTagEntry : BxlanPaiTagEntry
{
public override string TargetName => Target.ToString();
@ -2027,16 +2144,13 @@ namespace LayoutBXLYT
public virtual Dictionary<string, STGenericTexture> GetTextures { get; }
[Browsable(false)]
public virtual List<string> Textures { get; }
public virtual List<string> Textures { get; }
[Browsable(false)]
public virtual List<string> Fonts { get; }
[Browsable(false)]
public virtual List<BxlytMaterial> GetMaterials()
{
return new List<BxlytMaterial>();
}
public virtual List<BxlytMaterial> Materials { get;}
public virtual short AddMaterial(BxlytMaterial material, ushort index) { return -1; }
public virtual short AddMaterial(BxlytMaterial material) { return -1; }
@ -2057,17 +2171,16 @@ namespace LayoutBXLYT
public void RemoveTextureReferences(string texture)
{
foreach (var mat in GetMaterials())
foreach (var mat in Materials)
mat.TryRemoveTexture(texture);
}
public BxlytMaterial SearchMaterial(string name)
{
var materials = GetMaterials();
for (int i = 0; i < materials.Count; i++)
for (int i = 0; i < Materials.Count; i++)
{
if (materials[i].Name == name)
return materials[i];
if (Materials[i].Name == name)
return Materials[i];
}
return null;
}
@ -2181,21 +2294,27 @@ namespace LayoutBXLYT
//incase the settings get renabled, which keeps the previous data
[Browsable(false)]
[YamlIgnore]
public bool EnableAlphaCompare { get; set; }
[Browsable(false)]
[YamlIgnore]
public bool EnableBlend { get; set; }
[Browsable(false)]
[YamlIgnore]
public bool EnableBlendLogic { get; set; }
[Browsable(false)]
[YamlIgnore]
public bool EnableIndParams { get; set; }
[Browsable(false)]
[YamlIgnore]
public bool EnableFontShadowParams { get; set; }
[Browsable(false)]
[YamlIgnore]
public TreeNodeCustom NodeWrapper;
public bool TryRemoveTexture(string name)
@ -2244,12 +2363,14 @@ namespace LayoutBXLYT
public BxlytTextureTransform[] TextureTransforms { get; set; }
[Browsable(false)]
[YamlIgnore]
public MaterialAnimController animController = new MaterialAnimController();
[DisplayName("Name"), CategoryAttribute("General")]
public virtual string Name { get; set; }
[Browsable(false)]
[YamlIgnore]
public BxlytHeader ParentLayout;
public void SetName(string oldName, string newName)
@ -2321,6 +2442,20 @@ namespace LayoutBXLYT
Scale = new Vector2F(1, 1);
Rotate = 0;
}
public BxlytTextureTransform(FileReader reader)
{
Translate = reader.ReadVec2SY();
Rotate = reader.ReadSingle();
Scale = reader.ReadVec2SY();
}
public void Write(FileWriter writer)
{
writer.Write(Translate);
writer.Write(Rotate);
writer.Write(Scale);
}
}
public class BxlytIndTextureTransform
@ -2356,6 +2491,36 @@ namespace LayoutBXLYT
}
}
public class PerCharacterTransform
{
public float CurveTimeOffset { get; set; }
public float CurveWidth { get; set; }
public byte LoopType { get; set; }
public byte VerticalOrigin { get; set; }
public byte HasAnimInfo { get; set; }
public byte padding { get; set; }
public virtual void Read(FileReader reader, LayoutHeader header)
{
CurveTimeOffset = reader.ReadSingle();
CurveWidth = reader.ReadSingle();
LoopType = reader.ReadByte();
VerticalOrigin = reader.ReadByte();
HasAnimInfo = reader.ReadByte();
padding = reader.ReadByte();
}
public virtual void Write(FileWriter writer, LayoutHeader header)
{
writer.Write(CurveTimeOffset);
writer.Write(CurveWidth);
writer.Write(LoopType);
writer.Write(VerticalOrigin);
writer.Write(HasAnimInfo);
writer.Write(padding);
}
}
public class CustomRectangle
{
public int LeftPoint;
@ -2444,6 +2609,201 @@ namespace LayoutBXLYT
}
}
public class CNT1 : SectionCommon
{
public string Name { get; set; }
public CNT1(FileReader reader, Cafe.Header header)
{
uint paneNamesOffset = 0;
uint paneCount = 0;
uint animCount = 0;
uint controlUserNameOffset = 0;
uint paneParamNamesOffset = 0;
uint animParamNamesOffset = 0;
if (header.VersionMajor < 3)
{
paneNamesOffset = reader.ReadUInt32();
paneCount = reader.ReadUInt32();
animCount = reader.ReadUInt32();
}
else
{
controlUserNameOffset = reader.ReadUInt32();
paneNamesOffset = reader.ReadUInt32();
paneCount = reader.ReadUInt16();
animCount = reader.ReadUInt16();
paneParamNamesOffset = reader.ReadUInt32();
animParamNamesOffset = reader.ReadUInt32();
}
Name = reader.ReadZeroTerminatedString();
}
public override void Write(FileWriter writer, LayoutHeader header)
{
}
}
public class GroupPane : BasePane
{
public override string Signature { get; } = "grp1";
public List<string> Panes { get; set; } = new List<string>();
private bool displayInEditor = true;
internal override bool DisplayInEditor
{
get { return displayInEditor; }
set
{
displayInEditor = value;
for (int i = 0; i < Panes.Count; i++)
{
var pane = SearchPane(Panes[i]);
if (pane != null)
pane.DisplayInEditor = value;
}
}
}
public GroupPane() : base()
{
}
}
public class FNL1 : SectionCommon
{
public List<string> Fonts { get; set; }
public FNL1()
{
Fonts = new List<string>();
}
public FNL1(FileReader reader, BxlytHeader header) : base() {
Fonts = StringList.Read(reader, header);
}
public override void Write(FileWriter writer, LayoutHeader header) {
StringList.Write(Fonts, writer, header);
}
}
public class TXL1 : SectionCommon
{
public List<string> Textures { get; set; }
public TXL1()
{
Textures = new List<string>();
}
public TXL1(FileReader reader, BxlytHeader header) : base() {
Textures = StringList.Read(reader, header);
}
public override void Write(FileWriter writer, LayoutHeader header) {
StringList.Write(Textures, writer, header);
}
}
public class StringList
{
public static List<string> Read(FileReader reader, LayoutHeader header)
{
List<string> values = new List<string>();
ushort count = reader.ReadUInt16();
reader.Seek(2); //padding
long pos = reader.Position;
if (header is BRLYT.Header)
{
for (int i = 0; i < count; i++)
{
uint offset = reader.ReadUInt32();
reader.ReadUInt32(); //padding
using (reader.TemporarySeek(offset + pos, SeekOrigin.Begin)) {
values.Add(reader.ReadZeroTerminatedString());
}
}
}
else
{
uint[] offsets = reader.ReadUInt32s(count);
for (int i = 0; i < offsets.Length; i++)
{
reader.SeekBegin(offsets[i] + pos);
values.Add(reader.ReadZeroTerminatedString());
}
}
return values;
}
public static void Write(List<string> values,
FileWriter writer, LayoutHeader header)
{
writer.Write((ushort)values.Count);
writer.Write((ushort)0);
//Fill empty spaces for offsets later
long pos = writer.Position;
if (header is BRLYT.Header)
{
writer.Write(new uint[values.Count * 2]);
//Save offsets and strings
for (int i = 0; i < values.Count; i++)
{
writer.WriteUint32Offset(pos + (i * 8), pos);
writer.WriteString(values[i]);
}
}
else
{
writer.Write(new uint[values.Count]);
//Save offsets and strings
for (int i = 0; i < values.Count; i++)
{
writer.WriteUint32Offset(pos + (i * 4), pos);
writer.WriteString(values[i]);
}
}
}
}
public class LayoutInfo : SectionCommon
{
public bool DrawFromCenter { get; set; }
[DisplayName("Canvas Width"), CategoryAttribute("Layout")]
public float Width { get; set; }
[DisplayName("Canvas Height"), CategoryAttribute("Layout")]
public float Height { get; set; }
[DisplayName("Layout Name"), CategoryAttribute("Layout")]
public string Name { get; set; }
public LayoutInfo()
{
DrawFromCenter = false;
Width = 0;
Height = 0;
Name = "";
}
}
public class LayoutControlDocked : Toolbox.Library.Forms.STUserControl
{
public DockContent DockContent;

View File

@ -59,13 +59,13 @@ namespace LayoutBXLYT
if (!header.PaneLookup.ContainsKey($"L_Chara_{i.ToString("00")}"))
continue;
var partPane = (Cafe.BFLYT.PRT1)header.PaneLookup[$"L_Chara_{i.ToString("00")}"];
var partPane = (Cafe.PRT1)header.PaneLookup[$"L_Chara_{i.ToString("00")}"];
var charPane = partPane.GetExternalPane();
if (charPane == null) return;
var iconPane = charPane.SearchPane("P_Chara_00");
if (iconPane == null) return;
var mat = ((BFLYT.PIC1)iconPane).Material;
var mat = ((IPicturePane)iconPane).Material;
string textureName = "Mario";
switch (i)

View File

@ -404,7 +404,7 @@ namespace LayoutBXLYT
Entries.Add(new LVCTagEntry(reader, header));
break;
case "RLMC":
Entries.Add(new LMCTagEntry(reader, header));
Entries.Add(new RevLMCTagEntry(reader, header));
break;
case "RLTP":
Entries.Add(new LTPTagEntry(reader, header));
@ -415,6 +415,7 @@ namespace LayoutBXLYT
}
}
}
public void Write(FileWriter writer, LayoutHeader header, AnimationTarget target)
{

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,7 @@ namespace LayoutBXLYT
SetInt($"texCoords0Source", 0);
}
public static void SetMaterials(BxlytShader shader, BRLYT.Material material, BasePane pane, Dictionary<string, STGenericTexture> textures)
public static void SetMaterials(BxlytShader shader, Revolution.Material material, BasePane pane, Dictionary<string, STGenericTexture> textures)
{
var paneRotate = pane.Rotate;
if (pane.animController.PaneSRT?.Count > 0)
@ -131,7 +131,7 @@ namespace LayoutBXLYT
}
}
if (material.TextureTransforms.Count > 0)
if (material.TextureTransforms.Length > 0)
{
var transform = material.TextureTransforms[0];
var scale = transform.Scale;

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Revolution
{
public class GRP1 : GroupPane
{
public GRP1() { }
public GRP1(FileReader reader, BxlytHeader header)
{
LayoutFile = header;
Name = reader.ReadString(0x10, true);
ushort numNodes = reader.ReadUInt16();
reader.ReadUInt16();//padding
for (int i = 0; i < numNodes; i++)
Panes.Add(reader.ReadString(0x10, true));
}
public override void Write(FileWriter writer, LayoutHeader header)
{
writer.WriteString(Name, 0x10);
writer.Write((ushort)Panes.Count);
writer.Write((ushort)0);
for (int i = 0; i < Panes.Count; i++)
writer.WriteString(Panes[i], 0x10);
}
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Revolution
{
public class LYT1 : LayoutInfo
{
public LYT1()
{
DrawFromCenter = false;
Width = 0;
Height = 0;
}
public LYT1(FileReader reader)
{
DrawFromCenter = reader.ReadBoolean();
reader.Seek(3); //padding
Width = reader.ReadSingle();
Height = reader.ReadSingle();
}
public override void Write(FileWriter writer, LayoutHeader header)
{
writer.Write(DrawFromCenter);
writer.Seek(3);
writer.Write(Width);
writer.Write(Height);
}
}
}

View File

@ -0,0 +1,255 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
using Toolbox.Library;
using static Toolbox.Library.IO.Bit;
namespace LayoutBXLYT.Revolution
{
public class MAT1 : SectionCommon
{
public List<BxlytMaterial> Materials { get; set; }
public MAT1()
{
Materials = new List<BxlytMaterial>();
}
public MAT1(FileReader reader, BxlytHeader header) : base()
{
Materials = new List<BxlytMaterial>();
long pos = reader.Position;
ushort numMats = reader.ReadUInt16();
reader.Seek(2); //padding
uint[] offsets = reader.ReadUInt32s(numMats);
for (int i = 0; i < numMats; i++)
{
reader.SeekBegin(pos + offsets[i] - 8);
Materials.Add(new Material(reader, header));
}
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long pos = writer.Position - 8;
writer.Write((ushort)Materials.Count);
writer.Seek(2);
long _ofsPos = writer.Position;
//Fill empty spaces for offsets later
writer.Write(new uint[Materials.Count]);
//Save offsets and strings
for (int i = 0; i < Materials.Count; i++)
{
writer.WriteUint32Offset(_ofsPos + (i * 4), pos);
((Material)Materials[i]).Write(writer, header);
writer.Align(4);
}
}
}
public class Material : BxlytMaterial
{
public STColor8 ColorRegister3 { get; set; }
public STColor8 MatColor { get; set; } = STColor8.White;
public STColor8 TevColor1 { get; set; }
public STColor8 TevColor2 { get; set; }
public STColor8 TevColor3 { get; set; }
public STColor8 TevColor4 { get; set; }
public List<TexCoordGenEntry> TexCoordGens { get; set; }
public ChanCtrl ChanControl { get; set; } = new ChanCtrl();
public TevSwapModeTable TevSwapModeTable { get; set; } = new TevSwapModeTable();
public List<BxlytTextureTransform> IndirectTexTransforms { get; set; }
public List<IndirectTextureOrderEntry> IndirectTextureOrderEntries { get; set; }
private uint flags;
public string GetTexture(int index)
{
if (TextureMaps[index].ID != -1)
return ParentLayout.Textures[TextureMaps[index].ID];
else
return "";
}
public override BxlytMaterial Clone()
{
Material mat = new Material();
return mat;
}
public bool HasMaterialColor { get; set; }
public bool HasChannelControl { get; set; }
public bool HasBlendMode { get; set; }
public bool HasAlphaCompare { get; set; }
public bool HasTevSwapTable { get; set; }
public Shader Shader { get; set; }
public Material() { }
public Material(string name, BxlytHeader header)
{
ParentLayout = header;
Name = name;
TextureMaps = new TextureRef[0];
TextureTransforms = new BxlytTextureTransform[0];
TexCoordGens = new List<TexCoordGenEntry>();
IndirectTexTransforms = new List<BxlytTextureTransform>();
IndirectTextureOrderEntries = new List<IndirectTextureOrderEntry>();
TevSwapModeTable = new TevSwapModeTable();
ChanControl = new ChanCtrl();
BlackColor = new STColor8(0, 0, 0, 0);
WhiteColor = STColor8.White;
ColorRegister3 = STColor8.White;
TevColor1 = STColor8.White;
TevColor2 = STColor8.White;
TevColor3 = STColor8.White;
TevColor4 = STColor8.White;
TevStages = new TevStage[0];
BlendMode = new BxlytBlendMode();
AlphaCompare = new AlphaCompare();
}
public override void AddTexture(string texture)
{
int index = ParentLayout.AddTexture(texture);
TextureRef textureRef = new TextureRef();
textureRef.ID = (short)index;
textureRef.Name = texture;
TextureMaps = TextureMaps.AddToArray(textureRef);
TexCoordGens.Add(new TexCoordGenEntry()
{
MatrixSource = TexCoordGenEntry.TexCoordGenMatrixSource.GX_DTTMTX9 + (TexCoordGens.Count * 4),
Source = TexCoordGenEntry.TexCoordGenSource.GX_TG_TEX0
});
TextureTransforms = TextureTransforms.AddToArray(new BxlytTextureTransform());
}
public Material(FileReader reader, BxlytHeader header) : base()
{
ParentLayout = header;
BlendMode = new BxlytBlendMode();
AlphaCompare = new AlphaCompare();
TexCoordGens = new List<TexCoordGenEntry>();
IndirectTexTransforms = new List<BxlytTextureTransform>();
IndirectTextureOrderEntries = new List<IndirectTextureOrderEntry>();
Name = reader.ReadString(0x14, true);
BlackColor = reader.ReadColor16RGBA().ToColor8();
WhiteColor = reader.ReadColor16RGBA().ToColor8();
ColorRegister3 = reader.ReadColor16RGBA().ToColor8();
TevColor1 = reader.ReadColor8RGBA();
TevColor2 = reader.ReadColor8RGBA();
TevColor3 = reader.ReadColor8RGBA();
TevColor4 = reader.ReadColor8RGBA();
flags = reader.ReadUInt32();
HasMaterialColor = Convert.ToBoolean(ExtractBits(flags, 1, 4));
HasChannelControl = Convert.ToBoolean(ExtractBits(flags, 1, 6));
HasBlendMode = Convert.ToBoolean(ExtractBits(flags, 1, 7));
HasAlphaCompare = Convert.ToBoolean(ExtractBits(flags, 1, 8));
uint tevStagesCount = ExtractBits(flags, 5, 9);
uint indTexOrderCount = ExtractBits(flags, 2, 16);
uint indSrtCount = ExtractBits(flags, 2, 17);
HasTevSwapTable = Convert.ToBoolean(ExtractBits(flags, 1, 19));
uint texCoordGenCount = ExtractBits(flags, 4, 20);
uint mtxCount = ExtractBits(flags, 4, 24);
uint texCount = ExtractBits(flags, 4, 28);
TextureMaps = new TextureRef[texCount];
TevStages = new TevStage[tevStagesCount];
TextureTransforms = new BxlytTextureTransform[mtxCount];
for (int i = 0; i < texCount; i++)
TextureMaps[i] = new TextureRef(reader, header);
for (int i = 0; i < mtxCount; i++)
TextureTransforms[i] = new BxlytTextureTransform(reader);
for (int i = 0; i < texCoordGenCount; i++)
{
TexCoordGens.Add(new TexCoordGenEntry(reader));
}
if (HasChannelControl)
ChanControl = new ChanCtrl(reader);
if (HasMaterialColor)
MatColor = reader.ReadColor8RGBA();
if (HasTevSwapTable)
TevSwapModeTable = new TevSwapModeTable(reader);
for (int i = 0; i < indSrtCount; i++)
IndirectTexTransforms.Add(new BxlytTextureTransform(reader));
for (int i = 0; i < indTexOrderCount; i++)
IndirectTextureOrderEntries.Add(new IndirectTextureOrderEntry(reader));
for (int i = 0; i < tevStagesCount; i++)
TevStages[i] = new TevStage(reader, header);
if (HasAlphaCompare)
AlphaCompare = new AlphaCompare(reader);
if (HasBlendMode)
BlendMode = new BxlytBlendMode(reader, header);
}
public void Write(FileWriter writer, LayoutHeader header)
{
writer.WriteString(Name, 0x14);
writer.Write(BlackColor.ToColor16());
writer.Write(WhiteColor.ToColor16());
writer.Write(ColorRegister3.ToColor16());
writer.Write(TevColor1);
writer.Write(TevColor2);
writer.Write(TevColor3);
writer.Write(TevColor4);
writer.Write(flags);
for (int i = 0; i < TextureMaps.Length; i++)
((TextureRef)TextureMaps[i]).Write(writer);
for (int i = 0; i < TextureTransforms.Length; i++)
((BxlytTextureTransform)TextureTransforms[i]).Write(writer);
for (int i = 0; i < TexCoordGens.Count; i++)
TexCoordGens[i].Write(writer);
if (HasChannelControl)
ChanControl.Write(writer);
if (HasMaterialColor)
writer.Write(MatColor);
if (HasTevSwapTable)
TevSwapModeTable.Write(writer);
for (int i = 0; i < IndirectTexTransforms.Count; i++)
IndirectTexTransforms[i].Write(writer);
for (int i = 0; i < IndirectTextureOrderEntries.Count; i++)
IndirectTextureOrderEntries[i].Write(writer);
for (int i = 0; i < TevStages.Length; i++)
((TevStage)TevStages[i]).Write(writer);
if (HasAlphaCompare)
AlphaCompare.Write(writer);
if (HasBlendMode)
BlendMode.Write(writer);
}
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Revolution
{
public class AlphaCompare : LayoutBXLYT.BxlytAlphaCompare
{
public GfxAlphaFunction Comp0 { get; set; }
public GfxAlphaFunction Comp1 { get; set; }
public GfxAlphaOp AlphaOp { get; set; }
public byte Ref0 { get; set; }
public byte Ref1 { get; set; }
public AlphaCompare()
{
Comp0 = GfxAlphaFunction.Always;
Comp1 = GfxAlphaFunction.Always;
AlphaOp = GfxAlphaOp.And;
Ref0 = 0;
Ref1 = 0;
}
public AlphaCompare(FileReader reader) : base()
{
byte c = reader.ReadByte();
Comp0 = (GfxAlphaFunction)(c & 0x7);
Comp1 = (GfxAlphaFunction)((c >> 4) & 0x7);
AlphaOp = (GfxAlphaOp)reader.ReadByte();
Ref0 = reader.ReadByte();
Ref1 = reader.ReadByte();
}
public override void Write(FileWriter writer)
{
byte c = 0;
c |= (byte)(((byte)Comp1 & 0x7) << 4);
c |= (byte)(((byte)Comp0 & 0x7) << 0);
writer.Write(c);
writer.Write((byte)AlphaOp);
writer.Write(Ref0);
writer.Write(Ref1);
}
}
}

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Revolution
{
public class ChanCtrl
{
public byte ColorMatSource { get; set; }
public byte AlphaMatSource { get; set; }
public byte Unknown1 { get; set; }
public byte Unknown2 { get; set; }
public ChanCtrl() {
ColorMatSource = 1;
AlphaMatSource = 1;
Unknown1 = 0;
Unknown2 = 0;
}
public ChanCtrl(FileReader reader)
{
ColorMatSource = reader.ReadByte();
AlphaMatSource = reader.ReadByte();
Unknown1 = reader.ReadByte();
Unknown2 = reader.ReadByte();
}
public void Write(FileWriter writer)
{
writer.Write(ColorMatSource);
writer.Write(AlphaMatSource);
writer.Write(Unknown1);
writer.Write(Unknown2);
}
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Revolution
{
public class IndirectTextureOrderEntry
{
public byte TexCoord { get; set; }
public byte TexMap { get; set; }
public byte ScaleS { get; set; }
public byte ScaleT { get; set; }
public IndirectTextureOrderEntry(FileReader reader)
{
TexCoord = reader.ReadByte();
TexMap = reader.ReadByte();
ScaleS = reader.ReadByte();
ScaleT = reader.ReadByte();
}
public void Write(FileWriter writer)
{
writer.Write(TexCoord);
writer.Write(TexMap);
writer.Write(ScaleS);
writer.Write(ScaleT);
}
}
}

View File

@ -1,17 +1,463 @@
using Toolbox.Library.IO;
using System.ComponentModel;
namespace LayoutBXLYT.Revolution
{
public class TevStage
//From https://github.com/Gericom/WiiLayoutEditor/blob/master/WiiLayoutEditor/IO/BRLYT.cs#L1201
//Todo this needs major cleanup
public class TevStage : BxlytTevStage
{
public TevStage(FileReader reader, BRLYT.Header header)
{
}
[Category("Fragment Sources")]
public TexMapID TexMap { get; set; }
[Category("Fragment Sources")]
public TexCoordID TexCoord { get; set; }
[Category("Fragment Sources")]
public byte Color { get; set; }
[Category("Fragment Sources")]
public TevSwapSel RasSel { get; set; }
[Category("Fragment Sources")]
public TevSwapSel TexSel { get; set; }
public void Write(FileWriter writer)
{
[Category("Color Output")]
public TevKColorSel ColorConstantSel { get; set; }
[Category("Color Output")]
public ColorArg ColorA { get; set; }
[Category("Color Output")]
public ColorArg ColorB { get; set; }
[Category("Color Output")]
public ColorArg ColorC { get; set; }
[Category("Color Output")]
public ColorArg ColorD { get; set; }
[Category("Color Output")]
public Bias ColorBias { get; set; }
[Category("Color Output")]
public TevColorOp ColorOp { get; set; }
[Category("Color Output")]
public bool ColorClamp { get; set; }
[Category("Color Output")]
public TevScale ColorScale { get; set; }
[Category("Color Output")]
public TevColorRegID ColorRegID { get; set; }
}
}
[Category("Alpha Output")]
public TevKAlphaSel AlphaConstantSel { get; set; }
[Category("Alpha Output")]
public AlphaArg AlphaA { get; set; }
[Category("Alpha Output")]
public AlphaArg AlphaB { get; set; }
[Category("Alpha Output")]
public AlphaArg AlphaC { get; set; }
[Category("Alpha Output")]
public AlphaArg AlphaD { get; set; }
[Category("Alpha Output")]
public Bias AlphaBias { get; set; }
[Category("Alpha Output")]
public TevAlphaOp AlphaOp { get; set; }
[Category("Alpha Output")]
public bool AlphaClamp { get; set; }
[Category("Alpha Output")]
public TevScale AlphaScale { get; set; }
[Category("Alpha Output")]
public TevAlphaRegID AlphaRegID { get; set; }
[Category("Indirect Texturing")]
public IndTexFormat Format { get; set; }
[Category("Indirect Texturing")]
public byte TexID { get; set; }
[Category("Indirect Texturing")]
public Bias IndBias { get; set; }
[Category("Indirect Texturing")]
public IndTexMtxID Matrix { get; set; }
[Category("Indirect Texturing")]
public IndTexWrap WrapS { get; set; }
[Category("Indirect Texturing")]
public IndTexWrap WrapT { get; set; }
[Category("Indirect Texturing")]
public byte UsePreviousStage { get; set; }
[Category("Indirect Texturing")]
public byte UnmodifiedLOD { get; set; }
[Category("Indirect Texturing")]
public IndTexAlphaSel Alpha { get; set; }
public TevStage(FileReader reader, BxlytHeader header)
{
TexCoord = (TexCoordID)reader.ReadByte();
Color = reader.ReadByte();
ushort tmp16 = reader.ReadUInt16();
TexMap = (TexMapID)(tmp16 & 0x1ff);
RasSel = (TevSwapSel)((tmp16 & 0x7ff) >> 9);
TexSel = (TevSwapSel)(tmp16 >> 11);
byte tmp8 = reader.ReadByte();
ColorA = (ColorArg)(tmp8 & 0xf);
ColorB = (ColorArg)(tmp8 >> 4);
tmp8 = reader.ReadByte();
ColorC = (ColorArg)(tmp8 & 0xf);
ColorD = (ColorArg)(tmp8 >> 4);
tmp8 = reader.ReadByte();
ColorOp = (TevColorOp)(tmp8 & 0xf);
ColorBias = (Bias)((tmp8 & 0x3f) >> 4);
ColorScale = (TevScale)(tmp8 >> 6);
tmp8 = reader.ReadByte();
ColorClamp = (tmp8 & 0x1) == 1;
ColorRegID = (TevColorRegID)((tmp8 & 0x7) >> 1);
ColorConstantSel = (TevKColorSel)(tmp8 >> 3);
tmp8 = reader.ReadByte();
AlphaA = (AlphaArg)(tmp8 & 0xf);
AlphaB = (AlphaArg)(tmp8 >> 4);
tmp8 = reader.ReadByte();
AlphaC = (AlphaArg)(tmp8 & 0xf);
AlphaD = (AlphaArg)(tmp8 >> 4);
tmp8 = reader.ReadByte();
AlphaOp = (TevAlphaOp)(tmp8 & 0xf);
AlphaBias = (Bias)((tmp8 & 0x3f) >> 4);
AlphaScale = (TevScale)(tmp8 >> 6);
tmp8 = reader.ReadByte();
AlphaClamp = (tmp8 & 0x1) == 1;
AlphaRegID = (TevAlphaRegID)((tmp8 & 0x7) >> 1);
AlphaConstantSel = (TevKAlphaSel)(tmp8 >> 3);
tmp8 = reader.ReadByte();
TexID = (byte)(tmp8 & 0x3);
tmp8 = reader.ReadByte();
IndBias = (Bias)(tmp8 & 0x7);
Matrix = (IndTexMtxID)((tmp8 & 0x7F) >> 3);
tmp8 = reader.ReadByte();
WrapS = (IndTexWrap)(tmp8 & 0x7);
WrapT = (IndTexWrap)((tmp8 & 0x3F) >> 3);
tmp8 = reader.ReadByte();
Format = (IndTexFormat)(tmp8 & 0x3);
UsePreviousStage = (byte)((tmp8 & 0x7) >> 2);
UnmodifiedLOD = (byte)((tmp8 & 0xF) >> 3);
Alpha = (IndTexAlphaSel)((tmp8 & 0x3F) >> 4);
}
public void Write(FileWriter writer) {
writer.Write((byte)TexCoord);
writer.Write(Color);
ushort tmp16 = 0;
tmp16 |= (ushort)(((ushort)TexSel & 0x3F) << 11);
tmp16 |= (ushort)(((ushort)RasSel & 0x7) << 9);
tmp16 |= (ushort)(((ushort)TexMap & 0x1ff) << 0);
writer.Write(tmp16);
byte tmp8 = 0;
tmp8 |= (byte)(((byte)ColorB & 0xf) << 4);
tmp8 |= (byte)(((byte)ColorA & 0xf) << 0);
writer.Write(tmp8);
tmp8 = 0;
tmp8 |= (byte)(((byte)ColorD & 0xf) << 4);
tmp8 |= (byte)(((byte)ColorC & 0xf) << 0);
writer.Write(tmp8);
tmp8 = 0;
tmp8 |= (byte)(((byte)ColorScale & 0x3) << 6);
tmp8 |= (byte)(((byte)ColorBias & 0x3) << 4);
tmp8 |= (byte)(((byte)ColorOp & 0xf) << 0);
writer.Write(tmp8);
tmp8 = 0;
tmp8 |= (byte)(((byte)ColorConstantSel & 0x1F) << 3);
tmp8 |= (byte)(((byte)ColorRegID & 0x7) << 1);
tmp8 |= (byte)((ColorClamp ? 1 : 0) << 0);
writer.Write(tmp8);
tmp8 = 0;
tmp8 |= (byte)(((byte)AlphaB & 0xf) << 4);
tmp8 |= (byte)(((byte)AlphaA & 0xf) << 0);
writer.Write(tmp8);
tmp8 = 0;
tmp8 |= (byte)(((byte)AlphaD & 0xf) << 4);
tmp8 |= (byte)(((byte)AlphaC & 0xf) << 0);
writer.Write(tmp8);
tmp8 = 0;
tmp8 |= (byte)(((byte)AlphaScale & 0x3) << 6);
tmp8 |= (byte)(((byte)AlphaBias & 0x3) << 4);
tmp8 |= (byte)(((byte)AlphaOp & 0xf) << 0);
writer.Write(tmp8);
tmp8 = 0;
tmp8 |= (byte)(((byte)AlphaConstantSel & 0x1F) << 3);
tmp8 |= (byte)(((byte)AlphaRegID & 0x7) << 1);
tmp8 |= (byte)((AlphaClamp ? 1 : 0) << 0);
writer.Write(tmp8);
writer.Write((byte)(TexID & 0x3));
tmp8 = 0;
tmp8 |= (byte)(((byte)Matrix & 0x1F) << 3);
tmp8 |= (byte)(((byte)IndBias & 0x7) << 0);
writer.Write(tmp8);
tmp8 = 0;
tmp8 |= (byte)(((byte)WrapT & 0x7) << 3);
tmp8 |= (byte)(((byte)WrapS & 0x7) << 0);
writer.Write(tmp8);
tmp8 = 0;
tmp8 |= (byte)(((byte)Alpha & 0xF) << 4);
tmp8 |= (byte)((UnmodifiedLOD & 0x1) << 3);
tmp8 |= (byte)((UsePreviousStage & 0x1) << 2);
tmp8 |= (byte)(((byte)Format & 0x3) << 0);
writer.Write(tmp8);
}
//Thanks brawlbox. Layouts should work with these
//https://github.com/libertyernie/brawltools/blob/40d7431b1a01ef4a0411cd69e51411bd581e93e2/BrawlLib/Wii/Graphics/Enum.cs
public enum ColorArg : byte
{
OutputColor,//GX_CC_CPREV,
OutputAlpha,//GX_CC_APREV,
Color0,//GX_CC_C0,
Alpha0,//GX_CC_A0,
Color1,//GX_CC_C1,
Alpha1,//GX_CC_A1,
Color2,//GX_CC_C2,
Alpha2,//GX_CC_A2,
TextureColor,//GX_CC_TEXC,
TextureAlpha,//GX_CC_TEXA,
RasterColor,//GX_CC_RASC,
RasterAlpha,//GX_CC_RASA,
One,//GX_CC_ONE, //1
Half,//GX_CC_HALF, //0.5
ConstantColorSelection,//GX_CC_KONST,
Zero//GX_CC_ZERO //0
}
public enum Bias
{
Zero,//GX_TB_ZERO,
AddHalf,//GX_TB_ADDHALF,
SubHalf//GX_TB_SUBHALF
}
public enum TevColorRegID
{
OutputColor,
Color0,
Color1,
Color2,
}
public enum TevColorOp
{
Add = 0,
Subtract = 1,
CompR8Greater = 8,
CompR8Equal = 9,
CompGR16Greater = 10,
CompGR16Equal = 11,
CompBGR24Greater = 12,
CompBGR24Equal = 13,
CompRGB8Greater = 14,
CompRGB8Equal = 15,
//GX_TEV_COMP_A8_GT = GX_TEV_COMP_RGB8_GT, // for alpha channel
//GX_TEV_COMP_A8_EQ = GX_TEV_COMP_RGB8_EQ // for alpha channel
}
public enum TevAlphaRegID
{
OutputAlpha,
Alpha0,
Alpha1,
Alpha2,
}
public enum AlphaArg
{
OutputAlpha,//GX_CA_APREV,
Alpha0,//GX_CA_A0,
Alpha1,//GX_CA_A1,
Alpha2,//GX_CA_A2,
TextureAlpha,//GX_CA_TEXA,
RasterAlpha,//GX_CA_RASA,
ConstantAlphaSelection,//GX_CA_KONST,
Zero//GX_CA_ZERO //0
}
public enum TevAlphaOp
{
And,//ALPHAOP_AND = 0,
Or,//ALPHAOP_OR,
ExclusiveOr,//ALPHAOP_XOR,
InverseExclusiveOr//ALPHAOP_XNOR
}
public enum TevScale
{
MultiplyBy1,//GX_CS_SCALE_1,
MultiplyBy2,//GX_CS_SCALE_2,
MultiplyBy4,//GX_CS_SCALE_4,
DivideBy2//GX_CS_DIVIDE_2
}
public enum TevKAlphaSel
{
Constant1_1/*GX_TEV_KASEL_8_8*/ = 0x00, //1.0f
Constant7_8/*GX_TEV_KASEL_7_8*/ = 0x01, //0.875f
Constant3_4/*GX_TEV_KASEL_6_8*/ = 0x02, //0.75f
Constant5_8/*GX_TEV_KASEL_5_8*/ = 0x03, //0.625f
Constant1_2/*GX_TEV_KASEL_4_8*/ = 0x04, //0.5f
Constant3_8/*GX_TEV_KASEL_3_8*/ = 0x05, //0.375f
Constant1_4/*GX_TEV_KASEL_2_8*/ = 0x06, //0.25f
Constant1_8/*GX_TEV_KASEL_1_8*/ = 0x07, //0.125f
//GX_TEV_KASEL_1 = GX_TEV_KASEL_8_8,
//GX_TEV_KASEL_3_4 = GX_TEV_KASEL_6_8,
//GX_TEV_KASEL_1_2 = GX_TEV_KASEL_4_8,
//GX_TEV_KASEL_1_4 = GX_TEV_KASEL_2_8,
ConstantColor0_Red/*GX_TEV_KASEL_K0_R*/ = 0x10,
ConstantColor1_Red/*GX_TEV_KASEL_K1_R*/ = 0x11,
ConstantColor2_Red/*GX_TEV_KASEL_K2_R*/ = 0x12,
ConstantColor3_Red/*GX_TEV_KASEL_K3_R*/ = 0x13,
ConstantColor0_Green/*GX_TEV_KASEL_K0_G*/ = 0x14,
ConstantColor1_Green/*GX_TEV_KASEL_K1_G*/ = 0x15,
ConstantColor2_Green/*GX_TEV_KASEL_K2_G*/ = 0x16,
ConstantColor3_Green/*GX_TEV_KASEL_K3_G*/ = 0x17,
ConstantColor0_Blue/*GX_TEV_KASEL_K0_B*/ = 0x18,
ConstantColor1_Blue/*GX_TEV_KASEL_K1_B*/ = 0x19,
ConstantColor2_Blue/*GX_TEV_KASEL_K2_B*/ = 0x1A,
ConstantColor3_Blue/*GX_TEV_KASEL_K3_B*/ = 0x1B,
ConstantColor0_Alpha/*GX_TEV_KASEL_K0_A*/ = 0x1C,
ConstantColor1_Alpha/*GX_TEV_KASEL_K1_A*/ = 0x1D,
ConstantColor2_Alpha/*GX_TEV_KASEL_K2_A*/ = 0x1E,
ConstantColor3_Alpha/*GX_TEV_KASEL_K3_A*/ = 0x1F
}
public enum TevKColorSel
{
Constant1_1/*GX_TEV_KCSEL_8_8*/ = 0x00, //1.0f, 1.0f, 1.0f
Constant7_8/*GX_TEV_KCSEL_7_8*/ = 0x01, //0.875f, 0.875f, 0.875f
Constant3_4/*GX_TEV_KCSEL_6_8*/ = 0x02, //0.75f, 0.75f, 0.75f
Constant5_8/*GX_TEV_KCSEL_5_8*/ = 0x03, //0.625f, 0.625f, 0.625f
Constant1_2/*GX_TEV_KCSEL_4_8*/ = 0x04, //0.5f, 0.5f, 0.5f
Constant3_8/*GX_TEV_KCSEL_3_8*/ = 0x05, //0.375f, 0.375f, 0.375f
Constant1_4/*GX_TEV_KCSEL_2_8*/ = 0x06, //0.25f, 0.25f, 0.25f
Constant1_8/*GX_TEV_KCSEL_1_8*/ = 0x07, //0.125f, 0.125f, 0.125f
//GX_TEV_KCSEL_1 = GX_TEV_KCSEL_8_8,
//GX_TEV_KCSEL_3_4 = GX_TEV_KCSEL_6_8,
//GX_TEV_KCSEL_1_2 = GX_TEV_KCSEL_4_8,
//GX_TEV_KCSEL_1_4 = GX_TEV_KCSEL_2_8,
ConstantColor0_RGB/*GX_TEV_KCSEL_K0*/ = 0x0C,
ConstantColor1_RGB/*GX_TEV_KCSEL_K1*/ = 0x0D,
ConstantColor2_RGB/*GX_TEV_KCSEL_K2*/ = 0x0E,
ConstantColor3_RGB/*GX_TEV_KCSEL_K3*/ = 0x0F,
ConstantColor0_RRR/*GX_TEV_KCSEL_K0_R*/ = 0x10,
ConstantColor1_RRR/*GX_TEV_KCSEL_K1_R*/ = 0x11,
ConstantColor2_RRR/*GX_TEV_KCSEL_K2_R*/ = 0x12,
ConstantColor3_RRR/*GX_TEV_KCSEL_K3_R*/ = 0x13,
ConstantColor0_GGG/*GX_TEV_KCSEL_K0_G*/ = 0x14,
ConstantColor1_GGG/*GX_TEV_KCSEL_K1_G*/ = 0x15,
ConstantColor2_GGG/*GX_TEV_KCSEL_K2_G*/ = 0x16,
ConstantColor3_GGG/*GX_TEV_KCSEL_K3_G*/ = 0x17,
ConstantColor0_BBB/*GX_TEV_KCSEL_K0_B*/ = 0x18,
ConstantColor1_BBB/*GX_TEV_KCSEL_K1_B*/ = 0x19,
ConstantColor2_BBB/*GX_TEV_KCSEL_K2_B*/ = 0x1A,
ConstantColor3_BBB/*GX_TEV_KCSEL_K3_B*/ = 0x1B,
ConstantColor0_AAA/*GX_TEV_KCSEL_K0_A*/ = 0x1C,
ConstantColor1_AAA/*GX_TEV_KCSEL_K1_A*/ = 0x1D,
ConstantColor2_AAA/*GX_TEV_KCSEL_K2_A*/ = 0x1E,
ConstantColor3_AAA/*GX_TEV_KCSEL_K3_A*/ = 0x1F
}
public enum TevSwapSel : ushort
{
Swap0,//GX_TEV_SWAP0 = 0,
Swap1,//GX_TEV_SWAP1,
Swap2,//GX_TEV_SWAP2,
Swap3,//GX_TEV_SWAP3
}
public enum TexMapID
{
TexMap0,//GX_TEXMAP0,
TexMap1,//GX_TEXMAP1,
TexMap2,//GX_TEXMAP2,
TexMap3,//GX_TEXMAP3,
TexMap4,//GX_TEXMAP4,
TexMap5,//GX_TEXMAP5,
TexMap6,//GX_TEXMAP6,
TexMap7,//GX_TEXMAP7,
//GX_MAX_TEXMAP,
//GX_TEXMAP_NULL = 0xff,
//GX_TEX_DISABLE = 0x100 // mask : disables texture look up
}
public enum TexCoordID
{
TexCoord0,//GX_TEXCOORD0 = 0x0, // generated texture coordinate 0
TexCoord1,//GX_TEXCOORD1, // generated texture coordinate 1
TexCoord2,//GX_TEXCOORD2, // generated texture coordinate 2
TexCoord3,//GX_TEXCOORD3, // generated texture coordinate 3
TexCoord4,//GX_TEXCOORD4, // generated texture coordinate 4
TexCoord5,//GX_TEXCOORD5, // generated texture coordinate 5
TexCoord6,//GX_TEXCOORD6, // generated texture coordinate 6
TexCoord7,//GX_TEXCOORD7, // generated texture coordinate 7
//GX_MAX_TEXCOORD = 8,
//GX_TEXCOORD_NULL = 0xff
}
public enum IndTexMtxID
{
NoMatrix,//GX_ITM_OFF,
Matrix0,//GX_ITM_0,
Matrix1,//GX_ITM_1,
Matrix2,//GX_ITM_2,
MatrixS0 = 5,//GX_ITM_S0 = 5,
MatrixS1,//GX_ITM_S1,
MatrixS2,//GX_ITM_S2,
MatrixT0 = 9, //GX_ITM_T0 = 9,
MatrixT1,//GX_ITM_T1,
MatrixT2,//GX_ITM_T2
}
public enum IndTexWrap
{
NoWrap,//GX_ITW_OFF, // no wrapping
Wrap256,//GX_ITW_256, // wrap 256
Wrap128,//GX_ITW_128, // wrap 128
Wrap64,//GX_ITW_64, // wrap 64
Wrap32,//GX_ITW_32, // wrap 32
Wrap16,//GX_ITW_16, // wrap 16
Wrap0,//GX_ITW_0, // wrap 0
}
public enum IndTexScale
{
DivideBy1,//GX_ITS_1, // Scale by 1.
DivideBy2,//GX_ITS_2, // Scale by 1/2.
DivideBy4,//GX_ITS_4, // Scale by 1/4.
DivideBy8,//GX_ITS_8, // Scale by 1/8.
DivideBy16,//GX_ITS_16, // Scale by 1/16.
DivideBy32,//GX_ITS_32, // Scale by 1/32.
DivideBy64,//GX_ITS_64, // Scale by 1/64.
DivideBy128,//GX_ITS_128, // Scale by 1/128.
DivideBy256,//GX_ITS_256 // Scale by 1/256.
}
public enum IndTexFormat
{
F_8_Bit_Offsets,//GX_ITF_8, // 8 bit texture offsets.
F_5_Bit_Offsets,//GX_ITF_5, // 5 bit texture offsets.
F_4_Bit_Offsets,//GX_ITF_4, // 4 bit texture offsets.
F_3_Bit_Offsets,//GX_ITF_3 // 3 bit texture offsets.
}
public enum IndTexStageID
{
IndirectTexStg0,//GX_INDTEXSTAGE0,
IndirectTexStg1,//GX_INDTEXSTAGE1,
IndirectTexStg2,//GX_INDTEXSTAGE2,
IndirectTexStg3//GX_INDTEXSTAGE3
}
public enum IndTexAlphaSel
{
Off,//GX_ITBA_OFF,
S,//GX_ITBA_S,
T,//GX_ITBA_T,
U//GX_ITBA_U
}
}
}

View File

@ -0,0 +1,68 @@
using Toolbox.Library.IO;
namespace LayoutBXLYT.Revolution
{
public class TevSwapModeTable
{
public SwapMode[] SwapModes;
public TevSwapModeTable() {
SwapModes = new SwapMode[4];
for (int i = 0; i < 4; i++)
SwapModes[i] = new SwapMode();
}
public TevSwapModeTable(FileReader reader)
{
SwapModes = new SwapMode[4];
for (int i = 0; i < 4; i++)
SwapModes[i] = new SwapMode(reader);
}
public void Write(FileWriter writer)
{
for (int i = 0; i < 4; i++)
SwapModes[i].Write(writer);
}
}
public class SwapMode
{
public SwapChannel R { get; set; } = SwapChannel.Red;
public SwapChannel G { get; set; } = SwapChannel.Green;
public SwapChannel B { get; set; } = SwapChannel.Blue;
public SwapChannel A { get; set; } = SwapChannel.Alpha;
public SwapMode() { }
public SwapMode(FileReader reader) {
byte value = reader.ReadByte();
R = (SwapChannel)((value >> 0) & 0x3);
G = (SwapChannel)((value >> 2) & 0x3);
B = (SwapChannel)((value >> 4) & 0x3);
A = (SwapChannel)((value >> 6) & 0x3);
}
public void Write(FileWriter writer) {
writer.Write(GetFlags());
}
private byte GetFlags()
{
byte value = 0;
value |= (byte)(((byte)R & 0x3) << 0);
value |= (byte)(((byte)G & 0x3) << 2);
value |= (byte)(((byte)B & 0x3) << 4);
value |= (byte)(((byte)A & 0x3) << 6);
return value;
}
}
public enum SwapChannel
{
Red,
Green,
Blue,
Alpha
}
}

View File

@ -0,0 +1,120 @@
using Toolbox.Library.IO;
namespace LayoutBXLYT.Revolution
{
public class TexCoordGenEntry
{
public TexCoordGenTypes Type { get; set; }
public TexCoordGenSource Source { get; set; }
public TexCoordGenMatrixSource MatrixSource { get; set; }
public byte Unknown { get; set; }
public TexCoordGenEntry()
{
Type = TexCoordGenTypes.GX_TG_MTX3x4;
Source = TexCoordGenSource.GX_TG_TEX0;
MatrixSource = TexCoordGenMatrixSource.GX_TEXMTX0;
Unknown = 0;
}
public TexCoordGenEntry(FileReader reader)
{
Type = (TexCoordGenTypes)reader.ReadByte();
Source = (TexCoordGenSource)reader.ReadByte();
MatrixSource = (TexCoordGenMatrixSource)reader.ReadByte();
Unknown = reader.ReadByte();
}
public void Write(FileWriter writer)
{
writer.Write((byte)Type);
writer.Write((byte)Source);
writer.Write((byte)MatrixSource);
writer.Write(Unknown);
}
public enum TexCoordGenTypes
{
GX_TG_MTX3x4 = 0,
GX_TG_MTX2x4 = 1,
GX_TG_BUMP0 = 2,
GX_TG_BUMP1 = 3,
GX_TG_BUMP2 = 4,
GX_TG_BUMP3 = 5,
GX_TG_BUMP4 = 6,
GX_TG_BUMP5 = 7,
GX_TG_BUMP6 = 8,
GX_TG_BUMP7 = 9,
GX_TG_SRTG = 0xA
}
public enum TexCoordGenSource
{
GX_TG_POS,
GX_TG_NRM,
GX_TG_BINRM,
GX_TG_TANGENT,
GX_TG_TEX0,
GX_TG_TEX1,
GX_TG_TEX2,
GX_TG_TEX3,
GX_TG_TEX4,
GX_TG_TEX5,
GX_TG_TEX6,
GX_TG_TEX7,
GX_TG_TEXCOORD0,
GX_TG_TEXCOORD1,
GX_TG_TEXCOORD2,
GX_TG_TEXCOORD3,
GX_TG_TEXCOORD4,
GX_TG_TEXCOORD5,
GX_TG_TEXCOORD6,
GX_TG_COLOR0,
GX_TG_COLOR1
}
public enum TexCoordGenMatrixSource
{
GX_PNMTX0,
GX_PNMTX1,
GX_PNMTX2,
GX_PNMTX3,
GX_PNMTX4,
GX_PNMTX5,
GX_PNMTX6,
GX_PNMTX7,
GX_PNMTX8,
GX_PNMTX9,
GX_TEXMTX0,
GX_TEXMTX1,
GX_TEXMTX2,
GX_TEXMTX3,
GX_TEXMTX4,
GX_TEXMTX5,
GX_TEXMTX6,
GX_TEXMTX7,
GX_TEXMTX8,
GX_TEXMTX9,
GX_IDENTITY,
GX_DTTMTX0,
GX_DTTMTX1,
GX_DTTMTX2,
GX_DTTMTX3,
GX_DTTMTX4,
GX_DTTMTX5,
GX_DTTMTX6,
GX_DTTMTX7,
GX_DTTMTX8,
GX_DTTMTX9,
GX_DTTMTX10,
GX_DTTMTX11,
GX_DTTMTX12,
GX_DTTMTX13,
GX_DTTMTX14,
GX_DTTMTX15,
GX_DTTMTX16,
GX_DTTMTX17,
GX_DTTMTX18,
GX_DTTMTX19,
GX_DTTIDENTITY
}
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Revolution
{
public class TextureRef : BxlytTextureRef
{
public TextureRef() { }
public TextureRef(FileReader reader, BxlytHeader header)
{
ID = reader.ReadInt16();
WrapModeU = (WrapMode)reader.ReadByte();
WrapModeV = (WrapMode)reader.ReadByte();
MinFilterMode = FilterMode.Linear;
MaxFilterMode = FilterMode.Linear;
if (header.Textures.Count > 0)
Name = header.Textures[ID];
}
public void Write(FileWriter writer)
{
writer.Write(ID);
writer.Write((byte)WrapModeU);
writer.Write((byte)WrapModeV);
}
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace LayoutBXLYT.Revolution
{
public class BND1 : PAN1, IBoundryPane
{
public override string Signature { get; } = "bnd1";
public BND1() : base()
{
}
public BND1(BxlytHeader header, string name) : base()
{
LoadDefaults();
Name = name;
}
public BND1(FileReader reader) : base(reader)
{
}
public override void Write(FileWriter writer, LayoutHeader header)
{
base.Write(writer, header);
}
}
}

View File

@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
using Syroot.Maths;
namespace LayoutBXLYT.Revolution
{
public class PAN1 : BasePane
{
public override string Signature { get; } = "pan1";
private byte _flags1;
public override bool Visible
{
get { return (_flags1 & 0x1) == 0x1; }
set
{
if (value)
_flags1 |= 0x1;
else
_flags1 &= 0xFE;
}
}
public override bool InfluenceAlpha
{
get { return (_flags1 & 0x2) == 0x2; }
set
{
if (value)
_flags1 |= 0x2;
else
_flags1 &= 0xFD;
}
}
public bool IsWideScreen
{
get { return (_flags1 & 0x4) == 0x4; }
}
public byte PartsScale { get; set; }
public byte PaneMagFlags { get; set; }
public string UserDataInfo { get; set; }
public PAN1() { }
public PAN1(BxlytHeader header, string name) : base()
{
LoadDefaults();
Name = name;
}
public override void LoadDefaults()
{
base.LoadDefaults();
UserDataInfo = "";
}
enum OriginXRev : byte
{
Left = 0,
Center = 1,
Right = 2
};
enum OriginYRev : byte
{
Top = 0,
Center = 1,
Bottom = 2
};
public PAN1(FileReader reader) : base()
{
_flags1 = reader.ReadByte();
byte origin = reader.ReadByte();
Alpha = reader.ReadByte();
PaneMagFlags = reader.ReadByte();
Name = reader.ReadString(0x10, true);
UserDataInfo = reader.ReadString(0x8, true);
Translate = reader.ReadVec3SY();
Rotate = reader.ReadVec3SY();
Scale = reader.ReadVec2SY();
Width = reader.ReadSingle();
Height = reader.ReadSingle();
originX = OriginXMap[(OriginXRev)(origin % 3)];
originY = OriginYMap[(OriginYRev)(origin / 3)];
}
public override void Write(FileWriter writer, LayoutHeader header)
{
byte originL = (byte)OriginXMap.FirstOrDefault(x => x.Value == originX).Key;
byte originH = (byte)OriginYMap.FirstOrDefault(x => x.Value == originY).Key;
writer.Write(_flags1);
writer.Write((byte)(((int)originL) + ((int)originH * 3)));
writer.Write(Alpha);
writer.Write(PaneMagFlags);
writer.WriteString(Name, 0x10);
writer.WriteString(UserDataInfo, 0x8);
writer.Write(Translate);
writer.Write(Rotate);
writer.Write(Scale);
writer.Write(Width);
writer.Write(Height);
}
private Dictionary<OriginYRev, OriginY> OriginYMap = new Dictionary<OriginYRev, OriginY>()
{
{ OriginYRev.Center, OriginY.Center },
{ OriginYRev.Top, OriginY.Top },
{ OriginYRev.Bottom, OriginY.Bottom },
};
private Dictionary<OriginXRev, OriginX> OriginXMap = new Dictionary<OriginXRev, OriginX>()
{
{ OriginXRev.Center, OriginX.Center },
{ OriginXRev.Left, OriginX.Left },
{ OriginXRev.Right, OriginX.Right },
};
public bool ParentVisibility
{
get
{
if (Scale.X == 0 || Scale.Y == 0)
return false;
if (!Visible)
return false;
if (Parent != null && Parent is PAN1)
{
return ((PAN1)Parent).ParentVisibility && Visible;
}
return true;
}
}
}
}

View File

@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library;
using Toolbox.Library.IO;
using System.ComponentModel;
namespace LayoutBXLYT.Revolution
{
public class PIC1 : PAN1, IPicturePane
{
public override string Signature { get; } = "pic1";
public TexCoord[] TexCoords { get; set; }
public STColor8 ColorTopLeft { get; set; }
public STColor8 ColorTopRight { get; set; }
public STColor8 ColorBottomLeft { get; set; }
public STColor8 ColorBottomRight { get; set; }
public System.Drawing.Color[] GetVertexColors()
{
return new System.Drawing.Color[4]
{
ColorTopLeft.Color,
ColorTopRight.Color,
ColorBottomLeft.Color,
ColorBottomRight.Color,
};
}
public ushort MaterialIndex { get; set; }
public string GetTexture(int index)
{
return ParentLayout.Textures[Material.TextureMaps[index].ID];
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytMaterial Material { get; set; }
private BxlytHeader ParentLayout;
public PIC1() : base()
{
LoadDefaults();
}
public PIC1(BxlytHeader header, string name) : base()
{
LoadDefaults();
Name = name;
ParentLayout = header;
ColorTopLeft = STColor8.White;
ColorTopRight = STColor8.White;
ColorBottomLeft = STColor8.White;
ColorBottomRight = STColor8.White;
TexCoords = new TexCoord[1];
TexCoords[0] = new TexCoord();
Material = new Material(name, header);
}
public void CopyMaterial()
{
Material = (BxlytMaterial)Material.Clone();
}
public PIC1(FileReader reader, BRLYT.Header header) : base(reader)
{
ParentLayout = header;
ColorTopLeft = STColor8.FromBytes(reader.ReadBytes(4));
ColorTopRight = STColor8.FromBytes(reader.ReadBytes(4));
ColorBottomLeft = STColor8.FromBytes(reader.ReadBytes(4));
ColorBottomRight = STColor8.FromBytes(reader.ReadBytes(4));
MaterialIndex = reader.ReadUInt16();
byte numUVs = reader.ReadByte();
reader.Seek(1); //padding
TexCoords = new TexCoord[numUVs];
for (int i = 0; i < numUVs; i++)
{
TexCoords[i] = new TexCoord()
{
TopLeft = reader.ReadVec2SY(),
TopRight = reader.ReadVec2SY(),
BottomLeft = reader.ReadVec2SY(),
BottomRight = reader.ReadVec2SY(),
};
}
Material = header.MaterialList.Materials[MaterialIndex];
}
public override void Write(FileWriter writer, LayoutHeader header)
{
base.Write(writer, header);
writer.Write(ColorTopLeft.ToBytes());
writer.Write(ColorTopRight.ToBytes());
writer.Write(ColorBottomLeft.ToBytes());
writer.Write(ColorBottomRight.ToBytes());
writer.Write(MaterialIndex);
writer.Write(TexCoords != null ? (byte)TexCoords.Length : (byte)0);
writer.Write((byte)0);
for (int i = 0; i < TexCoords.Length; i++)
{
writer.Write(TexCoords[i].TopLeft);
writer.Write(TexCoords[i].TopRight);
writer.Write(TexCoords[i].BottomLeft);
writer.Write(TexCoords[i].BottomRight);
}
}
}
}

View File

@ -0,0 +1,274 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
using Toolbox.Library;
using System.ComponentModel;
using Syroot.Maths;
namespace LayoutBXLYT.Revolution
{
public class TXT1 : PAN1, ITextPane
{
public override string Signature { get; } = "txt1";
public TXT1() : base()
{
}
public List<string> GetFonts
{
get { return layoutFile.Fonts; }
}
[Browsable(false)]
public Toolbox.Library.Rendering.RenderableTex RenderableFont { get; set; }
[DisplayName("Horizontal Alignment"), CategoryAttribute("Font")]
public OriginX HorizontalAlignment
{
get { return (OriginX)((TextAlignment >> 2) & 0x3); }
set
{
TextAlignment &= unchecked((byte)(~0xC));
TextAlignment |= (byte)((byte)(value) << 2);
}
}
[DisplayName("Vertical Alignment"), CategoryAttribute("Font")]
public OriginY VerticalAlignment
{
get { return (OriginY)((TextAlignment) & 0x3); }
set
{
TextAlignment &= unchecked((byte)(~0x3));
TextAlignment |= (byte)(value);
}
}
[Browsable(false)]
public ushort RestrictedLength
{
get
{ //Divide by 2 due to 2 characters taking up 2 bytes
//Subtract 1 due to padding
return (ushort)((TextLength / 2) - 1);
}
set
{
TextLength = (ushort)((value * 2) + 1);
}
}
[Browsable(false)]
public ushort TextLength { get; set; }
[Browsable(false)]
public ushort MaxTextLength { get; set; }
[Browsable(false)]
public ushort MaterialIndex { get; set; }
[Browsable(false)]
public ushort FontIndex { get; set; }
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytMaterial Material { get; set; }
[DisplayName("Text Alignment"), CategoryAttribute("Font")]
public byte TextAlignment { get; set; }
[DisplayName("Line Alignment"), CategoryAttribute("Font")]
public LineAlign LineAlignment { get; set; }
[DisplayName("Italic Tilt"), CategoryAttribute("Font")]
public float ItalicTilt { get; set; }
[DisplayName("Top Color"), CategoryAttribute("Font")]
public STColor8 FontTopColor { get; set; }
[DisplayName("Bottom Color"), CategoryAttribute("Font")]
public STColor8 FontBottomColor { get; set; }
[DisplayName("Font Size"), CategoryAttribute("Font")]
public Vector2F FontSize { get; set; }
[DisplayName("Character Space"), CategoryAttribute("Font")]
public float CharacterSpace { get; set; }
[DisplayName("Line Space"), CategoryAttribute("Font")]
public float LineSpace { get; set; }
[DisplayName("Shadow Position"), CategoryAttribute("Shadows")]
public Vector2F ShadowXY { get; set; }
[DisplayName("Shadow Size"), CategoryAttribute("Shadows")]
public Vector2F ShadowXYSize { get; set; }
[DisplayName("Shadow Fore Color"), CategoryAttribute("Shadows")]
public STColor8 ShadowForeColor { get; set; }
[DisplayName("Shadow Back Color"), CategoryAttribute("Shadows")]
public STColor8 ShadowBackColor { get; set; }
[DisplayName("Shadow Italic"), CategoryAttribute("Shadows")]
public float ShadowItalic { get; set; }
[DisplayName("Text Box Name"), CategoryAttribute("Text Box")]
public string TextBoxName { get; set; }
private string text;
[DisplayName("Text"), CategoryAttribute("Text Box")]
public string Text
{
get { return text; }
set
{
text = value;
TextLength = (ushort)((text.Length * 2) + 2);
UpdateTextRender();
}
}
[DisplayName("Per Character Transform"), CategoryAttribute("Font")]
public bool PerCharTransform
{
get { return (_flags & 0x10) != 0; }
set { _flags = value ? (byte)(_flags | 0x10) : unchecked((byte)(_flags & (~0x10))); }
}
[DisplayName("Restricted Text Length"), CategoryAttribute("Font")]
public bool RestrictedTextLengthEnabled
{
get { return (_flags & 0x2) != 0; }
set { _flags = value ? (byte)(_flags | 0x2) : unchecked((byte)(_flags & (~0x2))); }
}
[DisplayName("Enable Shadows"), CategoryAttribute("Font")]
public bool ShadowEnabled
{
get { return (_flags & 1) != 0; }
set { _flags = value ? (byte)(_flags | 1) : unchecked((byte)(_flags & (~1))); }
}
[DisplayName("Font Name"), CategoryAttribute("Font")]
public string FontName { get; set; }
private byte _flags;
private BxlytHeader layoutFile;
public void UpdateTextRender()
{
}
public void CopyMaterial()
{
Material = Material.Clone();
}
public TXT1(BRLYT.Header header, string name)
{
LoadDefaults();
Name = name;
layoutFile = header;
//Add new material
var mat = new Material(this.Name, header);
header.MaterialList.Materials.Add(mat);
MaterialIndex = (ushort)header.MaterialList.Materials.IndexOf(mat);
Material = mat;
Text = Encoding.Unicode.GetString(new byte[0]);
FontIndex = 0;
FontName = "";
TextLength = 4;
MaxTextLength = 4;
TextAlignment = 0;
LineAlignment = LineAlign.Unspecified;
ItalicTilt = 0;
FontTopColor = STColor8.White;
FontBottomColor = STColor8.White;
FontSize = new Vector2F(92, 101);
CharacterSpace = 0;
LineSpace = 0;
ShadowXY = new Vector2F(1, -1);
ShadowXYSize = new Vector2F(1, 1);
ShadowBackColor = STColor8.Black;
ShadowForeColor = STColor8.Black;
ShadowItalic = 0;
}
public TXT1(FileReader reader, BxlytHeader header) : base(reader)
{
layoutFile = header;
TextLength = reader.ReadUInt16();
MaxTextLength = reader.ReadUInt16();
MaterialIndex = reader.ReadUInt16();
FontIndex = reader.ReadUInt16();
TextAlignment = reader.ReadByte();
LineAlignment = (LineAlign)reader.ReadByte();
_flags = reader.ReadByte();
reader.Seek(1); //padding
uint textOffset = reader.ReadUInt32();
FontTopColor = STColor8.FromBytes(reader.ReadBytes(4));
FontBottomColor = STColor8.FromBytes(reader.ReadBytes(4));
FontSize = reader.ReadVec2SY();
CharacterSpace = reader.ReadSingle();
LineSpace = reader.ReadSingle();
if (MaterialIndex != ushort.MaxValue && header.Materials.Count > 0)
Material = header.Materials[MaterialIndex];
if (FontIndex != ushort.MaxValue && header.Fonts.Count > 0)
FontName = header.Fonts[FontIndex];
if (RestrictedTextLengthEnabled)
text = reader.ReadZeroTerminatedString(Encoding.Unicode);
else
text = reader.ReadZeroTerminatedString(Encoding.Unicode);
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long pos = writer.Position - 8;
base.Write(writer, header);
writer.Write(TextLength);
writer.Write(MaxTextLength);
writer.Write(MaterialIndex);
writer.Write(FontIndex);
writer.Write(TextAlignment);
writer.Write(LineAlignment, false);
writer.Write(_flags);
writer.Seek(1);
long _ofsTextPos = writer.Position;
writer.Write(0); //text offset
writer.Write(FontTopColor.ToBytes());
writer.Write(FontBottomColor.ToBytes());
writer.Write(FontSize);
writer.Write(CharacterSpace);
writer.Write(LineSpace);
if (Text != null)
{
Encoding encoding = Encoding.Unicode;
if (writer.ByteOrder == Syroot.BinaryData.ByteOrder.BigEndian)
encoding = Encoding.BigEndianUnicode;
writer.WriteUint32Offset(_ofsTextPos, pos);
if (RestrictedTextLengthEnabled)
writer.WriteString(Text, MaxTextLength, encoding);
else
writer.WriteString(Text, TextLength, encoding);
}
}
public enum BorderType : byte
{
Standard = 0,
DeleteBorder = 1,
RenderTwoCycles = 2,
};
}
}

View File

@ -0,0 +1,252 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
using System.ComponentModel;
namespace LayoutBXLYT.Revolution
{
public class WND1 : PAN1, IWindowPane
{
public override string Signature { get; } = "wnd1";
public BxlytHeader layoutHeader;
public bool UseOneMaterialForAll
{
get { return Convert.ToBoolean(_flag & 1); }
set { }
}
public bool UseVertexColorForAll
{
get { return Convert.ToBoolean((_flag >> 1) & 1); }
set { }
}
public WindowKind WindowKind { get; set; }
public bool NotDrawnContent
{
get { return (_flag & 8) == 16; }
set { }
}
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; }
private byte _flag;
private byte frameCount;
public byte FrameCount
{
get { return frameCount; }
set
{
frameCount = value;
}
}
public System.Drawing.Color[] GetVertexColors()
{
return new System.Drawing.Color[4]
{
Content.ColorTopLeft.Color,
Content.ColorTopRight.Color,
Content.ColorBottomLeft.Color,
Content.ColorBottomRight.Color,
};
}
public void ReloadFrames()
{
SetFrames(layoutHeader);
}
public void SetFrames(BxlytHeader header)
{
if (WindowFrames == null)
WindowFrames = new List<BxlytWindowFrame>();
switch (FrameCount)
{
case 1:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LT"));
break;
case 2:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_L"));
if (WindowFrames.Count == 1)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_R"));
break;
case 4:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LT"));
if (WindowFrames.Count == 1)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RT"));
if (WindowFrames.Count == 2)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LB"));
if (WindowFrames.Count == 3)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RB"));
break;
case 8:
if (WindowFrames.Count == 0)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LT"));
if (WindowFrames.Count == 1)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RT"));
if (WindowFrames.Count == 2)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_LB"));
if (WindowFrames.Count == 3)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_RB"));
if (WindowFrames.Count == 4)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_T"));
if (WindowFrames.Count == 5)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_B"));
if (WindowFrames.Count == 6)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_R"));
if (WindowFrames.Count == 7)
WindowFrames.Add(new BxlytWindowFrame(header, $"{Name}_L"));
break;
}
//Now search for invalid unused materials and remove them
for (int i = 0; i < WindowFrames.Count; i++)
{
if (i >= FrameCount)
header.TryRemoveMaterial(WindowFrames[i].Material);
else if (!header.Materials.Contains(WindowFrames[i].Material))
header.AddMaterial(WindowFrames[i].Material);
}
}
public void CopyWindows()
{
Content = (BxlytWindowContent)Content.Clone();
for (int f = 0; f < WindowFrames.Count; f++)
WindowFrames[f] = (BxlytWindowFrame)WindowFrames[f].Clone();
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public BxlytWindowContent Content { get; set; }
[Browsable(false)]
public List<BxlytWindowFrame> WindowFrames { get; set; }
public WND1() : base()
{
}
public WND1(BxlytHeader header, string name)
{
layoutHeader = header;
LoadDefaults();
Name = name;
Content = new BxlytWindowContent(header, this.Name);
UseOneMaterialForAll = true;
UseVertexColorForAll = true;
WindowKind = WindowKind.Around;
NotDrawnContent = false;
StretchLeft = 0;
StretchRight = 0;
StretchTop = 0;
StretchBottm = 0;
Width = 70;
Height = 80;
FrameElementLeft = 16;
FrameElementRight = 16;
FrameElementTop = 16;
FrameElementBottm = 16;
FrameCount = 1;
WindowFrames = new List<BxlytWindowFrame>();
SetFrames(header);
}
public WND1(BxlytHeader header, FileReader reader) : base(reader)
{
layoutHeader = header;
WindowFrames = new List<BxlytWindowFrame>();
long pos = reader.Position - 0x4C;
StretchLeft = reader.ReadUInt16();
StretchRight = reader.ReadUInt16();
StretchTop = reader.ReadUInt16();
StretchBottm = reader.ReadUInt16();
FrameElementLeft = reader.ReadUInt16();
FrameElementRight = reader.ReadUInt16();
FrameElementTop = reader.ReadUInt16();
FrameElementBottm = reader.ReadUInt16();
FrameCount = reader.ReadByte();
_flag = reader.ReadByte();
reader.ReadUInt16();//padding
uint contentOffset = reader.ReadUInt32();
uint frameOffsetTbl = reader.ReadUInt32();
WindowKind = (WindowKind)((_flag >> 2) & 3);
reader.SeekBegin(pos + contentOffset);
Content = new BxlytWindowContent(reader, header);
reader.SeekBegin(pos + frameOffsetTbl);
var offsets = reader.ReadUInt32s(FrameCount);
foreach (int offset in offsets)
{
reader.SeekBegin(pos + offset);
WindowFrames.Add(new BxlytWindowFrame(reader, header));
}
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long pos = writer.Position - 8;
base.Write(writer, header);
writer.Write(StretchLeft);
writer.Write(StretchRight);
writer.Write(StretchTop);
writer.Write(StretchBottm);
writer.Write(FrameElementLeft);
writer.Write(FrameElementRight);
writer.Write(FrameElementTop);
writer.Write(FrameElementBottm);
writer.Write(FrameCount);
writer.Write(_flag);
writer.Write((ushort)0);
long _ofsContentPos = writer.Position;
writer.Write(0);
writer.Write(0);
writer.WriteUint32Offset(_ofsContentPos, pos);
Content.Write(writer);
if (WindowFrames.Count > 0)
{
writer.WriteUint32Offset(_ofsContentPos + 4, pos);
//Reserve space for frame offsets
long _ofsFramePos = writer.Position;
writer.Write(new uint[FrameCount]);
for (int i = 0; i < FrameCount; i++)
{
writer.WriteUint32Offset(_ofsFramePos + (i * 4), pos);
WindowFrames[i].Write(writer);
}
}
}
}
}

View File

@ -4,25 +4,27 @@ using System.Linq;
using System.Text;
using LayoutBXLYT;
using OpenTK.Graphics.OpenGL;
using Toolbox.Library;
//Code from Wii Layout Editor
//https://github.com/Gericom/WiiLayoutEditor
//This is so materials/tev display correctly for brlyt
namespace WiiLayoutEditor.IO
namespace LayoutBXLYT.Revolution
{
/* public class Shader
public class Shader
{
public BRLYT.Material.TevStage[] TevStages;
public int[] Textures;
public TevStage[] TevStages;
public uint TextureCount;
private float[][] g_color_registers;
private float[][] g_color_consts;
private float[] MatColor;
private byte color_matsrc;
private byte alpha_matsrc;
public Shader(BRLYT.Material Material, int[] textures)
public Shader(Material Material, uint textureCount)
{
this.color_matsrc = Material.ChanControl.ColorMaterialSource;
this.alpha_matsrc = Material.ChanControl.AlphaMaterialSource;
TextureCount = textureCount;
this.color_matsrc = Material.ChanControl.ColorMatSource;
this.alpha_matsrc = Material.ChanControl.AlphaMatSource;
this.MatColor = new float[]
{
Material.MatColor.R/255f,
@ -30,29 +32,32 @@ namespace WiiLayoutEditor.IO
Material.MatColor.B/255f,
Material.MatColor.A/255f
};
TevStages = Material.TevStageEntries;
Textures = textures;
TevStages = new TevStage[Material.TevStages.Length];
for (int i = 0; i < Material.TevStages?.Length; i++)
TevStages[i] = (TevStage)Material.TevStages[i];
g_color_registers = new float[3][];
g_color_registers[0] = new float[]
{
Material.ForeColor.R/255f,
Material.ForeColor.G/255f,
Material.ForeColor.B/255f,
Material.ForeColor.A/255f
Material.BlackColor.R/255f,
Material.BlackColor.G/255f,
Material.BlackColor.B/255f,
Material.BlackColor.A/255f
};
g_color_registers[1] = new float[]
{
Material.BackColor.R/255f,
Material.BackColor.G/255f,
Material.BackColor.B/255f,
Material.BackColor.A/255f
Material.WhiteColor.R/255f,
Material.WhiteColor.G/255f,
Material.WhiteColor.B/255f,
Material.WhiteColor.A/255f
};
g_color_registers[2] = new float[]
{
Material.ColorReg3.R/255f,
Material.ColorReg3.G/255f,
Material.ColorReg3.B/255f,
Material.ColorReg3.A/255f
Material.ColorRegister3.R/255f,
Material.ColorRegister3.G/255f,
Material.ColorRegister3.B/255f,
Material.ColorRegister3.A/255f
};
g_color_consts = new float[4][];
g_color_consts[0] = new float[]
@ -84,76 +89,168 @@ namespace WiiLayoutEditor.IO
Material.TevColor4.A/255f
};
}
public void RefreshColors(BRLYT.Material Material)
public void RefreshColors(Material Material)
{
STColor8 WhiteColor = Material.WhiteColor;
STColor8 BlackColor = Material.BlackColor;
STColor8 MatColor = Material.MatColor;
STColor8 TevColor1 = Material.TevColor1;
STColor8 TevColor2 = Material.TevColor2;
STColor8 TevColor3 = Material.TevColor3;
STColor8 TevColor4 = Material.TevColor4;
STColor8 ColorRegister3 = Material.ColorRegister3;
foreach (var animItem in Material.animController.MaterialColors)
{
switch ((RevLMCTarget)animItem.Key)
{
case RevLMCTarget.WhiteColorRed:
WhiteColor.R = (byte)animItem.Value; break;
case RevLMCTarget.WhiteColorGreen:
WhiteColor.G = (byte)animItem.Value; break;
case RevLMCTarget.WhiteColorBlue:
WhiteColor.B = (byte)animItem.Value; break;
case RevLMCTarget.WhiteColorAlpha:
WhiteColor.A = (byte)animItem.Value; break;
case RevLMCTarget.BlackColorRed:
BlackColor.R = (byte)animItem.Value; break;
case RevLMCTarget.BlackColorGreen:
BlackColor.G = (byte)animItem.Value; break;
case RevLMCTarget.BlackColorBlue:
BlackColor.B = (byte)animItem.Value; break;
case RevLMCTarget.BlackColorAlpha:
BlackColor.A = (byte)animItem.Value; break;
case RevLMCTarget.MatColorRed:
MatColor.R = (byte)animItem.Value; break;
case RevLMCTarget.MatColorGreen:
MatColor.G = (byte)animItem.Value; break;
case RevLMCTarget.MatColorBlue:
MatColor.B = (byte)animItem.Value; break;
case RevLMCTarget.MatColorAlpha:
MatColor.A = (byte)animItem.Value; break;
case RevLMCTarget.ColorReg3Red:
ColorRegister3.R = (byte)animItem.Value; break;
case RevLMCTarget.ColorReg3Green:
ColorRegister3.G = (byte)animItem.Value; break;
case RevLMCTarget.ColorReg3Blue:
ColorRegister3.B = (byte)animItem.Value; break;
case RevLMCTarget.ColorReg3Alpha:
ColorRegister3.A = (byte)animItem.Value; break;
case RevLMCTarget.TevColor1Red:
TevColor1.R = (byte)animItem.Value; break;
case RevLMCTarget.TevColor1Green:
TevColor1.G = (byte)animItem.Value; break;
case RevLMCTarget.TevColor1Blue:
TevColor1.B = (byte)animItem.Value; break;
case RevLMCTarget.TevColor1Alpha:
TevColor1.A = (byte)animItem.Value; break;
case RevLMCTarget.TevColor2Red:
TevColor2.R = (byte)animItem.Value; break;
case RevLMCTarget.TevColor2Green:
TevColor2.G = (byte)animItem.Value; break;
case RevLMCTarget.TevColor2Blue:
TevColor2.B = (byte)animItem.Value; break;
case RevLMCTarget.TevColor2Alpha:
TevColor2.A = (byte)animItem.Value; break;
case RevLMCTarget.TevColor3Red:
TevColor3.R = (byte)animItem.Value; break;
case RevLMCTarget.TevColor3Green:
TevColor3.G = (byte)animItem.Value; break;
case RevLMCTarget.TevColor3Blue:
TevColor3.B = (byte)animItem.Value; break;
case RevLMCTarget.TevColor3Alpha:
TevColor3.A = (byte)animItem.Value; break;
case RevLMCTarget.TevColor4Red:
TevColor4.R = (byte)animItem.Value; break;
case RevLMCTarget.TevColor4Green:
TevColor4.G = (byte)animItem.Value; break;
case RevLMCTarget.TevColor4Blue:
TevColor4.B = (byte)animItem.Value; break;
case RevLMCTarget.TevColor4Alpha:
TevColor4.A = (byte)animItem.Value; break;
}
}
this.MatColor = new float[]
{
Material.MatColor.R/255f,
Material.MatColor.G/255f,
Material.MatColor.B/255f,
Material.MatColor.A/255f
MatColor.R/255f,
MatColor.G/255f,
MatColor.B/255f,
MatColor.A/255f
};
g_color_registers = new float[3][];
g_color_registers[0] = new float[]
{
Material.ForeColor.R/255f,
Material.ForeColor.G/255f,
Material.ForeColor.B/255f,
Material.ForeColor.A/255f
BlackColor.R/255f,
BlackColor.G/255f,
BlackColor.B/255f,
BlackColor.A/255f
};
g_color_registers[1] = new float[]
{
Material.BackColor.R/255f,
Material.BackColor.G/255f,
Material.BackColor.B/255f,
Material.BackColor.A/255f
WhiteColor.R/255f,
WhiteColor.G/255f,
WhiteColor.B/255f,
WhiteColor.A/255f
};
g_color_registers[2] = new float[]
{
Material.ColorReg3.R/255f,
Material.ColorReg3.G/255f,
Material.ColorReg3.B/255f,
Material.ColorReg3.A/255f
ColorRegister3.R/255f,
ColorRegister3.G/255f,
ColorRegister3.B/255f,
ColorRegister3.A/255f
};
g_color_consts = new float[4][];
g_color_consts[0] = new float[]
{
Material.TevColor1.R/255f,
Material.TevColor1.G/255f,
Material.TevColor1.B/255f,
Material.TevColor1.A/255f
TevColor1.R/255f,
TevColor1.G/255f,
TevColor1.B/255f,
TevColor1.A/255f
};
g_color_consts[1] = new float[]
{
Material.TevColor2.R/255f,
Material.TevColor2.G/255f,
Material.TevColor2.B/255f,
Material.TevColor2.A/255f
TevColor2.R/255f,
TevColor2.G/255f,
TevColor2.B/255f,
TevColor2.A/255f
};
g_color_consts[2] = new float[]
{
Material.TevColor3.R/255f,
Material.TevColor3.G/255f,
Material.TevColor3.B/255f,
Material.TevColor3.A/255f
TevColor3.R/255f,
TevColor3.G/255f,
TevColor3.B/255f,
TevColor3.A/255f
};
g_color_consts[3] = new float[]
{
Material.TevColor4.R/255f,
Material.TevColor4.G/255f,
Material.TevColor4.B/255f,
Material.TevColor4.A/255f
TevColor4.R/255f,
TevColor4.G/255f,
TevColor4.B/255f,
TevColor4.A/255f
};
}
public void SetInt(string name, int value) {
GL.Uniform1(GL.GetUniformLocation(program, name), value);
}
public void SetMatrix4(string name, ref OpenTK.Matrix4 matrix) {
GL.UniformMatrix4(GL.GetUniformLocation(program, name), false, ref matrix);
}
public void SetVec3(string name, ref OpenTK.Vector3 value) {
GL.Uniform3(GL.GetUniformLocation(program, name), value);
}
public void SetVec2(string name, ref OpenTK.Vector2 value) {
GL.Uniform2(GL.GetUniformLocation(program, name), value);
}
public void Enable()
{
GL.UseProgram(program);
//for (int i = 0; i < Textures.Length; ++i)
//{
// String ss = "textures" + i;
// Gl.glUniform1i(Gl.glGetUniformLocation(program, ss), (int)i);
//}
for (int i = 0; i < 3; i++)
{
String ss = "color_register" + i;
@ -174,6 +271,8 @@ namespace WiiLayoutEditor.IO
}
public void Disable()
{
GL.UseProgram(0);
//Gl.glDeleteProgram(program);
//Gl.glDeleteShader(vertex_shader);
//Gl.glDeleteShader(fragment_shader);
@ -183,8 +282,10 @@ namespace WiiLayoutEditor.IO
public void Compile()
{
// w.e good for now
uint sampler_count = (uint)Textures.Length;
//if (sampler_count == 0)
uint sampler_count = (uint)TextureCount;
if (sampler_count == 0)
sampler_count = 1;
//if (sampler_count ==
//{
// sampler_count = 1;
//}
@ -193,16 +294,58 @@ namespace WiiLayoutEditor.IO
StringBuilder vert_ss = new StringBuilder();
//String vert_ss = "";
string FlipTextureFunction = @"
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.0, 1.0) * tex + vec2(1.0, 0.0);
else if (flipTexture == 2) //FlipV
return vec2(1.0, -1.0) * tex + vec2(0.0, 1.0);
else if (flipTexture == 3) //Rotate90
{
float degreesR = 90.0;
return rotateUV(tex, radians(degreesR));
}
else if (flipTexture == 4) //Rotate180
{
float degreesR = 180.0;
return rotateUV(tex, radians(degreesR));
}
else if (flipTexture == 5) //Rotate270
{
float degreesR = 270.0;
return rotateUV(tex, radians(degreesR));
}
return outTexCoord;
}";
vert_ss.AppendLine("uniform int flipTexture;");
vert_ss.AppendLine("uniform mat4 rotationMatrix;");
vert_ss.AppendLine("uniform mat4 textureTransforms[3];");
vert_ss.Append($"{FlipTextureFunction}");
vert_ss.AppendLine("void main()");
vert_ss.AppendLine("{");
{
vert_ss.AppendLine("gl_FrontColor = gl_Color;");
vert_ss.AppendLine("gl_BackColor = gl_Color;");
for (uint i = 0; i != sampler_count; ++i)
vert_ss.AppendFormat("gl_TexCoord[{0}] = gl_TextureMatrix[{0}] * gl_MultiTexCoord{0};\n", i);
for (uint i = 0; i != sampler_count; ++i) {
vert_ss.AppendFormat("gl_TexCoord[{0}] = textureTransforms[{0}] * gl_MultiTexCoord{0};\n", i);
vert_ss.AppendFormat("gl_TexCoord[{0}].st = SetFlip(vec2(0.5, 0.5) + gl_TexCoord[{0}].st);\n", i);
}
vert_ss.AppendLine("gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;");
vert_ss.AppendLine("gl_Position = gl_ModelViewProjectionMatrix * rotationMatrix * gl_Vertex;");
}
vert_ss.AppendLine("}");
@ -224,8 +367,13 @@ namespace WiiLayoutEditor.IO
StringBuilder frag_ss = new StringBuilder();
//frag_ss += "uniform sampler2D tex;";
// uniforms
for (uint i = 0; i != sampler_count; ++i)
for (uint i = 0; i != sampler_count; ++i) {
frag_ss.AppendFormat("uniform sampler2D textures{0};\n", i);
frag_ss.AppendFormat("uniform int hasTexture{0};\n", i);
}
frag_ss.AppendLine("uniform sampler2D uvTestPattern;");
frag_ss.AppendLine("uniform int debugShading;");
//frag_ss += "uniform vec4 registers[3]" + ";";
@ -315,14 +463,17 @@ namespace WiiLayoutEditor.IO
{
// current texture color
// 0xff is a common value for a disabled texture
if (stage.TexCoord < sampler_count)
if ((byte)stage.TexCoord < sampler_count)
{
frag_ss.AppendFormat("color_texture = texture2D(textures{0}, gl_TexCoord[{1}].st);\n", (int)stage.TexCoord, (int)stage.TexCoord);
frag_ss.AppendFormat("if (hasTexture{0} == 1)\n", (int)stage.TexCoord);
frag_ss.AppendFormat(" color_texture = texture2D(textures{0}, gl_TexCoord[{1}].st);\n", (int)stage.TexCoord, (int)stage.TexCoord);
frag_ss.AppendLine("else");
frag_ss.AppendLine(" color_texture = vec4(1);");
}
string color = "";
if (stage.ColorConstantSel <= 7)
if ((byte)stage.ColorConstantSel <= 7)
{
switch (stage.ColorConstantSel)
switch ((byte)stage.ColorConstantSel)
{
case 0: color = "vec3(1.0)"; break;
case 1: color = "vec3(0.875)"; break;
@ -335,7 +486,7 @@ namespace WiiLayoutEditor.IO
}
}
else if (stage.ColorConstantSel < 0xc)
else if ((byte)stage.ColorConstantSel < 0xc)
{
//warn("getColorOp(): unknown konst %x", konst);
//return "ERROR";
@ -346,12 +497,12 @@ namespace WiiLayoutEditor.IO
string[] v1 = { "color_consts0", "color_consts1", "color_consts2", "color_consts3" };
string[] v2 = { ".rgb", ".rrr", ".ggg", ".bbb", ".aaa" };
color = v1[(stage.ColorConstantSel - 0xc) % 4] + v2[(stage.ColorConstantSel - 0xc) / 4];
color = v1[((byte)stage.ColorConstantSel - 0xc) % 4] + v2[((byte)stage.ColorConstantSel - 0xc) / 4];
}
string alpha = "";
if (stage.AlphaConstantSel <= 7)
if ((byte)stage.AlphaConstantSel <= 7)
{
switch (stage.AlphaConstantSel)
switch ((byte)stage.AlphaConstantSel)
{
case 0: alpha = "vec3(1.0)"; break;
case 1: alpha = "vec3(0.875)"; break;
@ -364,7 +515,7 @@ namespace WiiLayoutEditor.IO
}
}
else if (stage.AlphaConstantSel < 0x10)
else if ((byte)stage.AlphaConstantSel < 0x10)
{
//warn("getColorOp(): unknown konst %x", konst);
//return "ERROR";
@ -375,7 +526,7 @@ namespace WiiLayoutEditor.IO
string[] v1 = { "color_consts0", "color_consts1", "color_consts2", "color_consts3" };
string[] v2 = { ".r", ".g", ".b", ".a" };
alpha = v1[(stage.AlphaConstantSel - 0x10) % 4] + v2[(stage.AlphaConstantSel - 0x10) / 4];
alpha = v1[((byte)stage.AlphaConstantSel - 0x10) % 4] + v2[((byte)stage.AlphaConstantSel - 0x10) / 4];
}
frag_ss.AppendFormat("color_constant = vec4({0}, {1});\n", color, alpha);
@ -384,22 +535,22 @@ namespace WiiLayoutEditor.IO
{
// all 4 inputs
frag_ss.AppendFormat("vec4 a = vec4({0}, {1});\n", color_inputs[stage.ColorA], alpha_inputs[stage.AlphaA]);
frag_ss.AppendFormat("vec4 b = vec4({0}, {1});\n", color_inputs[stage.ColorB], alpha_inputs[stage.AlphaB]);
frag_ss.AppendFormat("vec4 c = vec4({0}, {1});\n", color_inputs[stage.ColorC], alpha_inputs[stage.AlphaC]);
frag_ss.AppendFormat("vec4 d = vec4({0}, {1});\n", color_inputs[stage.ColorD], alpha_inputs[stage.AlphaD]);
frag_ss.AppendFormat("vec4 a = vec4({0}, {1});\n", color_inputs[(byte)stage.ColorA], alpha_inputs[(byte)stage.AlphaA]);
frag_ss.AppendFormat("vec4 b = vec4({0}, {1});\n", color_inputs[(byte)stage.ColorB], alpha_inputs[(byte)stage.AlphaB]);
frag_ss.AppendFormat("vec4 c = vec4({0}, {1});\n", color_inputs[(byte)stage.ColorC], alpha_inputs[(byte)stage.AlphaC]);
frag_ss.AppendFormat("vec4 d = vec4({0}, {1});\n", color_inputs[(byte)stage.ColorD], alpha_inputs[(byte)stage.AlphaD]);
// TODO: could eliminate this result variable
frag_ss.AppendLine("vec4 result;");
if (stage.ColorOp != stage.AlphaOp)
if ((byte)stage.ColorOp != (byte)stage.AlphaOp)
{
write_tevop(stage.ColorOp, ".rgb", ref frag_ss);
write_tevop(stage.AlphaOp, ".a", ref frag_ss);
write_tevop((byte)stage.ColorOp, ".rgb", ref frag_ss);
write_tevop((byte)stage.AlphaOp, ".a", ref frag_ss);
}
else
write_tevop(stage.ColorOp, "", ref frag_ss);
write_tevop((byte)stage.ColorOp, "", ref frag_ss);
string[] bias =
{
@ -416,31 +567,31 @@ namespace WiiLayoutEditor.IO
"*0.5"
};
if (stage.ColorOp < 2)
if ((byte)stage.ColorOp < 2)
{
frag_ss.AppendFormat("{0}.rgb = (result.rgb{1}){2};\n", output_registers[stage.ColorRegID], bias[stage.ColorBias], scale[stage.ColorScale]);
frag_ss.AppendFormat("{0}.rgb = (result.rgb{1}){2};\n", output_registers[(byte)stage.ColorRegID], bias[(byte)stage.ColorBias], scale[(byte)stage.ColorScale]);
}
else
{
frag_ss.AppendFormat("{0}.rgb = result.rgb;\n", output_registers[stage.ColorRegID]);
frag_ss.AppendFormat("{0}.rgb = result.rgb;\n", output_registers[(byte)stage.ColorRegID]);
}
if (stage.AlphaOp < 2)
if ((byte)stage.AlphaOp < 2)
{
frag_ss.AppendFormat("{0}.a = (result.a{1}){2};\n", output_registers[stage.AlphaRegID], bias[stage.AlphaBias], scale[stage.AlphaScale]);
frag_ss.AppendFormat("{0}.a = (result.a{1}){2};\n", output_registers[(byte)stage.AlphaRegID], bias[(byte)stage.AlphaBias], scale[(byte)stage.AlphaScale]);
}
else
{
frag_ss.AppendFormat("{0}.a = result.a;\n", output_registers[stage.AlphaRegID]);
frag_ss.AppendFormat("{0}.a = result.a;\n", output_registers[(byte)stage.AlphaRegID]);
}
if (stage.ColorClamp && stage.ColorOp < 2)
if (stage.ColorClamp && (byte)stage.ColorOp < 2)
{
frag_ss.AppendFormat("{0}.rgb = clamp({0}.rgb,vec3(0.0, 0.0, 0.0),vec3(1.0, 1.0, 1.0));\n", output_registers[stage.ColorRegID]);
frag_ss.AppendFormat("{0}.rgb = clamp({0}.rgb,vec3(0.0, 0.0, 0.0),vec3(1.0, 1.0, 1.0));\n", output_registers[(byte)stage.ColorRegID]);
}
if (stage.AlphaClamp && stage.AlphaOp < 2)
if (stage.AlphaClamp && (byte)stage.AlphaOp < 2)
{
frag_ss.AppendFormat("{0}.a = clamp({0}.a, 0.0, 1.0);\n", output_registers[stage.AlphaRegID]);
frag_ss.AppendFormat("{0}.a = clamp({0}.a, 0.0, 1.0);\n", output_registers[(byte)stage.AlphaRegID]);
}
}
frag_ss.AppendLine("}");
@ -458,7 +609,10 @@ namespace WiiLayoutEditor.IO
// 0xff is a common value for a disabled texture
if (i < sampler_count)
{
frag_ss.AppendFormat("color_texture = texture2D(textures{0}, gl_TexCoord[{0}].st);\n", i);
frag_ss.AppendFormat("if (hasTexture{0} == 1)\n", i);
frag_ss.AppendFormat(" color_texture = texture2D(textures{0}, gl_TexCoord[{0}].st);\n", i);
frag_ss.AppendLine("else");
frag_ss.AppendLine(" color_texture = vec4(1);");
}
frag_ss.AppendLine("{");
@ -485,7 +639,10 @@ namespace WiiLayoutEditor.IO
// 0xff is a common value for a disabled texture
if (i < sampler_count)
{
frag_ss.AppendFormat("color_texture = texture2D(textures{0}, gl_TexCoord[{0}].st);\n", i);
frag_ss.AppendFormat("if (hasTexture{0} == 1)\n", i);
frag_ss.AppendFormat(" color_texture = texture2D(textures{0}, gl_TexCoord[{0}].st);\n", i);
frag_ss.AppendLine("else");
frag_ss.AppendLine(" color_texture = vec4(1);");
}
frag_ss.AppendLine("{");
@ -513,6 +670,9 @@ namespace WiiLayoutEditor.IO
frag_ss.AppendLine("gl_FragColor = color_previous;");
}
}
frag_ss.AppendLine("if (debugShading == 4)");
frag_ss.AppendLine(" gl_FragColor = texture2D(uvTestPattern, gl_TexCoord[0].st);");
frag_ss.AppendLine("}");
//std::cout << frag_ss.str() << '\n';
@ -537,8 +697,14 @@ namespace WiiLayoutEditor.IO
GL.GetShader(vertex_shader, ShaderParameter.CompileStatus, out vert_compiled);
GL.GetShader(fragment_shader, ShaderParameter.CompileStatus, out frag_compiled);
string vertlog = GL.GetShaderInfoLog(vertex_shader);
string fraglog = GL.GetShaderInfoLog(fragment_shader);
Console.WriteLine(vertlog);
Console.WriteLine(fraglog);
if (vert_compiled == 0)
{
Console.WriteLine($"");
//std::cout << "Failed to compile vertex shader\n";
}
@ -677,5 +843,5 @@ namespace WiiLayoutEditor.IO
frag_ss.AppendLine(";");
}
public int program = 0, fragment_shader = 0, vertex_shader = 0;
}*/
}
}

View File

@ -1,14 +1,14 @@
using Toolbox.Library.IO;
using Toolbox.Library;
namespace LayoutBXLYT.Cafe
namespace LayoutBXLYT
{
public class FontShadowParameter
{
public STColor8 BlackColor { get; set; }
public STColor8 WhiteColor { get; set; }
public FontShadowParameter(FileReader reader, BFLYT.Header header)
public FontShadowParameter(FileReader reader, BxlytHeader header)
{
BlackColor = reader.ReadColor8RGBA();
WhiteColor = reader.ReadColor8RGBA();

View File

@ -1,10 +1,10 @@
using Toolbox.Library.IO;
namespace LayoutBXLYT.Cafe
namespace LayoutBXLYT
{
public class IndirectParameter : BxlytIndTextureTransform
{
public IndirectParameter(FileReader reader, BFLYT.Header header)
public IndirectParameter(FileReader reader, BxlytHeader header)
{
Rotation = reader.ReadSingle();
ScaleX = reader.ReadSingle();

View File

@ -1,7 +1,7 @@
using Toolbox.Library.IO;
using System;
namespace LayoutBXLYT.Cafe
namespace LayoutBXLYT
{
public class ProjectionTexGenParam
{
@ -27,7 +27,7 @@ namespace LayoutBXLYT.Cafe
byte flags;
public ProjectionTexGenParam(FileReader reader, BFLYT.Header header)
public ProjectionTexGenParam(FileReader reader, BxlytHeader header)
{
PosX = reader.ReadSingle();
PosY = reader.ReadSingle();

View File

@ -87,6 +87,23 @@ namespace LayoutBXLYT
}
}
break;
case PlatformType.Wii:
if (ArchiveParent == null) return null;
foreach (var file in ArchiveParent.Files)
{
if (file.FileName == name)
{
var fileFormat = file.FileFormat;
if (fileFormat == null)
fileFormat = file.OpenFile();
if (fileFormat is TPL)
{
}
}
}
break;
}
return texture;
}
@ -125,6 +142,22 @@ namespace LayoutBXLYT
}
}
break;
default:
{
var archive = ArchiveParent;
if (archive == null) return;
ArchiveFileInfo fileInfoDelete = null;
foreach (var file in archive.Files)
{
if (file.FileName.Contains(texture.Text))
fileInfoDelete = file;
}
if (fileInfoDelete != null)
archive.DeleteFile(fileInfoDelete);
}
break;
}
}

View File

@ -8,6 +8,7 @@ using System.Windows.Forms;
using Toolbox.Library;
using Toolbox.Library.Forms;
using Toolbox.Library.IO;
using System.ComponentModel;
namespace FirstPlugin
{
@ -79,36 +80,39 @@ namespace FirstPlugin
{
reader.Position = 0;
uint ImageCount = reader.ReadUInt32();
Console.WriteLine("ImageCount" + ImageCount);
for (int i = 0; i < ImageCount; i++)
{
reader.SeekBegin(4 + (i * 0x10));
uint format = reader.ReadUInt32();
uint offset = reader.ReadUInt32();
uint width = reader.ReadUInt16();
uint height = reader.ReadUInt16();
uint mipCount = reader.ReadUInt16();
var image = new ImageHeader();
image.Format = (Decode_Gamecube.TextureFormats)reader.ReadUInt32();
image.ImageOffset = reader.ReadUInt32();
image.Width = reader.ReadUInt16();
image.Height = reader.ReadUInt16();
image.MaxLOD = (byte)reader.ReadUInt16();
ushort unknown = reader.ReadUInt16();
if (format == 256)
if ((uint)image.Format == 256)
break;
Console.WriteLine(offset);
Console.WriteLine(format);
var GXFormat = (Decode_Gamecube.TextureFormats)format;
Console.WriteLine(image.ImageOffset);
Console.WriteLine(image.Format);
//Now create a wrapper
var texWrapper = new TplTextureWrapper();
texWrapper.Text = $"Texture {i}";
var texWrapper = new TplTextureWrapper(this, image);
string name = System.IO.Path.GetFileNameWithoutExtension(FileName);
if (ImageCount == 1)
texWrapper.Text = name;
else
texWrapper.Text = $"{name}_{i}";
texWrapper.ImageKey = "Texture";
texWrapper.SelectedImageKey = "Texture";
texWrapper.Format = Decode_Gamecube.ToGenericFormat(GXFormat);
texWrapper.Width = width;
texWrapper.Height = height;
texWrapper.MipCount = mipCount;
texWrapper.ImageData = reader.getSection(offset, (uint)Decode_Gamecube.GetDataSize(GXFormat, (int)width, (int)height));
texWrapper.Format = Decode_Gamecube.ToGenericFormat(image.Format);
texWrapper.Width = image.Width;
texWrapper.Height = image.Height;
texWrapper.MipCount = image.MaxLOD;
texWrapper.ImageData = reader.getSection(image.ImageOffset, (uint)Decode_Gamecube.GetDataSize(image.Format, (int)image.Width, (int)image.Height));
texWrapper.PlatformSwizzle = PlatformSwizzle.Platform_Gamecube;
Nodes.Add(texWrapper);
}
@ -130,24 +134,28 @@ namespace FirstPlugin
image.Read(reader);
ImageHeaders.Add(image);
var GXFormat = (Decode_Gamecube.TextureFormats)image.Format;
Console.WriteLine($"ImageOffset {image.ImageOffset}");
//Now create a wrapper
var texWrapper = new TplTextureWrapper();
texWrapper.Text = $"Texture {i}";
var texWrapper = new TplTextureWrapper(this, image);
string name = System.IO.Path.GetFileNameWithoutExtension(FileName);
if (ImageCount == 1)
texWrapper.Text = name;
else
texWrapper.Text = $"{name}_{i}";
texWrapper.ImageKey = "Texture";
texWrapper.SelectedImageKey = "Texture";
texWrapper.Format = Decode_Gamecube.ToGenericFormat(GXFormat);
texWrapper.Format = Decode_Gamecube.ToGenericFormat(image.Format);
texWrapper.Width = image.Width;
texWrapper.Height = image.Height;
texWrapper.MipCount = 1;
texWrapper.PlatformSwizzle = PlatformSwizzle.Platform_Gamecube;
texWrapper.ImageData = reader.getSection(image.ImageOffset,
(uint)Decode_Gamecube.GetDataSize(GXFormat, (int)image.Width, (int)image.Height));
(uint)Decode_Gamecube.GetDataSize(image.Format, (int)image.Width, (int)image.Height));
Console.WriteLine($"PaletteHeaderOffset {PaletteHeaderOffset}");
Console.WriteLine($"ImageData { texWrapper.ImageData.Length}");
//Palette is sometimes unused to check
if (PaletteHeaderOffset != 0)
@ -158,6 +166,7 @@ namespace FirstPlugin
PaletteHeaders.Add(palette);
var GXPaletteFormat = (Decode_Gamecube.PaletteFormats)palette.PaletteFormat;
image.PaletteFormat = GXPaletteFormat;
Console.WriteLine($"GXPaletteFormat {GXPaletteFormat}");
texWrapper.SetPaletteData(palette.Data, Decode_Gamecube.ToGenericPaletteFormat(GXPaletteFormat));
@ -171,7 +180,15 @@ namespace FirstPlugin
public class TplTextureWrapper : STGenericTexture
{
public TPL TPLParent { get; set; }
public byte[] ImageData { get; set; }
public ImageHeader ImageHeader;
public TplTextureWrapper(TPL tpl, ImageHeader header) {
TPLParent = tpl;
ImageHeader = header;
}
public override TEX_FORMAT[] SupportedFormats
{
@ -217,7 +234,7 @@ namespace FirstPlugin
LibraryGUI.LoadEditor(editor);
}
editor.LoadProperties(GenericProperties);
editor.LoadProperties(ImageHeader);
editor.LoadImage(this);
}
}
@ -257,30 +274,43 @@ namespace FirstPlugin
public class ImageHeader
{
[ReadOnly(true)]
public Decode_Gamecube.TextureFormats Format { get; set; }
[ReadOnly(true)]
public Decode_Gamecube.PaletteFormats PaletteFormat { get; set; }
[ReadOnly(true)]
public ushort Width { get; set; }
[ReadOnly(true)]
public ushort Height { get; set; }
public uint Format { get; set; }
[Browsable(false)]
public uint ImageOffset { get; set; }
public uint WrapS { get; set; }
public uint WrapT { get; set; }
public uint MinFilter { get; set; }
public uint MagFilter { get; set; }
public float LODBias { get; set; }
public bool EdgeLODEnable { get; set; }
public WrapMode WrapS { get; set; }
public WrapMode WrapT { get; set; }
public FilterMode MinFilter { get; set; }
public FilterMode MagFilter { get; set; }
[Browsable(false)]
public byte MinLOD { get; set; }
[Browsable(false)]
public byte MaxLOD { get; set; }
[Browsable(false)]
public byte Unpacked { get; set; }
public void Read(FileReader reader)
{
Height = reader.ReadUInt16();
Width = reader.ReadUInt16();
Format = reader.ReadUInt32();
Format = (Decode_Gamecube.TextureFormats)reader.ReadUInt32();
ImageOffset = reader.ReadUInt32();
WrapS = reader.ReadUInt32();
WrapT = reader.ReadUInt32();
MinFilter = reader.ReadUInt32();
MagFilter = reader.ReadUInt32();
WrapS = (WrapMode)reader.ReadUInt32();
WrapT = (WrapMode)reader.ReadUInt32();
MinFilter = (FilterMode)reader.ReadUInt32();
MagFilter = (FilterMode)reader.ReadUInt32();
LODBias = reader.ReadSingle();
EdgeLODEnable = reader.ReadBoolean();
MinLOD = reader.ReadByte();
@ -292,12 +322,12 @@ namespace FirstPlugin
{
writer.Write(Width);
writer.Write(Height);
writer.Write(Format);
writer.Write((uint)Format);
writer.Write(ImageOffset);
writer.Write(WrapS);
writer.Write(WrapT);
writer.Write(MinFilter);
writer.Write(MagFilter);
writer.Write((uint)WrapS);
writer.Write((uint)WrapT);
writer.Write((uint)MinFilter);
writer.Write((uint)MagFilter);
writer.Write(LODBias);
writer.Write(EdgeLODEnable);
writer.Write(MinLOD);
@ -306,6 +336,19 @@ namespace FirstPlugin
}
}
public enum WrapMode : uint
{
Clamp,
Repeat,
Mirror
}
public enum FilterMode : uint
{
Nearest,
Linear,
}
public void Unload()
{

View File

@ -210,6 +210,7 @@
<Compile Include="FileFormats\AAMP\AAMP.cs" />
<Compile Include="FileFormats\Archives\APAK.cs" />
<Compile Include="FileFormats\Archives\ARC.cs" />
<Compile Include="FileFormats\Archives\BNR.cs" />
<Compile Include="FileFormats\Archives\DARC.cs" />
<Compile Include="FileFormats\Archives\DAT_Bayonetta.cs" />
<Compile Include="FileFormats\Archives\GFA.cs" />
@ -232,6 +233,46 @@
<Compile Include="FileFormats\HyruleWarriors\G1M\G1MCommon.cs" />
<Compile Include="FileFormats\HyruleWarriors\G1M\NUNO.cs" />
<Compile Include="FileFormats\HyruleWarriors\G1M\NUNV.cs" />
<Compile Include="FileFormats\Layout\CAFE\GRP1.cs" />
<Compile Include="FileFormats\Layout\CAFE\Header.cs" />
<Compile Include="FileFormats\Layout\CAFE\LYT1.cs" />
<Compile Include="FileFormats\Layout\CAFE\MAT1.cs" />
<Compile Include="FileFormats\Layout\CAFE\Panes\ALI1.cs" />
<Compile Include="FileFormats\Layout\CAFE\Panes\BND1.cs" />
<Compile Include="FileFormats\Layout\CAFE\Panes\PAN1.cs" />
<Compile Include="FileFormats\Layout\CAFE\Panes\PIC1.cs" />
<Compile Include="FileFormats\Layout\CAFE\Panes\PRT1.cs" />
<Compile Include="FileFormats\Layout\CAFE\Panes\SCR1.cs" />
<Compile Include="FileFormats\Layout\CAFE\Panes\TXT1.cs" />
<Compile Include="FileFormats\Layout\CAFE\Panes\WND1.cs" />
<Compile Include="FileFormats\Layout\CAFE\USD1.cs" />
<Compile Include="FileFormats\Layout\CTR\GRP1.cs" />
<Compile Include="FileFormats\Layout\CTR\MAT1.cs" />
<Compile Include="FileFormats\Layout\CTR\Materials\TevStage.cs" />
<Compile Include="FileFormats\Layout\CTR\Materials\TexCoordGen.cs" />
<Compile Include="FileFormats\Layout\CTR\Materials\TextureRef.cs" />
<Compile Include="FileFormats\Layout\CTR\Panes\BND1.cs" />
<Compile Include="FileFormats\Layout\CTR\Panes\LYT1.cs" />
<Compile Include="FileFormats\Layout\CTR\Panes\PAN1.cs" />
<Compile Include="FileFormats\Layout\CTR\Panes\PIC1.cs" />
<Compile Include="FileFormats\Layout\CTR\Panes\PRT1.cs" />
<Compile Include="FileFormats\Layout\CTR\Panes\TXT1.cs" />
<Compile Include="FileFormats\Layout\CTR\Panes\WND1.cs" />
<Compile Include="FileFormats\Layout\CTR\USD1.cs" />
<Compile Include="FileFormats\Layout\Rev\GRP1.cs" />
<Compile Include="FileFormats\Layout\Rev\LYT1.cs" />
<Compile Include="FileFormats\Layout\Rev\MAT1.cs" />
<Compile Include="FileFormats\Layout\Rev\Materials\AlphaCompare.cs" />
<Compile Include="FileFormats\Layout\Rev\Materials\ChanCtrl.cs" />
<Compile Include="FileFormats\Layout\Rev\Materials\IndirectTextureOrderEntry.cs" />
<Compile Include="FileFormats\Layout\Rev\Materials\TevSwapModeTable.cs" />
<Compile Include="FileFormats\Layout\Rev\Materials\TexCoordGenEntry.cs" />
<Compile Include="FileFormats\Layout\Rev\Materials\TextureRef.cs" />
<Compile Include="FileFormats\Layout\Rev\Panes\BND1.cs" />
<Compile Include="FileFormats\Layout\Rev\Panes\PAN1.cs" />
<Compile Include="FileFormats\Layout\Rev\Panes\PIC1.cs" />
<Compile Include="FileFormats\Layout\Rev\Panes\TXT1.cs" />
<Compile Include="FileFormats\Layout\Rev\Panes\WND1.cs" />
<Compile Include="FileFormats\LM1\LM1_MDL.cs" />
<Compile Include="FileFormats\MarioParty\HSF.cs" />
<Compile Include="FileFormats\Message\MSYT.cs" />
@ -332,17 +373,16 @@
<Compile Include="FileFormats\Layout\Animation\LytKeyFrame.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\FontShadowParameter.cs" />
<Compile Include="FileFormats\Layout\CAFE\Materials\IndirectParameter.cs" />
<Compile Include="FileFormats\Layout\CAFE\Materials\ProjectionTexGenParam.cs" />
<Compile Include="FileFormats\Layout\CAFE\TextFormats\FLAN.cs" />
<Compile Include="FileFormats\Layout\Shared\FontShadowParameter.cs" />
<Compile Include="FileFormats\Layout\Shared\IndirectParameter.cs" />
<Compile Include="FileFormats\Layout\Shared\ProjectionTexGenParam.cs" />
<Compile Include="FileFormats\Layout\CAFE\Materials\TevStage.cs" />
<Compile Include="FileFormats\Layout\CAFE\Materials\TexCoordGen.cs" />
<Compile Include="FileFormats\Layout\CAFE\Materials\TextureRef.cs" />
<Compile Include="FileFormats\Layout\CAFE\Materials\TextureTransform.cs" />
<Compile Include="FileFormats\Layout\ShaderLoader.cs" />
<Compile Include="FileFormats\Layout\CTR\BCLYT.cs" />
<Compile Include="FileFormats\Layout\CAFE\FLYT.cs" />
<Compile Include="FileFormats\Layout\CAFE\TextFormats\FLYT.cs" />
<Compile Include="FileFormats\Layout\CTR\BclytShader.cs" />
<Compile Include="FileFormats\Layout\Animation\LytAnimation.cs" />
<Compile Include="FileFormats\Layout\LayoutCustomPaneMapper.cs" />
@ -356,7 +396,7 @@
<Compile Include="FileFormats\Layout\Rev\BrlytShader.cs" />
<Compile Include="FileFormats\Layout\Rev\BRLYT.cs" />
<Compile Include="FileFormats\Layout\Rev\Materials\TevStage.cs" />
<Compile Include="FileFormats\Layout\Rev\WiiLayoutEditor\Shader.cs" />
<Compile Include="FileFormats\Layout\Rev\Shaders\Shader.cs" />
<Compile Include="FileFormats\Layout\Wrappers\MatWrapper.cs" />
<Compile Include="FileFormats\Message\MSBP.cs" />
<Compile Include="FileFormats\CrashBandicoot\IGZ_TEX.cs" />
@ -497,6 +537,48 @@
<Compile Include="GUI\BFLYT\Animations\LytAnimationWindow.Designer.cs">
<DependentUpon>LytAnimationWindow.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\CTR\PaneMatColorEditor.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\CTR\PaneMatColorEditor.Designer.cs">
<DependentUpon>PaneMatColorEditor.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\CTR\PaneMatCTRTevEditor.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\CTR\PaneMatCTRTevEditor.Designer.cs">
<DependentUpon>PaneMatCTRTevEditor.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatBlending.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatBlending.Designer.cs">
<DependentUpon>PaneMatBlending.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatColorEditor.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatColorEditor.Designer.cs">
<DependentUpon>PaneMatColorEditor.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatRevTevSwapTableEditor.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatRevTevSwapTableEditor.Designer.cs">
<DependentUpon>PaneMatRevTevSwapTableEditor.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatRevTevEditor.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatRevTevEditor.Designer.cs">
<DependentUpon>PaneMatRevTevEditor.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\Rev\SwapTableEntry.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GUI\BFLYT\Editor\Materials\Rev\SwapTableEntry.Designer.cs">
<DependentUpon>SwapTableEntry.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFRES\BfresAnimationCopy.cs">
<SubType>Form</SubType>
</Compile>
@ -1607,6 +1689,27 @@
<EmbeddedResource Include="GUI\BFLYT\Animations\LytAnimationWindow.resx">
<DependentUpon>LytAnimationWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFLYT\Editor\Materials\CTR\PaneMatColorEditor.resx">
<DependentUpon>PaneMatColorEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFLYT\Editor\Materials\CTR\PaneMatCTRTevEditor.resx">
<DependentUpon>PaneMatCTRTevEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatBlending.resx">
<DependentUpon>PaneMatBlending.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatColorEditor.resx">
<DependentUpon>PaneMatColorEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatRevTevSwapTableEditor.resx">
<DependentUpon>PaneMatRevTevSwapTableEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFLYT\Editor\Materials\Rev\PaneMatRevTevEditor.resx">
<DependentUpon>PaneMatRevTevEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFLYT\Editor\Materials\Rev\SwapTableEntry.resx">
<DependentUpon>SwapTableEntry.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFRES\BfresAnimationCopy.resx">
<DependentUpon>BfresAnimationCopy.cs</DependentUpon>
</EmbeddedResource>

View File

@ -46,7 +46,7 @@ namespace LayoutBXLYT
}
else if ((AnimationTarget)typeCB.SelectedItem == AnimationTarget.Material)
{
foreach (var mat in ParentLayout.GetMaterials())
foreach (var mat in ParentLayout.Materials)
if (!AnimInfo.ContainsEntry(mat.Name))
objectTargetsCB.Items.Add(mat.Name);
}

View File

@ -46,7 +46,7 @@
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(0, 0);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(309, 396);
this.listView1.Size = new System.Drawing.Size(640, 481);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
@ -76,7 +76,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(309, 396);
this.ClientSize = new System.Drawing.Size(640, 481);
this.Controls.Add(this.listView1);
this.Name = "LayoutAnimList";
this.stContextMenuStrip1.ResumeLayout(false);

View File

@ -0,0 +1,89 @@
namespace LayoutBXLYT.CTR
{
partial class PaneMatCTRTevEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.stPropertyGrid1 = new Toolbox.Library.Forms.STPropertyGrid();
this.tevStageCB = new Toolbox.Library.Forms.STComboBox();
this.stageCounterLbl = new Toolbox.Library.Forms.STLabel();
this.SuspendLayout();
//
// stPropertyGrid1
//
this.stPropertyGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stPropertyGrid1.AutoScroll = true;
this.stPropertyGrid1.Location = new System.Drawing.Point(0, 42);
this.stPropertyGrid1.Name = "stPropertyGrid1";
this.stPropertyGrid1.ShowHintDisplay = false;
this.stPropertyGrid1.Size = new System.Drawing.Size(421, 346);
this.stPropertyGrid1.TabIndex = 0;
//
// tevStageCB
//
this.tevStageCB.BorderColor = System.Drawing.Color.Empty;
this.tevStageCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.tevStageCB.ButtonColor = System.Drawing.Color.Empty;
this.tevStageCB.FormattingEnabled = true;
this.tevStageCB.IsReadOnly = false;
this.tevStageCB.Location = new System.Drawing.Point(117, 12);
this.tevStageCB.Name = "tevStageCB";
this.tevStageCB.Size = new System.Drawing.Size(121, 21);
this.tevStageCB.TabIndex = 1;
this.tevStageCB.SelectedIndexChanged += new System.EventHandler(this.tevStageCB_SelectedIndexChanged);
//
// stageCounterLbl
//
this.stageCounterLbl.AutoSize = true;
this.stageCounterLbl.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.stageCounterLbl.Location = new System.Drawing.Point(12, 11);
this.stageCounterLbl.Name = "stageCounterLbl";
this.stageCounterLbl.Size = new System.Drawing.Size(87, 18);
this.stageCounterLbl.TabIndex = 2;
this.stageCounterLbl.Text = "Stage 0 of 5";
//
// PaneMatRevTevEditor
//
this.Controls.Add(this.stageCounterLbl);
this.Controls.Add(this.tevStageCB);
this.Controls.Add(this.stPropertyGrid1);
this.Name = "PaneMatRevTevEditor";
this.Size = new System.Drawing.Size(421, 391);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Toolbox.Library.Forms.STPropertyGrid stPropertyGrid1;
private Toolbox.Library.Forms.STComboBox tevStageCB;
private Toolbox.Library.Forms.STLabel stageCounterLbl;
}
}

View File

@ -0,0 +1,60 @@
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 LayoutBXLYT.Revolution;
namespace LayoutBXLYT.CTR
{
public partial class PaneMatCTRTevEditor : EditorPanelBase
{
private PaneEditor ParentEditor;
private Material ActiveMaterial;
private bool loaded = false;
public PaneMatCTRTevEditor()
{
InitializeComponent();
}
public void LoadMaterial(Material material, PaneEditor paneEditor)
{
ParentEditor = paneEditor;
ActiveMaterial = material;
tevStageCB.Items.Clear();
stPropertyGrid1.LoadProperty(null);
stageCounterLbl.Text = $"Stage 0 of {material.TevStages.Length}";
for (int i = 0; i < material.TevStages.Length; i++)
tevStageCB.Items.Add($"Stage[[{i}]");
if (tevStageCB.Items.Count > 0)
tevStageCB.SelectedIndex = 0;
}
private void tevStageCB_SelectedIndexChanged(object sender, EventArgs e) {
if (tevStageCB.SelectedIndex == -1)
return;
int index = tevStageCB.SelectedIndex;
stageCounterLbl.Text = $"Stage {index + 1} of {ActiveMaterial.TevStages.Length}";
LoadTevStage((TevStage)ActiveMaterial.TevStages[index]);
}
private void LoadTevStage(TevStage stage) {
stPropertyGrid1.LoadProperty(stage, OnPropertyChanged);
}
private void OnPropertyChanged() {
ParentEditor.PropertyChanged?.Invoke(EventArgs.Empty, null);
}
}
}

View File

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

View File

@ -0,0 +1,222 @@
namespace LayoutBXLYT.CTR
{
partial class PaneMatCTRColorEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.chkAlphaInterpolation = new Toolbox.Library.Forms.STCheckBox();
this.stLabel1 = new Toolbox.Library.Forms.STLabel();
this.stLabel2 = new Toolbox.Library.Forms.STLabel();
this.whiteColorPB = new Toolbox.Library.Forms.ColorAlphaBox();
this.blackColorBP = new Toolbox.Library.Forms.ColorAlphaBox();
this.tevColor1PB = new Toolbox.Library.Forms.ColorAlphaBox();
this.stLabel5 = new Toolbox.Library.Forms.STLabel();
this.tevColor2PB = new Toolbox.Library.Forms.ColorAlphaBox();
this.stLabel6 = new Toolbox.Library.Forms.STLabel();
this.tevColor4PB = new Toolbox.Library.Forms.ColorAlphaBox();
this.tevColor3PB = new Toolbox.Library.Forms.ColorAlphaBox();
this.stLabel7 = new Toolbox.Library.Forms.STLabel();
this.stLabel8 = new Toolbox.Library.Forms.STLabel();
this.SuspendLayout();
//
// chkAlphaInterpolation
//
this.chkAlphaInterpolation.AutoSize = true;
this.chkAlphaInterpolation.Location = new System.Drawing.Point(16, 13);
this.chkAlphaInterpolation.Name = "chkAlphaInterpolation";
this.chkAlphaInterpolation.Size = new System.Drawing.Size(147, 17);
this.chkAlphaInterpolation.TabIndex = 0;
this.chkAlphaInterpolation.Text = "Threshold Alpha Blending";
this.chkAlphaInterpolation.UseVisualStyleBackColor = true;
//
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(112, 54);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(62, 13);
this.stLabel1.TabIndex = 2;
this.stLabel1.Text = "White Color";
//
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(277, 51);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(61, 13);
this.stLabel2.TabIndex = 4;
this.stLabel2.Text = "Black Color";
//
// whiteColorPB
//
this.whiteColorPB.BackColor = System.Drawing.Color.Black;
this.whiteColorPB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.whiteColorPB.Color = System.Drawing.Color.Empty;
this.whiteColorPB.DisplayAlphaSolid = true;
this.whiteColorPB.Location = new System.Drawing.Point(16, 36);
this.whiteColorPB.Name = "whiteColorPB";
this.whiteColorPB.Size = new System.Drawing.Size(90, 45);
this.whiteColorPB.TabIndex = 5;
this.whiteColorPB.Click += new System.EventHandler(this.ColorPB_Click);
//
// blackColorBP
//
this.blackColorBP.BackColor = System.Drawing.Color.Black;
this.blackColorBP.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.blackColorBP.Color = System.Drawing.Color.Empty;
this.blackColorBP.DisplayAlphaSolid = true;
this.blackColorBP.Location = new System.Drawing.Point(180, 36);
this.blackColorBP.Name = "blackColorBP";
this.blackColorBP.Size = new System.Drawing.Size(90, 45);
this.blackColorBP.TabIndex = 6;
this.blackColorBP.Click += new System.EventHandler(this.ColorPB_Click);
//
// tevColor1PB
//
this.tevColor1PB.BackColor = System.Drawing.Color.Black;
this.tevColor1PB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tevColor1PB.Color = System.Drawing.Color.Empty;
this.tevColor1PB.DisplayAlphaSolid = true;
this.tevColor1PB.Location = new System.Drawing.Point(16, 87);
this.tevColor1PB.Name = "tevColor1PB";
this.tevColor1PB.Size = new System.Drawing.Size(90, 45);
this.tevColor1PB.TabIndex = 12;
this.tevColor1PB.Click += new System.EventHandler(this.ColorPB_Click);
//
// stLabel5
//
this.stLabel5.AutoSize = true;
this.stLabel5.Location = new System.Drawing.Point(113, 105);
this.stLabel5.Name = "stLabel5";
this.stLabel5.Size = new System.Drawing.Size(62, 13);
this.stLabel5.TabIndex = 11;
this.stLabel5.Text = "Tev Color 1";
//
// tevColor2PB
//
this.tevColor2PB.BackColor = System.Drawing.Color.Black;
this.tevColor2PB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tevColor2PB.Color = System.Drawing.Color.Empty;
this.tevColor2PB.DisplayAlphaSolid = true;
this.tevColor2PB.Location = new System.Drawing.Point(180, 87);
this.tevColor2PB.Name = "tevColor2PB";
this.tevColor2PB.Size = new System.Drawing.Size(90, 45);
this.tevColor2PB.TabIndex = 14;
this.tevColor2PB.Click += new System.EventHandler(this.ColorPB_Click);
//
// stLabel6
//
this.stLabel6.AutoSize = true;
this.stLabel6.Location = new System.Drawing.Point(283, 105);
this.stLabel6.Name = "stLabel6";
this.stLabel6.Size = new System.Drawing.Size(62, 13);
this.stLabel6.TabIndex = 13;
this.stLabel6.Text = "Tev Color 2";
//
// tevColor4PB
//
this.tevColor4PB.BackColor = System.Drawing.Color.Black;
this.tevColor4PB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tevColor4PB.Color = System.Drawing.Color.Empty;
this.tevColor4PB.DisplayAlphaSolid = true;
this.tevColor4PB.Location = new System.Drawing.Point(180, 138);
this.tevColor4PB.Name = "tevColor4PB";
this.tevColor4PB.Size = new System.Drawing.Size(90, 45);
this.tevColor4PB.TabIndex = 18;
this.tevColor4PB.Click += new System.EventHandler(this.ColorPB_Click);
//
// tevColor3PB
//
this.tevColor3PB.BackColor = System.Drawing.Color.Black;
this.tevColor3PB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tevColor3PB.Color = System.Drawing.Color.Empty;
this.tevColor3PB.DisplayAlphaSolid = true;
this.tevColor3PB.Location = new System.Drawing.Point(16, 138);
this.tevColor3PB.Name = "tevColor3PB";
this.tevColor3PB.Size = new System.Drawing.Size(90, 45);
this.tevColor3PB.TabIndex = 16;
this.tevColor3PB.Click += new System.EventHandler(this.ColorPB_Click);
//
// stLabel7
//
this.stLabel7.AutoSize = true;
this.stLabel7.Location = new System.Drawing.Point(283, 154);
this.stLabel7.Name = "stLabel7";
this.stLabel7.Size = new System.Drawing.Size(62, 13);
this.stLabel7.TabIndex = 17;
this.stLabel7.Text = "Tev Color 4";
//
// stLabel8
//
this.stLabel8.AutoSize = true;
this.stLabel8.Location = new System.Drawing.Point(113, 154);
this.stLabel8.Name = "stLabel8";
this.stLabel8.Size = new System.Drawing.Size(62, 13);
this.stLabel8.TabIndex = 15;
this.stLabel8.Text = "Tev Color 3";
//
// PaneMatCTRColorEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.tevColor4PB);
this.Controls.Add(this.tevColor2PB);
this.Controls.Add(this.tevColor3PB);
this.Controls.Add(this.tevColor1PB);
this.Controls.Add(this.stLabel7);
this.Controls.Add(this.stLabel8);
this.Controls.Add(this.stLabel6);
this.Controls.Add(this.stLabel5);
this.Controls.Add(this.blackColorBP);
this.Controls.Add(this.whiteColorPB);
this.Controls.Add(this.stLabel2);
this.Controls.Add(this.stLabel1);
this.Controls.Add(this.chkAlphaInterpolation);
this.Name = "PaneMatCTRColorEditor";
this.Size = new System.Drawing.Size(414, 347);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Toolbox.Library.Forms.STCheckBox chkAlphaInterpolation;
private Toolbox.Library.Forms.STLabel stLabel1;
private Toolbox.Library.Forms.STLabel stLabel2;
private Toolbox.Library.Forms.ColorAlphaBox whiteColorPB;
private Toolbox.Library.Forms.ColorAlphaBox blackColorBP;
private Toolbox.Library.Forms.ColorAlphaBox tevColor1PB;
private Toolbox.Library.Forms.STLabel stLabel5;
private Toolbox.Library.Forms.ColorAlphaBox tevColor2PB;
private Toolbox.Library.Forms.STLabel stLabel6;
private Toolbox.Library.Forms.ColorAlphaBox tevColor4PB;
private Toolbox.Library.Forms.ColorAlphaBox tevColor3PB;
private Toolbox.Library.Forms.STLabel stLabel7;
private Toolbox.Library.Forms.STLabel stLabel8;
}
}

View File

@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Toolbox.Library.Forms;
namespace LayoutBXLYT.CTR
{
public partial class PaneMatCTRColorEditor : EditorPanelBase
{
private PaneEditor ParentEditor;
private Material ActiveMaterial;
public PaneMatCTRColorEditor()
{
InitializeComponent();
whiteColorPB.DisplayAlphaSolid = true;
blackColorBP.DisplayAlphaSolid = true;
}
public void LoadMaterial(Material material, PaneEditor paneEditor)
{
ActiveMaterial = material;
ParentEditor = paneEditor;
whiteColorPB.Color = material.WhiteColor.Color;
blackColorBP.Color = material.BlackColor.Color;
tevColor1PB.Color = material.TevConstantColors[0].Color;
tevColor2PB.Color = material.TevConstantColors[1].Color;
tevColor3PB.Color = material.TevConstantColors[2].Color;
tevColor4PB.Color = material.TevConstantColors[3].Color;
chkAlphaInterpolation.Bind(material, "AlphaInterpolation");
}
private STColorDialog colorDlg;
private bool dialogActive = false;
private void ColorPB_Click(object sender, EventArgs e)
{
if (dialogActive)
{
colorDlg.Focus();
return;
}
dialogActive = true;
if (sender is ColorAlphaBox)
colorDlg = new STColorDialog(((ColorAlphaBox)sender).Color);
colorDlg.FormClosed += delegate
{
dialogActive = false;
};
colorDlg.ColorChanged += delegate
{
whiteColorPB.Color = colorDlg.NewColor;
ActiveMaterial.WhiteColor.Color = colorDlg.NewColor;
//Apply to all selected panes
foreach (BasePane pane in ParentEditor.SelectedPanes)
{
var mat = pane.TryGetActiveMaterial() as CTR.Material;
if (mat != null)
{
if (sender == whiteColorPB)
mat.WhiteColor.Color = colorDlg.NewColor;
else if (sender == blackColorBP)
mat.BlackColor.Color = colorDlg.NewColor;
else if (sender == tevColor1PB)
mat.TevConstantColors[0].Color = colorDlg.NewColor;
else if (sender == tevColor2PB)
mat.TevConstantColors[1].Color = colorDlg.NewColor;
else if (sender == tevColor3PB)
mat.TevConstantColors[2].Color = colorDlg.NewColor;
else if (sender == tevColor4PB)
mat.TevConstantColors[3].Color = colorDlg.NewColor;
}
}
ParentEditor.PropertyChanged?.Invoke(sender, e);
};
colorDlg.Show();
}
}
}

View File

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

View File

@ -407,7 +407,11 @@ namespace LayoutBXLYT
ActiveMaterial.TextureMaps[SelectedIndex].WrapModeV = (WrapMode)wrapModeVCB.SelectedValue;
ActiveMaterial.TextureMaps[SelectedIndex].MaxFilterMode = (FilterMode)expandCB.SelectedValue;
ActiveMaterial.TextureMaps[SelectedIndex].MinFilterMode = (FilterMode)shrinkCB.SelectedValue;
Console.WriteLine("Updating wrap mode! " + ActiveMaterial.TextureMaps[SelectedIndex].WrapModeU);
}
ParentEditor.PropertyChanged?.Invoke(sender, e);
}
}

View File

@ -0,0 +1,493 @@
namespace LayoutBXLYT
{
partial class PaneMatRevBlending
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.stFlowLayoutPanel1 = new Toolbox.Library.Forms.STFlowLayoutPanel();
this.stDropDownPanel1 = new Toolbox.Library.Forms.STDropDownPanel();
this.presetsCB = new Toolbox.Library.Forms.STComboBox();
this.stDropDownPanel2 = new Toolbox.Library.Forms.STDropDownPanel();
this.alphaComparePanel = new Toolbox.Library.Forms.STPanel();
this.alphaSource1CB = new Toolbox.Library.Forms.STComboBox();
this.alphaValue1UD = new BarSlider.BarSlider();
this.stLabel2 = new Toolbox.Library.Forms.STLabel();
this.stLabel1 = new Toolbox.Library.Forms.STLabel();
this.chkAlphaDefaults = new Toolbox.Library.Forms.STCheckBox();
this.stDropDownPanel3 = new Toolbox.Library.Forms.STDropDownPanel();
this.colorBlendPanel = new Toolbox.Library.Forms.STPanel();
this.stCheckBox1 = new Toolbox.Library.Forms.STCheckBox();
this.colorBlendSrcCB = new Toolbox.Library.Forms.STComboBox();
this.stLabel6 = new Toolbox.Library.Forms.STLabel();
this.stLabel3 = new Toolbox.Library.Forms.STLabel();
this.colorBlendLogicCB = new Toolbox.Library.Forms.STComboBox();
this.colorBlendOpCB = new Toolbox.Library.Forms.STComboBox();
this.stLabel5 = new Toolbox.Library.Forms.STLabel();
this.stLabel4 = new Toolbox.Library.Forms.STLabel();
this.colorBlendDestCB = new Toolbox.Library.Forms.STComboBox();
this.chkColorBlendDefaults = new Toolbox.Library.Forms.STCheckBox();
this.alphaSource2CB = new Toolbox.Library.Forms.STComboBox();
this.alphaValue2UD = new BarSlider.BarSlider();
this.stLabel7 = new Toolbox.Library.Forms.STLabel();
this.stLabel8 = new Toolbox.Library.Forms.STLabel();
this.stFlowLayoutPanel1.SuspendLayout();
this.stDropDownPanel1.SuspendLayout();
this.stDropDownPanel2.SuspendLayout();
this.alphaComparePanel.SuspendLayout();
this.stDropDownPanel3.SuspendLayout();
this.colorBlendPanel.SuspendLayout();
this.SuspendLayout();
//
// stFlowLayoutPanel1
//
this.stFlowLayoutPanel1.Controls.Add(this.stDropDownPanel1);
this.stFlowLayoutPanel1.Controls.Add(this.stDropDownPanel2);
this.stFlowLayoutPanel1.Controls.Add(this.stDropDownPanel3);
this.stFlowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.stFlowLayoutPanel1.FixedHeight = false;
this.stFlowLayoutPanel1.FixedWidth = true;
this.stFlowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.stFlowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.stFlowLayoutPanel1.Name = "stFlowLayoutPanel1";
this.stFlowLayoutPanel1.Size = new System.Drawing.Size(378, 465);
this.stFlowLayoutPanel1.TabIndex = 0;
//
// stDropDownPanel1
//
this.stDropDownPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stDropDownPanel1.Controls.Add(this.presetsCB);
this.stDropDownPanel1.ExpandedHeight = 0;
this.stDropDownPanel1.IsExpanded = true;
this.stDropDownPanel1.Location = new System.Drawing.Point(0, 0);
this.stDropDownPanel1.Margin = new System.Windows.Forms.Padding(0);
this.stDropDownPanel1.Name = "stDropDownPanel1";
this.stDropDownPanel1.PanelName = "Presets";
this.stDropDownPanel1.PanelValueName = "";
this.stDropDownPanel1.SetIcon = null;
this.stDropDownPanel1.SetIconAlphaColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel1.SetIconColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel1.Size = new System.Drawing.Size(378, 56);
this.stDropDownPanel1.TabIndex = 0;
//
// presetsCB
//
this.presetsCB.BorderColor = System.Drawing.Color.Empty;
this.presetsCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.presetsCB.ButtonColor = System.Drawing.Color.Empty;
this.presetsCB.FormattingEnabled = true;
this.presetsCB.IsReadOnly = false;
this.presetsCB.Location = new System.Drawing.Point(70, 25);
this.presetsCB.Name = "presetsCB";
this.presetsCB.Size = new System.Drawing.Size(199, 21);
this.presetsCB.TabIndex = 1;
//
// stDropDownPanel2
//
this.stDropDownPanel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stDropDownPanel2.Controls.Add(this.alphaComparePanel);
this.stDropDownPanel2.Controls.Add(this.chkAlphaDefaults);
this.stDropDownPanel2.ExpandedHeight = 0;
this.stDropDownPanel2.IsExpanded = true;
this.stDropDownPanel2.Location = new System.Drawing.Point(0, 56);
this.stDropDownPanel2.Margin = new System.Windows.Forms.Padding(0);
this.stDropDownPanel2.Name = "stDropDownPanel2";
this.stDropDownPanel2.PanelName = "Alpha";
this.stDropDownPanel2.PanelValueName = "";
this.stDropDownPanel2.SetIcon = null;
this.stDropDownPanel2.SetIconAlphaColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel2.SetIconColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel2.Size = new System.Drawing.Size(378, 176);
this.stDropDownPanel2.TabIndex = 1;
//
// alphaComparePanel
//
this.alphaComparePanel.Controls.Add(this.alphaSource2CB);
this.alphaComparePanel.Controls.Add(this.alphaValue2UD);
this.alphaComparePanel.Controls.Add(this.stLabel7);
this.alphaComparePanel.Controls.Add(this.stLabel8);
this.alphaComparePanel.Controls.Add(this.alphaSource1CB);
this.alphaComparePanel.Controls.Add(this.alphaValue1UD);
this.alphaComparePanel.Controls.Add(this.stLabel2);
this.alphaComparePanel.Controls.Add(this.stLabel1);
this.alphaComparePanel.Location = new System.Drawing.Point(3, 51);
this.alphaComparePanel.Name = "alphaComparePanel";
this.alphaComparePanel.Size = new System.Drawing.Size(357, 122);
this.alphaComparePanel.TabIndex = 56;
//
// alphaSource1CB
//
this.alphaSource1CB.BorderColor = System.Drawing.Color.Empty;
this.alphaSource1CB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.alphaSource1CB.ButtonColor = System.Drawing.Color.Empty;
this.alphaSource1CB.FormattingEnabled = true;
this.alphaSource1CB.IsReadOnly = false;
this.alphaSource1CB.Location = new System.Drawing.Point(110, 10);
this.alphaSource1CB.Name = "alphaSource1CB";
this.alphaSource1CB.Size = new System.Drawing.Size(161, 21);
this.alphaSource1CB.TabIndex = 2;
this.alphaSource1CB.SelectedIndexChanged += new System.EventHandler(this.alphaSourcCB_SelectedIndexChanged);
//
// alphaValue1UD
//
this.alphaValue1UD.ActiveEditColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.alphaValue1UD.BarInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.alphaValue1UD.BarPenColorBottom = System.Drawing.Color.Empty;
this.alphaValue1UD.BarPenColorMiddle = System.Drawing.Color.Empty;
this.alphaValue1UD.BarPenColorTop = System.Drawing.Color.Empty;
this.alphaValue1UD.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.alphaValue1UD.DataType = null;
this.alphaValue1UD.DrawSemitransparentThumb = false;
this.alphaValue1UD.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.alphaValue1UD.ElapsedPenColorBottom = System.Drawing.Color.Empty;
this.alphaValue1UD.ElapsedPenColorMiddle = System.Drawing.Color.Empty;
this.alphaValue1UD.ElapsedPenColorTop = System.Drawing.Color.Empty;
this.alphaValue1UD.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.alphaValue1UD.IncrementAmount = 0.01F;
this.alphaValue1UD.InputName = "X";
this.alphaValue1UD.LargeChange = 5F;
this.alphaValue1UD.Location = new System.Drawing.Point(110, 37);
this.alphaValue1UD.Maximum = 300000F;
this.alphaValue1UD.Minimum = -300000F;
this.alphaValue1UD.Name = "alphaValue1UD";
this.alphaValue1UD.Precision = 0.01F;
this.alphaValue1UD.ScaleDivisions = 1;
this.alphaValue1UD.ScaleSubDivisions = 2;
this.alphaValue1UD.ShowDivisionsText = false;
this.alphaValue1UD.ShowSmallScale = false;
this.alphaValue1UD.Size = new System.Drawing.Size(107, 25);
this.alphaValue1UD.SmallChange = 0.01F;
this.alphaValue1UD.TabIndex = 53;
this.alphaValue1UD.Text = "barSlider2";
this.alphaValue1UD.ThumbInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.alphaValue1UD.ThumbPenColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.alphaValue1UD.ThumbRoundRectSize = new System.Drawing.Size(1, 1);
this.alphaValue1UD.ThumbSize = new System.Drawing.Size(1, 1);
this.alphaValue1UD.TickAdd = 0F;
this.alphaValue1UD.TickColor = System.Drawing.Color.White;
this.alphaValue1UD.TickDivide = 0F;
this.alphaValue1UD.TickStyle = System.Windows.Forms.TickStyle.None;
this.alphaValue1UD.UseInterlapsedBar = false;
this.alphaValue1UD.Value = 30F;
this.alphaValue1UD.ValueChanged += new System.EventHandler(this.alphaValueUD_ValueChanged);
//
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(7, 44);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(37, 13);
this.stLabel2.TabIndex = 55;
this.stLabel2.Text = "Value:";
//
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(9, 13);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(91, 13);
this.stLabel1.TabIndex = 54;
this.stLabel1.Text = "Compare Mode 1:";
//
// chkAlphaDefaults
//
this.chkAlphaDefaults.AutoSize = true;
this.chkAlphaDefaults.Location = new System.Drawing.Point(32, 28);
this.chkAlphaDefaults.Name = "chkAlphaDefaults";
this.chkAlphaDefaults.Size = new System.Drawing.Size(83, 17);
this.chkAlphaDefaults.TabIndex = 1;
this.chkAlphaDefaults.Text = "Use default:";
this.chkAlphaDefaults.UseVisualStyleBackColor = true;
this.chkAlphaDefaults.CheckedChanged += new System.EventHandler(this.chkAlphaDefaults_CheckedChanged);
//
// stDropDownPanel3
//
this.stDropDownPanel3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.stDropDownPanel3.Controls.Add(this.colorBlendPanel);
this.stDropDownPanel3.Controls.Add(this.chkColorBlendDefaults);
this.stDropDownPanel3.ExpandedHeight = 0;
this.stDropDownPanel3.IsExpanded = true;
this.stDropDownPanel3.Location = new System.Drawing.Point(0, 232);
this.stDropDownPanel3.Margin = new System.Windows.Forms.Padding(0);
this.stDropDownPanel3.Name = "stDropDownPanel3";
this.stDropDownPanel3.PanelName = "Color Blending";
this.stDropDownPanel3.PanelValueName = "";
this.stDropDownPanel3.SetIcon = null;
this.stDropDownPanel3.SetIconAlphaColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel3.SetIconColor = System.Drawing.SystemColors.Control;
this.stDropDownPanel3.Size = new System.Drawing.Size(378, 212);
this.stDropDownPanel3.TabIndex = 2;
//
// colorBlendPanel
//
this.colorBlendPanel.Controls.Add(this.stCheckBox1);
this.colorBlendPanel.Controls.Add(this.colorBlendSrcCB);
this.colorBlendPanel.Controls.Add(this.stLabel6);
this.colorBlendPanel.Controls.Add(this.stLabel3);
this.colorBlendPanel.Controls.Add(this.colorBlendLogicCB);
this.colorBlendPanel.Controls.Add(this.colorBlendOpCB);
this.colorBlendPanel.Controls.Add(this.stLabel5);
this.colorBlendPanel.Controls.Add(this.stLabel4);
this.colorBlendPanel.Controls.Add(this.colorBlendDestCB);
this.colorBlendPanel.Location = new System.Drawing.Point(3, 55);
this.colorBlendPanel.Name = "colorBlendPanel";
this.colorBlendPanel.Size = new System.Drawing.Size(357, 163);
this.colorBlendPanel.TabIndex = 64;
//
// stCheckBox1
//
this.stCheckBox1.AutoSize = true;
this.stCheckBox1.Location = new System.Drawing.Point(12, 24);
this.stCheckBox1.Name = "stCheckBox1";
this.stCheckBox1.Size = new System.Drawing.Size(61, 17);
this.stCheckBox1.TabIndex = 57;
this.stCheckBox1.Text = "Disable";
this.stCheckBox1.UseVisualStyleBackColor = true;
this.stCheckBox1.Click += new System.EventHandler(this.colorBlend_ValueChanged);
//
// colorBlendSrcCB
//
this.colorBlendSrcCB.BorderColor = System.Drawing.Color.Empty;
this.colorBlendSrcCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.colorBlendSrcCB.ButtonColor = System.Drawing.Color.Empty;
this.colorBlendSrcCB.FormattingEnabled = true;
this.colorBlendSrcCB.IsReadOnly = false;
this.colorBlendSrcCB.Location = new System.Drawing.Point(105, 45);
this.colorBlendSrcCB.Name = "colorBlendSrcCB";
this.colorBlendSrcCB.Size = new System.Drawing.Size(161, 21);
this.colorBlendSrcCB.TabIndex = 55;
this.colorBlendSrcCB.SelectedIndexChanged += new System.EventHandler(this.colorBlend_ValueChanged);
//
// stLabel6
//
this.stLabel6.AutoSize = true;
this.stLabel6.Location = new System.Drawing.Point(9, 129);
this.stLabel6.Name = "stLabel6";
this.stLabel6.Size = new System.Drawing.Size(93, 13);
this.stLabel6.TabIndex = 63;
this.stLabel6.Text = "Logical Operation:";
//
// stLabel3
//
this.stLabel3.AutoSize = true;
this.stLabel3.Location = new System.Drawing.Point(10, 48);
this.stLabel3.Name = "stLabel3";
this.stLabel3.Size = new System.Drawing.Size(44, 13);
this.stLabel3.TabIndex = 56;
this.stLabel3.Text = "Source:";
//
// colorBlendLogicCB
//
this.colorBlendLogicCB.BorderColor = System.Drawing.Color.Empty;
this.colorBlendLogicCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.colorBlendLogicCB.ButtonColor = System.Drawing.Color.Empty;
this.colorBlendLogicCB.FormattingEnabled = true;
this.colorBlendLogicCB.IsReadOnly = false;
this.colorBlendLogicCB.Location = new System.Drawing.Point(104, 126);
this.colorBlendLogicCB.Name = "colorBlendLogicCB";
this.colorBlendLogicCB.Size = new System.Drawing.Size(161, 21);
this.colorBlendLogicCB.TabIndex = 62;
this.colorBlendLogicCB.SelectedIndexChanged += new System.EventHandler(this.colorBlend_ValueChanged);
//
// colorBlendOpCB
//
this.colorBlendOpCB.BorderColor = System.Drawing.Color.Empty;
this.colorBlendOpCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.colorBlendOpCB.ButtonColor = System.Drawing.Color.Empty;
this.colorBlendOpCB.FormattingEnabled = true;
this.colorBlendOpCB.IsReadOnly = false;
this.colorBlendOpCB.Location = new System.Drawing.Point(104, 72);
this.colorBlendOpCB.Name = "colorBlendOpCB";
this.colorBlendOpCB.Size = new System.Drawing.Size(161, 21);
this.colorBlendOpCB.TabIndex = 58;
this.colorBlendOpCB.SelectedIndexChanged += new System.EventHandler(this.colorBlend_ValueChanged);
//
// stLabel5
//
this.stLabel5.AutoSize = true;
this.stLabel5.Location = new System.Drawing.Point(10, 102);
this.stLabel5.Name = "stLabel5";
this.stLabel5.Size = new System.Drawing.Size(63, 13);
this.stLabel5.TabIndex = 61;
this.stLabel5.Text = "Destination:";
//
// stLabel4
//
this.stLabel4.AutoSize = true;
this.stLabel4.Location = new System.Drawing.Point(9, 75);
this.stLabel4.Name = "stLabel4";
this.stLabel4.Size = new System.Drawing.Size(56, 13);
this.stLabel4.TabIndex = 59;
this.stLabel4.Text = "Operation:";
//
// colorBlendDestCB
//
this.colorBlendDestCB.BorderColor = System.Drawing.Color.Empty;
this.colorBlendDestCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.colorBlendDestCB.ButtonColor = System.Drawing.Color.Empty;
this.colorBlendDestCB.FormattingEnabled = true;
this.colorBlendDestCB.IsReadOnly = false;
this.colorBlendDestCB.Location = new System.Drawing.Point(105, 99);
this.colorBlendDestCB.Name = "colorBlendDestCB";
this.colorBlendDestCB.Size = new System.Drawing.Size(161, 21);
this.colorBlendDestCB.TabIndex = 60;
this.colorBlendDestCB.SelectedIndexChanged += new System.EventHandler(this.colorBlend_ValueChanged);
//
// chkColorBlendDefaults
//
this.chkColorBlendDefaults.AutoSize = true;
this.chkColorBlendDefaults.Location = new System.Drawing.Point(23, 32);
this.chkColorBlendDefaults.Name = "chkColorBlendDefaults";
this.chkColorBlendDefaults.Size = new System.Drawing.Size(83, 17);
this.chkColorBlendDefaults.TabIndex = 2;
this.chkColorBlendDefaults.Text = "Use default:";
this.chkColorBlendDefaults.UseVisualStyleBackColor = true;
this.chkColorBlendDefaults.CheckedChanged += new System.EventHandler(this.chkColorBlendDefaults_CheckedChanged);
//
// alphaSource2CB
//
this.alphaSource2CB.BorderColor = System.Drawing.Color.Empty;
this.alphaSource2CB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.alphaSource2CB.ButtonColor = System.Drawing.Color.Empty;
this.alphaSource2CB.FormattingEnabled = true;
this.alphaSource2CB.IsReadOnly = false;
this.alphaSource2CB.Location = new System.Drawing.Point(110, 68);
this.alphaSource2CB.Name = "alphaSource2CB";
this.alphaSource2CB.Size = new System.Drawing.Size(161, 21);
this.alphaSource2CB.TabIndex = 56;
//
// alphaValue2UD
//
this.alphaValue2UD.ActiveEditColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.alphaValue2UD.BarInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.alphaValue2UD.BarPenColorBottom = System.Drawing.Color.Empty;
this.alphaValue2UD.BarPenColorMiddle = System.Drawing.Color.Empty;
this.alphaValue2UD.BarPenColorTop = System.Drawing.Color.Empty;
this.alphaValue2UD.BorderRoundRectSize = new System.Drawing.Size(32, 32);
this.alphaValue2UD.DataType = null;
this.alphaValue2UD.DrawSemitransparentThumb = false;
this.alphaValue2UD.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.alphaValue2UD.ElapsedPenColorBottom = System.Drawing.Color.Empty;
this.alphaValue2UD.ElapsedPenColorMiddle = System.Drawing.Color.Empty;
this.alphaValue2UD.ElapsedPenColorTop = System.Drawing.Color.Empty;
this.alphaValue2UD.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F);
this.alphaValue2UD.IncrementAmount = 0.01F;
this.alphaValue2UD.InputName = "X";
this.alphaValue2UD.LargeChange = 5F;
this.alphaValue2UD.Location = new System.Drawing.Point(110, 95);
this.alphaValue2UD.Maximum = 300000F;
this.alphaValue2UD.Minimum = -300000F;
this.alphaValue2UD.Name = "alphaValue2UD";
this.alphaValue2UD.Precision = 0.01F;
this.alphaValue2UD.ScaleDivisions = 1;
this.alphaValue2UD.ScaleSubDivisions = 2;
this.alphaValue2UD.ShowDivisionsText = false;
this.alphaValue2UD.ShowSmallScale = false;
this.alphaValue2UD.Size = new System.Drawing.Size(107, 25);
this.alphaValue2UD.SmallChange = 0.01F;
this.alphaValue2UD.TabIndex = 57;
this.alphaValue2UD.Text = "barSlider2";
this.alphaValue2UD.ThumbInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.alphaValue2UD.ThumbPenColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.alphaValue2UD.ThumbRoundRectSize = new System.Drawing.Size(1, 1);
this.alphaValue2UD.ThumbSize = new System.Drawing.Size(1, 1);
this.alphaValue2UD.TickAdd = 0F;
this.alphaValue2UD.TickColor = System.Drawing.Color.White;
this.alphaValue2UD.TickDivide = 0F;
this.alphaValue2UD.TickStyle = System.Windows.Forms.TickStyle.None;
this.alphaValue2UD.UseInterlapsedBar = false;
this.alphaValue2UD.Value = 30F;
//
// stLabel7
//
this.stLabel7.AutoSize = true;
this.stLabel7.Location = new System.Drawing.Point(7, 95);
this.stLabel7.Name = "stLabel7";
this.stLabel7.Size = new System.Drawing.Size(37, 13);
this.stLabel7.TabIndex = 59;
this.stLabel7.Text = "Value:";
//
// stLabel8
//
this.stLabel8.AutoSize = true;
this.stLabel8.Location = new System.Drawing.Point(9, 71);
this.stLabel8.Name = "stLabel8";
this.stLabel8.Size = new System.Drawing.Size(91, 13);
this.stLabel8.TabIndex = 58;
this.stLabel8.Text = "Compare Mode 2:";
//
// PaneMatRevBlending
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stFlowLayoutPanel1);
this.Name = "PaneMatRevBlending";
this.Size = new System.Drawing.Size(378, 465);
this.stFlowLayoutPanel1.ResumeLayout(false);
this.stDropDownPanel1.ResumeLayout(false);
this.stDropDownPanel1.PerformLayout();
this.stDropDownPanel2.ResumeLayout(false);
this.stDropDownPanel2.PerformLayout();
this.alphaComparePanel.ResumeLayout(false);
this.alphaComparePanel.PerformLayout();
this.stDropDownPanel3.ResumeLayout(false);
this.stDropDownPanel3.PerformLayout();
this.colorBlendPanel.ResumeLayout(false);
this.colorBlendPanel.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private Toolbox.Library.Forms.STFlowLayoutPanel stFlowLayoutPanel1;
private Toolbox.Library.Forms.STDropDownPanel stDropDownPanel1;
private Toolbox.Library.Forms.STComboBox presetsCB;
private Toolbox.Library.Forms.STDropDownPanel stDropDownPanel2;
private Toolbox.Library.Forms.STDropDownPanel stDropDownPanel3;
private Toolbox.Library.Forms.STComboBox alphaSource1CB;
private Toolbox.Library.Forms.STCheckBox chkAlphaDefaults;
private Toolbox.Library.Forms.STCheckBox chkColorBlendDefaults;
private BarSlider.BarSlider alphaValue1UD;
private Toolbox.Library.Forms.STComboBox colorBlendSrcCB;
private Toolbox.Library.Forms.STLabel stLabel2;
private Toolbox.Library.Forms.STLabel stLabel1;
private Toolbox.Library.Forms.STLabel stLabel5;
private Toolbox.Library.Forms.STComboBox colorBlendDestCB;
private Toolbox.Library.Forms.STLabel stLabel4;
private Toolbox.Library.Forms.STCheckBox stCheckBox1;
private Toolbox.Library.Forms.STLabel stLabel3;
private Toolbox.Library.Forms.STLabel stLabel6;
private Toolbox.Library.Forms.STComboBox colorBlendLogicCB;
private Toolbox.Library.Forms.STComboBox colorBlendOpCB;
private Toolbox.Library.Forms.STPanel colorBlendPanel;
private Toolbox.Library.Forms.STPanel alphaComparePanel;
private Toolbox.Library.Forms.STComboBox alphaSource2CB;
private BarSlider.BarSlider alphaValue2UD;
private Toolbox.Library.Forms.STLabel stLabel7;
private Toolbox.Library.Forms.STLabel stLabel8;
}
}

View File

@ -0,0 +1,200 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LayoutBXLYT
{
public partial class PaneMatRevBlending : EditorPanelBase
{
private bool loaded = false;
private PaneEditor ParentEditor;
private BxlytMaterial ActiveMaterial;
public PaneMatRevBlending()
{
InitializeComponent();
presetsCB.Items.Add("Default (Translucent)");
presetsCB.SelectedIndex = 0;
stDropDownPanel1.ResetColors();
stDropDownPanel2.ResetColors();
stDropDownPanel3.ResetColors();
}
public void LoadMaterial(Revolution.Material material, PaneEditor paneEditor)
{
loaded = false;
ActiveMaterial = material;
ParentEditor = paneEditor;
chkAlphaDefaults.Checked = !material.EnableAlphaCompare;
chkColorBlendDefaults.Checked = !material.EnableBlend;
SetupDefaults();
ReloadBlendValues(material);
alphaValue1UD.Maximum = 255;
alphaValue2UD.Maximum = 255;
alphaValue1UD.Minimum = 0;
alphaValue2UD.Minimum = 0;
alphaValue1UD.Value = 255;
alphaValue2UD.Value = 255;
loaded = true;
}
private void ReloadBlendValues(BxlytMaterial material)
{
ReloadAlphaCompareValues(material);
ReloadColorValues(material);
}
private void ReloadAlphaCompareValues(BxlytMaterial material)
{
loaded = false;
if (material.AlphaCompare != null && material.EnableAlphaCompare)
{
var alphaCompare = (Revolution.AlphaCompare)material.AlphaCompare;
alphaSource1CB.Bind(typeof(GfxAlphaFunction), alphaCompare, "Comp0");
alphaSource2CB.Bind(typeof(GfxAlphaFunction), alphaCompare, "Comp1");
alphaValue1UD.Value = alphaCompare.Ref0;
alphaValue2UD.Value = alphaCompare.Ref1;
alphaSource1CB.SelectedItem = material.AlphaCompare.CompareMode;
}
loaded = true;
}
private void ReloadColorValues(BxlytMaterial material)
{
loaded = false;
if (material.BlendMode != null && material.EnableBlend)
{
colorBlendSrcCB.Bind(typeof(BxlytBlendMode.GX2BlendFactor), material.BlendMode, "SourceFactor");
colorBlendDestCB.Bind(typeof(BxlytBlendMode.GX2BlendFactor), material.BlendMode, "DestFactor");
colorBlendOpCB.Bind(typeof(BxlytBlendMode.GX2BlendOp), material.BlendMode, "BlendOp");
colorBlendLogicCB.Bind(typeof(BxlytBlendMode.GX2LogicOp), material.BlendMode, "LogicOp");
colorBlendSrcCB.SelectedItem = material.BlendMode.SourceFactor;
colorBlendDestCB.SelectedItem = material.BlendMode.DestFactor;
colorBlendOpCB.SelectedItem = material.BlendMode.BlendOp;
colorBlendLogicCB.SelectedItem = material.BlendMode.LogicOp;
}
loaded = true;
}
private void SetupDefaults()
{
//Setup default values
alphaSource1CB.ResetBind();
alphaSource1CB.Items.Add("Always");
alphaSource1CB.SelectedIndex = 0;
alphaValue1UD.Value = 0;
colorBlendSrcCB.ResetBind();
colorBlendSrcCB.Items.Add(BxlytBlendMode.GX2BlendFactor.SourceAlpha);
colorBlendSrcCB.SelectedIndex = 0;
colorBlendDestCB.ResetBind();
colorBlendDestCB.Items.Add(BxlytBlendMode.GX2BlendFactor.SourceInvAlpha);
colorBlendDestCB.SelectedIndex = 0;
colorBlendOpCB.ResetBind();
colorBlendOpCB.Items.Add(BxlytBlendMode.GX2BlendOp.Add);
colorBlendOpCB.SelectedIndex = 0;
colorBlendLogicCB.ResetBind();
colorBlendLogicCB.Items.Add(BxlytBlendMode.GX2LogicOp.Disable);
colorBlendLogicCB.SelectedIndex = 0;
alphaSource1CB.SelectedIndex = 0;
}
private void chkAlphaDefaults_CheckedChanged(object sender, EventArgs e)
{
if (chkAlphaDefaults.Checked)
{
alphaComparePanel.Hide();
stDropDownPanel2.Height -= alphaComparePanel.Height;
}
else
{
alphaComparePanel.Show();
stDropDownPanel2.Height += alphaComparePanel.Height;
if (ActiveMaterial.AlphaCompare == null && loaded)
ActiveMaterial.AlphaCompare = new BxlytAlphaCompare();
}
ActiveMaterial.EnableAlphaCompare = !chkAlphaDefaults.Checked;
if (loaded)
{
ReloadAlphaCompareValues(ActiveMaterial);
ParentEditor.PropertyChanged?.Invoke(sender, e);
}
}
private void chkColorBlendDefaults_CheckedChanged(object sender, EventArgs e)
{
if (chkColorBlendDefaults.Checked)
{
colorBlendPanel.Hide();
stDropDownPanel3.Height -= colorBlendPanel.Height;
}
else
{
colorBlendPanel.Show();
stDropDownPanel3.Height += colorBlendPanel.Height;
if (ActiveMaterial.BlendMode == null && loaded)
ActiveMaterial.BlendMode = new BxlytBlendMode();
}
ActiveMaterial.EnableBlend = !chkColorBlendDefaults.Checked;
if (loaded)
{
ReloadColorValues(ActiveMaterial);
ParentEditor.PropertyChanged?.Invoke(sender, e);
}
}
private void alphaSourcCB_SelectedIndexChanged(object sender, EventArgs e) {
if (!loaded || ActiveMaterial.AlphaCompare == null || !ActiveMaterial.EnableAlphaCompare)
return;
ActiveMaterial.AlphaCompare.CompareMode = (GfxAlphaFunction)alphaSource1CB.SelectedItem;
ParentEditor.PropertyChanged?.Invoke(sender, e);
}
private void alphaValueUD_ValueChanged(object sender, EventArgs e) {
if (!loaded || ActiveMaterial.AlphaCompare == null || !ActiveMaterial.EnableAlphaCompare)
return;
ActiveMaterial.AlphaCompare.Value = alphaValue1UD.Value;
ParentEditor.PropertyChanged?.Invoke(sender, e);
}
private void colorBlend_ValueChanged(object sender, EventArgs e) {
if (!loaded || ActiveMaterial.BlendMode == null || !ActiveMaterial.EnableBlend)
return;
ActiveMaterial.BlendMode.SourceFactor = (BxlytBlendMode.GX2BlendFactor)colorBlendSrcCB.SelectedItem;
ActiveMaterial.BlendMode.DestFactor = (BxlytBlendMode.GX2BlendFactor)colorBlendDestCB.SelectedItem;
ActiveMaterial.BlendMode.BlendOp = (BxlytBlendMode.GX2BlendOp)colorBlendOpCB.SelectedItem;
ActiveMaterial.BlendMode.LogicOp = (BxlytBlendMode.GX2LogicOp)colorBlendLogicCB.SelectedItem;
ParentEditor.PropertyChanged?.Invoke(sender, e);
}
}
}

View File

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

View File

@ -0,0 +1,276 @@
namespace LayoutBXLYT
{
partial class PaneMatRevColorEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.chkAlphaInterpolation = new Toolbox.Library.Forms.STCheckBox();
this.stLabel1 = new Toolbox.Library.Forms.STLabel();
this.stLabel2 = new Toolbox.Library.Forms.STLabel();
this.whiteColorPB = new Toolbox.Library.Forms.ColorAlphaBox();
this.blackColorBP = new Toolbox.Library.Forms.ColorAlphaBox();
this.colorReg3PB = new Toolbox.Library.Forms.ColorAlphaBox();
this.stLabel3 = new Toolbox.Library.Forms.STLabel();
this.materialColorPB = new Toolbox.Library.Forms.ColorAlphaBox();
this.stLabel4 = new Toolbox.Library.Forms.STLabel();
this.tevColor1PB = new Toolbox.Library.Forms.ColorAlphaBox();
this.stLabel5 = new Toolbox.Library.Forms.STLabel();
this.tevColor2PB = new Toolbox.Library.Forms.ColorAlphaBox();
this.stLabel6 = new Toolbox.Library.Forms.STLabel();
this.tevColor4PB = new Toolbox.Library.Forms.ColorAlphaBox();
this.tevColor3PB = new Toolbox.Library.Forms.ColorAlphaBox();
this.stLabel7 = new Toolbox.Library.Forms.STLabel();
this.stLabel8 = new Toolbox.Library.Forms.STLabel();
this.SuspendLayout();
//
// chkAlphaInterpolation
//
this.chkAlphaInterpolation.AutoSize = true;
this.chkAlphaInterpolation.Location = new System.Drawing.Point(16, 13);
this.chkAlphaInterpolation.Name = "chkAlphaInterpolation";
this.chkAlphaInterpolation.Size = new System.Drawing.Size(147, 17);
this.chkAlphaInterpolation.TabIndex = 0;
this.chkAlphaInterpolation.Text = "Threshold Alpha Blending";
this.chkAlphaInterpolation.UseVisualStyleBackColor = true;
//
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(112, 54);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(62, 13);
this.stLabel1.TabIndex = 2;
this.stLabel1.Text = "White Color";
//
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(113, 102);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(61, 13);
this.stLabel2.TabIndex = 4;
this.stLabel2.Text = "Black Color";
//
// whiteColorPB
//
this.whiteColorPB.BackColor = System.Drawing.Color.Black;
this.whiteColorPB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.whiteColorPB.Color = System.Drawing.Color.Empty;
this.whiteColorPB.DisplayAlphaSolid = true;
this.whiteColorPB.Location = new System.Drawing.Point(16, 36);
this.whiteColorPB.Name = "whiteColorPB";
this.whiteColorPB.Size = new System.Drawing.Size(90, 45);
this.whiteColorPB.TabIndex = 5;
this.whiteColorPB.Click += new System.EventHandler(this.ColorPB_Click);
//
// blackColorBP
//
this.blackColorBP.BackColor = System.Drawing.Color.Black;
this.blackColorBP.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.blackColorBP.Color = System.Drawing.Color.Empty;
this.blackColorBP.DisplayAlphaSolid = true;
this.blackColorBP.Location = new System.Drawing.Point(16, 87);
this.blackColorBP.Name = "blackColorBP";
this.blackColorBP.Size = new System.Drawing.Size(90, 45);
this.blackColorBP.TabIndex = 6;
this.blackColorBP.Click += new System.EventHandler(this.ColorPB_Click);
//
// colorReg3PB
//
this.colorReg3PB.BackColor = System.Drawing.Color.Black;
this.colorReg3PB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.colorReg3PB.Color = System.Drawing.Color.Empty;
this.colorReg3PB.DisplayAlphaSolid = true;
this.colorReg3PB.Location = new System.Drawing.Point(180, 36);
this.colorReg3PB.Name = "colorReg3PB";
this.colorReg3PB.Size = new System.Drawing.Size(90, 45);
this.colorReg3PB.TabIndex = 8;
this.colorReg3PB.Click += new System.EventHandler(this.ColorPB_Click);
//
// stLabel3
//
this.stLabel3.AutoSize = true;
this.stLabel3.Location = new System.Drawing.Point(283, 54);
this.stLabel3.Name = "stLabel3";
this.stLabel3.Size = new System.Drawing.Size(82, 13);
this.stLabel3.TabIndex = 7;
this.stLabel3.Text = "Color Register 3";
//
// materialColorPB
//
this.materialColorPB.BackColor = System.Drawing.Color.Black;
this.materialColorPB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.materialColorPB.Color = System.Drawing.Color.Empty;
this.materialColorPB.DisplayAlphaSolid = true;
this.materialColorPB.Location = new System.Drawing.Point(180, 87);
this.materialColorPB.Name = "materialColorPB";
this.materialColorPB.Size = new System.Drawing.Size(90, 45);
this.materialColorPB.TabIndex = 10;
this.materialColorPB.Click += new System.EventHandler(this.ColorPB_Click);
//
// stLabel4
//
this.stLabel4.AutoSize = true;
this.stLabel4.Location = new System.Drawing.Point(283, 102);
this.stLabel4.Name = "stLabel4";
this.stLabel4.Size = new System.Drawing.Size(71, 13);
this.stLabel4.TabIndex = 9;
this.stLabel4.Text = "Material Color";
//
// tevColor1PB
//
this.tevColor1PB.BackColor = System.Drawing.Color.Black;
this.tevColor1PB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tevColor1PB.Color = System.Drawing.Color.Empty;
this.tevColor1PB.DisplayAlphaSolid = true;
this.tevColor1PB.Location = new System.Drawing.Point(16, 138);
this.tevColor1PB.Name = "tevColor1PB";
this.tevColor1PB.Size = new System.Drawing.Size(90, 45);
this.tevColor1PB.TabIndex = 12;
this.tevColor1PB.Click += new System.EventHandler(this.ColorPB_Click);
//
// stLabel5
//
this.stLabel5.AutoSize = true;
this.stLabel5.Location = new System.Drawing.Point(113, 156);
this.stLabel5.Name = "stLabel5";
this.stLabel5.Size = new System.Drawing.Size(62, 13);
this.stLabel5.TabIndex = 11;
this.stLabel5.Text = "Tev Color 1";
//
// tevColor2PB
//
this.tevColor2PB.BackColor = System.Drawing.Color.Black;
this.tevColor2PB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tevColor2PB.Color = System.Drawing.Color.Empty;
this.tevColor2PB.DisplayAlphaSolid = true;
this.tevColor2PB.Location = new System.Drawing.Point(180, 138);
this.tevColor2PB.Name = "tevColor2PB";
this.tevColor2PB.Size = new System.Drawing.Size(90, 45);
this.tevColor2PB.TabIndex = 14;
this.tevColor2PB.Click += new System.EventHandler(this.ColorPB_Click);
//
// stLabel6
//
this.stLabel6.AutoSize = true;
this.stLabel6.Location = new System.Drawing.Point(283, 156);
this.stLabel6.Name = "stLabel6";
this.stLabel6.Size = new System.Drawing.Size(62, 13);
this.stLabel6.TabIndex = 13;
this.stLabel6.Text = "Tev Color 2";
//
// tevColor4PB
//
this.tevColor4PB.BackColor = System.Drawing.Color.Black;
this.tevColor4PB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tevColor4PB.Color = System.Drawing.Color.Empty;
this.tevColor4PB.DisplayAlphaSolid = true;
this.tevColor4PB.Location = new System.Drawing.Point(180, 189);
this.tevColor4PB.Name = "tevColor4PB";
this.tevColor4PB.Size = new System.Drawing.Size(90, 45);
this.tevColor4PB.TabIndex = 18;
this.tevColor4PB.Click += new System.EventHandler(this.ColorPB_Click);
//
// tevColor3PB
//
this.tevColor3PB.BackColor = System.Drawing.Color.Black;
this.tevColor3PB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tevColor3PB.Color = System.Drawing.Color.Empty;
this.tevColor3PB.DisplayAlphaSolid = true;
this.tevColor3PB.Location = new System.Drawing.Point(16, 189);
this.tevColor3PB.Name = "tevColor3PB";
this.tevColor3PB.Size = new System.Drawing.Size(90, 45);
this.tevColor3PB.TabIndex = 16;
this.tevColor3PB.Click += new System.EventHandler(this.ColorPB_Click);
//
// stLabel7
//
this.stLabel7.AutoSize = true;
this.stLabel7.Location = new System.Drawing.Point(283, 205);
this.stLabel7.Name = "stLabel7";
this.stLabel7.Size = new System.Drawing.Size(62, 13);
this.stLabel7.TabIndex = 17;
this.stLabel7.Text = "Tev Color 4";
//
// stLabel8
//
this.stLabel8.AutoSize = true;
this.stLabel8.Location = new System.Drawing.Point(113, 205);
this.stLabel8.Name = "stLabel8";
this.stLabel8.Size = new System.Drawing.Size(62, 13);
this.stLabel8.TabIndex = 15;
this.stLabel8.Text = "Tev Color 3";
//
// PaneMatRevColorEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.tevColor4PB);
this.Controls.Add(this.tevColor2PB);
this.Controls.Add(this.tevColor3PB);
this.Controls.Add(this.tevColor1PB);
this.Controls.Add(this.stLabel7);
this.Controls.Add(this.stLabel8);
this.Controls.Add(this.stLabel6);
this.Controls.Add(this.materialColorPB);
this.Controls.Add(this.stLabel5);
this.Controls.Add(this.colorReg3PB);
this.Controls.Add(this.stLabel4);
this.Controls.Add(this.blackColorBP);
this.Controls.Add(this.stLabel3);
this.Controls.Add(this.whiteColorPB);
this.Controls.Add(this.stLabel2);
this.Controls.Add(this.stLabel1);
this.Controls.Add(this.chkAlphaInterpolation);
this.Name = "PaneMatRevColorEditor";
this.Size = new System.Drawing.Size(414, 347);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Toolbox.Library.Forms.STCheckBox chkAlphaInterpolation;
private Toolbox.Library.Forms.STLabel stLabel1;
private Toolbox.Library.Forms.STLabel stLabel2;
private Toolbox.Library.Forms.ColorAlphaBox whiteColorPB;
private Toolbox.Library.Forms.ColorAlphaBox blackColorBP;
private Toolbox.Library.Forms.ColorAlphaBox colorReg3PB;
private Toolbox.Library.Forms.STLabel stLabel3;
private Toolbox.Library.Forms.ColorAlphaBox materialColorPB;
private Toolbox.Library.Forms.STLabel stLabel4;
private Toolbox.Library.Forms.ColorAlphaBox tevColor1PB;
private Toolbox.Library.Forms.STLabel stLabel5;
private Toolbox.Library.Forms.ColorAlphaBox tevColor2PB;
private Toolbox.Library.Forms.STLabel stLabel6;
private Toolbox.Library.Forms.ColorAlphaBox tevColor4PB;
private Toolbox.Library.Forms.ColorAlphaBox tevColor3PB;
private Toolbox.Library.Forms.STLabel stLabel7;
private Toolbox.Library.Forms.STLabel stLabel8;
}
}

View File

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Toolbox.Library.Forms;
using LayoutBXLYT.Revolution;
namespace LayoutBXLYT
{
public partial class PaneMatRevColorEditor : EditorPanelBase
{
private PaneEditor ParentEditor;
private Material ActiveMaterial;
public PaneMatRevColorEditor()
{
InitializeComponent();
whiteColorPB.DisplayAlphaSolid = true;
blackColorBP.DisplayAlphaSolid = true;
}
public void LoadMaterial(Material material, PaneEditor paneEditor)
{
ActiveMaterial = material;
ParentEditor = paneEditor;
whiteColorPB.Color = material.WhiteColor.Color;
blackColorBP.Color = material.BlackColor.Color;
materialColorPB.Color = material.MatColor.Color;
colorReg3PB.Color = material.ColorRegister3.Color;
tevColor1PB.Color = material.TevColor1.Color;
tevColor2PB.Color = material.TevColor2.Color;
tevColor3PB.Color = material.TevColor3.Color;
tevColor4PB.Color = material.TevColor4.Color;
chkAlphaInterpolation.Bind(material, "AlphaInterpolation");
}
private STColorDialog colorDlg;
private bool dialogActive = false;
private void ColorPB_Click(object sender, EventArgs e)
{
if (dialogActive)
{
colorDlg.Focus();
return;
}
dialogActive = true;
if (sender is ColorAlphaBox)
colorDlg = new STColorDialog(((ColorAlphaBox)sender).Color);
colorDlg.FormClosed += delegate
{
dialogActive = false;
};
colorDlg.ColorChanged += delegate
{
whiteColorPB.Color = colorDlg.NewColor;
ActiveMaterial.WhiteColor.Color = colorDlg.NewColor;
//Apply to all selected panes
foreach (BasePane pane in ParentEditor.SelectedPanes)
{
var mat = pane.TryGetActiveMaterial() as Revolution.Material;
if (mat != null)
{
if (sender == whiteColorPB)
mat.WhiteColor.Color = colorDlg.NewColor;
else if (sender == blackColorBP)
mat.BlackColor.Color = colorDlg.NewColor;
else if (sender == materialColorPB)
mat.MatColor.Color = colorDlg.NewColor;
else if (sender == colorReg3PB)
mat.ColorRegister3.Color = colorDlg.NewColor;
else if (sender == tevColor1PB)
mat.TevColor1.Color = colorDlg.NewColor;
else if (sender == tevColor2PB)
mat.TevColor2.Color = colorDlg.NewColor;
else if (sender == tevColor3PB)
mat.TevColor3.Color = colorDlg.NewColor;
else if (sender == tevColor4PB)
mat.TevColor4.Color = colorDlg.NewColor;
}
}
ParentEditor.PropertyChanged?.Invoke(sender, e);
};
colorDlg.Show();
}
}
}

View File

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

View File

@ -0,0 +1,89 @@
namespace LayoutBXLYT.Revolution
{
partial class PaneMatRevTevEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.stPropertyGrid1 = new Toolbox.Library.Forms.STPropertyGrid();
this.tevStageCB = new Toolbox.Library.Forms.STComboBox();
this.stageCounterLbl = new Toolbox.Library.Forms.STLabel();
this.SuspendLayout();
//
// stPropertyGrid1
//
this.stPropertyGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stPropertyGrid1.AutoScroll = true;
this.stPropertyGrid1.Location = new System.Drawing.Point(0, 42);
this.stPropertyGrid1.Name = "stPropertyGrid1";
this.stPropertyGrid1.ShowHintDisplay = false;
this.stPropertyGrid1.Size = new System.Drawing.Size(421, 346);
this.stPropertyGrid1.TabIndex = 0;
//
// tevStageCB
//
this.tevStageCB.BorderColor = System.Drawing.Color.Empty;
this.tevStageCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.tevStageCB.ButtonColor = System.Drawing.Color.Empty;
this.tevStageCB.FormattingEnabled = true;
this.tevStageCB.IsReadOnly = false;
this.tevStageCB.Location = new System.Drawing.Point(117, 12);
this.tevStageCB.Name = "tevStageCB";
this.tevStageCB.Size = new System.Drawing.Size(121, 21);
this.tevStageCB.TabIndex = 1;
this.tevStageCB.SelectedIndexChanged += new System.EventHandler(this.tevStageCB_SelectedIndexChanged);
//
// stageCounterLbl
//
this.stageCounterLbl.AutoSize = true;
this.stageCounterLbl.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.stageCounterLbl.Location = new System.Drawing.Point(12, 11);
this.stageCounterLbl.Name = "stageCounterLbl";
this.stageCounterLbl.Size = new System.Drawing.Size(87, 18);
this.stageCounterLbl.TabIndex = 2;
this.stageCounterLbl.Text = "Stage 0 of 5";
//
// PaneMatRevTevEditor
//
this.Controls.Add(this.stageCounterLbl);
this.Controls.Add(this.tevStageCB);
this.Controls.Add(this.stPropertyGrid1);
this.Name = "PaneMatRevTevEditor";
this.Size = new System.Drawing.Size(421, 391);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Toolbox.Library.Forms.STPropertyGrid stPropertyGrid1;
private Toolbox.Library.Forms.STComboBox tevStageCB;
private Toolbox.Library.Forms.STLabel stageCounterLbl;
}
}

View File

@ -0,0 +1,61 @@
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 LayoutBXLYT.Revolution;
namespace LayoutBXLYT.Revolution
{
public partial class PaneMatRevTevEditor : EditorPanelBase
{
private PaneEditor ParentEditor;
private Material ActiveMaterial;
private bool loaded = false;
public PaneMatRevTevEditor()
{
InitializeComponent();
}
public void LoadMaterial(Material material, PaneEditor paneEditor)
{
ParentEditor = paneEditor;
ActiveMaterial = material;
tevStageCB.Items.Clear();
stPropertyGrid1.LoadProperty(null);
stageCounterLbl.Text = $"Stage 0 of {material.TevStages.Length}";
for (int i = 0; i < material.TevStages.Length; i++)
tevStageCB.Items.Add($"Stage[[{i}]");
if (tevStageCB.Items.Count > 0)
tevStageCB.SelectedIndex = 0;
}
private void tevStageCB_SelectedIndexChanged(object sender, EventArgs e) {
if (tevStageCB.SelectedIndex == -1)
return;
int index = tevStageCB.SelectedIndex;
stageCounterLbl.Text = $"Stage {index + 1} of {ActiveMaterial.TevStages.Length}";
LoadTevStage((TevStage)ActiveMaterial.TevStages[index]);
}
private void LoadTevStage(TevStage stage) {
stPropertyGrid1.LoadProperty(stage, OnPropertyChanged);
}
private void OnPropertyChanged() {
ActiveMaterial.Shader.Compile();
ParentEditor.PropertyChanged?.Invoke(EventArgs.Empty, null);
}
}
}

View File

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

View File

@ -0,0 +1,67 @@
namespace LayoutBXLYT
{
partial class PaneMatRevTevSwapTableEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.stFlowLayoutPanel1 = new Toolbox.Library.Forms.STFlowLayoutPanel();
this.SuspendLayout();
//
// stFlowLayoutPanel1
//
this.stFlowLayoutPanel1.AutoScroll = true;
this.stFlowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.stFlowLayoutPanel1.FixedHeight = false;
this.stFlowLayoutPanel1.FixedWidth = true;
this.stFlowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.stFlowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.stFlowLayoutPanel1.Name = "stFlowLayoutPanel1";
this.stFlowLayoutPanel1.Size = new System.Drawing.Size(451, 470);
this.stFlowLayoutPanel1.TabIndex = 0;
//
// PaneMatRevTevSwapTableEditor
//
this.Controls.Add(this.stFlowLayoutPanel1);
this.Name = "PaneMatRevTevSwapTableEditor";
this.Size = new System.Drawing.Size(451, 470);
this.ResumeLayout(false);
}
#endregion
private Toolbox.Library.Forms.STFlowLayoutPanel stFlowLayoutPanel1;
private Toolbox.Library.Forms.STComboBox swap0AlphaCB;
private Toolbox.Library.Forms.STComboBox swap0BlueCB;
private Toolbox.Library.Forms.STComboBox swap0GreenCB;
private Toolbox.Library.Forms.STLabel stLabel3;
private Toolbox.Library.Forms.STLabel stLabel4;
private Toolbox.Library.Forms.STLabel stLabel2;
private Toolbox.Library.Forms.STLabel stLabel1;
private Toolbox.Library.Forms.STComboBox swap0RedCB;
}
}

View File

@ -0,0 +1,60 @@
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;
using LayoutBXLYT.Revolution;
namespace LayoutBXLYT
{
public partial class PaneMatRevTevSwapTableEditor : EditorPanelBase
{
private PaneEditor ParentEditor;
private BxlytMaterial ActiveMaterial;
public SwapTableEntryControl[] SwapControls;
public PaneMatRevTevSwapTableEditor()
{
InitializeComponent();
SwapControls = new SwapTableEntryControl[4];
for (int i = 0; i < 4; i++)
{
SwapControls[i] = new SwapTableEntryControl(new SwapMode());
SwapControls[i].Dock = DockStyle.Fill;
var stDropDownPanel1 = new STDropDownPanel();
stDropDownPanel1.PanelName = $"SwapMode {i}";
stDropDownPanel1.Height = SwapControls[i].Height;
stDropDownPanel1.Controls.Add(SwapControls[i]);
stFlowLayoutPanel1.Controls.Add(stDropDownPanel1);
}
}
public void LoadMaterial(Revolution.Material material, PaneEditor paneEditor)
{
ParentEditor = paneEditor;
ActiveMaterial = material;
if (material.TevSwapModeTable != null)
{
var swapModes = material.TevSwapModeTable.SwapModes;
//Note these are always 4 in length for RGBA
for (int i = 0; i < swapModes?.Length; i++) {
SwapControls[i].LoadSwapMode(swapModes[i]);
}
}
}
private void CreatePanel(string name, int index, SwapMode swapMode)
{
}
}
}

View File

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

View File

@ -0,0 +1,197 @@
namespace LayoutBXLYT
{
partial class SwapTableEntryControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.stLabel1 = new Toolbox.Library.Forms.STLabel();
this.swapRedCB = new Toolbox.Library.Forms.STComboBox();
this.stPanel1 = new Toolbox.Library.Forms.STPanel();
this.stPanel2 = new Toolbox.Library.Forms.STPanel();
this.swapGreenCB = new Toolbox.Library.Forms.STComboBox();
this.stLabel2 = new Toolbox.Library.Forms.STLabel();
this.stPanel3 = new Toolbox.Library.Forms.STPanel();
this.stPanel4 = new Toolbox.Library.Forms.STPanel();
this.swapAlphaCB = new Toolbox.Library.Forms.STComboBox();
this.stLabel3 = new Toolbox.Library.Forms.STLabel();
this.swapBlueCB = new Toolbox.Library.Forms.STComboBox();
this.stLabel4 = new Toolbox.Library.Forms.STLabel();
this.SuspendLayout();
//
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(6, 30);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(57, 13);
this.stLabel1.TabIndex = 0;
this.stLabel1.Text = "Swap Red";
//
// swapRedCB
//
this.swapRedCB.BorderColor = System.Drawing.Color.Empty;
this.swapRedCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.swapRedCB.ButtonColor = System.Drawing.Color.Empty;
this.swapRedCB.FormattingEnabled = true;
this.swapRedCB.IsReadOnly = false;
this.swapRedCB.Location = new System.Drawing.Point(92, 27);
this.swapRedCB.Name = "swapRedCB";
this.swapRedCB.Size = new System.Drawing.Size(147, 21);
this.swapRedCB.TabIndex = 1;
this.swapRedCB.SelectedIndexChanged += new System.EventHandler(this.swapCB_SelectedIndexChanged);
//
// stPanel1
//
this.stPanel1.Location = new System.Drawing.Point(245, 27);
this.stPanel1.Name = "stPanel1";
this.stPanel1.Size = new System.Drawing.Size(23, 21);
this.stPanel1.TabIndex = 2;
//
// stPanel2
//
this.stPanel2.Location = new System.Drawing.Point(245, 54);
this.stPanel2.Name = "stPanel2";
this.stPanel2.Size = new System.Drawing.Size(23, 21);
this.stPanel2.TabIndex = 5;
//
// swapGreenCB
//
this.swapGreenCB.BorderColor = System.Drawing.Color.Empty;
this.swapGreenCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.swapGreenCB.ButtonColor = System.Drawing.Color.Empty;
this.swapGreenCB.FormattingEnabled = true;
this.swapGreenCB.IsReadOnly = false;
this.swapGreenCB.Location = new System.Drawing.Point(92, 54);
this.swapGreenCB.Name = "swapGreenCB";
this.swapGreenCB.Size = new System.Drawing.Size(147, 21);
this.swapGreenCB.TabIndex = 4;
this.swapGreenCB.SelectedIndexChanged += new System.EventHandler(this.swapCB_SelectedIndexChanged);
//
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(6, 57);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(58, 13);
this.stLabel2.TabIndex = 3;
this.stLabel2.Text = "Swap Blue";
//
// stPanel3
//
this.stPanel3.Location = new System.Drawing.Point(245, 81);
this.stPanel3.Name = "stPanel3";
this.stPanel3.Size = new System.Drawing.Size(23, 21);
this.stPanel3.TabIndex = 11;
//
// stPanel4
//
this.stPanel4.Location = new System.Drawing.Point(245, 108);
this.stPanel4.Name = "stPanel4";
this.stPanel4.Size = new System.Drawing.Size(23, 21);
this.stPanel4.TabIndex = 8;
//
// swapAlphaCB
//
this.swapAlphaCB.BorderColor = System.Drawing.Color.Empty;
this.swapAlphaCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.swapAlphaCB.ButtonColor = System.Drawing.Color.Empty;
this.swapAlphaCB.FormattingEnabled = true;
this.swapAlphaCB.IsReadOnly = false;
this.swapAlphaCB.Location = new System.Drawing.Point(92, 108);
this.swapAlphaCB.Name = "swapAlphaCB";
this.swapAlphaCB.Size = new System.Drawing.Size(147, 21);
this.swapAlphaCB.TabIndex = 10;
this.swapAlphaCB.SelectedIndexChanged += new System.EventHandler(this.swapCB_SelectedIndexChanged);
//
// stLabel3
//
this.stLabel3.AutoSize = true;
this.stLabel3.Location = new System.Drawing.Point(6, 111);
this.stLabel3.Name = "stLabel3";
this.stLabel3.Size = new System.Drawing.Size(64, 13);
this.stLabel3.TabIndex = 9;
this.stLabel3.Text = "Swap Alpha";
//
// swapBlueCB
//
this.swapBlueCB.BorderColor = System.Drawing.Color.Empty;
this.swapBlueCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.swapBlueCB.ButtonColor = System.Drawing.Color.Empty;
this.swapBlueCB.FormattingEnabled = true;
this.swapBlueCB.IsReadOnly = false;
this.swapBlueCB.Location = new System.Drawing.Point(92, 81);
this.swapBlueCB.Name = "swapBlueCB";
this.swapBlueCB.Size = new System.Drawing.Size(147, 21);
this.swapBlueCB.TabIndex = 7;
this.swapBlueCB.SelectedIndexChanged += new System.EventHandler(this.swapCB_SelectedIndexChanged);
//
// stLabel4
//
this.stLabel4.AutoSize = true;
this.stLabel4.Location = new System.Drawing.Point(6, 84);
this.stLabel4.Name = "stLabel4";
this.stLabel4.Size = new System.Drawing.Size(66, 13);
this.stLabel4.TabIndex = 6;
this.stLabel4.Text = "Swap Green";
//
// SwapTableEntryControl
//
this.Controls.Add(this.stPanel3);
this.Controls.Add(this.stPanel2);
this.Controls.Add(this.stPanel4);
this.Controls.Add(this.swapAlphaCB);
this.Controls.Add(this.stPanel1);
this.Controls.Add(this.stLabel3);
this.Controls.Add(this.swapGreenCB);
this.Controls.Add(this.swapBlueCB);
this.Controls.Add(this.stLabel2);
this.Controls.Add(this.stLabel4);
this.Controls.Add(this.swapRedCB);
this.Controls.Add(this.stLabel1);
this.Name = "SwapTableEntryControl";
this.Size = new System.Drawing.Size(342, 140);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Toolbox.Library.Forms.STLabel stLabel1;
private Toolbox.Library.Forms.STComboBox swapRedCB;
private Toolbox.Library.Forms.STPanel stPanel1;
private Toolbox.Library.Forms.STPanel stPanel2;
private Toolbox.Library.Forms.STComboBox swapGreenCB;
private Toolbox.Library.Forms.STLabel stLabel2;
private Toolbox.Library.Forms.STPanel stPanel3;
private Toolbox.Library.Forms.STPanel stPanel4;
private Toolbox.Library.Forms.STComboBox swapAlphaCB;
private Toolbox.Library.Forms.STLabel stLabel3;
private Toolbox.Library.Forms.STComboBox swapBlueCB;
private Toolbox.Library.Forms.STLabel stLabel4;
}
}

View File

@ -0,0 +1,83 @@
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;
using LayoutBXLYT.Revolution;
namespace LayoutBXLYT
{
public partial class SwapTableEntryControl : STUserControl
{
public SwapMode SwapMode;
private bool loaded = false;
public SwapTableEntryControl(SwapMode swapMode)
{
InitializeComponent();
swapRedCB.LoadEnum(typeof(SwapChannel));
swapGreenCB.LoadEnum(typeof(SwapChannel));
swapBlueCB.LoadEnum(typeof(SwapChannel));
swapAlphaCB.LoadEnum(typeof(SwapChannel));
LoadSwapMode(swapMode);
}
public void LoadSwapMode(SwapMode swapMode) {
SwapMode = swapMode;
Reload();
}
private void Reload() {
loaded = false;
swapRedCB.SelectedItem = SwapMode.R;
swapGreenCB.SelectedItem = SwapMode.G;
swapBlueCB.SelectedItem = SwapMode.B;
swapAlphaCB.SelectedItem = SwapMode.A;
loaded = true;
}
private void swapCB_SelectedIndexChanged(object sender, EventArgs e)
{
var comboBox = (ComboBox)sender;
if (comboBox.SelectedIndex == -1)
return;
var item = (SwapChannel)comboBox.SelectedItem;
if (comboBox == swapRedCB) {
SetColorDisplay(stPanel1, item);
if (loaded) SwapMode.R = item;
}
if (comboBox == swapGreenCB) {
SetColorDisplay(stPanel2, item);
if (loaded) SwapMode.G = item;
}
if (comboBox == swapBlueCB) {
SetColorDisplay(stPanel3, item);
if (loaded) SwapMode.B = item;
}
if (comboBox == swapAlphaCB) {
SetColorDisplay(stPanel4, item);
if (loaded) SwapMode.A = item;
}
}
private void SetColorDisplay(Panel panel, SwapChannel channel)
{
switch(channel)
{
case SwapChannel.Red: panel.BackColor = Color.Red; break;
case SwapChannel.Green: panel.BackColor = Color.Green; break;
case SwapChannel.Blue: panel.BackColor = Color.Blue; break;
case SwapChannel.Alpha: panel.BackColor = Color.Gray; break;
}
panel.Refresh();
}
}
}

View File

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

View File

@ -81,8 +81,18 @@ namespace LayoutBXLYT
private void AddItem(STGenericTexture texture)
{
listViewCustom1.Items.Add(new ListViewItem(texture.Text)
{ Name = texture.Text, Tag = texture, });
if (texture is FirstPlugin.TPL.TplTextureWrapper)
{
var tex = ((FirstPlugin.TPL.TplTextureWrapper)texture);
listViewCustom1.Items.Add(new ListViewItem(tex.TPLParent.FileName)
{ Name = tex.TPLParent.FileName , Tag = texture, });
}
else
{
listViewCustom1.Items.Add(new ListViewItem(texture.Text)
{ Name = texture.Text, Tag = texture, });
}
}
private void listViewCustom1_SelectedIndexChanged(object sender, EventArgs e)

View File

@ -133,9 +133,25 @@ namespace LayoutBXLYT
ActiveMaterial = ((IPicturePane)ActivePane).Material;
AddTab("Picture Pane", LoadPicturePane);
AddTab("Texture Maps", LoadTextureMaps);
AddTab("Colors", LoadColorBlending);
AddTab("Blending", LoadBlending);
AddTab("Combiners", LoadTextureCombiners);
if (ActiveMaterial is Revolution.Material)
{
AddTab("Colors", LoadBRLYTColorBlending);
AddTab("Blending", LoadBRLYTBlending);
AddTab("SwapTable", LoadBRLYTTevSwapChannel);
AddTab("Combiners", LoadBRLYTTextureCombiners);
}
else if (ActiveMaterial is CTR.Material)
{
AddTab("Colors", LoadBCLYTColorBlending);
AddTab("Blending", LoadBlending);
AddTab("Combiners", LoadBCLYTTextureCombiners);
}
else
{
AddTab("Colors", LoadColorBlending);
AddTab("Blending", LoadBlending);
AddTab("Combiners", LoadTextureCombiners);
}
}
if (pane is IWindowPane)
{
@ -143,6 +159,9 @@ namespace LayoutBXLYT
AddTab("Window Pane", LoadWindowPane);
AddTab("Texture Maps", LoadWindowLoadTextureMaps);
if (ActiveMaterial is Revolution.Material)
AddTab("SwapTable", LoadWindowTevSwapChannel);
AddTab("Colors", LoadWindowColorBlending);
AddTab("Blending", LoadWindowMatBlending);
AddTab("Combiners", LoadWindowTextureCombiners);
@ -152,8 +171,22 @@ namespace LayoutBXLYT
ActiveMaterial = ((ITextPane)ActivePane).Material;
AddTab("Text Pane", LoadTextPane);
AddTab("Colors", LoadColorBlending);
AddTab("Blending", LoadBlending);
if (ActiveMaterial is Revolution.Material)
{
AddTab("Colors", LoadBRLYTColorBlending);
AddTab("Blending", LoadBlending);
}
else if (ActiveMaterial is CTR.Material)
{
AddTab("Colors", LoadBCLYTColorBlending);
AddTab("Blending", LoadBlending);
AddTab("Combiners", LoadBCLYTTextureCombiners);
}
else
{
AddTab("Colors", LoadColorBlending);
AddTab("Blending", LoadBlending);
}
}
if (pane is IPartPane)
{
@ -245,6 +278,20 @@ namespace LayoutBXLYT
colorEditor.LoadMaterial(ActiveMaterial, this);
}
private void LoadBRLYTColorBlending(object sender, EventArgs e)
{
UpdateTabIndex();
var colorEditor = GetActiveEditor<PaneMatRevColorEditor>();
colorEditor.LoadMaterial((Revolution.Material)ActiveMaterial, this);
}
private void LoadBCLYTColorBlending(object sender, EventArgs e)
{
UpdateTabIndex();
var colorEditor = GetActiveEditor<CTR.PaneMatCTRColorEditor>();
colorEditor.LoadMaterial((CTR.Material)ActiveMaterial, this);
}
private void LoadBlending(object sender, EventArgs e)
{
UpdateTabIndex();
@ -252,6 +299,20 @@ namespace LayoutBXLYT
blendEditor.LoadMaterial(ActiveMaterial, this);
}
private void LoadBRLYTBlending(object sender, EventArgs e)
{
UpdateTabIndex();
var blendEditor = GetActiveEditor<PaneMatRevBlending>();
blendEditor.LoadMaterial((Revolution.Material)ActiveMaterial, this);
}
private void LoadBRLYTTevSwapChannel(object sender, EventArgs e)
{
UpdateTabIndex();
var swapTableEditor = GetActiveEditor<PaneMatRevTevSwapTableEditor>();
swapTableEditor.LoadMaterial((Revolution.Material)ActiveMaterial, this);
}
private void LoadTextureCombiners(object sender, EventArgs e)
{
UpdateTabIndex();
@ -259,6 +320,20 @@ namespace LayoutBXLYT
texCombEditor.LoadMaterial(ActiveMaterial, this);
}
private void LoadBRLYTTextureCombiners(object sender, EventArgs e)
{
UpdateTabIndex();
var texCombEditor = GetActiveEditor<Revolution.PaneMatRevTevEditor>();
texCombEditor.LoadMaterial((Revolution.Material)ActiveMaterial, this);
}
private void LoadBCLYTTextureCombiners(object sender, EventArgs e)
{
UpdateTabIndex();
var texCombEditor = GetActiveEditor<CTR.PaneMatCTRTevEditor>();
texCombEditor.LoadMaterial((CTR.Material)ActiveMaterial, this);
}
private void LoadTextPane(object sender, EventArgs e)
{
UpdateTabIndex();
@ -305,6 +380,13 @@ namespace LayoutBXLYT
WindowPaneEditor.ContentType.TextureCombiners, this);
}
public void LoadWindowTevSwapChannel(object sender, EventArgs e) {
UpdateTabIndex();
var windowEditor = GetActiveEditor<WindowPaneEditor>();
windowEditor.LoadPane(ActivePane as IWindowPane,
WindowPaneEditor.ContentType.TevSwapTable, this);
}
private void LoadWindowPane(object sender, EventArgs e)
{
UpdateTabIndex();

View File

@ -31,6 +31,7 @@ namespace LayoutBXLYT
stDropDownPanel1.ResetColors();
stDropDownPanel2.ResetColors();
stDropDownPanel4.ResetColors();
stDropDownPanel4.Visible = true;
}
public void LoadPane(ITextPane pane, PaneEditor paneEditor)
@ -62,7 +63,6 @@ namespace LayoutBXLYT
vertexColorTopBottomBox1.BottomColor = activePane.FontBottomColor.Color;
stTextBox1.Text = pane.Text;
// stTextBox1.Bind(pane, pane.Text);
alighmentHCB.Bind(typeof(OriginX), pane, "HorizontalAlignment");
alighmentVCB.Bind(typeof(OriginY), pane, "VerticalAlignment");
@ -75,17 +75,25 @@ namespace LayoutBXLYT
else
sizeRestrictUD.Value = 0;
shadowColorBox.BottomColor = pane.ShadowBackColor.Color;
shadowColorBox.TopColor = pane.ShadowForeColor.Color;
shadowItalicTiltUD.Maximum = sliderShadowItalicTilt.Maximum;
shadowItalicTiltUD.Value = pane.ShadowItalic;
sliderShadowItalicTilt.Value = (int)shadowItalicTiltUD.Value;
//BRLYT has no shader parameters. Text cannot do those so hide them
if (pane is Revolution.TXT1)
{
stDropDownPanel4.Visible = false;
}
else
{
shadowColorBox.BottomColor = pane.ShadowBackColor.Color;
shadowColorBox.TopColor = pane.ShadowForeColor.Color;
shadowItalicTiltUD.Maximum = sliderShadowItalicTilt.Maximum;
shadowItalicTiltUD.Value = pane.ShadowItalic;
sliderShadowItalicTilt.Value = (int)shadowItalicTiltUD.Value;
shadowOffseXUD.Value = pane.ShadowXY.X;
shadowOffseYUD.Value = pane.ShadowXY.Y;
shadowScaleXUD.Value = pane.ShadowXYSize.X;
shadowScaleYUD.Value = pane.ShadowXYSize.Y;
shadowOffseXUD.Value = pane.ShadowXY.X;
shadowOffseYUD.Value = pane.ShadowXY.Y;
shadowScaleXUD.Value = pane.ShadowXYSize.X;
shadowScaleYUD.Value = pane.ShadowXYSize.Y;
}
loaded = true;
}

View File

@ -24,6 +24,7 @@ namespace LayoutBXLYT
ColorInterpolation,
TextureCombiners,
Blending,
TevSwapTable,
}
public WindowPaneEditor()
@ -62,28 +63,87 @@ namespace LayoutBXLYT
private void LoadEditors()
{
var mat = GetActiveMaterial();
switch (EditorContentType)
if (mat is Revolution.Material)
{
case ContentType.Textures:
var textureEditor = GetActiveEditor<PaneMatTextureMapsEditor>();
textureEditor.LoadMaterial(mat, ParentEditor, ParentEditor.GetTextures());
break;
case ContentType.WindowContent:
var contentEditor = GetActiveEditor<WindowContentEditor>();
contentEditor.LoadPane(ActivePane, GetActiveFrame(), ParentEditor);
break;
case ContentType.ColorInterpolation:
var colorEditor = GetActiveEditor<PaneMatColorEditor>();
colorEditor.LoadMaterial(mat, ParentEditor);
break;
case ContentType.TextureCombiners:
var texComb = GetActiveEditor<PaneMatTextureCombiner>();
texComb.LoadMaterial(mat, ParentEditor);
break;
case ContentType.Blending:
var matBlend = GetActiveEditor<PaneMatBlending>();
matBlend.LoadMaterial(mat, ParentEditor);
break;
switch (EditorContentType)
{
case ContentType.Textures:
var textureEditor = GetActiveEditor<PaneMatTextureMapsEditor>();
textureEditor.LoadMaterial(mat, ParentEditor, ParentEditor.GetTextures());
break;
case ContentType.WindowContent:
var contentEditor = GetActiveEditor<WindowContentEditor>();
contentEditor.LoadPane(ActivePane, GetActiveFrame(), ParentEditor);
break;
case ContentType.ColorInterpolation:
var colorEditor = GetActiveEditor<PaneMatRevColorEditor>();
colorEditor.LoadMaterial((Revolution.Material)mat, ParentEditor);
break;
case ContentType.TextureCombiners:
var texComb = GetActiveEditor<Revolution.PaneMatRevTevEditor>();
texComb.LoadMaterial((Revolution.Material)mat, ParentEditor);
break;
case ContentType.Blending:
var matBlend = GetActiveEditor<PaneMatRevBlending>();
matBlend.LoadMaterial((Revolution.Material)mat, ParentEditor);
break;
case ContentType.TevSwapTable:
var tevSwapEditor = GetActiveEditor<PaneMatRevTevSwapTableEditor>();
tevSwapEditor.LoadMaterial((Revolution.Material)mat, ParentEditor);
break;
}
}
else if (mat is CTR.Material)
{
switch (EditorContentType)
{
case ContentType.Textures:
var textureEditor = GetActiveEditor<PaneMatTextureMapsEditor>();
textureEditor.LoadMaterial(mat, ParentEditor, ParentEditor.GetTextures());
break;
case ContentType.WindowContent:
var contentEditor = GetActiveEditor<WindowContentEditor>();
contentEditor.LoadPane(ActivePane, GetActiveFrame(), ParentEditor);
break;
case ContentType.ColorInterpolation:
var colorEditor = GetActiveEditor<CTR.PaneMatCTRColorEditor>();
colorEditor.LoadMaterial((CTR.Material)mat, ParentEditor);
break;
case ContentType.TextureCombiners:
var texComb = GetActiveEditor<CTR.PaneMatCTRTevEditor>();
texComb.LoadMaterial((CTR.Material)mat, ParentEditor);
break;
case ContentType.Blending:
var matBlend = GetActiveEditor<PaneMatBlending>();
matBlend.LoadMaterial(mat, ParentEditor);
break;
}
}
else
{
switch (EditorContentType)
{
case ContentType.Textures:
var textureEditor = GetActiveEditor<PaneMatTextureMapsEditor>();
textureEditor.LoadMaterial(mat, ParentEditor, ParentEditor.GetTextures());
break;
case ContentType.WindowContent:
var contentEditor = GetActiveEditor<WindowContentEditor>();
contentEditor.LoadPane(ActivePane, GetActiveFrame(), ParentEditor);
break;
case ContentType.ColorInterpolation:
var colorEditor = GetActiveEditor<PaneMatColorEditor>();
colorEditor.LoadMaterial(mat, ParentEditor);
break;
case ContentType.TextureCombiners:
var texComb = GetActiveEditor<PaneMatTextureCombiner>();
texComb.LoadMaterial(mat, ParentEditor);
break;
case ContentType.Blending:
var matBlend = GetActiveEditor<PaneMatBlending>();
matBlend.LoadMaterial(mat, ParentEditor);
break;
}
}
}

View File

@ -65,10 +65,10 @@
this.resetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.windowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.showGameWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.showAnimationWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.stLabel2 = new Toolbox.Library.Forms.STLabel();
this.editorModeCB = new Toolbox.Library.Forms.STComboBox();
this.chkAutoKey = new Toolbox.Library.Forms.STCheckBox();
this.showAnimationWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.backColorDisplay)).BeginInit();
this.stToolStrip1.SuspendLayout();
this.stMenuStrip1.SuspendLayout();
@ -389,7 +389,7 @@
// resetToolStripMenuItem
//
this.resetToolStripMenuItem.Name = "resetToolStripMenuItem";
this.resetToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.resetToolStripMenuItem.Size = new System.Drawing.Size(102, 22);
this.resetToolStripMenuItem.Text = "Reset";
this.resetToolStripMenuItem.Click += new System.EventHandler(this.resetToolStripMenuItem_Click);
//
@ -409,6 +409,13 @@
this.showGameWindowToolStripMenuItem.Text = "Show Game Window";
this.showGameWindowToolStripMenuItem.Click += new System.EventHandler(this.showGameWindowToolStripMenuItem_Click);
//
// showAnimationWindowToolStripMenuItem
//
this.showAnimationWindowToolStripMenuItem.Name = "showAnimationWindowToolStripMenuItem";
this.showAnimationWindowToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
this.showAnimationWindowToolStripMenuItem.Text = "Show Animation Window";
this.showAnimationWindowToolStripMenuItem.Click += new System.EventHandler(this.showAnimationWindowToolStripMenuItem_Click);
//
// stLabel2
//
this.stLabel2.AutoSize = true;
@ -443,13 +450,6 @@
this.chkAutoKey.Text = "Auto Key";
this.chkAutoKey.UseVisualStyleBackColor = true;
//
// showAnimationWindowToolStripMenuItem
//
this.showAnimationWindowToolStripMenuItem.Name = "showAnimationWindowToolStripMenuItem";
this.showAnimationWindowToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
this.showAnimationWindowToolStripMenuItem.Text = "Show Animation Window";
this.showAnimationWindowToolStripMenuItem.Click += new System.EventHandler(this.showAnimationWindowToolStripMenuItem_Click);
//
// LayoutEditor
//
this.AllowDrop = true;
@ -466,6 +466,7 @@
this.Controls.Add(this.dockPanel1);
this.Controls.Add(this.stToolStrip1);
this.Controls.Add(this.stMenuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.IsMdiContainer = true;
this.Name = "LayoutEditor";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.LayoutEditor_FormClosed);

View File

@ -56,6 +56,8 @@ namespace LayoutBXLYT
{
InitializeComponent();
Text = $"Switch Toolbox Layout Editor";
chkAutoKey.Enabled = false;
chkAutoKey.ForeColor = FormThemes.BaseTheme.FormForeColor;
@ -121,6 +123,7 @@ namespace LayoutBXLYT
private bool isLoaded = false;
public void LoadBxlyt(BxlytHeader header)
{
Text = $"Switch Toolbox Layout Editor [{header.FileName}]";
/* if (PluginRuntime.BxfntFiles.Count > 0)
{
var result = MessageBox.Show("Found font files opened. Would you like to save character images to disk? " +
@ -237,6 +240,8 @@ namespace LayoutBXLYT
{
if (!isLoaded) return;
Text = $"Switch Toolbox Layout Editor [{activeLayout.FileName}]";
if (LayoutProperties != null)
LayoutProperties.Reset();
if (LayoutHierarchy != null)
@ -961,6 +966,15 @@ namespace LayoutBXLYT
private void resetToolStripMenuItem_Click(object sender, EventArgs e)
{
AnimationPanel?.Reset();
if (ActiveLayout == null) return;
foreach (var pane in ActiveLayout.PaneLookup.Values)
pane.animController.ResetAnim();
foreach (var mat in ActiveLayout.Materials)
mat.animController.ResetAnim();
ActiveViewport?.UpdateViewport();
}
@ -1041,10 +1055,7 @@ namespace LayoutBXLYT
int fontIndex = ActiveLayout.AddFont(font);
string text = newTextDlg.GetText();
BasePane pane = null;
if (ActiveLayout is BFLYT.Header)
pane = new BFLYT.TXT1((BFLYT.Header)ActiveLayout, RenamePane("T_text"));
BasePane pane = ActiveLayout.CreateNewTextPane(RenamePane("T_text"));
if (pane != null)
{
((ITextPane)pane).FontIndex = (ushort)fontIndex;
@ -1063,10 +1074,7 @@ namespace LayoutBXLYT
public BasePane AddNewBoundryPane()
{
BasePane pane = null;
if (ActiveLayout is BFLYT.Header)
pane = new BFLYT.BND1((BFLYT.Header)ActiveLayout, RenamePane("B_bound"));
BasePane pane = ActiveLayout.CreateNewBoundryPane(RenamePane("B_bound"));
if (pane != null)
{
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
@ -1078,10 +1086,7 @@ namespace LayoutBXLYT
public BasePane AddNewWindowPane()
{
BasePane pane = null;
if (ActiveLayout is BFLYT.Header)
pane = new BFLYT.WND1((BFLYT.Header)ActiveLayout, RenamePane("W_window"));
BasePane pane = ActiveLayout.CreateNewWindowPane(RenamePane("W_window"));
if (pane != null)
{
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
@ -1093,10 +1098,7 @@ namespace LayoutBXLYT
public BasePane AddNewPicturePane()
{
BasePane pane = null;
if (ActiveLayout is BFLYT.Header)
pane = new BFLYT.PIC1((BFLYT.Header)ActiveLayout, RenamePane("P_pict"));
BasePane pane = ActiveLayout.CreateNewPicturePane(RenamePane("P_pict"));
if (pane != null)
{
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
@ -1107,6 +1109,30 @@ namespace LayoutBXLYT
return pane;
}
public BasePane AddNewPartPane()
{
BasePane pane = ActiveLayout.CreateNewPartPane(RenamePane("N_part")) as BasePane;
if (pane != null)
{
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
}
return pane;
}
public BasePane AddNewNullPane()
{
BasePane pane = ActiveLayout.CreateNewNullPane(RenamePane("N_null"));
if (pane != null)
{
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
}
return pane;
}
public void AddNewPastedPane(BasePane pane)
{
string name = pane.Name;
@ -1144,36 +1170,6 @@ namespace LayoutBXLYT
ActiveLayout.AddPane(pane, pane.Parent);
}
public BasePane AddNewPartPane()
{
BasePane pane = null;
if (ActiveLayout is BFLYT.Header)
pane = new BFLYT.PRT1((BFLYT.Header)ActiveLayout, RenamePane("N_part"));
if (pane != null)
{
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
}
return pane;
}
public BasePane AddNewNullPane()
{
BasePane pane = null;
if (ActiveLayout is BFLYT.Header)
pane = new BFLYT.PAN1((BFLYT.Header)ActiveLayout, RenamePane("N_null"));
if (pane != null)
{
pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane);
ActiveLayout.AddPane(pane, ActiveLayout.RootPane);
}
return pane;
}
private string RenamePane(string name)
{
List<string> names = ActiveLayout.PaneLookup.Keys.ToList();

Some files were not shown because too many files have changed in this diff Show More