mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Improve weapon identification for designs for unknown weapons.
This commit is contained in:
parent
06299d1966
commit
8b6e819fcd
3 changed files with 67 additions and 26 deletions
|
|
@ -333,7 +333,7 @@ public class DesignBase
|
|||
if (id == ItemManager.NothingId(EquipSlot.OffHand))
|
||||
id = ItemManager.NothingId(FullEquipType.Shield);
|
||||
|
||||
PrintWarning(items.ValidateWeapons(id.Item, idOff.Item, out var main, out var off));
|
||||
PrintWarning(items.ValidateWeapons(id, idOff, out var main, out var off, allowUnknown));
|
||||
PrintWarning(items.ValidateStain(stain, out stain, allowUnknown));
|
||||
PrintWarning(items.ValidateStain(stainOff, out stainOff, allowUnknown));
|
||||
design.DesignData.SetItem(EquipSlot.MainHand, main);
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ public class EquipmentDrawer
|
|||
}
|
||||
|
||||
label = combo.Label;
|
||||
|
||||
var unknown = !_gPose.InGPose && current.Type is FullEquipType.Unknown;
|
||||
var ret = false;
|
||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemInnerSpacing);
|
||||
|
|
@ -198,6 +199,7 @@ public class EquipmentDrawer
|
|||
weapon = combo.CurrentSelection;
|
||||
}
|
||||
}
|
||||
|
||||
if (unknown && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
|
||||
ImGui.SetTooltip("The weapon type could not be identified, thus changing it to other weapons of that type is not possible.");
|
||||
|
||||
|
|
@ -488,7 +490,7 @@ public class EquipmentDrawer
|
|||
return changes;
|
||||
}
|
||||
|
||||
private static void WeaponHelpMarker(string label)
|
||||
private static void WeaponHelpMarker(string label, string? type = null)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGuiComponents.HelpMarker(
|
||||
|
|
@ -496,6 +498,12 @@ public class EquipmentDrawer
|
|||
+ "thus it is only allowed to change weapons to other weapons of the same type.");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(label);
|
||||
if (type != null)
|
||||
{
|
||||
var pos = ImGui.GetItemRectMin();
|
||||
pos.Y += ImGui.GetFrameHeightWithSpacing();
|
||||
ImGui.GetWindowDrawList().AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), $"({type})");
|
||||
}
|
||||
}
|
||||
|
||||
private DataChange DrawWeaponsSmall(EquipItem cMainhand, out EquipItem rMainhand, EquipItem cOffhand, out EquipItem rOffhand,
|
||||
|
|
@ -534,8 +542,10 @@ public class EquipmentDrawer
|
|||
rApplyMainhandStain = true;
|
||||
}
|
||||
|
||||
if (allWeapons)
|
||||
mainhandLabel += $" ({cMainhand.Type.ToName()})";
|
||||
WeaponHelpMarker(mainhandLabel);
|
||||
|
||||
|
||||
if (rOffhand.Type is FullEquipType.Unknown)
|
||||
{
|
||||
rOffhandStain = cOffhandStain;
|
||||
|
|
@ -607,7 +617,7 @@ public class EquipmentDrawer
|
|||
rApplyMainhand = true;
|
||||
}
|
||||
|
||||
WeaponHelpMarker(mainhandLabel);
|
||||
WeaponHelpMarker(mainhandLabel, allWeapons ? cMainhand.Type.ToName() : null);
|
||||
|
||||
if (DrawStain(EquipSlot.MainHand, cMainhandStain, out rMainhandStain, locked, false))
|
||||
changes |= DataChange.Stain;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ public class ItemManager : IDisposable
|
|||
return EquipItem.FromId(itemId);
|
||||
|
||||
if (item.Type.ToSlot() != slot)
|
||||
return new EquipItem(string.Intern($"Invalid #{itemId}"), itemId, item.IconId, item.ModelId, item.WeaponType, item.Variant, 0, 0, 0, 0);
|
||||
return new EquipItem(string.Intern($"Invalid #{itemId}"), itemId, item.IconId, item.ModelId, item.WeaponType, item.Variant, 0, 0, 0,
|
||||
0);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
|
@ -88,11 +89,13 @@ public class ItemManager : IDisposable
|
|||
if (itemId == NothingId(type))
|
||||
return NothingItem(type);
|
||||
|
||||
if (!ItemService.AwaitedService.TryGetValue(itemId, type is FullEquipType.Shield ? EquipSlot.MainHand : EquipSlot.OffHand, out var item))
|
||||
if (!ItemService.AwaitedService.TryGetValue(itemId, type is FullEquipType.Shield ? EquipSlot.MainHand : EquipSlot.OffHand,
|
||||
out var item))
|
||||
return EquipItem.FromId(itemId);
|
||||
|
||||
if (item.Type != type)
|
||||
return new EquipItem(string.Intern($"Invalid #{itemId}"), itemId, item.IconId, item.ModelId, item.WeaponType, item.Variant, 0, 0, 0, 0);
|
||||
return new EquipItem(string.Intern($"Invalid #{itemId}"), itemId, item.IconId, item.ModelId, item.WeaponType, item.Variant, 0, 0, 0,
|
||||
0);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
|
@ -164,7 +167,7 @@ public class ItemManager : IDisposable
|
|||
if (!itemId.IsItem)
|
||||
{
|
||||
var (id, _, variant, _) = itemId.Split;
|
||||
item = Identify(slot, id, variant);
|
||||
item = Identify(slot, id, variant);
|
||||
return allowUnknown ? string.Empty : $"The item {itemId} yields an unknown item.";
|
||||
}
|
||||
|
||||
|
|
@ -217,33 +220,61 @@ public class ItemManager : IDisposable
|
|||
/// or the default sword and a nothing offhand.
|
||||
/// The return value is an empty string if there was no problem and a warning otherwise.
|
||||
/// </summary>
|
||||
public string ValidateWeapons(ItemId mainId, ItemId offId, out EquipItem main, out EquipItem off)
|
||||
public string ValidateWeapons(CustomItemId mainId, CustomItemId offId, out EquipItem main, out EquipItem off, bool allowUnknown)
|
||||
{
|
||||
var ret = string.Empty;
|
||||
if (!IsItemValid(EquipSlot.MainHand, mainId, out main))
|
||||
if (!mainId.IsItem)
|
||||
{
|
||||
var (id, weapon, variant, _) = mainId.Split;
|
||||
main = Identify(EquipSlot.MainHand, id, weapon, variant);
|
||||
if (!allowUnknown)
|
||||
{
|
||||
ret = $"The item {mainId} yields an unknown item, reset to default sword.";
|
||||
main = DefaultSword;
|
||||
}
|
||||
}
|
||||
else if (!IsItemValid(EquipSlot.MainHand, mainId.Item, out main))
|
||||
{
|
||||
main = DefaultSword;
|
||||
ret = $"The mainhand weapon {mainId} does not exist, reset to default sword.";
|
||||
}
|
||||
|
||||
var offType = main.Type.ValidOffhand();
|
||||
if (IsOffhandValid(offType, offId, out off))
|
||||
return ret;
|
||||
|
||||
// Try implicit offhand.
|
||||
// Can not be set to default sword before because then it could not be valid.
|
||||
if (IsOffhandValid(offType, mainId, out off))
|
||||
return $"The offhand weapon {offId} does not exist, reset to implied offhand.";
|
||||
|
||||
if (FullEquipTypeExtensions.OffhandTypes.Contains(offType))
|
||||
if (!offId.IsItem)
|
||||
{
|
||||
main = DefaultSword;
|
||||
off = NothingItem(FullEquipType.Shield);
|
||||
return
|
||||
$"The offhand weapon {offId} does not exist, but no default could be restored, reset mainhand to default sword and offhand to nothing.";
|
||||
var (id, weapon, variant, _) = offId.Split;
|
||||
off = Identify(EquipSlot.OffHand, id, weapon, variant, main.Type);
|
||||
if (!allowUnknown)
|
||||
{
|
||||
if (!FullEquipTypeExtensions.OffhandTypes.Contains(main.Type.ValidOffhand()))
|
||||
{
|
||||
main = DefaultSword;
|
||||
off = NothingItem(FullEquipType.Shield);
|
||||
return
|
||||
$"The offhand weapon {offId} does not exist, but no default could be restored, reset mainhand to default sword and offhand to nothing.";
|
||||
}
|
||||
|
||||
if (ret.Length > 0)
|
||||
ret += '\n';
|
||||
ret += $"The item {offId} yields an unknown item, reset to implied offhand.";
|
||||
off = GetDefaultOffhand(main);
|
||||
}
|
||||
}
|
||||
else if (!IsOffhandValid(main.Type.ValidOffhand(), offId.Item, out off))
|
||||
{
|
||||
if (!FullEquipTypeExtensions.OffhandTypes.Contains(main.Type.ValidOffhand()))
|
||||
{
|
||||
main = DefaultSword;
|
||||
off = NothingItem(FullEquipType.Shield);
|
||||
return
|
||||
$"The offhand weapon {offId} does not exist, but no default could be restored, reset mainhand to default sword and offhand to nothing.";
|
||||
}
|
||||
|
||||
if (ret.Length > 0)
|
||||
ret += '\n';
|
||||
ret += $"The offhand weapon {mainId} does not exist or is of invalid type, reset to default sword.";
|
||||
off = GetDefaultOffhand(main);
|
||||
}
|
||||
|
||||
off = NothingItem(offType);
|
||||
return ret.Length == 0 ? $"The offhand weapon {offId} does not exist, reset to no offhand." : ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue