From ca210307f077778ffd2158612d7c36961e1134be Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sun, 2 Nov 2025 09:32:17 +0800 Subject: [PATCH] Add DecodeSchema tool --- DecodeSchema/App.config | 6 ++ DecodeSchema/DecodeSchema.csproj | 89 +++++++++++++++++++++++++ DecodeSchema/Program.cs | 43 ++++++++++++ DecodeSchema/Properties/AssemblyInfo.cs | 33 +++++++++ DecodeSchema/packages.config | 4 ++ GARbro.sln | 13 +++- packages/repositories.config | 1 + 7 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 DecodeSchema/App.config create mode 100644 DecodeSchema/DecodeSchema.csproj create mode 100644 DecodeSchema/Program.cs create mode 100644 DecodeSchema/Properties/AssemblyInfo.cs create mode 100644 DecodeSchema/packages.config diff --git a/DecodeSchema/App.config b/DecodeSchema/App.config new file mode 100644 index 00000000..8324aa6f --- /dev/null +++ b/DecodeSchema/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DecodeSchema/DecodeSchema.csproj b/DecodeSchema/DecodeSchema.csproj new file mode 100644 index 00000000..045def76 --- /dev/null +++ b/DecodeSchema/DecodeSchema.csproj @@ -0,0 +1,89 @@ + + + + + Debug + AnyCPU + {A392D826-1E24-45D7-B706-5A59A097A25A} + Exe + DecodeSchema + DecodeSchema + v4.6 + 512 + true + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + ..\bin\Debug\ + DEBUG;TRACE + prompt + 5 + Off + false + + + AnyCPU + pdbonly + true + ..\bin\Release\ + TRACE + prompt + 4 + false + + + + ..\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + {453c087f-e416-4ae9-8c03-d8760da0574b} + GameRes + + + + + False + .NET Framework 3.5 SP1 + false + + + + + \ No newline at end of file diff --git a/DecodeSchema/Program.cs b/DecodeSchema/Program.cs new file mode 100644 index 00000000..19ff5160 --- /dev/null +++ b/DecodeSchema/Program.cs @@ -0,0 +1,43 @@ +using GameRes; +using GameRes.Compression; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Serialization.Formatters.Binary; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace DecodeSchema { + internal class Program { + static void Main(string[] args) { + DecodeSchema decodeSchema = new DecodeSchema(); + decodeSchema.decode(); + } + } + internal class DecodeSchema { + public void decode() { + DeserializeGameData(); + } + void DeserializeGameData() { + string scheme_file = Path.Combine(FormatCatalog.Instance.DataDirectory, "Formats.dat"); + try { + using (var file = File.OpenRead(scheme_file)) { + var version = FormatCatalog.Instance.GetSerializedSchemeVersion(file); + using (var zs = new ZLibStream(file, CompressionMode.Decompress, true)) { + var bin = new BinaryFormatter(); + var db = (SchemeDataBase)bin.Deserialize(zs); + string json = JsonConvert.SerializeObject(db, Formatting.Indented, + new JsonSerializerSettings { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore + }); + File.WriteAllText("Formats.json", json, Encoding.UTF8); + } + } + } catch (Exception X) { + Console.Error.WriteLine("Scheme deserialization failed: {0}", X.Message); + } + } + } +} diff --git a/DecodeSchema/Properties/AssemblyInfo.cs b/DecodeSchema/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..82203c1e --- /dev/null +++ b/DecodeSchema/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +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("DecodeSchema")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DecodeSchema")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[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("a392d826-1e24-45d7-b706-5a59a097a25a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DecodeSchema/packages.config b/DecodeSchema/packages.config new file mode 100644 index 00000000..8fc7a030 --- /dev/null +++ b/DecodeSchema/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/GARbro.sln b/GARbro.sln index 60b60880..8a80f3ef 100644 --- a/GARbro.sln +++ b/GARbro.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.14.36518.9 d17.14 +VisualStudioVersion = 17.14.36518.9 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GARbro.Console", "Console\GARbro.Console.csproj", "{B966F292-431A-4D8A-A1D3-1EB45048A1D2}" ProjectSection(ProjectDependencies) = postProject @@ -29,6 +29,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}") = "DecodeSchema", "DecodeSchema\DecodeSchema.csproj", "{A392D826-1E24-45D7-B706-5A59A097A25A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -76,8 +78,17 @@ 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 + {A392D826-1E24-45D7-B706-5A59A097A25A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A392D826-1E24-45D7-B706-5A59A097A25A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A392D826-1E24-45D7-B706-5A59A097A25A}.Prerelease|Any CPU.ActiveCfg = Release|Any CPU + {A392D826-1E24-45D7-B706-5A59A097A25A}.Prerelease|Any CPU.Build.0 = Release|Any CPU + {A392D826-1E24-45D7-B706-5A59A097A25A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A392D826-1E24-45D7-B706-5A59A097A25A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FC2D1BC7-F40A-494D-90C9-F1A5BB00BE1A} + EndGlobalSection EndGlobal diff --git a/packages/repositories.config b/packages/repositories.config index beb2ebb0..571e030c 100644 --- a/packages/repositories.config +++ b/packages/repositories.config @@ -1,6 +1,7 @@  +