diff --git a/File_Format_Library/FileFormats/Pikmin1/TXE.cs b/File_Format_Library/FileFormats/Pikmin1/TXE.cs index d42b1616..a223af5f 100644 --- a/File_Format_Library/FileFormats/Pikmin1/TXE.cs +++ b/File_Format_Library/FileFormats/Pikmin1/TXE.cs @@ -77,7 +77,7 @@ namespace FirstPlugin //Lets set our method of decoding PlatformSwizzle = PlatformSwizzle.Platform_Gamecube; - int imageDataSize = reader.ReadInt32(); + int imageDataSize = (int)reader.BaseStream.Length - 32; reader.SeekBegin(32); diff --git a/Switch_Toolbox_Library/StaticDynamic.cs b/Switch_Toolbox_Library/StaticDynamic.cs new file mode 100644 index 00000000..69cc13cf --- /dev/null +++ b/Switch_Toolbox_Library/StaticDynamic.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Dynamic; +using System.Reflection; + +namespace Toolbox.Library +{ + public class StaticDynamic : DynamicObject + { + private Type _type; + public StaticDynamic(Type type) { _type = type; } + + // Handle static properties + public override bool TryGetMember(GetMemberBinder binder, out object result) + { + PropertyInfo prop = _type.GetProperty(binder.Name, BindingFlags.FlattenHierarchy | BindingFlags.Static | BindingFlags.Public); + if (prop == null) + { + result = null; + return false; + } + + result = prop.GetValue(null, null); + return true; + } + + // Handle static methods + public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) + { + MethodInfo method = _type.GetMethod(binder.Name, BindingFlags.FlattenHierarchy | BindingFlags.Static | BindingFlags.Public); + if (method == null) + { + result = null; + return false; + } + + result = method.Invoke(null, args); + return true; + } + } +} diff --git a/Switch_Toolbox_Library/Texture Decoding/Gamecube/Decode_Gamecube.cs b/Switch_Toolbox_Library/Texture Decoding/Gamecube/Decode_Gamecube.cs index 0fe79362..ed7a5511 100644 --- a/Switch_Toolbox_Library/Texture Decoding/Gamecube/Decode_Gamecube.cs +++ b/Switch_Toolbox_Library/Texture Decoding/Gamecube/Decode_Gamecube.cs @@ -744,7 +744,7 @@ namespace Toolbox.Library private static byte[] DecodeRgb5A3(FileReader stream, uint width, uint height) { - uint numBlocksW = width / 4; //4 byte block width + uint numBlocksW = width / 4; //4 byte block width uint numBlocksH = height / 4; //4 byte block height byte[] decodedData = new byte[width * height * 4]; diff --git a/Switch_Toolbox_Library/Toolbox.Library.dll b/Switch_Toolbox_Library/Toolbox.Library.dll index ae1386af..15cae79c 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 959bb6d9..f712c99c 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 e33661b6..557fc077 100644 --- a/Switch_Toolbox_Library/Toolbox_Library.csproj +++ b/Switch_Toolbox_Library/Toolbox_Library.csproj @@ -295,6 +295,7 @@ + diff --git a/Toolbox/GUI/FileAssociationForm.cs b/Toolbox/GUI/FileAssociationForm.cs index 00a9e8b0..54815bc8 100644 --- a/Toolbox/GUI/FileAssociationForm.cs +++ b/Toolbox/GUI/FileAssociationForm.cs @@ -29,8 +29,9 @@ namespace Toolbox { listViewCustom1.Items.Clear(); - foreach (var item in FileManager.GetFileFormats()) + foreach (Type t in FileManager.GetFileFormats()) { + dynamic item = new StaticDynamic(t); for (int i = 0; i < item.Extension.Length; i++) { string Extension; diff --git a/Toolbox/MainForm.cs b/Toolbox/MainForm.cs index 701689de..49dc77a9 100644 --- a/Toolbox/MainForm.cs +++ b/Toolbox/MainForm.cs @@ -25,8 +25,8 @@ namespace Toolbox private static MainForm _instance; public static MainForm Instance { get { return _instance == null ? _instance = new MainForm() : _instance; } } - IFileFormat[] SupportedFormats; - IFileMenuExtension[] FileMenuExtensions; + IFileFormat[] SupportedFormats { get { return FileManager.GetFileFormats(); } } + IFileMenuExtension[] FileMenuExtensions { get { return FileManager.GetMenuExtensions(); } } public void AddChildContainer(Form form) { @@ -64,12 +64,6 @@ namespace Toolbox } } - public void Reload() - { - SupportedFormats = FileManager.GetFileFormats(); - FileMenuExtensions = FileManager.GetMenuExtensions(); - } - //Use for files opened with program public List openedFiles = new List(); @@ -122,7 +116,6 @@ namespace Toolbox LoadPLugins(); UpdateToolbar(HasVersionFile); - Reload(); LoadConfig(); LoadMDITheme(); LoadRecentList(); @@ -247,8 +240,6 @@ namespace Toolbox public void OpenFile(string FileName, bool InActiveEditor = false) { - Reload(); - if (File.Exists(FileName)) SaveRecentFile(FileName);