Skip to content

Commit

Permalink
Improve mod filters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Aug 29, 2024
1 parent 2a7d2ef commit 1760011
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 35 deletions.
2 changes: 1 addition & 1 deletion OtterGui
2 changes: 1 addition & 1 deletion Penumbra/Import/Textures/TexFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public static DXGIFormat ToDXGI(this TexFile.TextureFormat format)
TexFile.TextureFormat.BC1 => DXGIFormat.BC1UNorm,
TexFile.TextureFormat.BC2 => DXGIFormat.BC2UNorm,
TexFile.TextureFormat.BC3 => DXGIFormat.BC3UNorm,
(TexFile.TextureFormat)0x6120 => DXGIFormat.BC4UNorm, // TODO: upstream to Lumina
(TexFile.TextureFormat)0x6120 => DXGIFormat.BC4UNorm, // TODO: upstream to Lumina
TexFile.TextureFormat.BC5 => DXGIFormat.BC5UNorm,
(TexFile.TextureFormat)0x6330 => DXGIFormat.BC6HUF16, // TODO: upstream to Lumina
TexFile.TextureFormat.BC7 => DXGIFormat.BC7UNorm,
Expand Down
23 changes: 15 additions & 8 deletions Penumbra/UI/ModsTab/ModFileSystemSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using OtterGui.FileSystem.Selector;
using OtterGui.Raii;
using OtterGui.Services;
using OtterGui.Text;
using OtterGui.Text.Widget;
using Penumbra.Api.Enums;
using Penumbra.Collections;
using Penumbra.Collections.Manager;
Expand Down Expand Up @@ -84,8 +86,8 @@ public ModFileSystemSelector(IKeyState keyState, CommunicatorService communicato
_communicator.ModDiscoveryFinished.Subscribe(RestoreLastSelection, ModDiscoveryFinished.Priority.ModFileSystemSelector);
SetFilterDirty();
SelectionChanged += OnSelectionChanged;
}

}

public void SetRenameSearchPath(RenameField value)
{
switch (value)
Expand Down Expand Up @@ -703,8 +705,6 @@ private bool DrawFilterCombo(ref bool everything)

using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing,
ImGui.GetStyle().ItemSpacing with { Y = 3 * UiHelpers.Scale });
var flags = (int)_stateFilter;


if (ImGui.Checkbox("Everything", ref everything))
{
Expand All @@ -713,12 +713,19 @@ private bool DrawFilterCombo(ref bool everything)
}

ImGui.Dummy(new Vector2(0, 5 * UiHelpers.Scale));
foreach (ModFilter flag in Enum.GetValues(typeof(ModFilter)))
foreach (var (onFlag, offFlag, name) in ModFilterExtensions.TriStatePairs)
{
if (ImGui.CheckboxFlags(flag.ToName(), ref flags, (int)flag))
{
_stateFilter = (ModFilter)flags;
if (TriStateCheckbox.Instance.Draw(name, ref _stateFilter, onFlag, offFlag))
SetFilterDirty();
}

foreach (var group in ModFilterExtensions.Groups)
{
ImGui.Separator();
foreach (var (flag, name) in group)
{
if (ImUtf8.Checkbox(name, ref _stateFilter, flag))
SetFilterDirty();
}
}

Expand Down
49 changes: 24 additions & 25 deletions Penumbra/UI/ModsTab/ModFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,28 @@ public static class ModFilterExtensions
{
public const ModFilter UnfilteredStateMods = (ModFilter)((1 << 20) - 1);

public static string ToName(this ModFilter filter)
=> filter switch
{
ModFilter.Enabled => "Enabled",
ModFilter.Disabled => "Disabled",
ModFilter.Favorite => "Favorite",
ModFilter.NotFavorite => "No Favorite",
ModFilter.NoConflict => "No Conflicts",
ModFilter.SolvedConflict => "Solved Conflicts",
ModFilter.UnsolvedConflict => "Unsolved Conflicts",
ModFilter.HasNoMetaManipulations => "No Meta Manipulations",
ModFilter.HasMetaManipulations => "Meta Manipulations",
ModFilter.HasNoFileSwaps => "No File Swaps",
ModFilter.HasFileSwaps => "File Swaps",
ModFilter.HasNoConfig => "No Configuration",
ModFilter.HasConfig => "Configuration",
ModFilter.HasNoFiles => "No Files",
ModFilter.HasFiles => "Files",
ModFilter.IsNew => "Newly Imported",
ModFilter.NotNew => "Not Newly Imported",
ModFilter.Inherited => "Inherited Configuration",
ModFilter.Uninherited => "Own Configuration",
ModFilter.Undefined => "Not Configured",
_ => throw new ArgumentOutOfRangeException(nameof(filter), filter, null),
};
public static IReadOnlyList<(ModFilter On, ModFilter Off, string Name)> TriStatePairs =
[
(ModFilter.Enabled, ModFilter.Disabled, "Enabled"),
(ModFilter.IsNew, ModFilter.NotNew, "Newly Imported"),
(ModFilter.Favorite, ModFilter.NotFavorite, "Favorite"),
(ModFilter.HasConfig, ModFilter.HasNoConfig, "Has Options"),
(ModFilter.HasFiles, ModFilter.HasNoFiles, "Has Redirections"),
(ModFilter.HasMetaManipulations, ModFilter.HasNoMetaManipulations, "Has Meta Manipulations"),
(ModFilter.HasFileSwaps, ModFilter.HasNoFileSwaps, "Has File Swaps"),
];

public static IReadOnlyList<IReadOnlyList<(ModFilter Filter, string Name)>> Groups =
[
[
(ModFilter.NoConflict, "Has No Conflicts"),
(ModFilter.SolvedConflict, "Has Solved Conflicts"),
(ModFilter.UnsolvedConflict, "Has Unsolved Conflicts"),
],
[
(ModFilter.Undefined, "Not Configured"),
(ModFilter.Inherited, "Inherited Configuration"),
(ModFilter.Uninherited, "Own Configuration"),
],
];
}

0 comments on commit 1760011

Please sign in to comment.