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 UseNoModsInInspect { get; set; } = false;
|
||||||
public bool HideChangedItemFilters { get; set; } = false;
|
public bool HideChangedItemFilters { get; set; } = false;
|
||||||
|
|
||||||
|
public bool HidePrioritiesInSelector { get; set; } = false;
|
||||||
public bool HideRedrawBar { get; set; } = false;
|
public bool HideRedrawBar { get; set; } = false;
|
||||||
public int OptionGroupCollapsibleMin { get; set; } = 5;
|
public int OptionGroupCollapsibleMin { get; set; } = 5;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ using Penumbra.Mods.Manager;
|
||||||
using Penumbra.Mods.Subclasses;
|
using Penumbra.Mods.Subclasses;
|
||||||
using Penumbra.Services;
|
using Penumbra.Services;
|
||||||
using Penumbra.String.Classes;
|
using Penumbra.String.Classes;
|
||||||
using Penumbra.Util;
|
|
||||||
|
|
||||||
namespace Penumbra.Mods;
|
namespace Penumbra.Mods;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@ public enum ColorId
|
||||||
SelectedCollection,
|
SelectedCollection,
|
||||||
RedundantAssignment,
|
RedundantAssignment,
|
||||||
NoModsAssignment,
|
NoModsAssignment,
|
||||||
NoAssignment,
|
NoAssignment,
|
||||||
|
SelectorPriority,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Colors
|
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.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.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.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 ),
|
_ => throw new ArgumentOutOfRangeException( nameof( color ), color, null ),
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,27 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
|
||||||
.Push(ImGuiCol.HeaderHovered, 0x4000FFFF, leaf.Value.Favorite);
|
.Push(ImGuiCol.HeaderHovered, 0x4000FFFF, leaf.Value.Favorite);
|
||||||
using var id = ImRaii.PushId(leaf.Value.Index);
|
using var id = ImRaii.PushId(leaf.Value.Index);
|
||||||
ImRaii.TreeNode(leaf.Value.Name, flags).Dispose();
|
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 struct ModState
|
||||||
{
|
{
|
||||||
public ColorId Color;
|
public ColorId Color;
|
||||||
|
public int Priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
private const StringComparison IgnoreCase = StringComparison.OrdinalIgnoreCase;
|
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>
|
/// <summary> Combined wrapper for handling all filters and setting state. </summary>
|
||||||
private bool ApplyFiltersAndState(ModFileSystem.Leaf leaf, out ModState state)
|
private bool ApplyFiltersAndState(ModFileSystem.Leaf leaf, out ModState state)
|
||||||
{
|
{
|
||||||
state = new ModState { Color = ColorId.EnabledMod };
|
|
||||||
var mod = leaf.Value;
|
var mod = leaf.Value;
|
||||||
var (settings, collection) = _collectionManager.Active.Current[mod.Index];
|
var (settings, collection) = _collectionManager.Active.Current[mod.Index];
|
||||||
|
|
||||||
|
state = new ModState
|
||||||
|
{
|
||||||
|
Color = ColorId.EnabledMod,
|
||||||
|
Priority = settings?.Priority ?? 0,
|
||||||
|
};
|
||||||
if (ApplyStringFilters(leaf, mod))
|
if (ApplyStringFilters(leaf, mod))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,9 @@ public class SettingsTab : ITab
|
||||||
if (v)
|
if (v)
|
||||||
_config.ChangedItemFilter = ChangedItemDrawer.AllFlags;
|
_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();
|
DrawSingleSelectRadioMax();
|
||||||
DrawCollapsibleGroupMin();
|
DrawCollapsibleGroupMin();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue