mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Improve handling for bonus items in designs.
This commit is contained in:
parent
fc6604fd5a
commit
773f526fba
6 changed files with 45 additions and 12 deletions
|
|
@ -280,7 +280,7 @@ public class DesignBase
|
|||
var item = _designData.BonusItem(slot);
|
||||
ret[slot.ToString()] = new JObject()
|
||||
{
|
||||
["BonusId"] = item.Id.Id,
|
||||
["BonusId"] = item.CustomId.Id,
|
||||
["Apply"] = DoApplyBonusItem(slot),
|
||||
};
|
||||
}
|
||||
|
|
@ -431,7 +431,7 @@ public class DesignBase
|
|||
|
||||
protected static void LoadBonus(ItemManager items, DesignBase design, JToken? json)
|
||||
{
|
||||
if (json is not JObject obj)
|
||||
if (json is not JObject)
|
||||
{
|
||||
design.Application.BonusItem = 0;
|
||||
return;
|
||||
|
|
@ -439,8 +439,7 @@ public class DesignBase
|
|||
|
||||
foreach (var slot in BonusExtensions.AllFlags)
|
||||
{
|
||||
var itemJson = json[slot.ToString()] as JObject;
|
||||
if (itemJson == null)
|
||||
if (json[slot.ToString()] is not JObject itemJson)
|
||||
{
|
||||
design.Application.BonusItem &= ~slot;
|
||||
design.GetDesignDataRef().SetBonusItem(slot, BonusItem.Empty(slot));
|
||||
|
|
@ -448,7 +447,7 @@ public class DesignBase
|
|||
}
|
||||
|
||||
design.SetApplyBonusItem(slot, itemJson["Apply"]?.ToObject<bool>() ?? false);
|
||||
var id = itemJson["BonusId"]?.ToObject<ushort>() ?? 0;
|
||||
var id = itemJson["BonusId"]?.ToObject<ulong>() ?? 0;
|
||||
var item = items.Resolve(slot, id);
|
||||
design.GetDesignDataRef().SetBonusItem(slot, item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public unsafe struct DesignData
|
|||
=> slot switch
|
||||
{
|
||||
// @formatter:off
|
||||
BonusItemFlag.Glasses => new BonusItem(_nameGlasses, _iconIds[12], _bonusIds[0], _bonusModelIds[0], _bonusVariants[0], BonusItemFlag.Glasses),
|
||||
BonusItemFlag.Glasses => Penumbra.GameData.Structs.BonusItem.FromIds(_bonusIds[0], _iconIds[12], _bonusModelIds[0], _bonusVariants[0], BonusItemFlag.Glasses, _nameGlasses),
|
||||
_ => Penumbra.GameData.Structs.BonusItem.Empty(slot),
|
||||
// @formatter:on
|
||||
};
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ public class DesignEditor(
|
|||
public void ChangeBonusItem(object data, BonusItemFlag slot, BonusItem item, ApplySettings settings = default)
|
||||
{
|
||||
var design = (Design)data;
|
||||
if (!Items.IsBonusItemValid(slot, item.Id, out item))
|
||||
if (item.Slot != slot)
|
||||
return;
|
||||
|
||||
var oldItem = design.DesignData.BonusItem(slot);
|
||||
|
|
|
|||
|
|
@ -139,6 +139,8 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
|||
"If this is checked, Glamourer will try to revert the advanced dye row to its game state instead of applying a specific row."u8);
|
||||
}
|
||||
|
||||
public sealed class MaterialSlotCombo;
|
||||
|
||||
public void DrawNew(Design design)
|
||||
{
|
||||
if (EquipSlotCombo.Draw("##slot", "Choose a slot for an advanced dye row.", ref _newSlot))
|
||||
|
|
|
|||
|
|
@ -132,16 +132,48 @@ public class ItemManager
|
|||
if (index == uint.MaxValue)
|
||||
return new BonusItem($"Invalid ({id.Id}-{variant})", 0, 0, id, variant, slot);
|
||||
|
||||
if (id.Id == 0)
|
||||
return BonusItem.Empty(slot);
|
||||
var item = ObjectIdentification.Identify(id, variant, slot)
|
||||
.FirstOrDefault(BonusItem.FromIds(BonusItemId.Invalid, 0, id, variant, slot));
|
||||
if (item.Id != BonusItemId.Invalid)
|
||||
return item;
|
||||
|
||||
return ObjectIdentification.Identify(id, variant, slot)
|
||||
.FirstOrDefault(new BonusItem($"Invalid ({id.Id}-{variant})", 0, 0, id, variant, slot));
|
||||
if (slot is BonusItemFlag.Glasses)
|
||||
{
|
||||
var headItem = ObjectIdentification.Identify(id, 0, variant, EquipSlot.Head).FirstOrDefault();
|
||||
if (headItem.Valid)
|
||||
return BonusItem.FromIds(BonusItemId.Invalid, headItem.IconId, id, variant, slot, $"{headItem.Name} ({EquipSlot.Head.ToName()}: {id}-{variant})");
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public BonusItem Resolve(BonusItemFlag slot, BonusItemId id)
|
||||
=> IsBonusItemValid(slot, id, out var item) ? item : new BonusItem($"Invalid ({id.Id})", 0, id, 0, 0, slot);
|
||||
|
||||
public BonusItem Resolve(BonusItemFlag slot, CustomItemId id)
|
||||
{
|
||||
// Only from early designs as migration.
|
||||
if (!id.IsBonusItem)
|
||||
{
|
||||
IsBonusItemValid(slot, (BonusItemId)id.Id, out var item);
|
||||
return item;
|
||||
}
|
||||
|
||||
if (!id.IsCustom)
|
||||
{
|
||||
if (IsBonusItemValid(slot, id.BonusItem, out var item))
|
||||
return item;
|
||||
|
||||
return BonusItem.Empty(slot);
|
||||
}
|
||||
|
||||
var (model, variant, slot2) = id.SplitBonus;
|
||||
if (slot != slot2)
|
||||
return BonusItem.Empty(slot);
|
||||
|
||||
return Identify(slot, model, variant);
|
||||
}
|
||||
|
||||
/// <summary> Return the default offhand for a given mainhand, that is for both handed weapons, return the correct offhand part, and for everything else Nothing. </summary>
|
||||
public EquipItem GetDefaultOffhand(EquipItem mainhand)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 3a65ed1c86a2d5fd5794ff5c0559b02fc25d7224
|
||||
Subproject commit d9d4b286d54ad4027a1e8a2bbf900ee79aefaa93
|
||||
Loading…
Add table
Add a link
Reference in a new issue