Add option to clear non-ascii symbols from paths again.

This commit is contained in:
Ottermandias 2023-12-10 15:41:26 +01:00
parent b14cd26e4e
commit 59ea1f2dd6
13 changed files with 56 additions and 62 deletions

View file

@ -4,7 +4,6 @@ using OtterGui;
using OtterGui.Classes;
using Penumbra.Api.Enums;
using Penumbra.Communication;
using Penumbra.Meta.Manipulations;
using Penumbra.Mods.Manager;
using Penumbra.Mods.Subclasses;
using Penumbra.Services;
@ -15,6 +14,7 @@ namespace Penumbra.Mods.Editor;
public class ModMerger : IDisposable
{
private readonly Configuration _config;
private readonly CommunicatorService _communicator;
private readonly ModOptionEditor _editor;
private readonly ModFileSystemSelector _selector;
@ -40,13 +40,14 @@ public class ModMerger : IDisposable
public Exception? Error { get; private set; }
public ModMerger(ModManager mods, ModOptionEditor editor, ModFileSystemSelector selector, DuplicateManager duplicates,
CommunicatorService communicator, ModCreator creator)
CommunicatorService communicator, ModCreator creator, Configuration config)
{
_editor = editor;
_selector = selector;
_duplicates = duplicates;
_communicator = communicator;
_creator = creator;
_config = config;
_mods = mods;
_selector.SelectionChanged += OnSelectionChange;
_communicator.ModPathChanged.Subscribe(OnModPathChange, ModPathChanged.Priority.ModMerger);
@ -82,7 +83,8 @@ public class ModMerger : IDisposable
catch (Exception ex)
{
Error = ex;
Penumbra.Messager.NotificationMessage(ex, $"Could not merge {MergeFromMod!.Name} into {MergeToMod!.Name}, cleaning up changes.", NotificationType.Error, false);
Penumbra.Messager.NotificationMessage(ex, $"Could not merge {MergeFromMod!.Name} into {MergeToMod!.Name}, cleaning up changes.",
NotificationType.Error, false);
FailureCleanup();
DataCleanup();
}
@ -138,10 +140,10 @@ public class ModMerger : IDisposable
var (option, optionCreated) = _editor.FindOrAddOption(MergeToMod!, groupIdx, optionName);
if (optionCreated)
_createdOptions.Add(option);
var dir = ModCreator.NewOptionDirectory(MergeToMod!.ModPath, groupName);
var dir = ModCreator.NewOptionDirectory(MergeToMod!.ModPath, groupName, _config.ReplaceNonAsciiOnImport);
if (!dir.Exists)
_createdDirectories.Add(dir.FullName);
dir = ModCreator.NewOptionDirectory(dir, optionName);
dir = ModCreator.NewOptionDirectory(dir, optionName, _config.ReplaceNonAsciiOnImport);
if (!dir.Exists)
_createdDirectories.Add(dir.FullName);
CopyFiles(dir);

View file

@ -6,11 +6,10 @@ using Penumbra.Mods.Manager;
using Penumbra.Mods.Subclasses;
using Penumbra.String.Classes;
namespace Penumbra.Mods;
namespace Penumbra.Mods.Editor;
public class ModNormalizer
public class ModNormalizer(ModManager _modManager, Configuration _config)
{
private readonly ModManager _modManager;
private readonly List<List<Dictionary<Utf8GamePath, FullPath>>> _redirections = new();
public Mod Mod { get; private set; } = null!;
@ -25,9 +24,6 @@ public class ModNormalizer
public bool Running
=> !Worker.IsCompleted;
public ModNormalizer(ModManager modManager)
=> _modManager = modManager;
public void Normalize(Mod mod)
{
if (Step < TotalSteps)
@ -175,10 +171,10 @@ public class ModNormalizer
for (var i = _redirections[groupIdx + 1].Count; i < group.Count; ++i)
_redirections[groupIdx + 1].Add(new Dictionary<Utf8GamePath, FullPath>());
var groupDir = ModCreator.CreateModFolder(directory, group.Name);
var groupDir = ModCreator.CreateModFolder(directory, group.Name, _config.ReplaceNonAsciiOnImport, true);
foreach (var option in group.OfType<SubMod>())
{
var optionDir = ModCreator.CreateModFolder(groupDir, option.Name);
var optionDir = ModCreator.CreateModFolder(groupDir, option.Name, _config.ReplaceNonAsciiOnImport, true);
newDict = _redirections[groupIdx + 1][option.OptionIdx];
newDict.Clear();
@ -228,7 +224,8 @@ public class ModNormalizer
}
catch (Exception e)
{
Penumbra.Messager.NotificationMessage(e, $"Could not move old files out of the way while normalizing mod {Mod.Name}.", NotificationType.Error, false);
Penumbra.Messager.NotificationMessage(e, $"Could not move old files out of the way while normalizing mod {Mod.Name}.",
NotificationType.Error, false);
}
return false;
@ -251,7 +248,8 @@ public class ModNormalizer
}
catch (Exception e)
{
Penumbra.Messager.NotificationMessage(e, $"Could not move new files into the mod while normalizing mod {Mod.Name}.", NotificationType.Error, false);
Penumbra.Messager.NotificationMessage(e, $"Could not move new files into the mod while normalizing mod {Mod.Name}.",
NotificationType.Error, false);
foreach (var dir in Mod.ModPath.EnumerateDirectories())
{
if (dir.FullName.Equals(_oldDirName, StringComparison.OrdinalIgnoreCase)