mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-14 12:44:19 +01:00
Resource Tree: Add ChangedItem-like icons, make UI prettier
This commit is contained in:
parent
db521dd21c
commit
30c622c085
8 changed files with 139 additions and 95 deletions
|
|
@ -14,7 +14,8 @@ namespace Penumbra.UI.AdvancedWindow;
|
|||
public class ResourceTreeViewer
|
||||
{
|
||||
private readonly Configuration _config;
|
||||
private readonly ResourceTreeFactory _treeFactory;
|
||||
private readonly ResourceTreeFactory _treeFactory;
|
||||
private readonly ChangedItemDrawer _changedItemDrawer;
|
||||
private readonly int _actionCapacity;
|
||||
private readonly Action _onRefresh;
|
||||
private readonly Action<ResourceNode, Vector2> _drawActions;
|
||||
|
|
@ -22,15 +23,16 @@ public class ResourceTreeViewer
|
|||
|
||||
private Task<ResourceTree[]>? _task;
|
||||
|
||||
public ResourceTreeViewer(Configuration config, ResourceTreeFactory treeFactory, int actionCapacity, Action onRefresh,
|
||||
Action<ResourceNode, Vector2> drawActions)
|
||||
public ResourceTreeViewer(Configuration config, ResourceTreeFactory treeFactory, ChangedItemDrawer changedItemDrawer,
|
||||
int actionCapacity, Action onRefresh, Action<ResourceNode, Vector2> drawActions)
|
||||
{
|
||||
_config = config;
|
||||
_treeFactory = treeFactory;
|
||||
_actionCapacity = actionCapacity;
|
||||
_onRefresh = onRefresh;
|
||||
_drawActions = drawActions;
|
||||
_unfolded = new HashSet<nint>();
|
||||
_config = config;
|
||||
_treeFactory = treeFactory;
|
||||
_changedItemDrawer = changedItemDrawer;
|
||||
_actionCapacity = actionCapacity;
|
||||
_onRefresh = onRefresh;
|
||||
_drawActions = drawActions;
|
||||
_unfolded = new HashSet<nint>();
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
|
|
@ -122,8 +124,24 @@ public class ResourceTreeViewer
|
|||
ImGui.TableNextColumn();
|
||||
var unfolded = _unfolded.Contains(nodePathHash);
|
||||
using (var indent = ImRaii.PushIndent(level))
|
||||
{
|
||||
ImGui.TableHeader((resourceNode.Children.Count > 0 ? unfolded ? "[-] " : "[+] " : string.Empty) + resourceNode.Name);
|
||||
{
|
||||
if (resourceNode.Children.Count > 0)
|
||||
{
|
||||
using var font = ImRaii.PushFont(UiBuilder.IconFont);
|
||||
var icon = (unfolded ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight).ToIconString();
|
||||
var offset = (ImGui.GetFrameHeight() - ImGui.CalcTextSize(icon).X) / 2;
|
||||
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + offset);
|
||||
ImGui.TextUnformatted(icon);
|
||||
ImGui.SameLine(0f, offset + ImGui.GetStyle().ItemInnerSpacing.X);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Dummy(new Vector2(ImGui.GetFrameHeight()));
|
||||
ImGui.SameLine(0f, ImGui.GetStyle().ItemInnerSpacing.X);
|
||||
}
|
||||
_changedItemDrawer.DrawCategoryIcon(resourceNode.Icon);
|
||||
ImGui.SameLine(0f, ImGui.GetStyle().ItemInnerSpacing.X);
|
||||
ImGui.TableHeader(resourceNode.Name);
|
||||
if (ImGui.IsItemClicked() && resourceNode.Children.Count > 0)
|
||||
{
|
||||
if (unfolded)
|
||||
|
|
@ -170,7 +188,9 @@ public class ResourceTreeViewer
|
|||
ImGui.Selectable("(unavailable)", false, ImGuiSelectableFlags.Disabled,
|
||||
new Vector2(ImGui.GetContentRegionAvail().X, cellHeight));
|
||||
ImGuiUtil.HoverTooltip("The actual path to this file is unavailable.\nIt may be managed by another plug-in.");
|
||||
}
|
||||
}
|
||||
|
||||
mutedColor.Dispose();
|
||||
|
||||
if (_actionCapacity > 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue