1
0
mirror of synced 2024-09-24 11:38:22 +02:00

More layout editor improvements

Window panes render near perfectly aside from materials. Update fixes the texture flip flags and other uv fixes,
Fixed UV transformation issues. Commonly when a uv is suppose to be centered but it shifts wrong.
Add basic white and black color blending.
Fix LA8 texture rendering.
Start on BRLAN support.
This commit is contained in:
KillzXGaming 2019-09-18 18:23:27 -04:00
parent 3f142c4e81
commit 0f19107dd2
20 changed files with 919 additions and 222 deletions

View File

@ -289,7 +289,7 @@ namespace Bfres.Structs
if (ShaderName == "alRenderMaterial" || ShaderName == "alRenderCloudLayer" || ShaderName == "alRenderSky")
Runtime.activeGame = Runtime.ActiveGame.SMO;
else if (ShaderName == "forward_plus_char")
else if (ShaderName == "forward_plus_char" || ShaderName == "bezel_pbr")
Runtime.activeGame = Runtime.ActiveGame.Bezel;
else if (ShaderName == "Turbo_UBER")
Runtime.activeGame = Runtime.ActiveGame.MK8D;

View File

@ -323,6 +323,13 @@ namespace LayoutBXLYT
float contentWidth = ((window.StretchLeft + (pane.Width - frameLeft)) - frameRight) + window.StretchRight;
float contentHeight = ((window.StretchTop + (pane.Height - frameTop)) - frameBottom) + window.StretchBottm;
//Apply pane alpha
for (int i = 0; i < colors.Length; i++)
{
uint setalpha = (uint)((colors[i].A * effectiveAlpha) / 255);
colors[i] = Color.FromArgb((int)setalpha, colors[i]);
}
if (!window.NotDrawnContent && window.WindowKind != WindowKind.HorizontalNoContent)
{
SetupShaders(window.Content.Material, Textures);
@ -475,6 +482,8 @@ namespace LayoutBXLYT
{
SetupShaders(matTL, Textures);
matTL.Shader.SetInt("flipTexture", (int)window.WindowFrames[0].TextureFlip);
float pieceWidth = pane.Width - frameRight;
float pieceHeight = frameTop;
@ -492,15 +501,17 @@ namespace LayoutBXLYT
{
SetupShaders(matTR, Textures);
matTR.Shader.SetInt("flipTexture", (int)window.WindowFrames[1].TextureFlip);
float pieceWidth = frameRight;
float pieceHeight = pane.Height - frameBottom;
texCoords = new Vector2[]
{
new Vector2(1, 0),
new Vector2(0, 0),
new Vector2(0,(pane.Height - frameTop) / frameTop),
new Vector2(1, 0),
new Vector2(1,(pane.Height - frameTop) / frameTop),
new Vector2(0,(pane.Height - frameTop) / frameTop),
};
DrawQuad(dX + pane.Width - frameRight, dY, pieceWidth, pieceHeight, texCoords, colors);
@ -509,15 +520,17 @@ namespace LayoutBXLYT
{
SetupShaders(matBL, Textures);
matBL.Shader.SetInt("flipTexture", (int)window.WindowFrames[2].TextureFlip);
float pieceWidth = frameLeft;
float pieceHeight = pane.Height - frameTop;
texCoords = new Vector2[]
{
new Vector2(0,(pane.Height - frameBottom) / frameBottom),
new Vector2(1,(pane.Height - frameBottom) / frameBottom),
new Vector2(1, 0),
new Vector2(0, 0),
new Vector2(0,1 - ((pane.Height - frameTop) / frameTop)),
new Vector2(1,1 - ((pane.Height - frameTop) / frameTop)),
new Vector2(1, 1),
new Vector2(0, 1),
};
DrawQuad(dX, dY - frameTop, pieceWidth, pieceHeight, texCoords, colors);
@ -526,15 +539,17 @@ namespace LayoutBXLYT
{
SetupShaders(matBR, Textures);
matBR.Shader.SetInt("flipTexture", (int)window.WindowFrames[3].TextureFlip);
float pieceWidth = pane.Width - frameLeft;
float pieceHeight = frameBottom;
texCoords = new Vector2[]
{
new Vector2((pane.Width - frameLeft) / frameLeft, 1),
new Vector2(0, 1),
new Vector2(0, 0),
new Vector2((pane.Width - frameLeft) / frameLeft, 0),
new Vector2(1 - ((pane.Width - frameLeft) / frameLeft), 0),
new Vector2(1, 0),
new Vector2(1, 1),
new Vector2(1 - ((pane.Width - frameLeft) / frameLeft), 1),
};
DrawQuad(dX + frameLeft, dY - pane.Height + frameBottom, pieceWidth, pieceHeight, texCoords, colors);
@ -556,30 +571,71 @@ namespace LayoutBXLYT
if (matTL.TextureMaps.Length > 0)
{
SetupShaders(matTL, Textures);
matTL.Shader.SetInt("flipTexture", (int)window.WindowFrames[0].TextureFlip);
texCoords = new Vector2[]
{
new Vector2(0, 0),
new Vector2(1, 0),
new Vector2(1, 1),
new Vector2(0, 1),
};
DrawQuad(dX, dY, frameLeft, frameTop, texCoords, colors);
}
if (matTR.TextureMaps.Length > 0)
{
SetupShaders(matTR, Textures);
matTR.Shader.SetInt("flipTexture", (int)window.WindowFrames[1].TextureFlip);
texCoords = new Vector2[]
{
new Vector2(0, 0),
new Vector2(1, 0),
new Vector2(1, 1),
new Vector2(0, 1),
};
DrawQuad(dX + pane.Width - frameRight, dY, frameRight, frameTop, texCoords, colors);
}
if (matBL.TextureMaps.Length > 0)
{
SetupShaders(matBL, Textures);
matBL.Shader.SetInt("flipTexture", (int)window.WindowFrames[2].TextureFlip);
texCoords = new Vector2[]
{
new Vector2(0, 0),
new Vector2(1, 0),
new Vector2(1, 1),
new Vector2(0, 1),
};
DrawQuad(dX, dY - pane.Height + frameTop, frameLeft, frameBottom, texCoords, colors);
}
if (matBR.TextureMaps.Length > 0)
{
SetupShaders(matBR, Textures);
matBR.Shader.SetInt("flipTexture", (int)window.WindowFrames[3].TextureFlip);
texCoords = new Vector2[]
{
new Vector2(0, 0),
new Vector2(1, 0),
new Vector2(1, 1),
new Vector2(0, 1),
};
DrawQuad(dX + pane.Width - frameLeft, dY - pane.Height + frameBottom, frameRight, frameBottom, texCoords, colors);
}
if (matT.TextureMaps.Length > 0)
{
SetupShaders(matT, Textures);
matT.Shader.SetInt("flipTexture", (int)window.WindowFrames[4].TextureFlip);
texCoords = new Vector2[]
{
@ -595,13 +651,14 @@ namespace LayoutBXLYT
if (matB.TextureMaps.Length > 0)
{
SetupShaders(matB, Textures);
matB.Shader.SetInt("flipTexture", (int)window.WindowFrames[5].TextureFlip);
texCoords = new Vector2[]
{
new Vector2((pane.Width - frameLeft) / frameLeft, 1),
new Vector2(0, 1),
new Vector2(0, 0),
new Vector2((pane.Width - frameLeft) / frameLeft, 0),
new Vector2(1-((pane.Width - frameLeft) / frameLeft), 0),
new Vector2(1, 0),
new Vector2(1, 1),
new Vector2(1-((pane.Width - frameLeft) / frameLeft), 1),
};
DrawQuad(dX + frameRight, dY - (pane.Height - frameBottom), contentWidth, frameTop, texCoords, colors);
@ -610,13 +667,14 @@ namespace LayoutBXLYT
if (matL.TextureMaps.Length > 0)
{
SetupShaders(matL, Textures);
matL.Shader.SetInt("flipTexture", (int)window.WindowFrames[6].TextureFlip);
texCoords = new Vector2[]
{
new Vector2(0,(pane.Height - frameTop) / frameTop),
new Vector2(1,(pane.Height - frameTop) / frameTop),
new Vector2(1, 0),
new Vector2(0, 0),
new Vector2(0,1-((pane.Height - frameTop) / frameTop)),
new Vector2(1,1-((pane.Height - frameTop) / frameTop)),
new Vector2(1, 1),
new Vector2(0, 1),
};
DrawQuad(dX, dY - frameTop, frameLeft, contentHeight, texCoords, colors);
@ -625,6 +683,8 @@ namespace LayoutBXLYT
if (matR.TextureMaps.Length > 0)
{
SetupShaders(matR, Textures);
matR.Shader.SetInt("flipTexture", (int)window.WindowFrames[7].TextureFlip);
texCoords = new Vector2[]
{
new Vector2(0, 0),

View File

@ -109,9 +109,6 @@ namespace LayoutBXLYT
//As of now this should be empty but just for future proofing
private List<SectionCommon> UnknownSections = new List<SectionCommon>();
public PAT1 AnimationTag;
public PAI1 AnimationInfo;
public void Read(FileReader reader, BFLAN bflan)
{
AnimationTag = new PAT1();
@ -201,28 +198,9 @@ namespace LayoutBXLYT
}
}
public class PAT1 : SectionCommon
public class PAT1 : BxlanPAT1
{
[DisplayName("Name"), CategoryAttribute("Animation")]
public string Name { get; set; }
[DisplayName("Groups"), CategoryAttribute("Animation")]
public List<string> Groups { get; set; }
[DisplayName("Start"), CategoryAttribute("Frames")]
public short StartFrame { get; set; }
[DisplayName("End"), CategoryAttribute("Frames")]
public short EndFrame { get; set; }
[DisplayName("Animation Order"), CategoryAttribute("Parameters")]
public ushort AnimationOrder { get; set; }
[DisplayName("Child Binding"), CategoryAttribute("Parameters")]
public bool ChildBinding { get; set; }
private byte[] UnknownData;
private byte flags;
public PAT1()
@ -281,14 +259,9 @@ namespace LayoutBXLYT
}
}
public class PAI1 : SectionCommon
public class PAI1 : BxlanPAI1
{
public ushort FrameSize;
public bool Loop;
public List<string> Textures { get; set; }
public List<PaiEntry> Entries = new List<PaiEntry>();
public PAI1()
{
@ -355,22 +328,14 @@ namespace LayoutBXLYT
for (int i = 0; i < Entries.Count; i++)
{
writer.WriteUint32Offset(startOfsPos + (i * 4), startPos);
Entries[i].Write(writer, header);
((PaiEntry)Entries[i]).Write(writer, header);
}
}
}
}
public class PaiEntry
public class PaiEntry : BxlanPaiEntry
{
[DisplayName("Name"), CategoryAttribute("Animation")]
public string Name { get; set; }
[DisplayName("Target"), CategoryAttribute("Animation")]
public AnimationTarget Target { get; set; }
public List<PaiTag> Tags = new List<PaiTag>();
public PaiEntry(FileReader reader, Header header)
{
long startPos = reader.Position;
@ -402,37 +367,14 @@ namespace LayoutBXLYT
for (int i = 0; i < Tags.Count; i++)
{
writer.WriteUint32Offset(startPos + 32 + (i * 4), startPos);
Tags[i].Write(writer, header, Target);
((PaiTag)Tags[i]).Write(writer, header, Target);
}
}
}
}
public class PaiTag
public class PaiTag : BxlanPaiTag
{
public List<PaiTagEntry> Entries = new List<PaiTagEntry>();
private string Tag;
public string Type
{
get { return TypeDefine.ContainsKey(Tag) ? TypeDefine[Tag] : Tag; }
}
public Dictionary<string, string> TypeDefine = new Dictionary<string, string>()
{
{"FLPA","PaneSRT" },
{"FLVI","Visibility" },
{"FLTS","TextureSRT" },
{"FLVC","VertexColor" },
{"FLMC","MaterialColor" },
{"FLTP","TexturePattern" },
{"FLIM","IndTextureSRT" },
{"FLAC","AlphaTest" },
{"FLCT","FontShadow" },
{"FLCC","PerCharacterTransformCurve" },
};
private uint Unknown {get;set;}
public PaiTag(FileReader reader, Header header, AnimationTarget target)
@ -489,31 +431,15 @@ namespace LayoutBXLYT
for (int i = 0; i < Entries.Count; i++)
{
writer.WriteUint32Offset(startPos + 8 + (i * 4), startPos);
Entries[i].Write(writer, header);
((PaiTagEntry)Entries[i]).Write(writer, header);
}
}
}
public class PaiTagEntry
public class PaiTagEntry : BxlanPaiTagEntry
{
[Browsable(false)]
public virtual string TargetName
{
get { return AnimationTarget.ToString(); }
}
public byte AnimationTarget;
[DisplayName("Index"), CategoryAttribute("Tag")]
public byte Index { get; private set; }
[DisplayName("Data Type"), CategoryAttribute("Tag")]
public KeyType DataType { get; private set; }
public byte Unknown;
public List<KeyFrame> KeyFrames = new List<KeyFrame>();
public PaiTagEntry(FileReader reader, Header header)
{
long startPos = reader.Position;
@ -525,7 +451,6 @@ namespace LayoutBXLYT
reader.ReadUInt16(); //Padding
uint keyFrameOffset = reader.ReadUInt32();
reader.SeekBegin(startPos + keyFrameOffset);
for (int i = 0; i < KeyFrameCount; i++)
KeyFrames.Add(new KeyFrame(reader, DataType));
@ -552,48 +477,6 @@ namespace LayoutBXLYT
}
}
public class KeyFrame
{
[DisplayName("Blend"), CategoryAttribute("Key Frame")]
public float Blend { get; set; }
[DisplayName("Frame"), CategoryAttribute("Key Frame")]
public float Frame { get; set; }
[DisplayName("Value"), CategoryAttribute("Key Frame")]
public float Value { get; set; }
public KeyFrame(FileReader reader, KeyType DataType)
{
Frame = reader.ReadSingle();
switch (DataType)
{
case KeyType.Float:
Value = reader.ReadSingle();
Blend = reader.ReadSingle();
break;
case KeyType.Uin16:
Value = (float)reader.ReadInt16();
Blend = (float)reader.ReadInt16();
break;
}
}
public void Write(FileWriter writer, KeyType DataType)
{
writer.Write(Frame);
switch (DataType)
{
case KeyType.Float:
writer.Write(Value);
writer.Write(Blend);
break;
case KeyType.Uin16:
writer.Write((ushort)Value);
writer.Write((ushort)Blend);
break;
}
}
}
public class FLPATagEntry : PaiTagEntry
{
public override string TargetName => Target.ToString();

View File

@ -477,7 +477,8 @@ namespace LayoutBXLYT.Cafe
parentPane = currentPane;
break;
case "pae1":
currentPane = parentPane;
if (parentPane != null)
currentPane = parentPane;
parentPane = currentPane.Parent;
break;
case "grp1":
@ -1341,12 +1342,10 @@ namespace LayoutBXLYT.Cafe
}
}
foreach (var archive in PluginRuntime.SarcArchives)
for (int i = 0; i < PluginRuntime.SarcArchives.Count; i++)
{
Console.WriteLine("Searching archive! " + archive.FileName);
BFLYT bflyt = null;
SearchArchive(archive, ref bflyt);
SearchArchive(PluginRuntime.SarcArchives[i], ref bflyt);
if (bflyt != null)
return bflyt;
}

View File

@ -50,17 +50,13 @@ namespace LayoutBXLYT
BindTextureUniforms();
string textureMap0 = "";
if (material.TextureMaps.Length > 0)
textureMap0 = material.GetTexture(0);
for (int i = 0; i < material.TextureMaps.Length; i++)
{
if (textures.ContainsKey(material.TextureMaps[i].Name))
{
GL.ActiveTexture(TextureUnit.Texture0 + i);
SetInt($"textures{i}", 0);
bool isBinded = BxlytToGL.BindGLTexture(material.TextureMaps[i], textures[textureMap0]);
bool isBinded = BxlytToGL.BindGLTexture(material.TextureMaps[i], textures[material.TextureMaps[i].Name]);
if (isBinded)
SetInt($"hasTexture{i}", 1);
}
@ -72,10 +68,6 @@ namespace LayoutBXLYT
var transform = material.TextureTransforms[0];
float shiftX = 0;
float shiftY = 0;
if (transform.Scale.X < 0)
shiftX = -1;
if (transform.Scale.Y < 0)
shiftY = -1;
SetVec2("uvScale0",new Vector2(transform.Scale.X, transform.Scale.Y));
SetFloat("uvRotate0", transform.Rotate);

View File

@ -482,7 +482,7 @@ namespace LayoutBXLYT
public BxlytMaterial Material { get; set; }
public ushort MaterialIndex;
public WindowFrameTexFlip TextureFlip;
public WindowFrameTexFlip TextureFlip { get; set; }
}
public class TexCoord
@ -573,7 +573,158 @@ namespace LayoutBXLYT
public class BxlanHeader : LayoutHeader
{
public BxlanPAT1 AnimationTag;
public BxlanPAI1 AnimationInfo;
}
public class BxlanPAT1 : SectionCommon
{
[DisplayName("Name"), CategoryAttribute("Animation")]
public string Name { get; set; }
[DisplayName("Groups"), CategoryAttribute("Animation")]
public List<string> Groups { get; set; }
[DisplayName("Start"), CategoryAttribute("Frames")]
public short StartFrame { get; set; }
[DisplayName("End"), CategoryAttribute("Frames")]
public short EndFrame { get; set; }
[DisplayName("Animation Order"), CategoryAttribute("Parameters")]
public ushort AnimationOrder { get; set; }
[DisplayName("Child Binding"), CategoryAttribute("Parameters")]
public bool ChildBinding { get; set; }
}
public class BxlanPAI1 : SectionCommon
{
public ushort FrameSize;
public bool Loop;
public List<string> Textures { get; set; }
public List<BxlanPaiEntry> Entries = new List<BxlanPaiEntry>();
}
public class BxlanPaiEntry
{
[DisplayName("Name"), CategoryAttribute("Animation")]
public string Name { get; set; }
[DisplayName("Target"), CategoryAttribute("Animation")]
public AnimationTarget Target { get; set; }
public List<BxlanPaiTag> Tags = new List<BxlanPaiTag>();
}
public class BxlanPaiTag
{
public List<BxlanPaiTagEntry> Entries = new List<BxlanPaiTagEntry>();
public string Tag;
public string Type
{
get { return TypeDefine.ContainsKey(Tag) ? TypeDefine[Tag] : Tag; }
}
public Dictionary<string, string> TypeDefine = new Dictionary<string, string>()
{
{"FLPA","PaneSRT" },
{"FLVI","Visibility" },
{"FLTS","TextureSRT" },
{"FLVC","VertexColor" },
{"FLMC","MaterialColor" },
{"FLTP","TexturePattern" },
{"FLIM","IndTextureSRT" },
{"FLAC","AlphaTest" },
{"FLCT","FontShadow" },
{"FLCC","PerCharacterTransformCurve" },
{"RLPA","PaneSRT" },
{"RLVI","Visibility" },
{"RLTS","TextureSRT" },
{"RLVC","VertexColor" },
{"RLMC","MaterialColor" },
{"RLTP","TexturePattern" },
{"RLIM","IndTextureSRT" },
{"RLAC","AlphaTest" },
{"RLCT","FontShadow" },
{"RLCC","PerCharacterTransformCurve" },
{"CLPA","PaneSRT" },
{"CLVI","Visibility" },
{"CLTS","TextureSRT" },
{"CLVC","VertexColor" },
{"CLMC","MaterialColor" },
{"CLTP","TexturePattern" },
{"CLIM","IndTextureSRT" },
{"CLAC","AlphaTest" },
{"CLCT","FontShadow" },
{"CLCC","PerCharacterTransformCurve" },
};
}
public class BxlanPaiTagEntry
{
[Browsable(false)]
public virtual string TargetName
{
get { return AnimationTarget.ToString(); }
}
public byte AnimationTarget;
[DisplayName("Index"), CategoryAttribute("Tag")]
public byte Index { get; set; }
[DisplayName("Data Type"), CategoryAttribute("Tag")]
public KeyType DataType { get; set; }
public List<KeyFrame> KeyFrames = new List<KeyFrame>();
}
public class KeyFrame
{
[DisplayName("Blend"), CategoryAttribute("Key Frame")]
public float Blend { get; set; }
[DisplayName("Frame"), CategoryAttribute("Key Frame")]
public float Frame { get; set; }
[DisplayName("Value"), CategoryAttribute("Key Frame")]
public float Value { get; set; }
public KeyFrame(FileReader reader, KeyType DataType)
{
Frame = reader.ReadSingle();
switch (DataType)
{
case KeyType.Float:
Value = reader.ReadSingle();
Blend = reader.ReadSingle();
break;
case KeyType.Uin16:
Value = (float)reader.ReadInt16();
Blend = (float)reader.ReadInt16();
break;
}
}
public void Write(FileWriter writer, KeyType DataType)
{
writer.Write(Frame);
switch (DataType)
{
case KeyType.Float:
writer.Write(Value);
writer.Write(Blend);
break;
case KeyType.Uin16:
writer.Write((ushort)Value);
writer.Write((ushort)Blend);
break;
}
}
}
public class BxlytHeader : LayoutHeader

View File

@ -0,0 +1,553 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Toolbox;
using System.Windows.Forms;
using Toolbox.Library;
using Toolbox.Library.IO;
using SharpYaml.Serialization;
namespace LayoutBXLYT
{
public class BRLAN : IEditorForm<LayoutEditor>, IFileFormat, IConvertableTextFormat
{
public FileType FileType { get; set; } = FileType.Layout;
public bool CanSave { get; set; }
public string[] Description { get; set; } = new string[] { "Revolution Layout Animation (GUI)" };
public string[] Extension { get; set; } = new string[] { "*.brlan" };
public string FileName { get; set; }
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public bool Identify(System.IO.Stream stream)
{
using (var reader = new Toolbox.Library.IO.FileReader(stream, true))
{
return reader.CheckSignature(4, "RLAN");
}
}
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
#region Text Converter Interface
public TextFileType TextFileType => TextFileType.Xml;
public bool CanConvertBack => false;
public string ConvertToString()
{
return "";
/* var serializerSettings = new SerializerSettings()
/
// EmitTags = false
};
serializerSettings.DefaultStyle = SharpYaml.YamlStyle.Any;
serializerSettings.ComparerForKeySorting = null;
serializerSettings.RegisterTagMapping("Header", typeof(Header));
// return FLAN.ToXml(header);
var serializer = new Serializer(serializerSettings);
string yaml = serializer.Serialize(header, typeof(Header));
return yaml;*/
}
public void ConvertFromString(string text)
{
// header = RLAN.FromXml(text);
// header.FileInfo = this;
}
#endregion
Header header;
public void Load(System.IO.Stream stream)
{
CanSave = true;
header = new Header();
header.Read(new FileReader(stream),this);
}
public void Unload()
{
}
public void Save(System.IO.Stream stream) {
header.Write(new FileWriter(stream));
}
public LayoutEditor OpenForm()
{
LayoutEditor editor = new LayoutEditor();
editor.Dock = DockStyle.Fill;
editor.LoadBxlan(header);
return editor;
}
public void FillEditor(Form control)
{
((LayoutEditor)control).LoadBxlan(header);
}
public class Header : BxlanHeader
{
private const string Magic = "RLAN";
private ushort ByteOrderMark;
private ushort HeaderSize;
//As of now this should be empty but just for future proofing
private List<SectionCommon> UnknownSections = new List<SectionCommon>();
public void Read(FileReader reader, BRLAN bflan)
{
AnimationTag = new PAT1();
AnimationInfo = new PAI1();
reader.SetByteOrder(true);
reader.ReadSignature(4, Magic);
ByteOrderMark = reader.ReadUInt16();
reader.CheckByteOrderMark(ByteOrderMark);
Version = reader.ReadUInt16();
uint FileSize = reader.ReadUInt32();
HeaderSize = reader.ReadUInt16();
ushort sectionCount = reader.ReadUInt16();
reader.ReadUInt16(); //Padding
FileInfo = bflan;
IsBigEndian = reader.ByteOrder == Syroot.BinaryData.ByteOrder.BigEndian;
reader.SeekBegin(HeaderSize);
for (int i = 0; i < sectionCount; i++)
{
long pos = reader.Position;
string Signature = reader.ReadString(4, Encoding.ASCII);
uint SectionSize = reader.ReadUInt32();
SectionCommon section = new SectionCommon(Signature);
switch (Signature)
{
case "pat1":
AnimationTag = new PAT1(reader, this);
break;
case "pai1":
AnimationInfo = new PAI1(reader, this);
break;
default:
section.Data = reader.ReadBytes((int)SectionSize - 8);
UnknownSections.Add(section);
break;
}
section.SectionSize = SectionSize;
reader.SeekBegin(pos + SectionSize);
}
}
public void Write(FileWriter writer)
{
writer.SetByteOrder(true);
writer.WriteSignature(Magic);
if (!IsBigEndian)
writer.Write((ushort)0xFFFE);
else
writer.Write((ushort)0xFEFF);
writer.SetByteOrder(IsBigEndian);
writer.Write((ushort)Version);
writer.Write(uint.MaxValue); //Reserve space for file size later
writer.Write(HeaderSize);
writer.Write(ushort.MaxValue); //Reserve space for section count later
int sectionCount = 0;
WriteSection(writer, "pat1", AnimationTag, () => AnimationTag.Write(writer, this));
sectionCount++;
WriteSection(writer, "pai1", AnimationInfo, () => AnimationInfo.Write(writer, this));
sectionCount++;
foreach (var section in UnknownSections)
{
WriteSection(writer, section.Signature, section, () => section.Write(writer, this));
sectionCount++;
}
//Write the total section count
using (writer.TemporarySeek(0x10, System.IO.SeekOrigin.Begin))
{
writer.Write((ushort)sectionCount);
}
//Write the total file size
using (writer.TemporarySeek(0x0C, System.IO.SeekOrigin.Begin))
{
writer.Write((uint)writer.BaseStream.Length);
}
}
}
public class PAT1 : BxlanPAT1
{
private byte[] UnknownData;
private byte flags;
public PAT1()
{
AnimationOrder = 2;
Name = "";
EndFrame = 0;
StartFrame = 0;
ChildBinding = false;
Groups = new List<string>();
}
public PAT1(FileReader reader, Header header)
{
long startPos = reader.Position - 8;
Groups = new List<string>();
AnimationOrder = reader.ReadUInt16();
ushort groupCount = reader.ReadUInt16();
uint animNameOffset = reader.ReadUInt32();
uint groupNamesOffset = reader.ReadUInt32();
StartFrame = reader.ReadInt16();
EndFrame = reader.ReadInt16();
ChildBinding = reader.ReadBoolean();
UnknownData = reader.ReadBytes((int)(startPos + animNameOffset - reader.Position));
reader.SeekBegin(startPos + animNameOffset);
Name = reader.ReadZeroTerminatedString();
reader.SeekBegin(startPos + groupNamesOffset);
for (int i = 0; i < groupCount; i++)
Groups.Add(reader.ReadString(28, true));
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long startPos = writer.Position - 8;
writer.Write(AnimationOrder);
writer.Write((ushort)Groups.Count);
writer.Write(uint.MaxValue); //animNameOffset
writer.Write(uint.MaxValue); //groupNamesOffset
writer.Write(StartFrame);
writer.Write(EndFrame);
writer.Write(ChildBinding);
writer.Write(UnknownData);
writer.WriteUint32Offset(startPos + 12, startPos);
writer.WriteString(Name);
writer.Align(4);
writer.WriteUint32Offset(startPos + 16, startPos);
for (int i = 0; i < Groups.Count; i++)
writer.WriteString(Groups[i], 28);
}
}
public class PAI1 : BxlanPAI1
{
public PAI1()
{
Textures = new List<string>();
}
public PAI1(FileReader reader, Header header)
{
long startPos = reader.Position - 8;
Textures = new List<string>();
FrameSize = reader.ReadUInt16();
Loop = reader.ReadBoolean();
reader.ReadByte(); //padding
var numTextures = reader.ReadUInt16();
var numEntries = reader.ReadUInt16();
var entryOffsetTbl = reader.ReadUInt32();
var texOffsets = reader.ReadUInt32s(numTextures);
for (int i = 0; i < numTextures; i++)
{
reader.SeekBegin(startPos + texOffsets[i]);
Textures.Add(reader.ReadZeroTerminatedString());
}
reader.SeekBegin(startPos + entryOffsetTbl);
var entryOffsets = reader.ReadUInt32s(numEntries);
for (int i = 0; i < numEntries; i++)
{
reader.SeekBegin(startPos + entryOffsets[i]);
Entries.Add(new PaiEntry(reader, header));
}
}
public override void Write(FileWriter writer, LayoutHeader header)
{
long startPos = writer.Position - 8;
writer.Write(FrameSize);
writer.Write(Loop);
writer.Write((byte)0);
writer.Write((ushort)Textures.Count);
writer.Write((ushort)Entries.Count);
long entryOfsTblPos = writer.Position;
writer.Write(0);
if (Textures.Count > 0)
{
long startOfsPos = writer.Position;
writer.Write(new uint[Textures.Count]);
for (int i = 0; i < Textures.Count; i++)
{
writer.WriteUint32Offset(startOfsPos + (i * 4), startPos);
writer.WriteString(Textures[i]);
}
}
if (Entries.Count > 0)
{
writer.WriteUint32Offset(entryOfsTblPos, startPos);
long startOfsPos = writer.Position;
writer.Write(new uint[Entries.Count]);
for (int i = 0; i < Entries.Count; i++)
{
writer.WriteUint32Offset(startOfsPos + (i * 4), startPos);
((PaiEntry)Entries[i]).Write(writer, header);
}
}
}
}
public class PaiEntry : BxlanPaiEntry
{
public PaiEntry(FileReader reader, Header header)
{
long startPos = reader.Position;
Name = reader.ReadString(0x14, true);
var numTags = reader.ReadByte();
Target = reader.ReadEnum<AnimationTarget>(false);
reader.ReadUInt16(); //padding
var offsets = reader.ReadUInt32s(numTags);
for (int i = 0; i < numTags; i++)
{
reader.SeekBegin(startPos + offsets[i]);
Tags.Add(new PaiTag(reader, header, Target));
}
}
public void Write(FileWriter writer, LayoutHeader header)
{
long startPos = writer.Position;
writer.WriteString(Name, 0x14);
writer.Write((byte)Tags.Count);
writer.Write(Target, false);
writer.Write((ushort)0);
if (Tags.Count > 0)
{
writer.Write(new uint[Tags.Count]);
for (int i = 0; i < Tags.Count; i++)
{
writer.WriteUint32Offset(startPos + 32 + (i * 4), startPos);
((PaiTag)Tags[i]).Write(writer, header, Target);
}
}
}
}
public class PaiTag : BxlanPaiTag
{
private uint Unknown { get; set; }
public PaiTag(FileReader reader, Header header, AnimationTarget target)
{
if ((byte)target == 2)
Unknown = reader.ReadUInt32(); //This doesn't seem to be included in the offsets to the entries (?)
long startPos = reader.Position;
Tag = reader.ReadString(4, Encoding.ASCII);
var numEntries = reader.ReadByte();
reader.Seek(3);
var offsets = reader.ReadUInt32s((int)numEntries);
for (int i = 0; i < numEntries; i++)
{
reader.SeekBegin(startPos + offsets[i]);
switch (Tag)
{
case "RLPA":
Entries.Add(new FLPATagEntry(reader, header));
break;
case "RLTS":
Entries.Add(new FLTSTagEntry(reader, header));
break;
case "RLVI":
Entries.Add(new FLVITagEntry(reader, header));
break;
case "RLVC":
Entries.Add(new FLVCTagEntry(reader, header));
break;
case "RLMC":
Entries.Add(new FLMCTagEntry(reader, header));
break;
case "RLTP":
Entries.Add(new FLTPTagEntry(reader, header));
break;
default:
Entries.Add(new PaiTagEntry(reader, header));
break;
}
}
}
public void Write(FileWriter writer, LayoutHeader header, AnimationTarget target)
{
if ((byte)target == 2)
writer.Write(Unknown);
long startPos = writer.Position;
writer.WriteSignature(Tag);
writer.Write((byte)Entries.Count);
writer.Seek(3);
writer.Write(new uint[Entries.Count]);
for (int i = 0; i < Entries.Count; i++)
{
writer.WriteUint32Offset(startPos + 8 + (i * 4), startPos);
((PaiTagEntry)Entries[i]).Write(writer, header);
}
}
}
public class PaiTagEntry : BxlanPaiTagEntry
{
public byte Unknown;
public PaiTagEntry(FileReader reader, Header header)
{
long startPos = reader.Position;
Index = reader.ReadByte();
AnimationTarget = reader.ReadByte();
DataType = reader.ReadEnum<KeyType>(true);
Unknown = reader.ReadByte();
var KeyFrameCount = reader.ReadUInt16();
reader.ReadUInt16(); //Padding
uint keyFrameOffset = reader.ReadUInt32();
reader.SeekBegin(startPos + keyFrameOffset);
for (int i = 0; i < KeyFrameCount; i++)
KeyFrames.Add(new KeyFrame(reader, DataType));
}
public void Write(FileWriter writer, LayoutHeader header)
{
long startPos = writer.Position;
writer.Write(Index);
writer.Write(AnimationTarget);
writer.Write(DataType, true);
writer.Write(Unknown);
writer.Write((ushort)KeyFrames.Count);
writer.Write((ushort)0); //padding
writer.Write(0); //key offset
if (KeyFrames.Count > 0)
{
writer.WriteUint32Offset(startPos + 8, startPos);
for (int i = 0; i < KeyFrames.Count; i++)
KeyFrames[i].Write(writer, DataType);
}
}
}
public class FLPATagEntry : PaiTagEntry
{
public override string TargetName => Target.ToString();
[DisplayName("Target"), CategoryAttribute("Tag")]
public LPATarget Target
{
get { return (LPATarget)AnimationTarget; }
set { AnimationTarget = (byte)value; }
}
public FLPATagEntry(FileReader reader, Header header) : base(reader, header) { }
}
public class FLTSTagEntry : PaiTagEntry
{
public override string TargetName => Target.ToString();
[DisplayName("Target"), CategoryAttribute("Tag")]
public LTSTarget Target
{
get { return (LTSTarget)AnimationTarget; }
set { AnimationTarget = (byte)value; }
}
public FLTSTagEntry(FileReader reader, Header header) : base(reader, header) { }
}
public class FLVITagEntry : PaiTagEntry
{
public override string TargetName => Target.ToString();
[DisplayName("Target"), CategoryAttribute("Tag")]
public LVITarget Target
{
get { return (LVITarget)AnimationTarget; }
set { AnimationTarget = (byte)value; }
}
public FLVITagEntry(FileReader reader, Header header) : base(reader, header) { }
}
public class FLVCTagEntry : PaiTagEntry
{
public override string TargetName => Target.ToString();
[DisplayName("Target"), CategoryAttribute("Tag")]
public LVCTarget Target
{
get { return (LVCTarget)AnimationTarget; }
set { AnimationTarget = (byte)value; }
}
public FLVCTagEntry(FileReader reader, Header header) : base(reader, header) { }
}
public class FLMCTagEntry : PaiTagEntry
{
public override string TargetName => Target.ToString();
[DisplayName("Target"), CategoryAttribute("Tag")]
public LMCTarget Target
{
get { return (LMCTarget)AnimationTarget; }
set { AnimationTarget = (byte)value; }
}
public FLMCTagEntry(FileReader reader, Header header) : base(reader, header) { }
}
public class FLTPTagEntry : PaiTagEntry
{
public override string TargetName => Target.ToString();
[DisplayName("Target"), CategoryAttribute("Tag")]
public LTPTarget Target
{
get { return (LTPTarget)AnimationTarget; }
set { AnimationTarget = (byte)value; }
}
public FLTPTagEntry(FileReader reader, Header header) : base(reader, header) { }
}
}
}

View File

@ -579,7 +579,7 @@ namespace FirstPlugin
surf.numMips = 1;
surf.mipOffset = new uint[0];
surf.mipData = ImageData;
surf.tileMode = (uint)GX2.GX2TileMode.MODE_2D_TILED_THIN1;
surf.tileMode = (uint)image.TileMode;
surf.swizzle = image.Swizzle;
surf.numArray = 1;

View File

@ -76,7 +76,7 @@ namespace FirstPlugin
reader.SeekBegin(offset + 48);
ulong unk = reader.ReadUInt64(); //Varies. Shifts like a offset or size
ulong headerOffset = reader.ReadUInt64();
ulong headerOffset = reader.ReadUInt64();
ulong sectionSize = reader.ReadUInt64();
ulong unk3 = reader.ReadUInt64(); //16
ulong unk4 = reader.ReadUInt64(); //4
@ -87,16 +87,17 @@ namespace FirstPlugin
ulong unk6 = reader.ReadUInt64(); //32
ulong unk7 = reader.ReadUInt64(); //24
ulong unk8 = reader.ReadUInt64(); //40
ulong imageSize = reader.ReadUInt64();
//Matches XTX info header
uint imageSize = reader.ReadUInt32();
uint Alignment = reader.ReadUInt32();
entry.Width = reader.ReadUInt32();
entry.Height = reader.ReadUInt32();
entry.Depth = reader.ReadUInt32();
entry.ArrayCount = reader.ReadUInt32();
entry.Target = reader.ReadUInt32();
uint Format = reader.ReadUInt32();
if (Formats.ContainsKey(Format))
entry.Format = Formats[Format];
else
Console.WriteLine("Unsupported format! " + Format.ToString("X"));
XTX.TextureInfo.ConvertFormat(Format);
uint unk10 = reader.ReadUInt32(); //1
entry.ImageData = reader.ReadBytes((int)imageSize);
@ -106,12 +107,6 @@ namespace FirstPlugin
}
}
private Dictionary<uint, TEX_FORMAT> Formats = new Dictionary<uint, TEX_FORMAT>()
{
{0x25 , TEX_FORMAT.R8G8B8A8_UNORM},
{0x4d , TEX_FORMAT.BC7_UNORM},
};
public void Unload()
{
@ -123,6 +118,8 @@ namespace FirstPlugin
public class TextureWrapper : STGenericTexture
{
public uint Target = 1;
public byte[] ImageData;
public TextureWrapper()
@ -161,7 +158,7 @@ namespace FirstPlugin
private bool hasShownDialog = false;
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
{
return TegraX1Swizzle.GetImageData(this, ImageData, ArrayLevel, MipLevel, 1);
return TegraX1Swizzle.GetImageData(this, ImageData, ArrayLevel, MipLevel, (int)Target);
}

View File

@ -98,6 +98,7 @@ namespace FirstPlugin
BC4S = 0x0000004a,
BC5U = 0x0000004b,
BC5S = 0x0000004c,
BC7U = 0x0000004d,
//Same order as this https://github.com/aboood40091/BNTX-Editor/blob/master/globals.py
//However SRGB goes after unorm
@ -515,7 +516,7 @@ namespace FirstPlugin
editor.LoadProperties(GenericProperties);
}
private static XTXFormats.XTXImageFormat ConvertFromGenericFormat(TEX_FORMAT Format)
public static XTXFormats.XTXImageFormat ConvertFromGenericFormat(TEX_FORMAT Format)
{
switch (Format)
{
@ -525,6 +526,7 @@ namespace FirstPlugin
case TEX_FORMAT.BC4_UNORM: return XTXFormats.XTXImageFormat.BC4U;
case TEX_FORMAT.BC4_SNORM: return XTXFormats.XTXImageFormat.BC4S;
case TEX_FORMAT.BC5_UNORM: return XTXFormats.XTXImageFormat.BC5U;
case TEX_FORMAT.BC7_UNORM: return XTXFormats.XTXImageFormat.BC7U;
case TEX_FORMAT.R8_UNORM: return XTXFormats.XTXImageFormat.NVN_FORMAT_R8;
case TEX_FORMAT.R8G8_UNORM: return XTXFormats.XTXImageFormat.NVN_FORMAT_RG8;
case TEX_FORMAT.R10G10B10A2_UNORM: return XTXFormats.XTXImageFormat.NVN_FORMAT_RGB10A2;
@ -564,7 +566,12 @@ namespace FirstPlugin
}
}
private static TEX_FORMAT ConvertFormat(XTXFormats.XTXImageFormat Format)
public static TEX_FORMAT ConvertFormat(uint Format)
{
return ConvertFormat((XTXFormats.XTXImageFormat)Format);
}
public static TEX_FORMAT ConvertFormat(XTXFormats.XTXImageFormat Format)
{
switch (Format)
{
@ -575,6 +582,7 @@ namespace FirstPlugin
case XTXFormats.XTXImageFormat.BC4S: return TEX_FORMAT.BC4_SNORM;
case XTXFormats.XTXImageFormat.BC5U: return TEX_FORMAT.BC5_UNORM;
case XTXFormats.XTXImageFormat.BC5S: return TEX_FORMAT.BC5_SNORM;
case XTXFormats.XTXImageFormat.BC7U: return TEX_FORMAT.BC7_UNORM;
case XTXFormats.XTXImageFormat.NVN_FORMAT_R8: return TEX_FORMAT.R8_UNORM;
case XTXFormats.XTXImageFormat.NVN_FORMAT_RG8: return TEX_FORMAT.R8G8_UNORM;
case XTXFormats.XTXImageFormat.NVN_FORMAT_RGB10A2: return TEX_FORMAT.R10G10B10A2_UNORM;

View File

@ -149,7 +149,6 @@
</Reference>
<Reference Include="Syroot.Maths">
<HintPath>..\Toolbox\Lib\Syroot.Maths.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Syroot.NintenTools.Bfres">
<HintPath>..\Toolbox\Lib\Syroot.NintenTools.Bfres.dll</HintPath>
@ -314,6 +313,7 @@
<Compile Include="FileFormats\Layout\PaneTreeWrapper.cs" />
<Compile Include="FileFormats\Layout\Common.cs" />
<Compile Include="FileFormats\Layout\RenderablePane.cs" />
<Compile Include="FileFormats\Layout\Rev\BRLAN.cs" />
<Compile Include="FileFormats\Layout\Rev\BrlytShader.cs" />
<Compile Include="FileFormats\Layout\Rev\BRLYT.cs" />
<Compile Include="FileFormats\Message\MSBP.cs" />

View File

@ -95,9 +95,9 @@ namespace LayoutBXLYT
private void LoadAnimations(BxlanHeader bxlan, TreeNode root)
{
treeView1.Nodes.Add(root);
if (bxlan is BFLAN.Header)
if (bxlan is BxlanHeader)
{
var header = bxlan as BFLAN.Header;
var header = bxlan as BxlanHeader;
var pat1 = new TreeNode("Tag Info") { Tag = header.AnimationTag };
var pai1 = new TreeNode("Animation Info") { Tag = header.AnimationInfo };
@ -109,7 +109,7 @@ namespace LayoutBXLYT
}
}
private void LoadAnimationEntry(BFLAN.PaiEntry entry, TreeNode root)
private void LoadAnimationEntry(BxlanPaiEntry entry, TreeNode root)
{
var nodeEntry = new TreeNode(entry.Name) { Tag = entry };
root.Nodes.Add(nodeEntry);
@ -123,7 +123,7 @@ namespace LayoutBXLYT
}
}
private void LoadTagEntry(BFLAN.PaiTagEntry entry, TreeNode root, int index)
private void LoadTagEntry(BxlanPaiTagEntry entry, TreeNode root, int index)
{
var nodeEntry = new TreeNode(entry.TargetName) { Tag = entry };
root.Nodes.Add(nodeEntry);

View File

@ -367,6 +367,8 @@ namespace FirstPlugin
Formats.Add(typeof(LayoutBXLYT.Cafe.BFLYT));
Formats.Add(typeof(LayoutBXLYT.BCLYT));
Formats.Add(typeof(LayoutBXLYT.BRLYT));
Formats.Add(typeof(LayoutBXLYT.BFLAN));
Formats.Add(typeof(LayoutBXLYT.BRLAN));
Formats.Add(typeof(ZSI));
Formats.Add(typeof(IGZ_TEX));
Formats.Add(typeof(MOD));
@ -383,7 +385,6 @@ namespace FirstPlugin
Formats.Add(typeof(DARC));
Formats.Add(typeof(BFLIM));
Formats.Add(typeof(BCLIM));
Formats.Add(typeof(LayoutBXLYT.BFLAN));
Formats.Add(typeof(DAT_Bayonetta));
Formats.Add(typeof(XCI));
Formats.Add(typeof(TVOL));

View File

@ -8,32 +8,30 @@ namespace Toolbox.Library
{
public class RGBAPixelDecoder
{
private static byte[] GetComponentsFromPixel(TEX_FORMAT format, int pixel)
private static byte[] GetComponentsFromPixel(TEX_FORMAT format, int pixel, byte[] comp)
{
byte[] comp = new byte[] { 0, 0xFF, 0, 0, 0, 0xFF };
switch (format)
{
case TEX_FORMAT.L8:
comp[2] = (byte)(pixel & 0xFF);
break;
case TEX_FORMAT.L4:
comp[2] = (byte)((pixel & 0xF) * 17);
comp[3] = (byte)(((pixel & 0xF0) >> 4) * 17);
comp[0] = (byte)(pixel & 0xFF);
break;
case TEX_FORMAT.LA8:
comp[2] = (byte)(pixel & 0xFF);
comp[3] = (byte)((pixel & 0xFF00) >> 8);
comp[0] = (byte)(pixel & 0xFF);
comp[1] = (byte)((pixel & 0xFF00) >> 8);
break;
case TEX_FORMAT.LA4:
comp[0] = (byte)((pixel & 0xF) * 17);
comp[1] = (byte)(((pixel & 0xF0) >> 4) * 17);
break;
case TEX_FORMAT.R5G5B5_UNORM:
comp[2] = (byte)((pixel & 0x1F) / 0x1F * 0xFF);
comp[3] = (byte)(((pixel & 0x7E0) >> 5) / 0x3F * 0xFF);
comp[4] = (byte)(((pixel & 0xF800) >> 11) / 0x1F * 0xFF);
comp[0] = (byte)((pixel & 0x1F) / 0x1F * 0xFF);
comp[1] = (byte)(((pixel & 0x7E0) >> 5) / 0x3F * 0xFF);
comp[2] = (byte)(((pixel & 0xF800) >> 11) / 0x1F * 0xFF);
break;
case TEX_FORMAT.B5G6R5_UNORM:
comp[2] = (byte)(((pixel & 0xF800) >> 11) / 0x1F * 0xFF);
comp[3] = (byte)(((pixel & 0x7E0) >> 5) / 0x3F * 0xFF);
comp[4] = (byte)((pixel & 0x1F) / 0x1F * 0xFF);
comp[0] = (byte)(((pixel & 0xF800) >> 11) / 0x1F * 0xFF);
comp[1] = (byte)(((pixel & 0x7E0) >> 5) / 0x3F * 0xFF);
comp[2] = (byte)((pixel & 0x1F) / 0x1F * 0xFF);
break;
}
@ -54,10 +52,16 @@ namespace Toolbox.Library
int inPos = 0;
int outPos = 0;
byte[] comp = new byte[] { 0, 0, 0, 0xFF, 0, 0xFF };
byte[] compSel = new byte[4] {0,1,2,3 };
if (format == TEX_FORMAT.L8 || format == TEX_FORMAT.LA8)
compSel = new byte[4] { 2, 2, 2, 3 };
if (format == TEX_FORMAT.LA8)
{
compSel = new byte[4] { 0, 0, 0, 1 };
bpp = 2;
}
else if (format == TEX_FORMAT.L8)
compSel = new byte[4] { 0, 0, 0, 5 };
for (int Y = 0; Y < height; Y++)
{
@ -70,7 +74,7 @@ namespace Toolbox.Library
for (int i = 0; i < bpp; i++)
pixel |= data[inPos + i] << (8 * i);
byte[] comp = GetComponentsFromPixel(format, pixel);
comp = GetComponentsFromPixel(format, pixel, comp);
output[outPos + 3] = comp[compSel[3]];
output[outPos + 2] = comp[compSel[2]];

View File

@ -31,7 +31,21 @@ namespace Toolbox.Library.Forms
}
}
public STColor8 Color8 { get; set; }
public STColor8 Color8
{
get { return new STColor8(NewColor); }
}
public STColor16 Color16
{
get { return new STColor16(NewColor); }
}
public STColor Color32
{
get { return new STColor(NewColor); }
}
/// <summary>
/// The color the dialog gets and sets.
@ -328,8 +342,6 @@ namespace Toolbox.Library.Forms
protected virtual void OnColorChanged(bool hsvToRgb)
{
Color8 = new STColor8(NewColor);
colorSquare.Invalidate();
huePanel.Invalidate();

View File

@ -33,6 +33,7 @@
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBoxCustom1 = new Toolbox.Library.Forms.PictureBoxCustom();
this.stButton1 = new Toolbox.Library.Forms.STButton();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCustom1)).BeginInit();
@ -44,7 +45,6 @@
this.colorSelector1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.colorSelector1.Color = System.Drawing.Color.Empty;
this.colorSelector1.Color8 = null;
this.colorSelector1.DisplayAlpha = true;
this.colorSelector1.DisplayColor = true;
this.colorSelector1.Location = new System.Drawing.Point(3, 3);
@ -56,7 +56,7 @@
// pictureBox1
//
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox1.Location = new System.Drawing.Point(254, 3);
this.pictureBox1.Location = new System.Drawing.Point(272, 40);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(30, 30);
this.pictureBox1.TabIndex = 1;
@ -65,7 +65,7 @@
// pictureBox2
//
this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox2.Location = new System.Drawing.Point(254, 39);
this.pictureBox2.Location = new System.Drawing.Point(272, 76);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(30, 30);
this.pictureBox2.TabIndex = 2;
@ -75,23 +75,35 @@
//
this.pictureBoxCustom1.BackColor = System.Drawing.Color.Transparent;
this.pictureBoxCustom1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBoxCustom1.BackgroundImage")));
this.pictureBoxCustom1.Location = new System.Drawing.Point(254, 75);
this.pictureBoxCustom1.Location = new System.Drawing.Point(272, 112);
this.pictureBoxCustom1.Name = "pictureBoxCustom1";
this.pictureBoxCustom1.Size = new System.Drawing.Size(30, 30);
this.pictureBoxCustom1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBoxCustom1.TabIndex = 3;
this.pictureBoxCustom1.TabStop = false;
//
// stButton1
//
this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton1.Location = new System.Drawing.Point(252, 4);
this.stButton1.Name = "stButton1";
this.stButton1.Size = new System.Drawing.Size(50, 30);
this.stButton1.TabIndex = 4;
this.stButton1.Text = "Apply";
this.stButton1.UseVisualStyleBackColor = false;
this.stButton1.Click += new System.EventHandler(this.stButton1_Click);
//
// ColorSelectorDropdown
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stButton1);
this.Controls.Add(this.pictureBoxCustom1);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.colorSelector1);
this.Name = "ColorSelectorDropdown";
this.Size = new System.Drawing.Size(292, 244);
this.Size = new System.Drawing.Size(310, 244);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCustom1)).EndInit();
@ -105,5 +117,6 @@
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
private PictureBoxCustom pictureBoxCustom1;
private STButton stButton1;
}
}

View File

@ -12,10 +12,21 @@ namespace Toolbox.Library.Forms
{
public partial class ColorSelectorDropdown : STUserControl
{
public EventHandler ColorApplied;
public STColor8 Color8
{
get { return colorSelector1.Color8; }
set { colorSelector1.Color8 = value; }
}
public STColor16 Color16
{
get { return colorSelector1.Color16; }
}
public STColor Color32
{
get { return colorSelector1.Color32; }
}
public Color Color
@ -48,5 +59,10 @@ namespace Toolbox.Library.Forms
var fullColor = Color.FromArgb(colorSelector1.Alpha, colorSelector1.Color);
pictureBoxCustom1.Image = BitmapExtension.FillColor(30,30, fullColor);
}
private void stButton1_Click(object sender, EventArgs e)
{
ColorApplied?.Invoke(sender,e);
}
}
}

View File

@ -16,6 +16,7 @@ namespace Toolbox.Library.IO
return UITypeEditorEditStyle.DropDown;
}
IWindowsFormsEditorService _service;
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (value.GetType() != typeof(STColor8) &&
@ -25,11 +26,12 @@ namespace Toolbox.Library.IO
return value;
}
IWindowsFormsEditorService frmsvr = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (frmsvr == null)
_service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (_service == null)
return null;
var control = new ColorSelectorDropdown();
control.ColorApplied += ColorSelectorClose;
Color color = Color.White;
if (value is STColor8)
@ -42,18 +44,24 @@ namespace Toolbox.Library.IO
control.Color = color;
control.Alpha = color.A;
frmsvr.DropDownControl(control);
_service.DropDownControl(control);
if (value is STColor8)
return control.Color8;
if (value is STColor16)
return (STColor16)value;
return control.Color16;
if (value is STColor)
return (STColor)value;
return control.Color32;
return value;
}
private void ColorSelectorClose(object sender, EventArgs e)
{
if (_service != null)
_service.CloseDropDown();
}
private void OnColorChanged(object sender, EventArgs e)
{

View File

@ -28,10 +28,10 @@ void main()
if (debugShading == 0)
{
vec3 whiteInterpolation = mix(textureMap0.rgb, whiteColor.rgb, vec3(1));
vec3 blackInterpolation = mix(vec3(1) - textureMap0.rgb, blackColor.rgb, vec3(1));
vec3 whiteInterpolation = whiteColor.rgb * textureMap0.rgb;
vec3 blackInterpolation = (vec3(1) - textureMap0.rgb) * blackColor.rgb;
vec3 colorBlend = textureMap0.rgb * whiteColor.rgb;
vec3 colorBlend = whiteInterpolation + blackInterpolation;
float alpha = textureMap0.a * whiteColor.a;
gl_FragColor = gl_Color * vec4(colorBlend,alpha);
}

View File

@ -21,11 +21,11 @@ vec2 SetFlip(vec2 tex)
else if (flipTexture == 2) //FlipV
return vec2(1, -1) * tex + vec2(0, 1);
else if (flipTexture == 3) //Rotate90
return rotateUV(tex, 90.0);
return rotateUV(tex, radians(90.0));
else if (flipTexture == 4) //Rotate180
return rotateUV(tex, 180.0);
return rotateUV(tex, radians(180.0));
else if (flipTexture == 5) //Rotate270
return rotateUV(tex, 270.0);
return rotateUV(tex, radians(270.0));
return outTexCoord;
}
@ -33,7 +33,7 @@ vec2 SetFlip(vec2 tex)
void main()
{
gl_FrontColor = gl_Color;
vec2 texCoord0 = uvScale0 * (gl_MultiTexCoord0.xy + uvTranslate0);
vec2 texCoord0 = vec2(0.5, 0.5) + uvScale0 * (gl_MultiTexCoord0.xy + (uvTranslate0 / uvScale0 - 0.5));
gl_TexCoord[0].st = SetFlip(texCoord0);
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}