refactoring
This commit is contained in:
parent
0c9f958cc5
commit
bb282dd6a3
2
.gitignore
vendored
2
.gitignore
vendored
@ -19,3 +19,5 @@
|
|||||||
|
|
||||||
#backups
|
#backups
|
||||||
.old*/
|
.old*/
|
||||||
|
|
||||||
|
nuget.config
|
||||||
|
|||||||
71
Clear.cs
Normal file
71
Clear.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
namespace ParadoxModMerger;
|
||||||
|
|
||||||
|
static class Clear
|
||||||
|
{
|
||||||
|
|
||||||
|
static ConsoleLogger logger = new($"logs", "clear");
|
||||||
|
static void Log(params string[] msg) => logger.Log(msg);
|
||||||
|
|
||||||
|
public static void ClearWorkshop(string workshopDir, string outDir)
|
||||||
|
{
|
||||||
|
string[] moddirs = Directory.GetDirectories(workshopDir);
|
||||||
|
Log("b", $"found {moddirs.Length} mod dirs");
|
||||||
|
for (int i = 0; i < moddirs.Length; i++)
|
||||||
|
{
|
||||||
|
string modarch = "";
|
||||||
|
if (Directory.GetFiles(moddirs[i], "*.zip").Length != 0)
|
||||||
|
modarch = Directory.GetFiles(moddirs[i], "*.zip")[0];
|
||||||
|
if (modarch.Length != 0)
|
||||||
|
{
|
||||||
|
Log("y", $"archive found: {modarch}");
|
||||||
|
var pr = new Process();
|
||||||
|
pr.StartInfo.CreateNoWindow = true;
|
||||||
|
pr.StartInfo.UseShellExecute = false;
|
||||||
|
pr.StartInfo.FileName = Path.Concat("7z", "7z.exe");
|
||||||
|
pr.StartInfo.Arguments = $"x -y -o _UNZIP \"{modarch}\"";
|
||||||
|
pr.Start();
|
||||||
|
pr.WaitForExit();
|
||||||
|
moddirs[i] = "_UNZIP";
|
||||||
|
Log("g", "\tfiles extracted");
|
||||||
|
}
|
||||||
|
|
||||||
|
string modname = File.ReadAllText(Path.Concat(moddirs[i], "descriptor.mod"));
|
||||||
|
modname = modname.Remove(0, modname.IndexOf("name=\"", StringComparison.Ordinal) + 6);
|
||||||
|
modname = Path.CorrectString(modname.Remove(modname.IndexOf("\"", StringComparison.Ordinal)));
|
||||||
|
Log("b", $"[{i + 1}/{moddirs.Length}] copying mod ", "c", $"{modname}");
|
||||||
|
string[] subdirs = Directory.GetDirectories(moddirs[i]);
|
||||||
|
for (sbyte n = 0; n < subdirs.Length; n++)
|
||||||
|
{
|
||||||
|
subdirs[n] = subdirs[n].Remove(0, subdirs[n].LastIndexOf(Path.Sep) + 1);
|
||||||
|
switch (subdirs[n])
|
||||||
|
{
|
||||||
|
// stellaris
|
||||||
|
case "common":
|
||||||
|
case "events":
|
||||||
|
case "flags":
|
||||||
|
case "fonts":
|
||||||
|
case "gfx":
|
||||||
|
case "interface":
|
||||||
|
case "localisation":
|
||||||
|
case "localisation_synced":
|
||||||
|
case "map":
|
||||||
|
case "music":
|
||||||
|
case "prescripted_countries":
|
||||||
|
case "sound":
|
||||||
|
// hoi4
|
||||||
|
case "history":
|
||||||
|
case "portraits":
|
||||||
|
{
|
||||||
|
Directory.Copy(Path.Concat(moddirs[i], subdirs[n]),
|
||||||
|
Path.Concat(outDir, modname, subdirs[n]),
|
||||||
|
out List<string> _conflicts, true);
|
||||||
|
Program.LogConflicts(_conflicts);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.Exists("_UNZIP")) Directory.Delete("_UNZIP");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
76
Diff.cs
Normal file
76
Diff.cs
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
namespace ParadoxModMerger;
|
||||||
|
|
||||||
|
static class Diff
|
||||||
|
{
|
||||||
|
static ConsoleLogger logger = new($"logs", "diff");
|
||||||
|
static void Log(params string[] msg) => logger.Log(msg);
|
||||||
|
|
||||||
|
public static void DiffMods(string connectedPathes)
|
||||||
|
{
|
||||||
|
string[] split = connectedPathes.Split(';');
|
||||||
|
DiffMods(split[0], split[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DiffMods(string moddir0, string moddir1)
|
||||||
|
{
|
||||||
|
var hasher = new Hasher();
|
||||||
|
var diff = new Dictionary<string, byte[]>();
|
||||||
|
// добавление файлов из первой папки
|
||||||
|
List<string> files = Directory.GetAllFiles(moddir0);
|
||||||
|
var mods = new List<string>();
|
||||||
|
for (short i = 0; i < files.Count; i++)
|
||||||
|
{
|
||||||
|
byte[] hash = hasher.HashFile(files[i]);
|
||||||
|
files[i] = files[i].Replace(moddir0, "");
|
||||||
|
diff.Add(files[i], hash);
|
||||||
|
AddMod(files[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// убирание совпадающих файлов
|
||||||
|
files = Directory.GetAllFiles(moddir1);
|
||||||
|
for (short i = 0; i < files.Count; i++)
|
||||||
|
{
|
||||||
|
byte[] hash = hasher.HashFile(files[i]);
|
||||||
|
files[i] = files[i].Replace(moddir1, "");
|
||||||
|
if (diff.ContainsKey(files[i]) && diff[files[i]].HashToString() == hash.HashToString())
|
||||||
|
diff.Remove(files[i]);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
diff.Add(moddir1 + files[i], hash);
|
||||||
|
AddMod(files[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddMod(string mod)
|
||||||
|
{
|
||||||
|
mod = mod.Remove(0, 1);
|
||||||
|
mod = mod.Remove(mod.IndexOf(Path.Sep));
|
||||||
|
if (!mods.Contains(mod)) mods.Add(mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
// вывод результата
|
||||||
|
StringBuilder output = new StringBuilder();
|
||||||
|
output.Append($"[{DateTime.Now}]\n\n");
|
||||||
|
foreach (string mod in mods)
|
||||||
|
{
|
||||||
|
output.Append('\n').Append(mod).Append("\n{\n");
|
||||||
|
foreach (string file in diff.Keys)
|
||||||
|
{
|
||||||
|
if (file.Contains(mod))
|
||||||
|
{
|
||||||
|
output.Append('\t');
|
||||||
|
if (!file.Contains(moddir1)) output.Append(moddir0).Append(file).Append('\n');
|
||||||
|
output.Append(file).Append('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output.Append("}\n");
|
||||||
|
// не убирать, это полезное
|
||||||
|
if (output[output.Length - 4] == '{')
|
||||||
|
output.Remove(output.Length - mod.Length - 5, mod.Length + 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
var _outStr = output.ToString();
|
||||||
|
Log("w", _outStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
Localisation.cs
Normal file
26
Localisation.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
namespace ParadoxModMerger;
|
||||||
|
|
||||||
|
static class Localisation
|
||||||
|
{
|
||||||
|
static ConsoleLogger logger = new($"logs", "autoloc");
|
||||||
|
static void Log(params string[] msg) => logger.Log(msg);
|
||||||
|
|
||||||
|
public static void GenerateRussian(string engDir, string rusDir)
|
||||||
|
{
|
||||||
|
foreach (string enfFileName in Directory.GetAllFiles(engDir))
|
||||||
|
{
|
||||||
|
string rusFileName = enfFileName
|
||||||
|
.Replace(engDir, rusDir)
|
||||||
|
.Replace("l_english", "l_russian");
|
||||||
|
if (!File.Exists(rusFileName))
|
||||||
|
{
|
||||||
|
string text = File.ReadAllText(enfFileName)
|
||||||
|
.Replace("l_english:", "l_russian: ");
|
||||||
|
byte[] bytes = StringConverter.UTF8BOM.GetBytes(text);
|
||||||
|
File.WriteAllBytes(rusFileName, bytes);
|
||||||
|
Log("g", $"file {rusFileName} created");
|
||||||
|
}
|
||||||
|
else Log("y", $"file {rusFileName} already exists");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Merge.cs
Normal file
24
Merge.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
namespace ParadoxModMerger;
|
||||||
|
|
||||||
|
static class Merge
|
||||||
|
{
|
||||||
|
static ConsoleLogger logger = new($"logs", "merge");
|
||||||
|
static void Log(params string[] msg) => logger.Log(msg);
|
||||||
|
|
||||||
|
public static void MergeAll(string[] moddirs, string outDir)
|
||||||
|
{
|
||||||
|
Log("b", $"found {moddirs.Length} mod dirs");
|
||||||
|
for (short i = 0; i < moddirs.Length; i++)
|
||||||
|
{
|
||||||
|
Log("b", $"[{i + 1}/{moddirs.Length}] merging mod ", "c", $"{moddirs[i]}");
|
||||||
|
Directory.Copy(moddirs[i], outDir, out List<string> _conflicts, true);
|
||||||
|
Program.LogConflicts(_conflicts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void MergeSingle(string moddir, string outDir)
|
||||||
|
{
|
||||||
|
Directory.Copy(moddir, outDir, out List<string> _conflicts, true);
|
||||||
|
Program.LogConflicts(_conflicts);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,217 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Text;
|
|
||||||
using DTLib;
|
|
||||||
using DTLib.Filesystem;
|
|
||||||
using DTLib.Logging;
|
|
||||||
using DTLib.Extensions;
|
|
||||||
|
|
||||||
static class ParadoxModMerger
|
|
||||||
{
|
|
||||||
|
|
||||||
// вывод лога в консоль и файл
|
|
||||||
static ConsoleLogger logger = new ConsoleLogger("merger-logs", "merger");
|
|
||||||
static void Log(params string[] msg) => logger.Log(msg);
|
|
||||||
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
PublicLog.LogEvent += Log;
|
|
||||||
|
|
||||||
// хелп
|
|
||||||
if (args.Length == 0 || args[0] == "/?" || args[0] == "-h")
|
|
||||||
{
|
|
||||||
Log(
|
|
||||||
"b", "paradox mod merger help:\n",
|
|
||||||
"c", "-clear \"steamworkshop dir\" -out \"utput dir\" ",
|
|
||||||
"b", "clear mod files and put them into separate dirs in output dir\n",
|
|
||||||
"c", "-merge \"dir with mods\" -out \"output dir\" ",
|
|
||||||
"b", "merge mods and show conflicts\n",
|
|
||||||
"c", "-merge-single \"dir with mod\" -out \"output dir\" ",
|
|
||||||
"b", "copy single mod files and show conflicts\n",
|
|
||||||
"c", "-diff \"dir with mods\" \"another dir with mods\" -out \"output file\" ",
|
|
||||||
"b", "compare mod files hashes for finding different files");
|
|
||||||
Console.ResetColor();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string srcdir = "";
|
|
||||||
string srcdir2 = "";
|
|
||||||
string outdir = "";
|
|
||||||
int mode = -1;
|
|
||||||
// определение всех аргументов
|
|
||||||
for (sbyte i = 0; i < args.Length; i++)
|
|
||||||
{
|
|
||||||
switch (args[i])
|
|
||||||
{
|
|
||||||
case "-clear":
|
|
||||||
srcdir = args[++i].Replace("\"", "").ИсправитьРазд();
|
|
||||||
mode = 0;
|
|
||||||
break;
|
|
||||||
case "-merge":
|
|
||||||
srcdir = args[++i].Replace("\"", "").ИсправитьРазд();
|
|
||||||
mode = 1;
|
|
||||||
break;
|
|
||||||
case "-diff":
|
|
||||||
srcdir = args[++i].Replace("\"", "").ИсправитьРазд();
|
|
||||||
srcdir2 = args[++i].Replace("\"", "").ИсправитьРазд();
|
|
||||||
mode = 2;
|
|
||||||
break;
|
|
||||||
case "-merge-single":
|
|
||||||
srcdir = args[++i].Replace("\"", "").ИсправитьРазд();
|
|
||||||
mode = 3;
|
|
||||||
break;
|
|
||||||
case "-out":
|
|
||||||
outdir = args[++i].Replace("\"", "").ИсправитьРазд();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Exception($"invalid argument: <{args[i]}>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var conflicts = new List<string>();
|
|
||||||
string[] moddirs = Directory.GetDirectories(srcdir);
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
Log("b", $"found {moddirs.Length} mod dirs");
|
|
||||||
for (int i = 0; i < moddirs.Length; i++)
|
|
||||||
{
|
|
||||||
string modarch = "";
|
|
||||||
if (Directory.GetFiles(moddirs[i], "*.zip").Length != 0) modarch = Directory.GetFiles(moddirs[i], "*.zip")[0];
|
|
||||||
if (modarch.Length != 0)
|
|
||||||
{
|
|
||||||
Log("y", $"archive found: {modarch}");
|
|
||||||
var pr = new Process();
|
|
||||||
pr.StartInfo.CreateNoWindow = true;
|
|
||||||
pr.StartInfo.UseShellExecute = false;
|
|
||||||
pr.StartInfo.FileName = "7z{Путь.Разд}7z.exe";
|
|
||||||
pr.StartInfo.Arguments = $"x -y -o_TEMP \"{modarch}\"";
|
|
||||||
pr.Start();
|
|
||||||
pr.WaitForExit();
|
|
||||||
moddirs[i] = "_TEMP";
|
|
||||||
Log("g", "\tfiles extracted");
|
|
||||||
}
|
|
||||||
string modname = File.ReadAllText($"{moddirs[i]}{Путь.Разд}descriptor.mod");
|
|
||||||
modname = modname.Remove(0, modname.IndexOf("name=\"") + 6);
|
|
||||||
modname = modname.Remove(modname.IndexOf("\""))
|
|
||||||
.Replace($"{Путь.Разд}", "").Replace(":", "").Replace("?", "").Replace("\"", "").Replace("/", "")
|
|
||||||
.Replace("\'", "").Replace("|", "").Replace("<", "").Replace(">", "").Replace("*", "");
|
|
||||||
Log("b", $"[{i + 1}/{moddirs.Length}] copying mod ", "c", $"{modname}");
|
|
||||||
string[] subdirs = Directory.GetDirectories(moddirs[i]);
|
|
||||||
for (sbyte n = 0; n < subdirs.Length; n++)
|
|
||||||
{
|
|
||||||
subdirs[n] = subdirs[n].Remove(0, subdirs[n].LastIndexOf(Путь.Разд) + 1);
|
|
||||||
switch (subdirs[n])
|
|
||||||
{
|
|
||||||
// stellaris
|
|
||||||
case "common":
|
|
||||||
case "events":
|
|
||||||
case "flags":
|
|
||||||
case "fonts":
|
|
||||||
case "gfx":
|
|
||||||
case "interface":
|
|
||||||
case "localisation":
|
|
||||||
case "localisation_synced":
|
|
||||||
case "map":
|
|
||||||
case "music":
|
|
||||||
case "prescripted_countries":
|
|
||||||
case "sound":
|
|
||||||
// hoi4
|
|
||||||
case "history":
|
|
||||||
case "portraits":
|
|
||||||
Directory.Copy($"{moddirs[i]}{Путь.Разд}{{subdirs[n]}}",
|
|
||||||
$"{outdir}{Путь.Разд}{{modname}}{Путь.Разд}{{subdirs[n]}}", out List<string> _conflicts, true);
|
|
||||||
conflicts.AddRange(_conflicts);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Directory.Exists("_TEMP")) Directory.Delete("_TEMP");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
Log("b", $"found {moddirs.Length} mod dirs");
|
|
||||||
for (short i = 0; i < moddirs.Length; i++)
|
|
||||||
{
|
|
||||||
Log("b", $"[{i + 1}/{moddirs.Length}] merging mod ", "c", $"{moddirs[i]}");
|
|
||||||
Directory.Copy(moddirs[i], outdir, out List<string> _conflicts, true);
|
|
||||||
conflicts.AddRange(_conflicts);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
var hasher = new Hasher();
|
|
||||||
var diff = new Dictionary<string, byte[]>();
|
|
||||||
// добавление файлов из первой папки
|
|
||||||
List<string> files = Directory.GetAllFiles(srcdir);
|
|
||||||
var mods = new List<string>();
|
|
||||||
for (short i = 0; i < files.Count; i++)
|
|
||||||
{
|
|
||||||
byte[] hash = hasher.HashFile(files[i]);
|
|
||||||
files[i] = files[i].Replace(srcdir, "");
|
|
||||||
diff.Add(files[i], hash);
|
|
||||||
AddMod(files[i]);
|
|
||||||
}
|
|
||||||
// убирание совпадающих файлов
|
|
||||||
files = Directory.GetAllFiles(srcdir2);
|
|
||||||
for (short i = 0; i < files.Count; i++)
|
|
||||||
{
|
|
||||||
byte[] hash = hasher.HashFile(files[i]);
|
|
||||||
files[i] = files[i].Replace(srcdir2, "");
|
|
||||||
if (diff.ContainsKey(files[i]) && diff[files[i]].HashToString() == hash.HashToString()) diff.Remove(files[i]);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
diff.Add(srcdir2 + files[i], hash);
|
|
||||||
AddMod(files[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void AddMod(string mod)
|
|
||||||
{
|
|
||||||
mod = mod.Remove(0, 1);
|
|
||||||
mod = mod.Remove(mod.IndexOf(Путь.Разд));
|
|
||||||
if (!mods.Contains(mod)) mods.Add(mod);
|
|
||||||
}
|
|
||||||
// вывод результата
|
|
||||||
StringBuilder output = new StringBuilder();
|
|
||||||
output.Append($"[{DateTime.Now}]\n\n");
|
|
||||||
foreach (string mod in mods)
|
|
||||||
{
|
|
||||||
output.Append('\n').Append(mod).Append("\n{\n");
|
|
||||||
foreach (string file in diff.Keys)
|
|
||||||
{
|
|
||||||
if (file.Contains(mod))
|
|
||||||
{
|
|
||||||
output.Append('\t');
|
|
||||||
if (!file.Contains(srcdir2)) output.Append(srcdir).Append(file).Append('\n');
|
|
||||||
output.Append(file).Append('\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output.Append("}\n");
|
|
||||||
// не убирать, это полезное
|
|
||||||
if (output[output.Length - 4] == '{') output.Remove(output.Length - mod.Length - 5, mod.Length + 5);
|
|
||||||
}
|
|
||||||
// хоть называется outdir, в данном случае это путь к файлу
|
|
||||||
var _outStr = output.ToString();
|
|
||||||
File.WriteAllText(outdir, _outStr);
|
|
||||||
Log("g", $"output written to {outdir}");
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
Directory.Copy(srcdir, outdir, out List<string> __conflicts, true);
|
|
||||||
conflicts.AddRange(__conflicts);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// вывод конфликтующих файлов при -merge и -clear если такие есть
|
|
||||||
if (conflicts.Count > 0)
|
|
||||||
{
|
|
||||||
Log("r", $"found {conflicts.Count} conflicts:\n",
|
|
||||||
"m", conflicts.MergeToString("\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log("r", $"{ex.Message}\n{ex.StackTrace}");
|
|
||||||
}
|
|
||||||
Console.ResetColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
using System;
|
|
||||||
using DTLib;
|
|
||||||
using DTLib.Extensions;
|
|
||||||
using DTLib.Filesystem;
|
|
||||||
using DTLib.Logging;
|
|
||||||
|
|
||||||
static class ParadoxRusLocalisationGen
|
|
||||||
{
|
|
||||||
static ConsoleLogger logger = new ConsoleLogger("autoloc-logs", "merger");
|
|
||||||
|
|
||||||
static void Main(string[] args)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (args.Length != 2 || args[0] == "/?" || args[0] == "help" || args[0] == "--help")
|
|
||||||
{
|
|
||||||
Console.WriteLine("[dir with eng localisation] [dir with rus localisation]");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string engDir = args[0];
|
|
||||||
string rusir = args[1];
|
|
||||||
foreach (string enfFileName in Directory.GetAllFiles(engDir))
|
|
||||||
{
|
|
||||||
string rusFileName = enfFileName
|
|
||||||
.Replace(engDir, rusir)
|
|
||||||
.Replace("l_english", "l_russian");
|
|
||||||
if (!File.Exists(rusFileName))
|
|
||||||
{
|
|
||||||
string text = File.ReadAllText(enfFileName)
|
|
||||||
.Replace("l_english:", "l_russian: ");
|
|
||||||
byte[] bytes = StringConverter.UTF8BOM.GetBytes(text);
|
|
||||||
File.WriteAllBytes(rusFileName, bytes);
|
|
||||||
logger.Log("g", $"file {rusFileName} created");
|
|
||||||
}
|
|
||||||
else logger.Log("y", $"file {rusFileName} already exists");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger.Log("r", $"{ex.Message}\n{ex.StackTrace}");
|
|
||||||
}
|
|
||||||
Console.ResetColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
72
Program.cs
Normal file
72
Program.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
global using System;
|
||||||
|
global using System.Collections.Generic;
|
||||||
|
global using System.Diagnostics;
|
||||||
|
global using System.Text;
|
||||||
|
global using DTLib;
|
||||||
|
global using DTLib.Extensions;
|
||||||
|
global using DTLib.Filesystem;
|
||||||
|
global using DTLib.Logging;
|
||||||
|
using DTLib.Console;
|
||||||
|
|
||||||
|
namespace ParadoxModMerger;
|
||||||
|
|
||||||
|
public static class Program
|
||||||
|
{
|
||||||
|
static ConsoleLogger logger = new($"logs", "main");
|
||||||
|
static void Log(params string[] msg) => logger.Log(msg);
|
||||||
|
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string outPath = "" ;
|
||||||
|
|
||||||
|
new LaunchArgumentParser(
|
||||||
|
new LaunchArgument(new []{"o", "out"},
|
||||||
|
"sets output path",
|
||||||
|
p => outPath=p,
|
||||||
|
"out_path",
|
||||||
|
0),
|
||||||
|
new LaunchArgument(new []{"clear"},
|
||||||
|
"Clear mod files and put them into separate dirs in output dir. Requires -o",
|
||||||
|
wdir=>Clear.ClearWorkshop(wdir, outPath),
|
||||||
|
"workshop_dir",
|
||||||
|
1),
|
||||||
|
new LaunchArgument(new []{"diff"},
|
||||||
|
"Compare mod files by hash",
|
||||||
|
p=>Diff.DiffMods(p),
|
||||||
|
"first_mod_directory;second_mod_directory", 1),
|
||||||
|
new LaunchArgument(new []{"merge-subdirs"},
|
||||||
|
"Merge mods and show conflicts. Requires -o",
|
||||||
|
d => Merge.MergeAll(Directory.GetDirectories(d), outPath),
|
||||||
|
"dir_with_mods",
|
||||||
|
1),
|
||||||
|
new LaunchArgument(new []{"merge-single"},
|
||||||
|
"Merges one mod into output dir and shows conflicts. Requires -o",
|
||||||
|
mod=>Merge.MergeSingle(mod, outPath),
|
||||||
|
"mod_dir",
|
||||||
|
1),
|
||||||
|
new LaunchArgument(new []{"gen-rus-locale"},
|
||||||
|
"Creates l_russian copy of english locale in output directory. Requires -o",
|
||||||
|
eng=>Localisation.GenerateRussian(eng, outPath),
|
||||||
|
"english_locale_path", 1)
|
||||||
|
).ParseAndHandle(args);
|
||||||
|
}
|
||||||
|
catch (LaunchArgumentParser.ExitAfterHelpException)
|
||||||
|
{ }
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log("r", DTLib.Ben.Demystifier.ExceptionExtensions.ToStringDemystified(ex));
|
||||||
|
}
|
||||||
|
Console.ResetColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// вывод конфликтующих файлов при -merge и -clear если такие есть
|
||||||
|
public static void LogConflicts(List<string> conflicts)
|
||||||
|
{
|
||||||
|
Log("w", $"found {conflicts.Count}");
|
||||||
|
if(conflicts.Count>0)
|
||||||
|
Log("w","conflicts:\n", "m", conflicts.MergeToString("\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,43 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project Sdk="Microsoft.Net.Sdk">
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{076BFCFF-1D3E-44FB-B434-73716B79A135}</ProjectGuid>
|
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<RootNamespace>ParadoxModMerger</RootNamespace>
|
||||||
|
<AssemblyName>paradox-mod-merger</AssemblyName>
|
||||||
<LangVersion>10</LangVersion>
|
<LangVersion>10</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Build|AnyCPU' ">
|
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugType>none</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="ParadoxModMerger.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\DTLib\DTLib\DTLib.csproj">
|
|
||||||
<Project>{e22e3abf-b364-46a0-814e-48e1035697cb}</Project>
|
|
||||||
<Name>DTLib</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="7z\**">
|
<None Include="7z\**">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DTLib" Version="1.0.4" />
|
||||||
|
<PackageReference Include="DTLib.Ben.Demystifier" Version="1.0.2" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@ -5,40 +5,22 @@ VisualStudioVersion = 16.0.30907.101
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "paradox-mod-merger", "paradox-mod-merger.csproj", "{076BFCFF-1D3E-44FB-B434-73716B79A135}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "paradox-mod-merger", "paradox-mod-merger.csproj", "{076BFCFF-1D3E-44FB-B434-73716B79A135}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTLib", "..\DTLib\DTLib\DTLib.csproj", "{E22E3ABF-B364-46A0-814E-48E1035697CB}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "paradox-rus-localisation-gen", "paradox-rus-localisation-gen.csproj", "{839133EF-6481-498A-B70D-878404BB78A4}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution_files", "solution_files", "{8B5F0B90-06A8-48B6-897A-19A0A3474F51}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution_files", "solution_files", "{8B5F0B90-06A8-48B6-897A-19A0A3474F51}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
|
nuget.config = nuget.config
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Build|Any CPU = Build|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
Build|x64 = Build|x64
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Build|x86 = Build|x86
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{076BFCFF-1D3E-44FB-B434-73716B79A135}.Build|Any CPU.ActiveCfg = Build|Any CPU
|
{076BFCFF-1D3E-44FB-B434-73716B79A135}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{076BFCFF-1D3E-44FB-B434-73716B79A135}.Build|Any CPU.Build.0 = Build|Any CPU
|
{076BFCFF-1D3E-44FB-B434-73716B79A135}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{076BFCFF-1D3E-44FB-B434-73716B79A135}.Build|x64.ActiveCfg = Build|Any CPU
|
{076BFCFF-1D3E-44FB-B434-73716B79A135}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{076BFCFF-1D3E-44FB-B434-73716B79A135}.Build|x64.Build.0 = Build|Any CPU
|
{076BFCFF-1D3E-44FB-B434-73716B79A135}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{076BFCFF-1D3E-44FB-B434-73716B79A135}.Build|x86.ActiveCfg = Build|Any CPU
|
|
||||||
{076BFCFF-1D3E-44FB-B434-73716B79A135}.Build|x86.Build.0 = Build|Any CPU
|
|
||||||
{E22E3ABF-B364-46A0-814E-48E1035697CB}.Build|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{E22E3ABF-B364-46A0-814E-48E1035697CB}.Build|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{E22E3ABF-B364-46A0-814E-48E1035697CB}.Build|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{E22E3ABF-B364-46A0-814E-48E1035697CB}.Build|x64.Build.0 = Debug|Any CPU
|
|
||||||
{E22E3ABF-B364-46A0-814E-48E1035697CB}.Build|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{E22E3ABF-B364-46A0-814E-48E1035697CB}.Build|x86.Build.0 = Debug|Any CPU
|
|
||||||
{839133EF-6481-498A-B70D-878404BB78A4}.Build|Any CPU.ActiveCfg = Build|Any CPU
|
|
||||||
{839133EF-6481-498A-B70D-878404BB78A4}.Build|Any CPU.Build.0 = Build|Any CPU
|
|
||||||
{839133EF-6481-498A-B70D-878404BB78A4}.Build|x64.ActiveCfg = Build|Any CPU
|
|
||||||
{839133EF-6481-498A-B70D-878404BB78A4}.Build|x64.Build.0 = Build|Any CPU
|
|
||||||
{839133EF-6481-498A-B70D-878404BB78A4}.Build|x86.ActiveCfg = Build|Any CPU
|
|
||||||
{839133EF-6481-498A-B70D-878404BB78A4}.Build|x86.Build.0 = Build|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -28,10 +28,4 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="ParadoxRusLocalisationGen.cs" />
|
<Compile Include="ParadoxRusLocalisationGen.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\DTLib\DTLib\DTLib.csproj">
|
|
||||||
<Project>{e22e3abf-b364-46a0-814e-48e1035697cb}</Project>
|
|
||||||
<Name>DTLib</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
Loading…
Reference in New Issue
Block a user