From da566bd42cde8c832c73fc5edfa5d33cd5fbc225 Mon Sep 17 00:00:00 2001 From: Mixone-FinallyHere Date: Wed, 6 Nov 2024 00:04:07 +0100 Subject: [PATCH] Removed json script stuff outside of main --- DS_Map/DSPRE.csproj | 31 ---------------- DS_Map/Main Window.cs | 3 +- DS_Map/Tools/JsonExporter.cs | 72 ------------------------------------ 3 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 DS_Map/Tools/JsonExporter.cs diff --git a/DS_Map/DSPRE.csproj b/DS_Map/DSPRE.csproj index 46bcd69..20c9c83 100644 --- a/DS_Map/DSPRE.csproj +++ b/DS_Map/DSPRE.csproj @@ -322,7 +322,6 @@ SpawnEditor.cs - Form @@ -493,36 +492,6 @@ WildEditorDPPt.cs - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - SettingsSingleFileGenerator Settings.Designer.cs diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs index 6c80cd3..e824e85 100644 --- a/DS_Map/Main Window.cs +++ b/DS_Map/Main Window.cs @@ -27,7 +27,6 @@ using static DSPRE.ROMFiles.SpeciesFile; using System.Reflection; using System.ComponentModel; using DSPRE.Editors; -using DSPRE.Tools; namespace DSPRE { @@ -10027,7 +10026,7 @@ namespace DSPRE { private void exportScriptDatabaseJSONToolStripMenuItem_Click(object sender, EventArgs e) { - JsonExporter.ExportDictionaries(); + MessageBox.Show("Not implemented yet"); } } } diff --git a/DS_Map/Tools/JsonExporter.cs b/DS_Map/Tools/JsonExporter.cs deleted file mode 100644 index f911dcc..0000000 --- a/DS_Map/Tools/JsonExporter.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.IO; -using System.Text.Json; -using System.Text.Json.Serialization; -using System.Collections.Generic; -using System.Linq; -using DSPRE.Resources; -using System.Collections; -using System; - -namespace DSPRE.Tools -{ - public static class JsonExporter - { - private const string ExportDirectory = "Exports/ScriptDatabase/"; - - public static void ExportDictionaries() - { - // Ensure the directory exists - Directory.CreateDirectory(ExportDirectory); - - ExportWithMetadata(Path.Combine(ExportDirectory, "comparisonOperatorsDict.json"), ScriptDatabase.comparisonOperatorsDict); - ExportWithMetadata(Path.Combine(ExportDirectory, "comparisonOperatorsGenVappendix.json"), ScriptDatabase.comparisonOperatorsGenVappendix); - ExportWithMetadata(Path.Combine(ExportDirectory, "specialOverworlds.json"), ScriptDatabase.specialOverworlds); - ExportWithMetadata(Path.Combine(ExportDirectory, "overworldDirections.json"), ScriptDatabase.overworldDirections); - ExportWithMetadata(Path.Combine(ExportDirectory, "commandsWithRelativeJump.json"), ScriptDatabase.commandsWithRelativeJump); - ExportWithMetadata(Path.Combine(ExportDirectory, "endCodes.json"), ScriptDatabase.endCodes); - ExportWithMetadata(Path.Combine(ExportDirectory, "movementsDictIDName.json"), ScriptDatabase.movementsDictIDName); - ExportWithMetadata(Path.Combine(ExportDirectory, "movementEndCodes.json"), ScriptDatabase.movementEndCodes); - ExportCommandJson(Path.Combine(ExportDirectory, "DPPtCommands.json"), ScriptDatabase.DPPtScrCmdNames, ScriptDatabase.DPPtScrCmdParameters); - ExportCommandJson(Path.Combine(ExportDirectory, "HGSSCommands.json"), ScriptDatabase.HGSSScrCmdNames, ScriptDatabase.HGSSScrCmdParameters); - } - - private static void ExportWithMetadata(string filePath, T data) - { - var output = new - { - Type = typeof(T).Name, - Data = data - }; - string json = JsonSerializer.Serialize(output, new JsonSerializerOptions - { - WriteIndented = true, - NumberHandling = JsonNumberHandling.AllowReadingFromString - }); - File.WriteAllText(filePath, json); - } - - private static void ExportCommandJson(string filePath, Dictionary commandNames, Dictionary commandParameters) - { - var commands = commandNames.ToDictionary( - entry => entry.Key, - entry => new { - Name = entry.Value, - Parameters = commandParameters.ContainsKey(entry.Key) ? Array.ConvertAll(commandParameters[entry.Key], b => (int)b) : null - } - ); - - var output = new - { - Type = "Dictionary", - Data = commands - }; - - string json = JsonSerializer.Serialize(output, new JsonSerializerOptions - { - WriteIndented = true, - NumberHandling = JsonNumberHandling.AllowReadingFromString - }); - File.WriteAllText(filePath, json); - } - } -}