diff --git a/DumpCleaner/DumpCleaner.csproj b/DumpCleaner/DumpCleaner.csproj new file mode 100644 index 0000000..35361f5 --- /dev/null +++ b/DumpCleaner/DumpCleaner.csproj @@ -0,0 +1,14 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + diff --git a/DumpCleaner/DumpFiles.cs b/DumpCleaner/DumpFiles.cs new file mode 100644 index 0000000..7e1c793 --- /dev/null +++ b/DumpCleaner/DumpFiles.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DumpCleaner +{ + public static class DumpFiles + { + public static List filenames = new List() + { + new DumpData{InputName = "resp.client.items", OutputName = "items", OutputFolder = "templates"}, + new DumpData{InputName = "resp.client.handbook.templates", OutputName = "handbook", OutputFolder = "templates"}, + new DumpData{InputName = "resp.client.customization", OutputName = "customization", OutputFolder = "templates"}, + + new DumpData{InputName = "resp.client.locale.ru", OutputName = "ru", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.en", OutputName = "en", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.jp", OutputName = "jp", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.es-mx", OutputName = "es-mx", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.kr", OutputName = "kr", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.es", OutputName = "es", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.fr", OutputName = "fr", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.ge", OutputName = "ge", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.it", OutputName = "it", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.hu", OutputName = "hu", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.tu", OutputName = "tu", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.pl", OutputName = "pl", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.po", OutputName = "po", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.sk", OutputName = "sk", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.cz", OutputName = "cz", OutputFolder = "locales\\global"}, + new DumpData{InputName = "resp.client.locale.ch", OutputName = "ch", OutputFolder = "locales\\global"}, + + new DumpData{InputName = "resp.client.menu.locale.en", OutputName = "en", OutputFolder = "locales\\menu"}, + + new DumpData{InputName = "resp.client.globals", OutputName = "globals", OutputFolder = ""}, + + new DumpData{InputName = "resp.client.hideout.production.recipes", OutputName = "production", OutputFolder = "hideout"}, + new DumpData{InputName = "resp.client.hideout.areas", OutputName = "areas", OutputFolder = "hideout"}, + new DumpData{InputName = "resp.client.hideout.production.scavcase.recipes", OutputName = "scavcase", OutputFolder = "hideout"}, + new DumpData{InputName = "resp.client.hideout.settings", OutputName = "settings", OutputFolder = "hideout"}, + + }; + } + + public class DumpData + { + public string InputName { get; set; } + public string OutputName { get; set; } + public string OutputFolder { get; set; } + } + + public class Dump + { + public int err { get; set; } + public string errMsg { get; set; } + public object data { get; set; } + } +} diff --git a/DumpCleaner/Program.cs b/DumpCleaner/Program.cs new file mode 100644 index 0000000..025c348 --- /dev/null +++ b/DumpCleaner/Program.cs @@ -0,0 +1,48 @@ + + +// read contents of input folder +using AssortGenerator.Common.Helpers; +using DumpCleaner; +using QuestValidator.Common; +using QuestValidator.Common.Helpers; +using QuestValidator.Helpers; +using System.Text.Json; + +var inputPath = DiskHelpers.CreateWorkingFolders(); +InputFileHelper.SetInputFiles(inputPath); + +var filePaths = InputFileHelper.GetInputFilePaths(); + +//create list of paths +foreach (var path in filePaths) +{ + var filename = Path.GetFileNameWithoutExtension(path); + var names = DumpFiles.filenames.FirstOrDefault(x=> filename.StartsWith(x.InputName)); + + if (names == null) + { + LoggingHelpers.LogToConsole($"No mapping found for file: {filename} Skipping", ConsoleColor.Yellow); + continue; + } + + var questDataJson = File.ReadAllText(path); + var dumpFile = JsonSerializer.Deserialize(questDataJson); + + if (dumpFile.data == null) + { + LoggingHelpers.LogWarning($"file: {filename} had no data in it, skipping"); + continue; + } + + JsonWriter.WriteJson(dumpFile.data, names.OutputFolder, Directory.GetCurrentDirectory(), names.OutputName); + LoggingHelpers.LogToConsole($"Found file: {filename} wrote file to output folder"); +} + + +// iterate over paths + +// check if filename matches a file in a list of files we want +// it matches: clean up file and output to 'output' +// get data object from it, save this into new file + +// doesnt match: ignore it with warning \ No newline at end of file