mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Add priority display to mod selector.
This commit is contained in:
parent
3738b5f8f0
commit
a95877b9e4
5 changed files with 34 additions and 3 deletions
|
|
@ -50,6 +50,7 @@ public class Configuration : IPluginConfiguration, ISavable
|
|||
public bool UseNoModsInInspect { get; set; } = false;
|
||||
public bool HideChangedItemFilters { get; set; } = false;
|
||||
|
||||
public bool HidePrioritiesInSelector { get; set; } = false;
|
||||
public bool HideRedrawBar { get; set; } = false;
|
||||
public int OptionGroupCollapsibleMin { get; set; } = 5;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ using Penumbra.Mods.Manager;
|
|||
using Penumbra.Mods.Subclasses;
|
||||
using Penumbra.Services;
|
||||
using Penumbra.String.Classes;
|
||||
using Penumbra.Util;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public enum ColorId
|
|||
RedundantAssignment,
|
||||
NoModsAssignment,
|
||||
NoAssignment,
|
||||
SelectorPriority,
|
||||
}
|
||||
|
||||
public static class Colors
|
||||
|
|
@ -62,6 +63,7 @@ public static class Colors
|
|||
ColorId.RedundantAssignment => ( 0x6050D0D0, "Redundant Collection Assignment", "A collection assignment that currently has no effect as it is redundant with more general assignments."),
|
||||
ColorId.NoModsAssignment => ( 0x50000080, "'Use No Mods' Collection Assignment", "A collection assignment set to not use any mods at all."),
|
||||
ColorId.NoAssignment => ( 0x00000000, "Unassigned Collection Assignment", "A collection assignment that is not configured to any collection and thus just has no specific treatment."),
|
||||
ColorId.SelectorPriority => ( 0xFF808080, "Mod Selector Priority", "The priority displayed for non-zero priority mods in the mod selector."),
|
||||
_ => throw new ArgumentOutOfRangeException( nameof( color ), color, null ),
|
||||
// @formatter:on
|
||||
};
|
||||
|
|
|
|||
|
|
@ -168,6 +168,27 @@ 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 (state.Priority != 0 && !_config.HidePrioritiesInSelector)
|
||||
{
|
||||
var priorityString = $"[{state.Priority}]";
|
||||
var requiredSize = ImGui.CalcTextSize(priorityString).X;
|
||||
ImGui.SameLine();
|
||||
var remainingSpace = ImGui.GetContentRegionAvail().X;
|
||||
var offset = remainingSpace - requiredSize;
|
||||
if (ImGui.GetScrollMaxY() == 0)
|
||||
offset -= ImGui.GetStyle().ItemInnerSpacing.X;
|
||||
|
||||
if (offset > ImGui.GetStyle().ItemSpacing.X)
|
||||
{
|
||||
c.Push(ImGuiCol.Text, ColorId.SelectorPriority.Value());
|
||||
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + offset);
|
||||
ImGui.TextUnformatted(priorityString);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.NewLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -468,6 +489,7 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
|
|||
public struct ModState
|
||||
{
|
||||
public ColorId Color;
|
||||
public int Priority;
|
||||
}
|
||||
|
||||
private const StringComparison IgnoreCase = StringComparison.OrdinalIgnoreCase;
|
||||
|
|
@ -664,10 +686,14 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
|
|||
/// <summary> Combined wrapper for handling all filters and setting state. </summary>
|
||||
private bool ApplyFiltersAndState(ModFileSystem.Leaf leaf, out ModState state)
|
||||
{
|
||||
state = new ModState { Color = ColorId.EnabledMod };
|
||||
var mod = leaf.Value;
|
||||
var (settings, collection) = _collectionManager.Active.Current[mod.Index];
|
||||
|
||||
state = new ModState
|
||||
{
|
||||
Color = ColorId.EnabledMod,
|
||||
Priority = settings?.Priority ?? 0,
|
||||
};
|
||||
if (ApplyStringFilters(leaf, mod))
|
||||
return true;
|
||||
|
||||
|
|
|
|||
|
|
@ -379,6 +379,9 @@ public class SettingsTab : ITab
|
|||
if (v)
|
||||
_config.ChangedItemFilter = ChangedItemDrawer.AllFlags;
|
||||
});
|
||||
Checkbox("Hide Priority Numbers in Mod Selector",
|
||||
"Hides the bracketed non-zero priority numbers displayed in the mod selector when there is enough space for them.",
|
||||
_config.HidePrioritiesInSelector, v => _config.HidePrioritiesInSelector = v);
|
||||
DrawSingleSelectRadioMax();
|
||||
DrawCollapsibleGroupMin();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue