Add support for middle-clicking mods.

This commit is contained in:
Ottermandias 2023-10-10 18:01:55 +02:00
parent f5822cf2c8
commit c24a40fd9f
2 changed files with 30 additions and 7 deletions

@ -1 +1 @@
Subproject commit a9dac59d36e25064ebd9cd17d519bfac91acc17e
Subproject commit 791a9c98aa5a533f754f4e1085d1ae6f890717ac

View file

@ -1,4 +1,3 @@
using Dalamud.Game.ClientState.Keys;
using Dalamud.Interface;
using Dalamud.Interface.DragDrop;
using Dalamud.Interface.Internal.Notifications;
@ -25,7 +24,7 @@ namespace Penumbra.UI.ModsTab;
public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSystemSelector.ModState>
{
private readonly CommunicatorService _communicator;
private readonly MessageService _messager;
private readonly MessageService _messager;
private readonly Configuration _config;
private readonly FileDialogService _fileDialog;
private readonly ModManager _modManager;
@ -37,7 +36,8 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
public ModCollection SelectedSettingCollection { get; private set; } = ModCollection.Empty;
public ModFileSystemSelector(IKeyState keyState, CommunicatorService communicator, ModFileSystem fileSystem, ModManager modManager,
CollectionManager collectionManager, Configuration config, TutorialService tutorial, FileDialogService fileDialog, MessageService messager,
CollectionManager collectionManager, Configuration config, TutorialService tutorial, FileDialogService fileDialog,
MessageService messager,
ModImportManager modImportManager, IDragDropManager dragDrop)
: base(fileSystem, keyState, Penumbra.Log, HandleException, allowMultipleSelection: true)
{
@ -47,7 +47,7 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
_config = config;
_tutorial = tutorial;
_fileDialog = fileDialog;
_messager = messager;
_messager = messager;
_modImportManager = modImportManager;
_dragDrop = dragDrop;
@ -167,6 +167,22 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
.Push(ImGuiCol.HeaderHovered, 0x4000FFFF, leaf.Value.Favorite);
using var id = ImRaii.PushId(leaf.Value.Index);
ImRaii.TreeNode(leaf.Value.Name, flags).Dispose();
if (ImGui.IsItemClicked(ImGuiMouseButton.Middle))
{
var (setting, collection) = _collectionManager.Active.Current[leaf.Value.Index];
if (_config.DeleteModModifier.ForcedModifier(new DoubleModifier(ModifierHotkey.Control, ModifierHotkey.Shift)).IsActive())
{
_collectionManager.Editor.SetModInheritance(_collectionManager.Active.Current, leaf.Value, true);
}
else
{
var inherited = collection != _collectionManager.Active.Current;
if (inherited)
_collectionManager.Editor.SetModInheritance(_collectionManager.Active.Current, leaf.Value, false);
_collectionManager.Editor.SetModState(_collectionManager.Active.Current, leaf.Value, setting is not { Enabled: true });
}
}
if (state.Priority != 0 && !_config.HidePrioritiesInSelector)
{
var line = ImGui.GetItemRectMin().Y;
@ -326,13 +342,15 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
}
catch (Exception e)
{
_messager.NotificationMessage(e, $"Could not move newly imported mod {mod.Name} to default import folder {_config.DefaultImportFolder}.", NotificationType.Warning);
_messager.NotificationMessage(e,
$"Could not move newly imported mod {mod.Name} to default import folder {_config.DefaultImportFolder}.",
NotificationType.Warning);
}
}
private void DrawHelpPopup()
{
ImGuiUtil.HelpPopup("ExtendedHelp", new Vector2(1000 * UiHelpers.Scale, 36.5f * ImGui.GetTextLineHeightWithSpacing()), () =>
ImGuiUtil.HelpPopup("ExtendedHelp", new Vector2(1000 * UiHelpers.Scale, 38.5f * ImGui.GetTextLineHeightWithSpacing()), () =>
{
ImGui.Dummy(Vector2.UnitY * ImGui.GetTextLineHeight());
ImGui.TextUnformatted("Mod Management");
@ -363,6 +381,11 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
ImGuiUtil.BulletTextColored(ColorId.FolderExpanded.Value(), "expanded mod folder.");
ImGuiUtil.BulletTextColored(ColorId.FolderCollapsed.Value(), "collapsed mod folder");
indent.Pop(1);
ImGui.BulletText("Middle-click a mod to disable it if it is enabled or enable it if it is disabled.");
indent.Push();
ImGui.BulletText(
$"Holding {_config.DeleteModModifier.ForcedModifier(new DoubleModifier(ModifierHotkey.Control, ModifierHotkey.Shift))} while middle-clicking lets it inherit, discarding settings.");
indent.Pop(1);
ImGui.BulletText("Right-click a mod to enter its sort order, which is its name by default, possibly with a duplicate number.");
indent.Push();
ImGui.BulletText("A sort order differing from the mods name will not be displayed, it will just be used for ordering.");