mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2026-01-01 05:13:44 +01:00
Fix some issues with NPC Equip.
This commit is contained in:
parent
e1fc08fce7
commit
cf566932f9
5 changed files with 32 additions and 8 deletions
|
|
@ -345,7 +345,7 @@ public class DesignManager
|
||||||
/// <summary> Change a non-weapon equipment piece. </summary>
|
/// <summary> Change a non-weapon equipment piece. </summary>
|
||||||
public void ChangeEquip(Design design, EquipSlot slot, EquipItem item)
|
public void ChangeEquip(Design design, EquipSlot slot, EquipItem item)
|
||||||
{
|
{
|
||||||
if (!_items.IsItemValid(slot, item.ItemId, out item))
|
if (!_items.IsItemValid(slot, item.Id, out item))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var old = design.DesignData.Item(slot);
|
var old = design.DesignData.Item(slot);
|
||||||
|
|
|
||||||
|
|
@ -263,6 +263,11 @@ public class EquipmentDrawer
|
||||||
var change = combo.Draw(armor.Name, armor.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth);
|
var change = combo.Draw(armor.Name, armor.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength, _requiredComboWidth);
|
||||||
if (change)
|
if (change)
|
||||||
armor = combo.CurrentSelection;
|
armor = combo.CurrentSelection;
|
||||||
|
else if (combo.CustomVariant.Id > 0)
|
||||||
|
{
|
||||||
|
armor = _items.Identify(slot, combo.CustomSetId, combo.CustomVariant);
|
||||||
|
change = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!locked && armor.ModelId.Id != 0)
|
if (!locked && armor.ModelId.Id != 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using Glamourer.Services;
|
using Glamourer.Services;
|
||||||
|
|
@ -22,6 +23,9 @@ public sealed class ItemCombo : FilterComboCache<EquipItem>
|
||||||
private ItemId _currentItem;
|
private ItemId _currentItem;
|
||||||
private float _innerWidth;
|
private float _innerWidth;
|
||||||
|
|
||||||
|
public SetId CustomSetId { get; private set; }
|
||||||
|
public Variant CustomVariant { get; private set; }
|
||||||
|
|
||||||
public ItemCombo(IDataManager gameData, ItemManager items, EquipSlot slot, Logger log, FavoriteManager favorites)
|
public ItemCombo(IDataManager gameData, ItemManager items, EquipSlot slot, Logger log, FavoriteManager favorites)
|
||||||
: base(() => GetItems(favorites, items, slot), log)
|
: base(() => GetItems(favorites, items, slot), log)
|
||||||
{
|
{
|
||||||
|
|
@ -50,8 +54,9 @@ public sealed class ItemCombo : FilterComboCache<EquipItem>
|
||||||
|
|
||||||
public bool Draw(string previewName, ItemId previewIdx, float width, float innerWidth)
|
public bool Draw(string previewName, ItemId previewIdx, float width, float innerWidth)
|
||||||
{
|
{
|
||||||
_innerWidth = innerWidth;
|
_innerWidth = innerWidth;
|
||||||
_currentItem = previewIdx;
|
_currentItem = previewIdx;
|
||||||
|
CustomVariant = 0;
|
||||||
return Draw($"##{Label}", previewName, string.Empty, width, ImGui.GetTextLineHeightWithSpacing());
|
return Draw($"##{Label}", previewName, string.Empty, width, ImGui.GetTextLineHeightWithSpacing());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,4 +122,18 @@ public sealed class ItemCombo : FilterComboCache<EquipItem>
|
||||||
enumerable = enumerable.Append(ItemManager.SmallClothesItem(slot));
|
enumerable = enumerable.Append(ItemManager.SmallClothesItem(slot));
|
||||||
return enumerable.OrderByDescending(favorites.Contains).ThenBy(i => i.Name).Prepend(nothing).ToList();
|
return enumerable.OrderByDescending(favorites.Contains).ThenBy(i => i.Name).Prepend(nothing).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnClosePopup()
|
||||||
|
{
|
||||||
|
// If holding control while the popup closes, try to parse the input as a full pair of set id and variant, and set a custom item for that.
|
||||||
|
if (!ImGui.GetIO().KeyCtrl)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var split = Filter.Text.Split('-', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||||
|
if (split.Length != 2 || !ushort.TryParse(split[0], out var setId) || !byte.TryParse(split[1], out var variant))
|
||||||
|
return;
|
||||||
|
|
||||||
|
CustomSetId = setId;
|
||||||
|
CustomVariant = variant;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class ItemManager : IDisposable
|
||||||
public static EquipItem SmallClothesItem(EquipSlot slot)
|
public static EquipItem SmallClothesItem(EquipSlot slot)
|
||||||
=> new(SmallClothesNpc, SmallclothesId(slot), 0, SmallClothesNpcModel, 0, 1, slot.ToEquipType(), 0, 0, 0);
|
=> new(SmallClothesNpc, SmallclothesId(slot), 0, SmallClothesNpcModel, 0, 1, slot.ToEquipType(), 0, 0, 0);
|
||||||
|
|
||||||
public EquipItem Resolve(EquipSlot slot, ItemId itemId)
|
public EquipItem Resolve(EquipSlot slot, CustomItemId itemId)
|
||||||
{
|
{
|
||||||
slot = slot.ToSlot();
|
slot = slot.ToSlot();
|
||||||
if (itemId == NothingId(slot))
|
if (itemId == NothingId(slot))
|
||||||
|
|
@ -74,7 +74,7 @@ public class ItemManager : IDisposable
|
||||||
if (itemId == SmallclothesId(slot))
|
if (itemId == SmallclothesId(slot))
|
||||||
return SmallClothesItem(slot);
|
return SmallClothesItem(slot);
|
||||||
|
|
||||||
if (!ItemService.AwaitedService.TryGetValue(itemId, slot, out var item))
|
if (!itemId.IsItem || !ItemService.AwaitedService.TryGetValue(itemId.Item, slot, out var item))
|
||||||
return EquipItem.FromId(itemId);
|
return EquipItem.FromId(itemId);
|
||||||
|
|
||||||
if (item.Type.ToSlot() != slot)
|
if (item.Type.ToSlot() != slot)
|
||||||
|
|
@ -151,7 +151,7 @@ public class ItemManager : IDisposable
|
||||||
|
|
||||||
/// <summary> Returns whether an item id represents a valid item for a slot and gives the item. </summary>
|
/// <summary> Returns whether an item id represents a valid item for a slot and gives the item. </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
public bool IsItemValid(EquipSlot slot, ItemId itemId, out EquipItem item)
|
public bool IsItemValid(EquipSlot slot, CustomItemId itemId, out EquipItem item)
|
||||||
{
|
{
|
||||||
item = Resolve(slot, itemId);
|
item = Resolve(slot, itemId);
|
||||||
return item.Valid;
|
return item.Valid;
|
||||||
|
|
|
||||||
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
||||||
Subproject commit f55733a96fdc9f82c9bbf8272ca6366079aa8e32
|
Subproject commit 8df162f7dc7adc8be1af3eeae80bee3c0cfa4c5c
|
||||||
Loading…
Add table
Add a link
Reference in a new issue