mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-22 07:47:48 +01:00
Add unpacking to import popup and fix line endings, improve global mod importer.
This commit is contained in:
parent
31ea4902ca
commit
93e685ce58
8 changed files with 136 additions and 108 deletions
2
Luna
2
Luna
|
|
@ -1 +1 @@
|
||||||
Subproject commit d580f7a6ec62b0d7d60be07130133a54f10a3337
|
Subproject commit 616d66b1d384588c23a3b5725ad1330037ce6987
|
||||||
|
|
@ -68,7 +68,8 @@ public sealed class ModFileSystem : BaseFileSystem, IDisposable, IRequiredServic
|
||||||
NotificationType.Warning);
|
NotificationType.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateDuplicateDataNode(parent, arguments.Mod.Name, arguments.Mod);
|
var (data, _) = CreateDuplicateDataNode(parent, arguments.Mod.Name, arguments.Mod);
|
||||||
|
Selection.Select(data);
|
||||||
break;
|
break;
|
||||||
case ModPathChangeType.Deleted:
|
case ModPathChangeType.Deleted:
|
||||||
if (arguments.Mod.Node is not null)
|
if (arguments.Mod.Node is not null)
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,8 @@ public class ModImportManager(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
modManager.AddMod(directory, true);
|
mod = modManager.AddMod(directory, true);
|
||||||
mod = modManager.LastOrDefault();
|
return mod is not null && mod.ModPath == directory;
|
||||||
return mod != null && mod.ModPath == directory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
||||||
|
|
@ -82,20 +82,21 @@ public sealed class ModManager : ModStorage, IDisposable, Luna.IService
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Load a new mod and add it to the manager if successful. </summary>
|
/// <summary> Load a new mod and add it to the manager if successful. </summary>
|
||||||
public void AddMod(DirectoryInfo modFolder, bool deleteDefaultMeta)
|
public Mod? AddMod(DirectoryInfo modFolder, bool deleteDefaultMeta)
|
||||||
{
|
{
|
||||||
if (this.Any(m => m.ModPath.Name == modFolder.Name))
|
if (this.Any(m => m.ModPath.Name == modFolder.Name))
|
||||||
return;
|
return null;
|
||||||
|
|
||||||
Creator.SplitMultiGroups(modFolder);
|
Creator.SplitMultiGroups(modFolder);
|
||||||
var mod = Creator.LoadMod(modFolder, true, deleteDefaultMeta);
|
var mod = Creator.LoadMod(modFolder, true, deleteDefaultMeta);
|
||||||
if (mod == null)
|
if (mod is null)
|
||||||
return;
|
return null;
|
||||||
|
|
||||||
mod.Index = Count;
|
mod.Index = Count;
|
||||||
Mods.Add(mod);
|
Mods.Add(mod);
|
||||||
_communicator.ModPathChanged.Invoke(new ModPathChanged.Arguments(ModPathChangeType.Added, mod, null, mod.ModPath));
|
_communicator.ModPathChanged.Invoke(new ModPathChanged.Arguments(ModPathChangeType.Added, mod, null, mod.ModPath));
|
||||||
Penumbra.Log.Debug($"Added new mod {mod.Name} from {modFolder.FullName}.");
|
Penumbra.Log.Debug($"Added new mod {mod.Name} from {modFolder.FullName}.");
|
||||||
|
return mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,20 @@ public sealed class GlobalModImporter : IRequiredService, IDisposable
|
||||||
dragDropManager.AddTarget(DragDropId, ImportFiles);
|
dragDropManager.AddTarget(DragDropId, ImportFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DrawItemTarget()
|
||||||
|
{
|
||||||
|
using var target = Im.DragDrop.Target();
|
||||||
|
if (target.IsDropping("ModDragDrop"u8))
|
||||||
|
ImportFiles(_dragDropManager.DalamudManager.Files, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawWindowTarget()
|
||||||
|
{
|
||||||
|
using var target = Im.DragDrop.TargetWindow();
|
||||||
|
if (target.IsDropping("ModDragDrop"u8))
|
||||||
|
ImportFiles(_dragDropManager.DalamudManager.Files, []);
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_dragDropManager.RemoveSource(DragDropId);
|
_dragDropManager.RemoveSource(DragDropId);
|
||||||
|
|
@ -39,7 +53,9 @@ public sealed class GlobalModImporter : IRequiredService, IDisposable
|
||||||
|
|
||||||
private static bool DragTooltip(IDragDropManager manager)
|
private static bool DragTooltip(IDragDropManager manager)
|
||||||
{
|
{
|
||||||
Im.Text($"Dragging mods for import:\n\t{StringU8.Join("\n\t"u8, manager.Files.Select(Path.GetFileName))}");
|
Im.Text(manager.Files.Count > 1 ? "Dragging mods for import:"u8 : "Dragging mod for import:"u8);
|
||||||
|
foreach (var file in manager.Files.Select(Path.GetFileName))
|
||||||
|
Im.BulletText(file!);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ using Penumbra.Mods.Manager;
|
||||||
namespace Penumbra.UI;
|
namespace Penumbra.UI;
|
||||||
|
|
||||||
/// <summary> Draw the progress information for import. </summary>
|
/// <summary> Draw the progress information for import. </summary>
|
||||||
public sealed class ImportPopup : Window, IUiService
|
public sealed class ImportPopup : Window
|
||||||
{
|
{
|
||||||
public const string WindowLabel = "Penumbra Import Status";
|
public const string WindowLabel = "Penumbra Import Status";
|
||||||
|
|
||||||
|
|
@ -47,6 +47,9 @@ public sealed class ImportPopup : Window, IUiService
|
||||||
PopupWasDrawn = false;
|
PopupWasDrawn = false;
|
||||||
_modImportManager.TryUnpacking();
|
_modImportManager.TryUnpacking();
|
||||||
IsOpen = true;
|
IsOpen = true;
|
||||||
|
|
||||||
|
while (_modImportManager.AddUnpackedMod(out _))
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
|
|
|
||||||
|
|
@ -12,17 +12,19 @@ public sealed class MainWindow : Window
|
||||||
private readonly IDalamudPluginInterface _pluginInterface;
|
private readonly IDalamudPluginInterface _pluginInterface;
|
||||||
private readonly Configuration _config;
|
private readonly Configuration _config;
|
||||||
private readonly ValidityChecker _validityChecker;
|
private readonly ValidityChecker _validityChecker;
|
||||||
|
private readonly GlobalModImporter _globalModImporter;
|
||||||
private Penumbra? _penumbra;
|
private Penumbra? _penumbra;
|
||||||
private MainTabBar _configTabs = null!;
|
private MainTabBar _configTabs = null!;
|
||||||
private string? _lastException;
|
private string? _lastException;
|
||||||
|
|
||||||
public MainWindow(IDalamudPluginInterface pi, Configuration config, ValidityChecker checker,
|
public MainWindow(IDalamudPluginInterface pi, Configuration config, ValidityChecker checker,
|
||||||
TutorialService tutorial)
|
TutorialService tutorial, GlobalModImporter globalModImporter)
|
||||||
: base(GetLabel(checker))
|
: base(GetLabel(checker))
|
||||||
{
|
{
|
||||||
_pluginInterface = pi;
|
_pluginInterface = pi;
|
||||||
_config = config;
|
_config = config;
|
||||||
_validityChecker = checker;
|
_validityChecker = checker;
|
||||||
|
_globalModImporter = globalModImporter;
|
||||||
|
|
||||||
RespectCloseHotkey = true;
|
RespectCloseHotkey = true;
|
||||||
tutorial.UpdateTutorialStep();
|
tutorial.UpdateTutorialStep();
|
||||||
|
|
@ -61,6 +63,7 @@ public sealed class MainWindow : Window
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
UiHelpers.SetupCommonSizes();
|
UiHelpers.SetupCommonSizes();
|
||||||
|
_globalModImporter.DrawWindowTarget();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_validityChecker.ImcExceptions.Count > 0)
|
if (_validityChecker.ImcExceptions.Count > 0)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using ImSharp;
|
||||||
using Luna;
|
using Luna;
|
||||||
using Penumbra.Collections.Manager;
|
using Penumbra.Collections.Manager;
|
||||||
using Penumbra.Mods;
|
using Penumbra.Mods;
|
||||||
|
|
@ -16,9 +17,11 @@ public sealed class ModFileSystemDrawer : FileSystemDrawer<ModFileSystemCache.Mo
|
||||||
public readonly FileDialogService FileService;
|
public readonly FileDialogService FileService;
|
||||||
public readonly TutorialService Tutorial;
|
public readonly TutorialService Tutorial;
|
||||||
public readonly CommunicatorService Communicator;
|
public readonly CommunicatorService Communicator;
|
||||||
|
public readonly GlobalModImporter GlobalModImporter;
|
||||||
|
|
||||||
public ModFileSystemDrawer(ModFileSystem fileSystem, ModManager modManager, CollectionManager collectionManager, Configuration config,
|
public ModFileSystemDrawer(ModFileSystem fileSystem, ModManager modManager, CollectionManager collectionManager, Configuration config,
|
||||||
ModImportManager modImport, FileDialogService fileService, TutorialService tutorial, CommunicatorService communicator)
|
ModImportManager modImport, FileDialogService fileService, TutorialService tutorial, CommunicatorService communicator,
|
||||||
|
GlobalModImporter globalModImporter)
|
||||||
: base(fileSystem, new ModFilter(modManager, collectionManager.Active))
|
: base(fileSystem, new ModFilter(modManager, collectionManager.Active))
|
||||||
{
|
{
|
||||||
ModManager = modManager;
|
ModManager = modManager;
|
||||||
|
|
@ -27,27 +30,29 @@ public sealed class ModFileSystemDrawer : FileSystemDrawer<ModFileSystemCache.Mo
|
||||||
ModImport = modImport;
|
ModImport = modImport;
|
||||||
FileService = fileService;
|
FileService = fileService;
|
||||||
Tutorial = tutorial;
|
Tutorial = tutorial;
|
||||||
Communicator = communicator;
|
Communicator = communicator;
|
||||||
|
GlobalModImporter = globalModImporter;
|
||||||
|
SortMode = Config.SortMode;
|
||||||
|
|
||||||
MainContext.AddButton(new ClearTemporarySettingsButton(this), 105);
|
MainContext.AddButton(new ClearTemporarySettingsButton(this), 105);
|
||||||
MainContext.AddButton(new ClearDefaultImportFolderButton(this), -10);
|
MainContext.AddButton(new ClearDefaultImportFolderButton(this), -10);
|
||||||
MainContext.AddButton(new ClearQuickMoveFoldersButtons(this), -20);
|
MainContext.AddButton(new ClearQuickMoveFoldersButtons(this), -20);
|
||||||
|
|
||||||
FolderContext.AddButton(new SetDescendantsButton(this, true), 11);
|
FolderContext.AddButton(new SetDescendantsButton(this, true), 11);
|
||||||
FolderContext.AddButton(new SetDescendantsButton(this, false), 10);
|
FolderContext.AddButton(new SetDescendantsButton(this, false), 10);
|
||||||
FolderContext.AddButton(new SetDescendantsButton(this, true, true), 6);
|
FolderContext.AddButton(new SetDescendantsButton(this, true, true), 6);
|
||||||
FolderContext.AddButton(new SetDescendantsButton(this, false, true), 5);
|
FolderContext.AddButton(new SetDescendantsButton(this, false, true), 5);
|
||||||
FolderContext.AddButton(new SetDefaultImportFolderButton(this), -50);
|
FolderContext.AddButton(new SetDefaultImportFolderButton(this), -50);
|
||||||
FolderContext.AddButton(new SetQuickMoveFoldersButtons(this), -70);
|
FolderContext.AddButton(new SetQuickMoveFoldersButtons(this), -70);
|
||||||
|
|
||||||
DataContext.AddButton(new ToggleFavoriteButton(this), 10);
|
DataContext.AddButton(new ToggleFavoriteButton(this), 10);
|
||||||
DataContext.AddButton(new TemporaryButtons(this), 20);
|
DataContext.AddButton(new TemporaryButtons(this), 20);
|
||||||
DataContext.AddButton(new MoveToQuickMoveFoldersButtons(this), -100);
|
DataContext.AddButton(new MoveToQuickMoveFoldersButtons(this), -100);
|
||||||
|
|
||||||
Footer.Buttons.AddButton(new AddNewModButton(this), 1000);
|
Footer.Buttons.AddButton(new AddNewModButton(this), 1000);
|
||||||
Footer.Buttons.AddButton(new ImportModButton(this), 900);
|
Footer.Buttons.AddButton(new ImportModButton(this), 900);
|
||||||
Footer.Buttons.AddButton(new HelpButton(this), 500);
|
Footer.Buttons.AddButton(new HelpButton(this), 500);
|
||||||
Footer.Buttons.AddButton(new DeleteSelectionButton(this), -100);
|
Footer.Buttons.AddButton(new DeleteSelectionButton(this), -100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ReadOnlySpan<byte> Id
|
public override ReadOnlySpan<byte> Id
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue