mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Improve changed items somewhat.
This commit is contained in:
parent
b748e34917
commit
6ec60c9150
6 changed files with 78 additions and 52 deletions
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
|||
Subproject commit c69f49e026e17e81df546aa0621f1f575a22534d
|
||||
Subproject commit 1eda5406db266e49ffb04a73bd5217ce6281f489
|
||||
|
|
@ -26,11 +26,11 @@ public class ChangedItemDrawer : IDisposable
|
|||
private const EquipSlot ActionSlot = (EquipSlot)103;
|
||||
|
||||
private readonly CommunicatorService _communicator;
|
||||
private readonly Dictionary<EquipSlot, TextureWrap> _icons;
|
||||
private readonly Dictionary<EquipSlot, TextureWrap> _icons = new(16);
|
||||
|
||||
public ChangedItemDrawer(UiBuilder uiBuilder, DataManager gameData, CommunicatorService communicator)
|
||||
{
|
||||
_icons = CreateEquipSlotIcons(uiBuilder, gameData);
|
||||
uiBuilder.RunWhenUiPrepared(() => CreateEquipSlotIcons(uiBuilder, gameData), true);
|
||||
_communicator = communicator;
|
||||
}
|
||||
|
||||
|
|
@ -64,12 +64,15 @@ public class ChangedItemDrawer : IDisposable
|
|||
name = ChangedItemName(name, data);
|
||||
DrawCategoryIcon(name, data);
|
||||
ImGui.SameLine();
|
||||
var ret = ImGui.Selectable(name) ? MouseButton.Left : MouseButton.None;
|
||||
ret = ImGui.IsItemClicked(ImGuiMouseButton.Right) ? MouseButton.Right : ret;
|
||||
ret = ImGui.IsItemClicked(ImGuiMouseButton.Middle) ? MouseButton.Middle : ret;
|
||||
|
||||
if (ret != MouseButton.None)
|
||||
_communicator.ChangedItemClick.Invoke(ret, data);
|
||||
using (var style = ImRaii.PushStyle(ImGuiStyleVar.SelectableTextAlign, new Vector2(0, 0.5f))
|
||||
.Push(ImGuiStyleVar.ItemSpacing, new Vector2(ImGui.GetStyle().ItemSpacing.X, ImGui.GetStyle().CellPadding.Y * 2)))
|
||||
{
|
||||
var ret = ImGui.Selectable(name, false, ImGuiSelectableFlags.None, new Vector2(0, ImGui.GetFrameHeight())) ? MouseButton.Left : MouseButton.None;
|
||||
ret = ImGui.IsItemClicked(ImGuiMouseButton.Right) ? MouseButton.Right : ret;
|
||||
ret = ImGui.IsItemClicked(ImGuiMouseButton.Middle) ? MouseButton.Middle : ret;
|
||||
if (ret != MouseButton.None)
|
||||
_communicator.ChangedItemClick.Invoke(ret, data);
|
||||
}
|
||||
|
||||
if (_communicator.ChangedItemHover.HasTooltip && ImGui.IsItemHovered())
|
||||
{
|
||||
|
|
@ -87,12 +90,13 @@ public class ChangedItemDrawer : IDisposable
|
|||
return;
|
||||
|
||||
ImGui.SameLine(ImGui.GetContentRegionAvail().X);
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGuiUtil.RightJustify(text, ColorId.ItemId.Value());
|
||||
}
|
||||
|
||||
private void DrawCategoryIcon(string name, object? obj)
|
||||
{
|
||||
var height = ImGui.GetTextLineHeight();
|
||||
var height = ImGui.GetFrameHeight();
|
||||
var slot = EquipSlot.Unknown;
|
||||
var desc = string.Empty;
|
||||
if (obj is Item it)
|
||||
|
|
@ -152,104 +156,102 @@ public class ChangedItemDrawer : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
private static Dictionary<EquipSlot, TextureWrap> CreateEquipSlotIcons(UiBuilder uiBuilder, DataManager gameData)
|
||||
private bool CreateEquipSlotIcons(UiBuilder uiBuilder, DataManager gameData)
|
||||
{
|
||||
using var equipTypeIcons = uiBuilder.LoadUld("ui/uld/ArmouryBoard.uld");
|
||||
|
||||
if (!equipTypeIcons.Valid)
|
||||
return new Dictionary<EquipSlot, TextureWrap>();
|
||||
|
||||
var dict = new Dictionary<EquipSlot, TextureWrap>(12);
|
||||
return false;
|
||||
|
||||
// Weapon
|
||||
var tex = equipTypeIcons.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 0);
|
||||
if (tex != null)
|
||||
{
|
||||
dict.Add(EquipSlot.MainHand, tex);
|
||||
dict.Add(EquipSlot.BothHand, tex);
|
||||
_icons.Add(EquipSlot.MainHand, tex);
|
||||
_icons.Add(EquipSlot.BothHand, tex);
|
||||
}
|
||||
|
||||
// Hat
|
||||
tex = equipTypeIcons.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 1);
|
||||
if (tex != null)
|
||||
dict.Add(EquipSlot.Head, tex);
|
||||
_icons.Add(EquipSlot.Head, tex);
|
||||
|
||||
// Body
|
||||
tex = equipTypeIcons.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 2);
|
||||
if (tex != null)
|
||||
{
|
||||
dict.Add(EquipSlot.Body, tex);
|
||||
dict.Add(EquipSlot.BodyHands, tex);
|
||||
dict.Add(EquipSlot.BodyHandsLegsFeet, tex);
|
||||
dict.Add(EquipSlot.BodyLegsFeet, tex);
|
||||
dict.Add(EquipSlot.ChestHands, tex);
|
||||
dict.Add(EquipSlot.FullBody, tex);
|
||||
dict.Add(EquipSlot.HeadBody, tex);
|
||||
_icons.Add(EquipSlot.Body, tex);
|
||||
_icons.Add(EquipSlot.BodyHands, tex);
|
||||
_icons.Add(EquipSlot.BodyHandsLegsFeet, tex);
|
||||
_icons.Add(EquipSlot.BodyLegsFeet, tex);
|
||||
_icons.Add(EquipSlot.ChestHands, tex);
|
||||
_icons.Add(EquipSlot.FullBody, tex);
|
||||
_icons.Add(EquipSlot.HeadBody, tex);
|
||||
}
|
||||
|
||||
// Hands
|
||||
tex = equipTypeIcons.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 3);
|
||||
if (tex != null)
|
||||
dict.Add(EquipSlot.Hands, tex);
|
||||
_icons.Add(EquipSlot.Hands, tex);
|
||||
|
||||
// Pants
|
||||
tex = equipTypeIcons.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 5);
|
||||
if (tex != null)
|
||||
{
|
||||
dict.Add(EquipSlot.Legs, tex);
|
||||
dict.Add(EquipSlot.LegsFeet, tex);
|
||||
_icons.Add(EquipSlot.Legs, tex);
|
||||
_icons.Add(EquipSlot.LegsFeet, tex);
|
||||
}
|
||||
|
||||
// Shoes
|
||||
tex = equipTypeIcons.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 6);
|
||||
if (tex != null)
|
||||
dict.Add(EquipSlot.Feet, tex);
|
||||
_icons.Add(EquipSlot.Feet, tex);
|
||||
|
||||
// Offhand
|
||||
tex = equipTypeIcons.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 7);
|
||||
if (tex != null)
|
||||
dict.Add(EquipSlot.OffHand, tex);
|
||||
_icons.Add(EquipSlot.OffHand, tex);
|
||||
|
||||
// Earrings
|
||||
tex = equipTypeIcons.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 8);
|
||||
if (tex != null)
|
||||
dict.Add(EquipSlot.Ears, tex);
|
||||
_icons.Add(EquipSlot.Ears, tex);
|
||||
|
||||
// Necklace
|
||||
tex = equipTypeIcons.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 9);
|
||||
if (tex != null)
|
||||
dict.Add(EquipSlot.Neck, tex);
|
||||
_icons.Add(EquipSlot.Neck, tex);
|
||||
|
||||
// Bracelet
|
||||
tex = equipTypeIcons.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 10);
|
||||
if (tex != null)
|
||||
dict.Add(EquipSlot.Wrists, tex);
|
||||
_icons.Add(EquipSlot.Wrists, tex);
|
||||
|
||||
// Ring
|
||||
tex = equipTypeIcons.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 11);
|
||||
if (tex != null)
|
||||
dict.Add(EquipSlot.RFinger, tex);
|
||||
_icons.Add(EquipSlot.RFinger, tex);
|
||||
|
||||
// Monster
|
||||
tex = gameData.GetImGuiTexture("ui/icon/062000/062042_hr1.tex");
|
||||
if (tex != null)
|
||||
dict.Add(MonsterSlot, tex);
|
||||
_icons.Add(MonsterSlot, tex);
|
||||
|
||||
// Demihuman
|
||||
tex = gameData.GetImGuiTexture("ui/icon/062000/062041_hr1.tex");
|
||||
if (tex != null)
|
||||
dict.Add(DemihumanSlot, tex);
|
||||
_icons.Add(DemihumanSlot, tex);
|
||||
|
||||
// Customization
|
||||
tex = gameData.GetImGuiTexture("ui/icon/062000/062043_hr1.tex");
|
||||
if (tex != null)
|
||||
dict.Add(CustomizationSlot, tex);
|
||||
_icons.Add(CustomizationSlot, tex);
|
||||
|
||||
// Action
|
||||
tex = gameData.GetImGuiTexture("ui/icon/062000/062001_hr1.tex");
|
||||
if (tex != null)
|
||||
dict.Add(ActionSlot, tex);
|
||||
_icons.Add(ActionSlot, tex);
|
||||
|
||||
return dict;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,11 +27,9 @@ public sealed class ConfigWindow : Window
|
|||
public void SelectTab(TabType tab)
|
||||
=> _configTabs.SelectTab = tab;
|
||||
|
||||
|
||||
public void SelectMod(Mod mod)
|
||||
=> _configTabs.Mods.SelectMod = mod;
|
||||
|
||||
|
||||
public ConfigWindow(PerformanceTracker tracker, DalamudPluginInterface pi, Configuration config, ValidityChecker checker,
|
||||
TutorialService tutorial)
|
||||
: base(GetLabel(checker))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using OtterGui;
|
|||
using OtterGui.Classes;
|
||||
using OtterGui.Raii;
|
||||
using OtterGui.Widgets;
|
||||
using Penumbra.Services;
|
||||
|
||||
namespace Penumbra.UI.ModsTab;
|
||||
|
||||
|
|
@ -34,7 +33,7 @@ public class ModPanelChangedItemsTab : ITab
|
|||
return;
|
||||
|
||||
var zipList = ZipList.FromSortedList((SortedList<string, object?>)_selector.Selected!.ChangedItems);
|
||||
var height = ImGui.GetTextLineHeight();
|
||||
var height = ImGui.GetFrameHeight();
|
||||
ImGuiClip.ClippedDraw(zipList, kvp => _drawer.DrawChangedItem(kvp.Item1, kvp.Item2, true), height);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using OtterGui;
|
|||
using OtterGui.Classes;
|
||||
using OtterGui.Raii;
|
||||
using OtterGui.Widgets;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Collections.Manager;
|
||||
using Penumbra.Mods;
|
||||
using Penumbra.UI.Classes;
|
||||
|
|
@ -18,6 +19,7 @@ public class ChangedItemsTab : ITab
|
|||
private readonly CollectionManager _collectionManager;
|
||||
private readonly ChangedItemDrawer _drawer;
|
||||
private readonly CollectionSelectHeader _collectionHeader;
|
||||
private ConfigTabBar? _tabBar = null;
|
||||
|
||||
public ChangedItemsTab(CollectionManager collectionManager, CollectionSelectHeader collectionHeader, ChangedItemDrawer drawer)
|
||||
{
|
||||
|
|
@ -26,6 +28,9 @@ public class ChangedItemsTab : ITab
|
|||
_drawer = drawer;
|
||||
}
|
||||
|
||||
public void SetTabBar(ConfigTabBar tabBar)
|
||||
=> _tabBar = tabBar;
|
||||
|
||||
public ReadOnlySpan<byte> Label
|
||||
=> "Changed Items"u8;
|
||||
|
||||
|
|
@ -40,14 +45,14 @@ public class ChangedItemsTab : ITab
|
|||
if (!child)
|
||||
return;
|
||||
|
||||
var height = ImGui.GetTextLineHeightWithSpacing() + 2 * ImGui.GetStyle().CellPadding.Y;
|
||||
var height = ImGui.GetFrameHeight() + 2 * ImGui.GetStyle().CellPadding.Y;
|
||||
var skips = ImGuiClip.GetNecessarySkips(height);
|
||||
using var list = ImRaii.Table("##changedItems", 3, ImGuiTableFlags.RowBg, -Vector2.One);
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
const ImGuiTableColumnFlags flags = ImGuiTableColumnFlags.NoResize | ImGuiTableColumnFlags.WidthFixed;
|
||||
ImGui.TableSetupColumn("items", flags, 400 * UiHelpers.Scale);
|
||||
ImGui.TableSetupColumn("items", flags, 450 * UiHelpers.Scale);
|
||||
ImGui.TableSetupColumn("mods", flags, varWidth - 130 * UiHelpers.Scale);
|
||||
ImGui.TableSetupColumn("id", flags, 130 * UiHelpers.Scale);
|
||||
|
||||
|
|
@ -62,9 +67,9 @@ public class ChangedItemsTab : ITab
|
|||
private float DrawFilters()
|
||||
{
|
||||
var varWidth = ImGui.GetContentRegionAvail().X
|
||||
- 400 * UiHelpers.Scale
|
||||
- 450 * UiHelpers.Scale
|
||||
- ImGui.GetStyle().ItemSpacing.X;
|
||||
ImGui.SetNextItemWidth(400 * UiHelpers.Scale);
|
||||
ImGui.SetNextItemWidth(450 * UiHelpers.Scale);
|
||||
LowerString.InputWithHint("##changedItemsFilter", "Filter Item...", ref _changedItemFilter, 128);
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(varWidth);
|
||||
|
|
@ -85,18 +90,39 @@ public class ChangedItemsTab : ITab
|
|||
ImGui.TableNextColumn();
|
||||
_drawer.DrawChangedItem(item.Key, item.Value.Item2, false);
|
||||
ImGui.TableNextColumn();
|
||||
if (item.Value.Item1.Count > 0)
|
||||
{
|
||||
ImGui.TextUnformatted(item.Value.Item1[0].Name);
|
||||
if (item.Value.Item1.Count > 1 && ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(string.Join("\n", item.Value.Item1.Skip(1).Select(m => m.Name)));
|
||||
}
|
||||
DrawModColumn(item.Value.Item1);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (!ChangedItemDrawer.GetChangedItemObject(item.Value.Item2, out var text))
|
||||
return;
|
||||
|
||||
using var color = ImRaii.PushColor(ImGuiCol.Text, ColorId.ItemId.Value());
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGuiUtil.RightAlign(text);
|
||||
}
|
||||
|
||||
private void DrawModColumn(SingleArray<IMod> mods)
|
||||
{
|
||||
if (mods.Count <= 0)
|
||||
return;
|
||||
|
||||
var first = mods[0];
|
||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.SelectableTextAlign, new Vector2(0, 0.5f));
|
||||
if (ImGui.Selectable(first.Name, false, ImGuiSelectableFlags.None, new Vector2(0, ImGui.GetFrameHeight()))
|
||||
&& ImGui.GetIO().KeyCtrl
|
||||
&& _tabBar != null
|
||||
&& first is Mod mod)
|
||||
{
|
||||
_tabBar.SelectTab = TabType.Mods;
|
||||
_tabBar.Mods.SelectMod = mod;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
using var _ = ImRaii.Tooltip();
|
||||
ImGui.TextUnformatted("Hold Control and click to jump to mod.\n");
|
||||
if (mods.Count > 1)
|
||||
ImGui.TextUnformatted("Other mods affecting this item:\n" + string.Join("\n", mods.Skip(1).Select(m => m.Name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public class ConfigTabBar
|
|||
Resource,
|
||||
Watcher,
|
||||
};
|
||||
ChangedItems.SetTabBar(this);
|
||||
}
|
||||
|
||||
public TabType Draw()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue