diff --git a/File_Format_Library/FileFormats/Effects/PCTL.cs b/File_Format_Library/FileFormats/Effects/PCTL.cs index e6d002d1..d28751f2 100644 --- a/File_Format_Library/FileFormats/Effects/PCTL.cs +++ b/File_Format_Library/FileFormats/Effects/PCTL.cs @@ -1010,42 +1010,26 @@ namespace FirstPlugin public class Emitter : TreeNodeCustom { - public Color[] Color0s = new Color[8]; - public Color[] Color1s = new Color[8]; public List DrawableTex = new List(); public List Samplers = new List(); - public ColorData[] Color0Array = new ColorData[8]; - public ColorData[] Color1Array = new ColorData[8]; - - public class ColorData - { - public float R; - public float G; - public float B; - public float A; - } + public STColor[] Color0Array = new STColor[8]; + public STColor[] Color1Array = new STColor[8]; public void Read(FileReader reader, Header ptclHeader) { uint Position = (uint)reader.Position; - Color0Array = new ColorData[8]; - Color1Array = new ColorData[8]; + Color0Array = new STColor[8]; + Color1Array = new STColor[8]; reader.Seek(Position + 880, SeekOrigin.Begin); for (int i = 0; i < 8; i++) { - Color0Array[i] = new ColorData(); + Color0Array[i] = new STColor(); Color0Array[i].R = reader.ReadSingle(); Color0Array[i].G = reader.ReadSingle(); Color0Array[i].B = reader.ReadSingle(); float time = reader.ReadSingle(); - - int red = Utils.FloatToIntClamp(Color0Array[i].R); - int green = Utils.FloatToIntClamp(Color0Array[i].G); - int blue = Utils.FloatToIntClamp(Color0Array[i].B); - - Color0s[i] = Color.FromArgb(255, red, green, blue); } for (int i = 0; i < 8; i++) { @@ -1053,22 +1037,14 @@ namespace FirstPlugin float padding = reader.ReadSingle(); float padding2 = reader.ReadSingle(); float time = reader.ReadSingle(); - - int alpha = Utils.FloatToIntClamp(Color0Array[i].A); } for (int i = 0; i < 8; i++) { - Color1Array[i] = new ColorData(); + Color1Array[i] = new STColor(); Color1Array[i].R = reader.ReadSingle(); Color1Array[i].G = reader.ReadSingle(); Color1Array[i].B = reader.ReadSingle(); float time = reader.ReadSingle(); - - int red = Utils.FloatToIntClamp(Color1Array[i].R); - int green = Utils.FloatToIntClamp(Color1Array[i].G); - int blue = Utils.FloatToIntClamp(Color1Array[i].B); - - Color1s[i] = Color.FromArgb(255, red, green, blue); } for (int i = 0; i < 8; i++) { @@ -1143,7 +1119,7 @@ namespace FirstPlugin { } - float R = reader.ReadSingle(); + float R = reader.ReadSingle(); float G = reader.ReadSingle(); float B = reader.ReadSingle(); float A = reader.ReadSingle(); diff --git a/File_Format_Library/FileFormats/Effects/PTCL_3DS.cs b/File_Format_Library/FileFormats/Effects/PTCL_3DS.cs index 54bb3912..0ba7ac1e 100644 --- a/File_Format_Library/FileFormats/Effects/PTCL_3DS.cs +++ b/File_Format_Library/FileFormats/Effects/PTCL_3DS.cs @@ -283,41 +283,21 @@ namespace FirstPlugin ColorPosition = reader.Position; for (int i = 0; i < 8; i++) { - ColorData clr = new ColorData(); + STColor clr = new STColor(); clr.R = reader.ReadSingle(); clr.G = reader.ReadSingle(); clr.B = reader.ReadSingle(); clr.A = reader.ReadSingle(); Color0Array[i] = clr; - - int red = Utils.FloatToIntClamp(clr.R); - int green = Utils.FloatToIntClamp(clr.G); - int blue = Utils.FloatToIntClamp(clr.B); - int alpha = Utils.FloatToIntClamp(clr.A); - - // Console.WriteLine($"Color0 {i} R {R} G {G} B {B} A {A}"); - // Console.WriteLine($"Color0 {i} R {red} G {green} B {blue} A {alpha}"); - - Color0s[i] = Color.FromArgb(alpha, red, green, blue); } for (int i = 0; i < 8; i++) { - ColorData clr = new ColorData(); + STColor clr = new STColor(); clr.R = reader.ReadSingle(); clr.G = reader.ReadSingle(); clr.B = reader.ReadSingle(); clr.A = reader.ReadSingle(); Color1Array[i] = clr; - - int red = Utils.FloatToIntClamp(clr.R); - int green = Utils.FloatToIntClamp(clr.G); - int blue = Utils.FloatToIntClamp(clr.B); - int alpha = Utils.FloatToIntClamp(clr.A); - - // Console.WriteLine($"Color1 {i} R {R} G {G} B {B} A {A}"); - // Console.WriteLine($"Color1 {i} R {red} G {green} B {blue} A {alpha}"); - - Color1s[i] = Color.FromArgb(alpha, red, green, blue); } } diff --git a/File_Format_Library/FileFormats/Effects/PTCL_WiiU.cs b/File_Format_Library/FileFormats/Effects/PTCL_WiiU.cs index b56bbb98..5ada183d 100644 --- a/File_Format_Library/FileFormats/Effects/PTCL_WiiU.cs +++ b/File_Format_Library/FileFormats/Effects/PTCL_WiiU.cs @@ -262,41 +262,21 @@ namespace FirstPlugin ColorPosition = reader.Position; for (int i = 0; i < 8; i++) { - ColorData clr = new ColorData(); + STColor clr = new STColor(); clr.R = reader.ReadSingle(); clr.G = reader.ReadSingle(); clr.B = reader.ReadSingle(); clr.A = reader.ReadSingle(); Color0Array[i] = clr; - - int red = Utils.FloatToIntClamp(clr.R); - int green = Utils.FloatToIntClamp(clr.G); - int blue = Utils.FloatToIntClamp(clr.B); - int alpha = Utils.FloatToIntClamp(clr.A); - - // Console.WriteLine($"Color0 {i} R {R} G {G} B {B} A {A}"); - // Console.WriteLine($"Color0 {i} R {red} G {green} B {blue} A {alpha}"); - - Color0s[i] = Color.FromArgb(alpha, red, green, blue); } for (int i = 0; i < 8; i++) { - ColorData clr = new ColorData(); + STColor clr = new STColor(); clr.R = reader.ReadSingle(); clr.G = reader.ReadSingle(); clr.B = reader.ReadSingle(); clr.A = reader.ReadSingle(); Color1Array[i] = clr; - - int red = Utils.FloatToIntClamp(clr.R); - int green = Utils.FloatToIntClamp(clr.G); - int blue = Utils.FloatToIntClamp(clr.B); - int alpha = Utils.FloatToIntClamp(clr.A); - - // Console.WriteLine($"Color1 {i} R {R} G {G} B {B} A {A}"); - // Console.WriteLine($"Color1 {i} R {red} G {green} B {blue} A {alpha}"); - - Color1s[i] = Color.FromArgb(alpha, red, green, blue); } } diff --git a/File_Format_Library/GUI/Editors/PTCL/EmitterEditor.cs b/File_Format_Library/GUI/Editors/PTCL/EmitterEditor.cs index ca18bbc1..795bc029 100644 --- a/File_Format_Library/GUI/Editors/PTCL/EmitterEditor.cs +++ b/File_Format_Library/GUI/Editors/PTCL/EmitterEditor.cs @@ -103,41 +103,41 @@ namespace FirstPlugin { IsColorsLoaded = false; - color0Index0.BackColor = Emitter.Color0s[0]; - color0Index1.BackColor = Emitter.Color0s[1]; - color0Index2.BackColor = Emitter.Color0s[2]; - color0Index3.BackColor = Emitter.Color0s[3]; - color0Index4.BackColor = Emitter.Color0s[4]; - color0Index5.BackColor = Emitter.Color0s[5]; - color0Index6.BackColor = Emitter.Color0s[6]; - color0Index7.BackColor = Emitter.Color0s[7]; + color0Index0.BackColor = Emitter.Color0Array[0].Color; + color0Index1.BackColor = Emitter.Color0Array[1].Color; + color0Index2.BackColor = Emitter.Color0Array[2].Color; + color0Index3.BackColor = Emitter.Color0Array[3].Color; + color0Index4.BackColor = Emitter.Color0Array[4].Color; + color0Index5.BackColor = Emitter.Color0Array[5].Color; + color0Index6.BackColor = Emitter.Color0Array[6].Color; + color0Index7.BackColor = Emitter.Color0Array[7].Color; - color1Index0.BackColor = Emitter.Color1s[0]; - color1Index1.BackColor = Emitter.Color1s[1]; - color1Index2.BackColor = Emitter.Color1s[2]; - color1Index3.BackColor = Emitter.Color1s[3]; - color1Index4.BackColor = Emitter.Color1s[4]; - color1Index5.BackColor = Emitter.Color1s[5]; - color1Index6.BackColor = Emitter.Color1s[6]; - color1Index7.BackColor = Emitter.Color1s[7]; + color1Index0.BackColor = Emitter.Color1Array[0].Color; + color1Index1.BackColor = Emitter.Color1Array[1].Color; + color1Index2.BackColor = Emitter.Color1Array[2].Color; + color1Index3.BackColor = Emitter.Color1Array[3].Color; + color1Index4.BackColor = Emitter.Color1Array[4].Color; + color1Index5.BackColor = Emitter.Color1Array[5].Color; + color1Index6.BackColor = Emitter.Color1Array[6].Color; + color1Index7.BackColor = Emitter.Color1Array[7].Color; - color0TB.Text = Utils.ColorToHex(Emitter.Color0s[0]); - color0TB2.Text = Utils.ColorToHex(Emitter.Color0s[1]); - color0TB3.Text = Utils.ColorToHex(Emitter.Color0s[2]); - color0TB4.Text = Utils.ColorToHex(Emitter.Color0s[3]); - color0TB5.Text = Utils.ColorToHex(Emitter.Color0s[4]); - color0TB6.Text = Utils.ColorToHex(Emitter.Color0s[5]); - color0TB7.Text = Utils.ColorToHex(Emitter.Color0s[6]); - color0TB8.Text = Utils.ColorToHex(Emitter.Color0s[7]); - color1TB.Text = Utils.ColorToHex(Emitter.Color1s[0]); - color1TB2.Text = Utils.ColorToHex(Emitter.Color1s[1]); - color1TB3.Text = Utils.ColorToHex(Emitter.Color1s[2]); - color1TB4.Text = Utils.ColorToHex(Emitter.Color1s[3]); - color1TB5.Text = Utils.ColorToHex(Emitter.Color1s[4]); - color1TB6.Text = Utils.ColorToHex(Emitter.Color1s[5]); - color1TB7.Text = Utils.ColorToHex(Emitter.Color1s[6]); - color1TB8.Text = Utils.ColorToHex(Emitter.Color1s[7]); + color0TB.Text = Utils.ColorToHex(Emitter.Color0Array[0].Color); + color0TB2.Text = Utils.ColorToHex(Emitter.Color0Array[1].Color); + color0TB3.Text = Utils.ColorToHex(Emitter.Color0Array[2].Color); + color0TB4.Text = Utils.ColorToHex(Emitter.Color0Array[3].Color); + color0TB5.Text = Utils.ColorToHex(Emitter.Color0Array[4].Color); + color0TB6.Text = Utils.ColorToHex(Emitter.Color0Array[5].Color); + color0TB7.Text = Utils.ColorToHex(Emitter.Color0Array[6].Color); + color0TB8.Text = Utils.ColorToHex(Emitter.Color0Array[7].Color); + color1TB.Text = Utils.ColorToHex(Emitter.Color1Array[0].Color); + color1TB2.Text = Utils.ColorToHex(Emitter.Color1Array[1].Color); + color1TB3.Text = Utils.ColorToHex(Emitter.Color1Array[2].Color); + color1TB4.Text = Utils.ColorToHex(Emitter.Color1Array[3].Color); + color1TB5.Text = Utils.ColorToHex(Emitter.Color1Array[4].Color); + color1TB6.Text = Utils.ColorToHex(Emitter.Color1Array[5].Color); + color1TB7.Text = Utils.ColorToHex(Emitter.Color1Array[6].Color); + color1TB8.Text = Utils.ColorToHex(Emitter.Color1Array[7].Color); IsColorsLoaded = true; } @@ -185,21 +185,9 @@ namespace FirstPlugin if (dialog.ShowDialog() == DialogResult.OK) { if (button.Name.Contains("color0")) - { - ActiveEmitter.Color0Array[index].R = (float)dialog.Color.R / 255; - ActiveEmitter.Color0Array[index].G = (float)dialog.Color.G / 255; - ActiveEmitter.Color0Array[index].B = (float)dialog.Color.B / 255; - ActiveEmitter.Color0Array[index].A = (float)dialog.Color.A / 255; - ActiveEmitter.Color0s[index] = dialog.Color; - } + ActiveEmitter.Color0Array[index].Color = dialog.Color; else - { - ActiveEmitter.Color1Array[index].R = (float)dialog.Color.R / 255; - ActiveEmitter.Color1Array[index].G = (float)dialog.Color.G / 255; - ActiveEmitter.Color1Array[index].B = (float)dialog.Color.B / 255; - ActiveEmitter.Color1Array[index].A = (float)dialog.Color.A / 255; - ActiveEmitter.Color1s[index] = dialog.Color; - } + ActiveEmitter.Color1Array[index].Color = dialog.Color; button.BackColor = dialog.Color; } @@ -222,26 +210,23 @@ namespace FirstPlugin Color[] colors0 = new Color[8]; Color[] colors1 = new Color[8]; - colors0[0] = Utils.HexToColor(color0TB.Text); - colors0[1] = Utils.HexToColor(color0TB2.Text); - colors0[2] = Utils.HexToColor(color0TB3.Text); - colors0[3] = Utils.HexToColor(color0TB4.Text); - colors0[4] = Utils.HexToColor(color0TB5.Text); - colors0[5] = Utils.HexToColor(color0TB6.Text); - colors0[6] = Utils.HexToColor(color0TB7.Text); - colors0[7] = Utils.HexToColor(color0TB8.Text); + ActiveEmitter.Color0Array[0].Color = Utils.HexToColor(color0TB.Text); + ActiveEmitter.Color0Array[1].Color = Utils.HexToColor(color0TB2.Text); + ActiveEmitter.Color0Array[2].Color = Utils.HexToColor(color0TB3.Text); + ActiveEmitter.Color0Array[3].Color = Utils.HexToColor(color0TB4.Text); + ActiveEmitter.Color0Array[4].Color = Utils.HexToColor(color0TB5.Text); + ActiveEmitter.Color0Array[5].Color = Utils.HexToColor(color0TB6.Text); + ActiveEmitter.Color0Array[6].Color = Utils.HexToColor(color0TB7.Text); + ActiveEmitter.Color0Array[7].Color = Utils.HexToColor(color0TB8.Text); - colors1[0] = Utils.HexToColor(color1TB.Text); - colors1[1] = Utils.HexToColor(color1TB2.Text); - colors1[2] = Utils.HexToColor(color1TB3.Text); - colors1[3] = Utils.HexToColor(color1TB4.Text); - colors1[4] = Utils.HexToColor(color1TB5.Text); - colors1[5] = Utils.HexToColor(color1TB6.Text); - colors1[6] = Utils.HexToColor(color1TB7.Text); - colors1[7] = Utils.HexToColor(color1TB8.Text); - - ActiveEmitter.Color0s = colors0; - ActiveEmitter.Color1s = colors1; + ActiveEmitter.Color1Array[0].Color = Utils.HexToColor(color1TB.Text); + ActiveEmitter.Color1Array[1].Color = Utils.HexToColor(color1TB2.Text); + ActiveEmitter.Color1Array[2].Color = Utils.HexToColor(color1TB3.Text); + ActiveEmitter.Color1Array[3].Color = Utils.HexToColor(color1TB4.Text); + ActiveEmitter.Color1Array[4].Color = Utils.HexToColor(color1TB5.Text); + ActiveEmitter.Color1Array[5].Color = Utils.HexToColor(color1TB6.Text); + ActiveEmitter.Color1Array[6].Color = Utils.HexToColor(color1TB7.Text); + ActiveEmitter.Color1Array[7].Color = Utils.HexToColor(color1TB8.Text); LoadColors(ActiveEmitter); } diff --git a/Switch_Toolbox_Library/IO/STColor.cs b/Switch_Toolbox_Library/IO/STColor.cs new file mode 100644 index 00000000..d488f3a4 --- /dev/null +++ b/Switch_Toolbox_Library/IO/STColor.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Drawing; + +namespace Toolbox.Library +{ + //Class that contains colors and useful color related methods + public class STColor + { + public float R { get; set; } + public float G { get; set; } + public float B { get; set; } + public float A { get; set; } + + public Color Color + { + get + { + int red = Utils.FloatToIntClamp(R); + int green = Utils.FloatToIntClamp(G); + int blue = Utils.FloatToIntClamp(B); + int alpha = Utils.FloatToIntClamp(A); + + return Color.FromArgb(alpha, red, green, blue); + } + set + { + var color = value; + R = color.R / 255f; + G = color.G / 255f; + B = color.B / 255f; + A = color.A / 255f; + } + } + + + public STColor() + { + R = 1; + G = 1; + B = 1; + A = 1; + } + } +} diff --git a/Switch_Toolbox_Library/Toolbox.Library.dll b/Switch_Toolbox_Library/Toolbox.Library.dll index fa396ba5..7782a8b1 100644 Binary files a/Switch_Toolbox_Library/Toolbox.Library.dll and b/Switch_Toolbox_Library/Toolbox.Library.dll differ diff --git a/Switch_Toolbox_Library/Toolbox.Library.pdb b/Switch_Toolbox_Library/Toolbox.Library.pdb index a4bfe0f6..434cd75a 100644 Binary files a/Switch_Toolbox_Library/Toolbox.Library.pdb and b/Switch_Toolbox_Library/Toolbox.Library.pdb differ diff --git a/Switch_Toolbox_Library/Toolbox_Library.csproj b/Switch_Toolbox_Library/Toolbox_Library.csproj index 37573683..66d4ff5b 100644 --- a/Switch_Toolbox_Library/Toolbox_Library.csproj +++ b/Switch_Toolbox_Library/Toolbox_Library.csproj @@ -237,6 +237,7 @@ +