mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Fix some weapon display stuff.
This commit is contained in:
parent
ffa1eadfd4
commit
16d4cedbf2
3 changed files with 24 additions and 16 deletions
|
|
@ -6,6 +6,7 @@ using System.Numerics;
|
|||
using Dalamud.Interface;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Glamourer.Designs;
|
||||
using Glamourer.Events;
|
||||
using Glamourer.Services;
|
||||
using Glamourer.Structs;
|
||||
using ImGuiNET;
|
||||
|
|
@ -30,16 +31,19 @@ public class EquipmentDrawer
|
|||
private readonly CodeService _codes;
|
||||
private readonly TextureService _textures;
|
||||
private readonly Configuration _config;
|
||||
private readonly GPoseService _gPose;
|
||||
|
||||
private float _requiredComboWidthUnscaled;
|
||||
private float _requiredComboWidth;
|
||||
|
||||
public EquipmentDrawer(IDataManager gameData, ItemManager items, CodeService codes, TextureService textures, Configuration config)
|
||||
public EquipmentDrawer(IDataManager gameData, ItemManager items, CodeService codes, TextureService textures, Configuration config,
|
||||
GPoseService gPose)
|
||||
{
|
||||
_items = items;
|
||||
_codes = codes;
|
||||
_textures = textures;
|
||||
_config = config;
|
||||
_gPose = gPose;
|
||||
_stainData = items.Stains;
|
||||
_stainCombo = new FilterComboColors(DefaultWidth - 20,
|
||||
_stainData.Data.Prepend(new KeyValuePair<byte, (string Name, uint Dye, bool Gloss)>(0, ("None", 0, false))));
|
||||
|
|
@ -183,8 +187,9 @@ public class EquipmentDrawer
|
|||
return false;
|
||||
}
|
||||
|
||||
label = combo.Label;
|
||||
using var disabled = ImRaii.Disabled(locked);
|
||||
label = combo.Label;
|
||||
locked |= !_gPose.InGPose && current.Type is FullEquipType.Unknown;
|
||||
using var disabled = ImRaii.Disabled(locked );
|
||||
if (!locked && open)
|
||||
UiHelpers.OpenCombo($"##{combo.Label}");
|
||||
if (!combo.Draw(weapon.Name, weapon.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth))
|
||||
|
|
@ -204,7 +209,8 @@ public class EquipmentDrawer
|
|||
return false;
|
||||
}
|
||||
|
||||
label = combo.Label;
|
||||
label = combo.Label;
|
||||
locked |= !_gPose.InGPose && (current.Type is FullEquipType.Unknown || mainhand.Type is FullEquipType.Unknown);
|
||||
using var disabled = ImRaii.Disabled(locked);
|
||||
if (!locked && open)
|
||||
UiHelpers.OpenCombo($"##{combo.Label}");
|
||||
|
|
@ -435,7 +441,7 @@ public class EquipmentDrawer
|
|||
EquipFlag? cApply, out bool rApply, out bool rApplyStain, bool locked, Gender gender, Race race)
|
||||
{
|
||||
var changes = DataChange.None;
|
||||
cArmor.DrawIcon(_textures, _iconSize);
|
||||
cArmor.DrawIcon(_textures, _iconSize, slot);
|
||||
var right = ImGui.IsItemClicked(ImGuiMouseButton.Right);
|
||||
var left = ImGui.IsItemClicked(ImGuiMouseButton.Left);
|
||||
ImGui.SameLine();
|
||||
|
|
@ -560,7 +566,7 @@ public class EquipmentDrawer
|
|||
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing,
|
||||
ImGui.GetStyle().ItemInnerSpacing with { Y = ImGui.GetStyle().ItemSpacing.Y });
|
||||
|
||||
cMainhand.DrawIcon(_textures, _iconSize);
|
||||
cMainhand.DrawIcon(_textures, _iconSize, EquipSlot.MainHand);
|
||||
var left = ImGui.IsItemClicked(ImGuiMouseButton.Left);
|
||||
ImGui.SameLine();
|
||||
using (var group = ImRaii.Group())
|
||||
|
|
@ -612,7 +618,7 @@ public class EquipmentDrawer
|
|||
return changes;
|
||||
}
|
||||
|
||||
rOffhand.DrawIcon(_textures, _iconSize);
|
||||
rOffhand.DrawIcon(_textures, _iconSize, EquipSlot.OffHand);
|
||||
var right = ImGui.IsItemClicked(ImGuiMouseButton.Right);
|
||||
left = ImGui.IsItemClicked(ImGuiMouseButton.Left);
|
||||
ImGui.SameLine();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using ImGuiNET;
|
|||
using Lumina.Misc;
|
||||
using OtterGui;
|
||||
using OtterGui.Raii;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
|
||||
namespace Glamourer.Gui;
|
||||
|
|
@ -34,18 +35,19 @@ public static class UiHelpers
|
|||
ImGui.OpenPopup(popupId);
|
||||
}
|
||||
|
||||
public static void DrawIcon(this EquipItem item, TextureService textures, Vector2 size)
|
||||
public static void DrawIcon(this EquipItem item, TextureService textures, Vector2 size, EquipSlot slot)
|
||||
{
|
||||
var isEmpty = item.ModelId.Id == 0;
|
||||
var (ptr, textureSize, empty) = textures.GetIcon(item);
|
||||
var (ptr, textureSize, empty) = textures.GetIcon(item, slot);
|
||||
if (empty)
|
||||
{
|
||||
var (bgColor, tint) = isEmpty
|
||||
? (ImGui.GetColorU32(ImGuiCol.FrameBg), new Vector4(0.1f, 0.1f, 0.1f, 0.5f))
|
||||
: (ImGui.GetColorU32(ImGuiCol.FrameBgActive), new Vector4(0.3f, 0.3f, 0.3f, 0.8f));
|
||||
var pos = ImGui.GetCursorScreenPos();
|
||||
ImGui.GetWindowDrawList().AddRectFilled(pos, pos + size,
|
||||
ImGui.GetColorU32(isEmpty ? ImGuiCol.FrameBg : ImGuiCol.FrameBgActive), 5 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.GetWindowDrawList().AddRectFilled(pos, pos + size, bgColor, 5 * ImGuiHelpers.GlobalScale);
|
||||
if (ptr != nint.Zero)
|
||||
ImGui.Image(ptr, size, Vector2.Zero, Vector2.One,
|
||||
isEmpty ? new Vector4(0.1f, 0.1f, 0.1f, 0.5f) : new Vector4(0.3f, 0.3f, 0.3f, 0.8f));
|
||||
ImGui.Image(ptr, size, Vector2.Zero, Vector2.One, tint);
|
||||
else
|
||||
ImGui.Dummy(size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ public sealed class TextureService : TextureCache, IDisposable
|
|||
|
||||
private readonly TextureWrap?[] _slotIcons;
|
||||
|
||||
public (nint, Vector2, bool) GetIcon(EquipItem item)
|
||||
public (nint, Vector2, bool) GetIcon(EquipItem item, EquipSlot slot)
|
||||
{
|
||||
if (item.IconId.Id != 0 && TryLoadIcon(item.IconId.Id, out var ret))
|
||||
return (ret.ImGuiHandle, new Vector2(ret.Width, ret.Height), false);
|
||||
|
||||
var idx = item.Type.ToSlot().ToIndex();
|
||||
var idx = slot.ToIndex();
|
||||
return idx < 12 && _slotIcons[idx] != null
|
||||
? (_slotIcons[idx]!.ImGuiHandle, new Vector2(_slotIcons[idx]!.Width, _slotIcons[idx]!.Height), true)
|
||||
: (nint.Zero, Vector2.Zero, true);
|
||||
|
|
@ -59,7 +59,7 @@ public sealed class TextureService : TextureCache, IDisposable
|
|||
ret[6] = uldWrapper.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 9)!;
|
||||
ret[7] = uldWrapper.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 10)!;
|
||||
ret[8] = uldWrapper.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 11)!;
|
||||
ret[9] = ret[10];
|
||||
ret[9] = ret[8];
|
||||
ret[10] = uldWrapper.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 0)!;
|
||||
ret[11] = uldWrapper.LoadTexturePart("ui/uld/ArmouryBoard_hr1.tex", 7)!;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue