Add dump cleaner project

This commit is contained in:
Chomp 2022-01-04 16:10:00 +00:00
parent 2132f0e7b7
commit 340cd0705e
3 changed files with 121 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\QuestValidator.Common\QuestValidator.Common.csproj" />
</ItemGroup>
</Project>

59
DumpCleaner/DumpFiles.cs Normal file
View File

@ -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<DumpData> filenames = new List<DumpData>()
{
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; }
}
}

48
DumpCleaner/Program.cs Normal file
View File

@ -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<Dump>(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