mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-31 21:03:48 +01:00
Added Filter to Installed Mod List.
This commit is contained in:
parent
a4d36d7f61
commit
b9a9e30388
4 changed files with 105 additions and 17 deletions
|
|
@ -35,12 +35,14 @@ namespace Penumbra.UI
|
||||||
|
|
||||||
private void ReloadMods()
|
private void ReloadMods()
|
||||||
{
|
{
|
||||||
|
_menu._installedTab._selector.ResetModNamesLower();
|
||||||
_menu._installedTab._selector.ClearSelection();
|
_menu._installedTab._selector.ClearSelection();
|
||||||
// create the directory if it doesn't exist
|
// create the directory if it doesn't exist
|
||||||
Directory.CreateDirectory( _plugin.Configuration.CurrentCollection );
|
Directory.CreateDirectory( _plugin.Configuration.CurrentCollection );
|
||||||
|
|
||||||
_plugin.ModManager.DiscoverMods( _plugin.Configuration.CurrentCollection );
|
_plugin.ModManager.DiscoverMods( _plugin.Configuration.CurrentCollection );
|
||||||
_menu._effectiveTab.RebuildFileList(_plugin.Configuration.ShowAdvanced);
|
_menu._effectiveTab.RebuildFileList(_plugin.Configuration.ShowAdvanced);
|
||||||
|
_menu._installedTab._selector.ResetModNamesLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -416,7 +416,7 @@ namespace Penumbra.UI
|
||||||
foreach (var gamePath in gamePaths)
|
foreach (var gamePath in gamePaths)
|
||||||
{
|
{
|
||||||
string tmp = gamePath;
|
string tmp = gamePath;
|
||||||
if (ImGui.InputText($"##{gamePath}", ref tmp, 128, ImGuiInputTextFlags.EnterReturnsTrue))
|
if (ImGui.InputText($"##{fileName}_{gamePath}", ref tmp, 128, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||||
{
|
{
|
||||||
if (tmp != gamePath)
|
if (tmp != gamePath)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,17 +13,19 @@ namespace Penumbra.UI
|
||||||
{
|
{
|
||||||
private class Selector
|
private class Selector
|
||||||
{
|
{
|
||||||
private const string LabelSelectorList = "##availableModList";
|
private const string LabelSelectorList = "##availableModList";
|
||||||
private const string TooltipMoveDown = "Move the selected mod down in priority";
|
private const string LabelModFilter = "##ModFilter";
|
||||||
private const string TooltipMoveUp = "Move the selected mod up in priority";
|
private const string TooltipModFilter = "Filter mods for those containing the given substring.";
|
||||||
private const string TooltipDelete = "Delete the selected mod";
|
private const string TooltipMoveDown = "Move the selected mod down in priority";
|
||||||
private const string TooltipAdd = "Add an empty mod";
|
private const string TooltipMoveUp = "Move the selected mod up in priority";
|
||||||
private const string DialogDeleteMod = "PenumbraDeleteMod";
|
private const string TooltipDelete = "Delete the selected mod";
|
||||||
private const string ButtonYesDelete = "Yes, delete it";
|
private const string TooltipAdd = "Add an empty mod";
|
||||||
private const string ButtonNoDelete = "No, keep it";
|
private const string DialogDeleteMod = "PenumbraDeleteMod";
|
||||||
private const float SelectorPanelWidth = 240f;
|
private const string ButtonYesDelete = "Yes, delete it";
|
||||||
private const uint DisabledModColor = 0xFF666666;
|
private const string ButtonNoDelete = "No, keep it";
|
||||||
private const uint ConflictingModColor = 0xFFAAAAFF;
|
private const float SelectorPanelWidth = 240f;
|
||||||
|
private const uint DisabledModColor = 0xFF666666;
|
||||||
|
private const uint ConflictingModColor = 0xFFAAAAFF;
|
||||||
|
|
||||||
private static readonly Vector2 SelectorButtonSizes = new(60, 0);
|
private static readonly Vector2 SelectorButtonSizes = new(60, 0);
|
||||||
private static readonly string ArrowUpString = FontAwesomeIcon.ArrowUp.ToIconString();
|
private static readonly string ArrowUpString = FontAwesomeIcon.ArrowUp.ToIconString();
|
||||||
|
|
@ -32,13 +34,22 @@ namespace Penumbra.UI
|
||||||
private readonly SettingsInterface _base;
|
private readonly SettingsInterface _base;
|
||||||
private ModCollection Mods{ get{ return _base._plugin.ModManager.Mods; } }
|
private ModCollection Mods{ get{ return _base._plugin.ModManager.Mods; } }
|
||||||
|
|
||||||
private ModInfo _mod = null;
|
private ModInfo _mod = null;
|
||||||
private int _index = 0;
|
private int _index = 0;
|
||||||
private int? _deleteIndex = null;
|
private int? _deleteIndex = null;
|
||||||
|
private string _modFilter = "";
|
||||||
|
private string[] _modNamesLower = null;
|
||||||
|
|
||||||
|
|
||||||
public Selector(SettingsInterface ui)
|
public Selector(SettingsInterface ui)
|
||||||
{
|
{
|
||||||
_base = ui;
|
_base = ui;
|
||||||
|
ResetModNamesLower();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetModNamesLower()
|
||||||
|
{
|
||||||
|
_modNamesLower = Mods.ModSettings.Select( I => I.Mod.Meta.Name.ToLowerInvariant() ).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawPriorityChangeButton(string iconString, bool up, int unavailableWhen)
|
private void DrawPriorityChangeButton(string iconString, bool up, int unavailableWhen)
|
||||||
|
|
@ -50,6 +61,7 @@ namespace Penumbra.UI
|
||||||
{
|
{
|
||||||
SetSelection(_index);
|
SetSelection(_index);
|
||||||
_base._plugin.ModManager.ChangeModPriority( _mod, up );
|
_base._plugin.ModManager.ChangeModPriority( _mod, up );
|
||||||
|
_modNamesLower.Swap(_index, _index + (up ? 1 : -1));
|
||||||
_index += up ? 1 : -1;
|
_index += up ? 1 : -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -100,6 +112,18 @@ namespace Penumbra.UI
|
||||||
ImGui.SetTooltip( TooltipAdd );
|
ImGui.SetTooltip( TooltipAdd );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawModsSelectorFilter()
|
||||||
|
{
|
||||||
|
ImGui.SetNextItemWidth( SelectorButtonSizes.X * 4 );
|
||||||
|
string tmp = _modFilter;
|
||||||
|
if (ImGui.InputText(LabelModFilter, ref tmp, 256))
|
||||||
|
{
|
||||||
|
_modFilter = tmp.ToLowerInvariant();
|
||||||
|
}
|
||||||
|
if( ImGui.IsItemHovered() )
|
||||||
|
ImGui.SetTooltip( TooltipModFilter );
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawModsSelectorButtons()
|
private void DrawModsSelectorButtons()
|
||||||
{
|
{
|
||||||
// Selector controls
|
// Selector controls
|
||||||
|
|
@ -168,12 +192,17 @@ namespace Penumbra.UI
|
||||||
ImGui.BeginGroup();
|
ImGui.BeginGroup();
|
||||||
ImGui.PushStyleVar( ImGuiStyleVar.ItemSpacing, ZeroVector );
|
ImGui.PushStyleVar( ImGuiStyleVar.ItemSpacing, ZeroVector );
|
||||||
|
|
||||||
|
DrawModsSelectorFilter();
|
||||||
|
|
||||||
// Inlay selector list
|
// Inlay selector list
|
||||||
ImGui.BeginChild( LabelSelectorList, new Vector2(SelectorPanelWidth, -ImGui.GetFrameHeightWithSpacing() ), true );
|
ImGui.BeginChild( LabelSelectorList, new Vector2(SelectorPanelWidth, -ImGui.GetFrameHeightWithSpacing() ), true );
|
||||||
|
|
||||||
for( var modIndex = 0; modIndex < Mods.ModSettings.Count; modIndex++ )
|
for( var modIndex = 0; modIndex < Mods.ModSettings.Count; modIndex++ )
|
||||||
{
|
{
|
||||||
var settings = Mods.ModSettings[ modIndex ];
|
var settings = Mods.ModSettings[ modIndex ];
|
||||||
|
var modName = settings.Mod.Meta.Name;
|
||||||
|
if (_modFilter.Length > 0 && !_modNamesLower[modIndex].Contains(_modFilter) )
|
||||||
|
continue;
|
||||||
|
|
||||||
var changedColour = false;
|
var changedColour = false;
|
||||||
if( !settings.Enabled )
|
if( !settings.Enabled )
|
||||||
|
|
@ -189,11 +218,11 @@ namespace Penumbra.UI
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
var selected = ImGui.Selectable(
|
var selected = ImGui.Selectable(
|
||||||
$"id={modIndex} {settings.Mod.Meta.Name}",
|
$"id={modIndex} {modName}",
|
||||||
modIndex == _index
|
modIndex == _index
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
var selected = ImGui.Selectable( settings.Mod.Meta.Name, modIndex == _index );
|
var selected = ImGui.Selectable( modName, modIndex == _index );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( changedColour )
|
if( changedColour )
|
||||||
|
|
@ -266,6 +295,7 @@ namespace Penumbra.UI
|
||||||
_mod.Mod.RefreshModFiles();
|
_mod.Mod.RefreshModFiles();
|
||||||
_base._plugin.ModManager.CalculateEffectiveFileList();
|
_base._plugin.ModManager.CalculateEffectiveFileList();
|
||||||
_base._menu._effectiveTab.RebuildFileList(_base._plugin.Configuration.ShowAdvanced);
|
_base._menu._effectiveTab.RebuildFileList(_base._plugin.Configuration.ShowAdvanced);
|
||||||
|
ResetModNamesLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SaveCurrentMod()
|
public string SaveCurrentMod()
|
||||||
|
|
|
||||||
56
Penumbra/Util/ArrayExtensions.cs
Normal file
56
Penumbra/Util/ArrayExtensions.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Penumbra
|
||||||
|
{
|
||||||
|
public static class ArrayExtensions
|
||||||
|
{
|
||||||
|
public static void Swap<T>( this T[] array, int idx1, int idx2 )
|
||||||
|
{
|
||||||
|
var tmp = array[idx1];
|
||||||
|
array[idx1] = array[idx2];
|
||||||
|
array[idx2] = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Swap<T>( this List<T> array, int idx1, int idx2 )
|
||||||
|
{
|
||||||
|
var tmp = array[idx1];
|
||||||
|
array[idx1] = array[idx2];
|
||||||
|
array[idx2] = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Swap<T>( this T[] array, T lhs, T rhs )
|
||||||
|
{
|
||||||
|
var idx1 = Array.IndexOf( array, lhs );
|
||||||
|
if( idx1 < 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var idx2 = Array.IndexOf( array, rhs );
|
||||||
|
if( idx2 < 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
array.Swap( idx1, idx2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Swap<T>( this List<T> array, T lhs, T rhs )
|
||||||
|
{
|
||||||
|
var idx1 = array.IndexOf( lhs );
|
||||||
|
if( idx1 < 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var idx2 = array.IndexOf( rhs );
|
||||||
|
if( idx2 < 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
array.Swap( idx1, idx2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue