diff --git a/diff-text/diff-text.csproj b/diff-text/diff-text.csproj
index 2f99905..5eda0b1 100644
--- a/diff-text/diff-text.csproj
+++ b/diff-text/diff-text.csproj
@@ -15,6 +15,6 @@
-
+
diff --git a/paradox-mod-merger/Diff.cs b/paradox-mod-merger/Diff.cs
index 14305a1..a8d4ef4 100644
--- a/paradox-mod-merger/Diff.cs
+++ b/paradox-mod-merger/Diff.cs
@@ -2,7 +2,6 @@ using System.Linq;
using DTLib.Console;
using DTLib.Dtsod;
using diff_text;
-using DiffMatchPatch;
using DTLib.Ben.Demystifier;
namespace ParadoxModMerger;
@@ -29,7 +28,7 @@ static class Diff
LogModConflicts(conflicts);
}
- public static void DiffConflictsCommandHandler(IOPath conflicts_dtsod_path)
+ public static void DiffDetailedCommandHandler(IOPath conflicts_dtsod_path)
{
var dtsod = new DtsodV23(File.ReadAllText(conflicts_dtsod_path));
var conflicts = new ConflictingModFile[dtsod.Count];
@@ -233,7 +232,7 @@ static class Diff
var dtsod = new DtsodV23();
foreach (var cfl in conflicts)
{
- Log("m", "file ","c", cfl.FilePath, "m", "in mods", "b", cfl.Mods.MergeToString(", "));
+ Log("m", "file ","c", cfl.FilePath, "m", " in mods ", "m", cfl.Mods.MergeToString(", "));
dtsod.Add(cfl.FilePath, cfl.Mods);
}
diff --git a/paradox-mod-merger/Merge.cs b/paradox-mod-merger/Merge.cs
index c816b0b..3b13225 100644
--- a/paradox-mod-merger/Merge.cs
+++ b/paradox-mod-merger/Merge.cs
@@ -8,22 +8,52 @@ static class Merge
static ConsoleLogger logger = new($"logs", "merge");
static void Log(params string[] msg) => logger.Log(msg);
+ private const string modlist_filename = "modlist.txt";
+
+ /// analog of Directory.Copy(srcDir, outDir, true)
+ /// has special behavior for some files
+ private static void ModDirCopy(IOPath srcDir, IOPath outDir, IOPath out_modlist_file)
+ {
+ var files = Directory.GetAllFiles(srcDir);
+ for (int i = 0; i < files.Count; i++)
+ {
+ string file_basename = files[i].LastName().Str;
+ if(file_basename=="descriptor.mod") // skip file
+ continue;
+ if (file_basename == modlist_filename) // append modlist
+ {
+ File.AppendAllText(out_modlist_file, File.ReadAllText(files[i]));
+ }
+
+ var newfile = files[i].ReplaceBase(srcDir, outDir);
+ File.Copy(files[i], newfile, true);
+ }
+ }
+
public static void MergeAll(IOPath[] moddirs, IOPath outDir)
{
Log("b", $"found {moddirs.Length} mod dirs");
HandleConflicts(moddirs);
-
+
+ var modnamelist = new string[moddirs.Length];
+ IOPath out_modlist_file = Path.Concat(outDir, modlist_filename);
for (short i = 0; i < moddirs.Length; i++)
{
Log("b", $"[{i + 1}/{moddirs.Length}] merging mod ", "c", $"{moddirs[i]}");
- Directory.Copy(moddirs[i], outDir, true);
+ ModDirCopy(moddirs[i], outDir, out_modlist_file);
+ modnamelist[i]=moddirs[i].LastName().Str;
}
+
+ File.AppendAllText(out_modlist_file, modnamelist.MergeToString('\n'));
+ File.AppendAllText(out_modlist_file, "\n");
}
public static void MergeInto(IOPath moddir, IOPath outDir)
{
HandleConflicts(new[] { moddir, outDir });
- Directory.Copy(moddir, outDir, true);
+ IOPath out_modlist_file = Path.Concat(outDir, modlist_filename);
+ ModDirCopy(moddir, outDir, modlist_filename);
+ File.AppendAllText(out_modlist_file, $"{moddir.LastName()}\n");
}
public static void ConsoleAskYN(string question, Action yes, Action no)
diff --git a/paradox-mod-merger/Program.cs b/paradox-mod-merger/Program.cs
index fb5685c..fd866e9 100644
--- a/paradox-mod-merger/Program.cs
+++ b/paradox-mod-merger/Program.cs
@@ -40,9 +40,9 @@ public static class Program
p=>Diff.DiffCommandHandler(p),
"first_mod_directory:second_mod_directory:...",
1),
- new LaunchArgument(new []{"diff-conflicts"},
+ new LaunchArgument(new []{"diff-detailed"},
"reads conflicts_XXX.dtsod file and shows text diff for each file",
- p=>Diff.DiffConflictsCommandHandler(p),
+ p=>Diff.DiffDetailedCommandHandler(p),
"conflicts_dtsod_path",
1
),
@@ -79,9 +79,14 @@ public static class Program
public static IOPath[] SplitStringToPaths(string connected_paths)
{
- if (!connected_paths.Contains(':'))
- throw new Exception($"<{connected_paths}> doesn't contain any separators (:)");
- string[] split = connected_paths.Split(':');
+ char part_sep;
+ if (connected_paths.Contains(':'))
+ part_sep = ':';
+ else if (!connected_paths.Contains(':'))
+ part_sep = ';';
+ else throw new Exception($"<{connected_paths}> doesn't contain any separators (:/;)");
+
+ string[] split = connected_paths.Split(part_sep);
IOPath[] split_iop = new IOPath[split.Length];
for (int i = 0; i < split.Length; i++)
split_iop[i] = new IOPath(split[i]);
diff --git a/paradox-mod-merger/paradox-mod-merger.csproj b/paradox-mod-merger/paradox-mod-merger.csproj
index 4e123f1..cf0adcd 100644
--- a/paradox-mod-merger/paradox-mod-merger.csproj
+++ b/paradox-mod-merger/paradox-mod-merger.csproj
@@ -12,14 +12,14 @@
-
+
-
+