From f1bfd81823b297fb6f810d48859853606a9f35b5 Mon Sep 17 00:00:00 2001 From: crskycode Date: Mon, 15 Mar 2021 03:40:47 +0800 Subject: [PATCH] Add scheme tool --- GARbro.sln | 8 ++++ SchemeTool/App.config | 18 ++++++++ SchemeTool/Program.cs | 49 +++++++++++++++++++++ SchemeTool/Properties/AssemblyInfo.cs | 36 +++++++++++++++ SchemeTool/SchemeTool.csproj | 63 +++++++++++++++++++++++++++ 5 files changed, 174 insertions(+) create mode 100644 SchemeTool/App.config create mode 100644 SchemeTool/Program.cs create mode 100644 SchemeTool/Properties/AssemblyInfo.cs create mode 100644 SchemeTool/SchemeTool.csproj diff --git a/GARbro.sln b/GARbro.sln index 90a3ffb8..db7e686b 100644 --- a/GARbro.sln +++ b/GARbro.sln @@ -37,6 +37,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Legacy", "Legacy\Legacy.csp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Net20", "Net20\Net20.csproj", "{73B6C693-9846-4D33-8300-A80239FCFFF9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchemeTool", "SchemeTool\SchemeTool.csproj", "{CF0D6842-D071-49AF-A6B7-D5C5799CE582}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -88,6 +90,12 @@ Global {73B6C693-9846-4D33-8300-A80239FCFFF9}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU {73B6C693-9846-4D33-8300-A80239FCFFF9}.Release|Any CPU.ActiveCfg = Release|Any CPU {73B6C693-9846-4D33-8300-A80239FCFFF9}.Release|Any CPU.Build.0 = Release|Any CPU + {CF0D6842-D071-49AF-A6B7-D5C5799CE582}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF0D6842-D071-49AF-A6B7-D5C5799CE582}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF0D6842-D071-49AF-A6B7-D5C5799CE582}.Prerelease|Any CPU.ActiveCfg = Debug|Any CPU + {CF0D6842-D071-49AF-A6B7-D5C5799CE582}.Prerelease|Any CPU.Build.0 = Debug|Any CPU + {CF0D6842-D071-49AF-A6B7-D5C5799CE582}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF0D6842-D071-49AF-A6B7-D5C5799CE582}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SchemeTool/App.config b/SchemeTool/App.config new file mode 100644 index 00000000..0ce8d82b --- /dev/null +++ b/SchemeTool/App.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SchemeTool/Program.cs b/SchemeTool/Program.cs new file mode 100644 index 00000000..a38e8bb6 --- /dev/null +++ b/SchemeTool/Program.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SchemeTool +{ + class Program + { + static void Main(string[] args) + { + // Load database + using (Stream stream = File.OpenRead(".\\GameData\\Formats.dat")) + { + GameRes.FormatCatalog.Instance.DeserializeScheme(stream); + } + + GameRes.Formats.KiriKiri.Xp3Opener format = GameRes.FormatCatalog.Instance.ArcFormats + .FirstOrDefault(a => a is GameRes.Formats.KiriKiri.Xp3Opener) as GameRes.Formats.KiriKiri.Xp3Opener; + + if (format != null) + { + GameRes.Formats.KiriKiri.Xp3Scheme scheme = format.Scheme as GameRes.Formats.KiriKiri.Xp3Scheme; + + // Add scheme information here + GameRes.Formats.KiriKiri.ICrypt crypt = new GameRes.Formats.KiriKiri.XorCrypt(0x00); + + scheme.KnownSchemes.Add("game title", crypt); + } + + var gameMap = typeof(GameRes.FormatCatalog).GetField("m_game_map", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) + .GetValue(GameRes.FormatCatalog.Instance) as Dictionary; + + if (gameMap != null) + { + // Add file name here + gameMap.Add("file.exe", "game title"); + } + + // Save database + using (Stream stream = File.Create(".\\GameData\\Formats.dat")) + { + GameRes.FormatCatalog.Instance.SerializeScheme(stream); + } + } + } +} diff --git a/SchemeTool/Properties/AssemblyInfo.cs b/SchemeTool/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a05c429c --- /dev/null +++ b/SchemeTool/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SchemeTool")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SchemeTool")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("cf0d6842-d071-49af-a6b7-d5c5799ce582")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SchemeTool/SchemeTool.csproj b/SchemeTool/SchemeTool.csproj new file mode 100644 index 00000000..9339af1e --- /dev/null +++ b/SchemeTool/SchemeTool.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {CF0D6842-D071-49AF-A6B7-D5C5799CE582} + Exe + SchemeTool + SchemeTool + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + ..\bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + ..\bin\Debug\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + {a8865685-27cc-427b-ac38-e48d2ad05df4} + ArcFormats + + + {453c087f-e416-4ae9-8c03-d8760da0574b} + GameRes + + + + \ No newline at end of file