Fix some data issues. 0.1.3.1.

This commit is contained in:
Ottermandias 2023-06-12 01:14:24 +02:00
parent 579ef97dcc
commit 9ec597cf2a
7 changed files with 197 additions and 201 deletions

View file

@ -51,7 +51,7 @@ namespace Glamourer
=> new(sheet.First(), "Nothing", slot); => new(sheet.First(), "Nothing", slot);
static Item EmptyNpc(EquipSlot slot) static Item EmptyNpc(EquipSlot slot)
=> new(new Lumina.Excel.GeneratedSheets.Item() { ModelMain = 9903 }, "Smallclothes (NPC)", slot); => new(new Lumina.Excel.GeneratedSheets.Item() { ModelMain = 9903, RowId = 1 }, "Smallclothes (NPC)", slot);
_itemsBySlot = new Dictionary<EquipSlot, List<Item>>() _itemsBySlot = new Dictionary<EquipSlot, List<Item>>()
{ {

Binary file not shown.

View file

@ -5,8 +5,8 @@
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<RootNamespace>Glamourer</RootNamespace> <RootNamespace>Glamourer</RootNamespace>
<AssemblyName>Glamourer</AssemblyName> <AssemblyName>Glamourer</AssemblyName>
<FileVersion>0.1.3.0</FileVersion> <FileVersion>0.1.3.1</FileVersion>
<AssemblyVersion>0.1.3.0</AssemblyVersion> <AssemblyVersion>0.1.3.1</AssemblyVersion>
<Company>SoftOtter</Company> <Company>SoftOtter</Company>
<Product>Glamourer</Product> <Product>Glamourer</Product>
<Copyright>Copyright © 2020</Copyright> <Copyright>Copyright © 2020</Copyright>

View file

@ -5,7 +5,7 @@
"Description": "Adds functionality to change and store appearance of players, customization and equip. Requires Penumbra to be installed and activated to work. Can also add preview options to the Changed Items tab for Penumbra.", "Description": "Adds functionality to change and store appearance of players, customization and equip. Requires Penumbra to be installed and activated to work. Can also add preview options to the Changed Items tab for Penumbra.",
"Tags": [ "Appearance", "Glamour", "Race", "Outfit", "Armor", "Clothes", "Skins", "Customization", "Design", "Character" ], "Tags": [ "Appearance", "Glamour", "Race", "Outfit", "Armor", "Clothes", "Skins", "Customization", "Design", "Character" ],
"InternalName": "Glamourer", "InternalName": "Glamourer",
"AssemblyVersion": "0.1.3.0", "AssemblyVersion": "0.1.3.1",
"RepoUrl": "https://github.com/Ottermandias/Glamourer", "RepoUrl": "https://github.com/Ottermandias/Glamourer",
"ApplicableVersion": "any", "ApplicableVersion": "any",
"DalamudApiLevel": 8, "DalamudApiLevel": 8,

View file

@ -1,9 +1,6 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using System.Reflection;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Logging; using Dalamud.Logging;
@ -11,7 +8,6 @@ using Glamourer.Customization;
using Glamourer.Designs; using Glamourer.Designs;
using Glamourer.FileSystem; using Glamourer.FileSystem;
using ImGuiNET; using ImGuiNET;
using Penumbra.GameData.Structs;
using Penumbra.PlayerWatch; using Penumbra.PlayerWatch;
namespace Glamourer.Gui namespace Glamourer.Gui

View file

@ -1,237 +1,237 @@
using System.Collections; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using ImGuiNET; using ImGuiNET;
using Lumina.Text;
using Penumbra.GameData.Enums; using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs; using Penumbra.GameData.Structs;
using Penumbra.PlayerWatch; using Penumbra.PlayerWatch;
namespace Glamourer.Gui namespace Glamourer.Gui;
internal partial class Interface
{ {
internal partial class Interface private bool DrawStainSelector(ComboWithFilter<Stain> stainCombo, EquipSlot slot, StainId stainIdx)
{ {
private bool DrawStainSelector(ComboWithFilter<Stain> stainCombo, EquipSlot slot, StainId stainIdx) stainCombo.PostPreview = null;
if (_stains.TryGetValue((byte)stainIdx, out var stain))
{ {
stainCombo.PostPreview = null; var previewPush = PushColor(stain, ImGuiCol.FrameBg);
if (_stains.TryGetValue((byte) stainIdx, out var stain)) stainCombo.PostPreview = () => ImGui.PopStyleColor(previewPush);
{
var previewPush = PushColor(stain, ImGuiCol.FrameBg);
stainCombo.PostPreview = () => ImGui.PopStyleColor(previewPush);
}
var change = stainCombo.Draw(string.Empty, out var newStain) && !newStain.RowIndex.Equals(stainIdx);
if (!change && (byte) stainIdx != 0)
{
ImGuiCustom.HoverTooltip("Right-click to clear.");
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
change = true;
newStain = Stain.None;
}
}
if (!change)
return false;
if (_player == null)
return _inDesignMode && (_selection?.Data.WriteStain(slot, newStain.RowIndex) ?? false);
Glamourer.RevertableDesigns.Add(_player);
newStain.Write(_player.Address, slot);
return true;
} }
private bool DrawGlobalStainSelector(ComboWithFilter<Stain> stainCombo) var change = stainCombo.Draw(string.Empty, out var newStain) && !newStain.RowIndex.Equals(stainIdx);
if (!change && (byte)stainIdx != 0)
{ {
stainCombo.PostPreview = null; ImGuiCustom.HoverTooltip("Right-click to clear.");
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
var change = stainCombo.Draw(string.Empty, out var newStain);
ImGui.SameLine();
ImGui.TextUnformatted("Dye All Slots");
if (!change)
{ {
ImGuiCustom.HoverTooltip("Right-click to clear."); change = true;
if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) newStain = Stain.None;
{
change = true;
newStain = Stain.None;
}
} }
}
if (!change) if (!change)
return false; return false;
if (_player == null) if (_player == null)
return _inDesignMode && (_selection?.Data.WriteStain(slot, newStain.RowIndex) ?? false);
Glamourer.RevertableDesigns.Add(_player);
newStain.Write(_player.Address, slot);
return true;
}
private bool DrawGlobalStainSelector(ComboWithFilter<Stain> stainCombo)
{
stainCombo.PostPreview = null;
var change = stainCombo.Draw(string.Empty, out var newStain);
ImGui.SameLine();
ImGui.TextUnformatted("Dye All Slots");
if (!change)
{
ImGuiCustom.HoverTooltip("Right-click to clear.");
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{ {
foreach (var key in GetEquipSlotNames().Keys) change = true;
{ newStain = Stain.None;
if (key is EquipSlot.OffHand && _selection?.Data.Equipment.OffHand.Set.Value == 0)
continue;
_selection?.Data.WriteStain(key, newStain.RowIndex);
}
return _inDesignMode;
} }
}
Glamourer.RevertableDesigns.Add(_player); if (!change)
return false;
if (_player == null)
{
foreach (var key in GetEquipSlotNames().Keys) foreach (var key in GetEquipSlotNames().Keys)
{ {
newStain.Write(_player.Address, key); if (key is EquipSlot.OffHand && _selection?.Data.Equipment.OffHand.Set.Value == 0)
} continue;
return true;
}
private bool DrawItemSelector(ComboWithFilter<Item> equipCombo, Lumina.Excel.GeneratedSheets.Item item, EquipSlot slot = EquipSlot.Unknown) _selection?.Data.WriteStain(key, newStain.RowIndex);
{
var currentName = item.Name.ToString();
var change = equipCombo.Draw(currentName, out var newItem, _itemComboWidth) && newItem.Base.RowId != item.RowId;
if (!change && !ReferenceEquals(item, SmallClothes))
{
ImGuiCustom.HoverTooltip("Right-click to clear.");
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
change = true;
newItem = Item.Nothing(slot);
}
} }
if (!change) return _inDesignMode;
return false;
newItem = new Item(newItem.Base, newItem.Name, slot);
if (_player == null)
return _inDesignMode && (_selection?.Data.WriteItem(newItem) ?? false);
Glamourer.RevertableDesigns.Add(_player);
newItem.Write(_player.Address);
return true;
} }
private static bool DrawCheckbox(CharacterEquipMask flag, ref CharacterEquipMask mask) Glamourer.RevertableDesigns.Add(_player);
foreach (var key in GetEquipSlotNames().Keys)
newStain.Write(_player.Address, key);
return true;
}
private bool DrawItemSelector(ComboWithFilter<Item> equipCombo, EquipItem item, EquipSlot slot = EquipSlot.Unknown)
{
var currentName = item.Name;
var change = equipCombo.Draw(currentName, out var newItem, _itemComboWidth) && newItem.Base.RowId != item.Id;
if (!change && item.Name != SmallClothes.Name)
{ {
var tmp = (uint) mask; ImGuiCustom.HoverTooltip("Right-click to clear.");
var ret = false; if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
if (ImGui.CheckboxFlags($"##flag_{(uint) flag}", ref tmp, (uint) flag) && tmp != (uint) mask)
{ {
mask = (CharacterEquipMask) tmp; change = true;
ret = true; newItem = Item.Nothing(slot);
} }
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Enable writing this slot in this save.");
return ret;
} }
private static readonly Lumina.Excel.GeneratedSheets.Item SmallClothes = new(){ Name = new SeString("Nothing"), RowId = 0 }; if (!change)
private static readonly Lumina.Excel.GeneratedSheets.Item SmallClothesNpc = new(){ Name = new SeString("Smallclothes (NPC)"), RowId = 1 }; return false;
private static readonly Lumina.Excel.GeneratedSheets.Item Unknown = new(){ Name = new SeString("Unknown"), RowId = 2 };
private Lumina.Excel.GeneratedSheets.Item Identify(SetId set, WeaponType weapon, ushort variant, EquipSlot slot) newItem = new Item(newItem.Base, newItem.Name, slot);
if (_player == null)
return _inDesignMode && (_selection?.Data.WriteItem(newItem) ?? false);
Glamourer.RevertableDesigns.Add(_player);
newItem.Write(_player.Address);
return true;
}
private static bool DrawCheckbox(CharacterEquipMask flag, ref CharacterEquipMask mask)
{
var tmp = (uint)mask;
var ret = false;
if (ImGui.CheckboxFlags($"##flag_{(uint)flag}", ref tmp, (uint)flag) && tmp != (uint)mask)
{ {
return (uint) set switch mask = (CharacterEquipMask)tmp;
{ ret = true;
0 => SmallClothes,
9903 => SmallClothesNpc,
_ => ToItem(_identifier.Identify(set, weapon, variant, slot.ToSlot())),
};
} }
private Lumina.Excel.GeneratedSheets.Item ToItem(IEnumerable<EquipItem> items) if (ImGui.IsItemHovered())
ImGui.SetTooltip("Enable writing this slot in this save.");
return ret;
}
private static readonly EquipItem SmallClothes = new("Nothing", 0, 0, 0, 0, 0, 0, EquipSlot.Unknown);
private static readonly EquipItem SmallClothesNpc = new("Smallclothes (NPC)", 1, 0, 9903, 0, 1, 0, EquipSlot.Unknown);
private static readonly EquipItem Unknown = new("Unknown", 3, 0, 0, 0, 0, 0, EquipSlot.Unknown);
private EquipItem Identify(SetId set, WeaponType weapon, ushort variant, EquipSlot slot)
{
return (uint)set switch
{ {
var item = items.FirstOrDefault(); 0 => SmallClothes,
if (item.Valid) 9903 => SmallClothesNpc,
return Dalamud.GameData.GetExcelSheet<Lumina.Excel.GeneratedSheets.Item>()!.GetRow(item.Id) ?? Unknown; _ => ToItem(_identifier.Identify(set, weapon, variant, slot.ToSlot())),
};
}
return Unknown; private static EquipItem ToItem(IEnumerable<EquipItem> items)
} {
var item = items.FirstOrDefault();
if (item.Valid)
return item;
private bool DrawEquipSlot(EquipSlot slot, CharacterArmor equip) return Unknown;
}
private bool DrawEquipSlot(EquipSlot slot, CharacterArmor equip)
{
var (equipCombo, stainCombo) = _combos[slot];
var ret = DrawStainSelector(stainCombo, slot, equip.Stain);
ImGui.SameLine();
var item = Identify(equip.Set, new WeaponType(), equip.Variant, slot);
if (item.Name == Unknown.Name)
item = new EquipItem($"Unknown ({item.ModelId.Value}, {item.Variant})", 0, 0, equip.Set, 0, equip.Variant,
FullEquipType.Unknown, slot);
ret |= DrawItemSelector(equipCombo, item, slot);
return ret;
}
private bool DrawEquipSlotWithCheck(EquipSlot slot, CharacterArmor equip, CharacterEquipMask flag, ref CharacterEquipMask mask)
{
var ret = DrawCheckbox(flag, ref mask);
ImGui.SameLine();
ret |= DrawEquipSlot(slot, equip);
return ret;
}
private bool DrawWeapon(EquipSlot slot, CharacterWeapon weapon)
{
var (equipCombo, stainCombo) = _combos[slot];
var ret = DrawStainSelector(stainCombo, slot, weapon.Stain);
ImGui.SameLine();
var item = Identify(weapon.Set, weapon.Type, weapon.Variant, slot);
if (item.Name == Unknown.Name)
item = new EquipItem($"Unknown ({weapon.Set.Value}, {weapon.Type.Value}, {weapon.Variant})", 0, 0, weapon.Set, weapon.Type, (byte) weapon.Variant, FullEquipType.Unknown, slot);
ret |= DrawItemSelector(equipCombo, item, slot);
return ret;
}
private bool DrawWeaponWithCheck(EquipSlot slot, CharacterWeapon weapon, CharacterEquipMask flag, ref CharacterEquipMask mask)
{
var ret = DrawCheckbox(flag, ref mask);
ImGui.SameLine();
ret |= DrawWeapon(slot, weapon);
return ret;
}
private bool DrawEquip(CharacterEquipment equip)
{
var ret = false;
if (ImGui.CollapsingHeader("Character Equipment"))
{ {
var (equipCombo, stainCombo) = _combos[slot]; ret |= DrawGlobalStainSelector(_globalStainCombo);
ret |= DrawWeapon(EquipSlot.MainHand, equip.MainHand);
var ret = DrawStainSelector(stainCombo, slot, equip.Stain); ret |= DrawWeapon(EquipSlot.OffHand, equip.OffHand);
ImGui.SameLine(); ret |= DrawEquipSlot(EquipSlot.Head, equip.Head);
var item = Identify(equip.Set, new WeaponType(), equip.Variant, slot); ret |= DrawEquipSlot(EquipSlot.Body, equip.Body);
ret |= DrawItemSelector(equipCombo, item, slot); ret |= DrawEquipSlot(EquipSlot.Hands, equip.Hands);
ret |= DrawEquipSlot(EquipSlot.Legs, equip.Legs);
return ret; ret |= DrawEquipSlot(EquipSlot.Feet, equip.Feet);
ret |= DrawEquipSlot(EquipSlot.Ears, equip.Ears);
ret |= DrawEquipSlot(EquipSlot.Neck, equip.Neck);
ret |= DrawEquipSlot(EquipSlot.Wrists, equip.Wrists);
ret |= DrawEquipSlot(EquipSlot.RFinger, equip.RFinger);
ret |= DrawEquipSlot(EquipSlot.LFinger, equip.LFinger);
} }
private bool DrawEquipSlotWithCheck(EquipSlot slot, CharacterArmor equip, CharacterEquipMask flag, ref CharacterEquipMask mask) return ret;
}
private bool DrawEquip(CharacterEquipment equip, ref CharacterEquipMask mask)
{
var ret = false;
if (ImGui.CollapsingHeader("Character Equipment"))
{ {
var ret = DrawCheckbox(flag, ref mask); ret |= DrawGlobalStainSelector(_globalStainCombo);
ImGui.SameLine(); ret |= DrawWeaponWithCheck(EquipSlot.MainHand, equip.MainHand, CharacterEquipMask.MainHand, ref mask);
ret |= DrawEquipSlot(slot, equip); ret |= DrawWeaponWithCheck(EquipSlot.OffHand, equip.OffHand, CharacterEquipMask.OffHand, ref mask);
return ret; ret |= DrawEquipSlotWithCheck(EquipSlot.Head, equip.Head, CharacterEquipMask.Head, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Body, equip.Body, CharacterEquipMask.Body, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Hands, equip.Hands, CharacterEquipMask.Hands, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Legs, equip.Legs, CharacterEquipMask.Legs, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Feet, equip.Feet, CharacterEquipMask.Feet, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Ears, equip.Ears, CharacterEquipMask.Ears, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Neck, equip.Neck, CharacterEquipMask.Neck, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Wrists, equip.Wrists, CharacterEquipMask.Wrists, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.RFinger, equip.RFinger, CharacterEquipMask.RFinger, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.LFinger, equip.LFinger, CharacterEquipMask.LFinger, ref mask);
} }
private bool DrawWeapon(EquipSlot slot, CharacterWeapon weapon) return ret;
{
var (equipCombo, stainCombo) = _combos[slot];
var ret = DrawStainSelector(stainCombo, slot, weapon.Stain);
ImGui.SameLine();
var item = Identify(weapon.Set, weapon.Type, weapon.Variant, slot);
ret |= DrawItemSelector(equipCombo, item, slot);
return ret;
}
private bool DrawWeaponWithCheck(EquipSlot slot, CharacterWeapon weapon, CharacterEquipMask flag, ref CharacterEquipMask mask)
{
var ret = DrawCheckbox(flag, ref mask);
ImGui.SameLine();
ret |= DrawWeapon(slot, weapon);
return ret;
}
private bool DrawEquip(CharacterEquipment equip)
{
var ret = false;
if (ImGui.CollapsingHeader("Character Equipment"))
{
ret |= DrawGlobalStainSelector(_globalStainCombo);
ret |= DrawWeapon(EquipSlot.MainHand, equip.MainHand);
ret |= DrawWeapon(EquipSlot.OffHand, equip.OffHand);
ret |= DrawEquipSlot(EquipSlot.Head, equip.Head);
ret |= DrawEquipSlot(EquipSlot.Body, equip.Body);
ret |= DrawEquipSlot(EquipSlot.Hands, equip.Hands);
ret |= DrawEquipSlot(EquipSlot.Legs, equip.Legs);
ret |= DrawEquipSlot(EquipSlot.Feet, equip.Feet);
ret |= DrawEquipSlot(EquipSlot.Ears, equip.Ears);
ret |= DrawEquipSlot(EquipSlot.Neck, equip.Neck);
ret |= DrawEquipSlot(EquipSlot.Wrists, equip.Wrists);
ret |= DrawEquipSlot(EquipSlot.RFinger, equip.RFinger);
ret |= DrawEquipSlot(EquipSlot.LFinger, equip.LFinger);
}
return ret;
}
private bool DrawEquip(CharacterEquipment equip, ref CharacterEquipMask mask)
{
var ret = false;
if (ImGui.CollapsingHeader("Character Equipment"))
{
ret |= DrawGlobalStainSelector(_globalStainCombo);
ret |= DrawWeaponWithCheck(EquipSlot.MainHand, equip.MainHand, CharacterEquipMask.MainHand, ref mask);
ret |= DrawWeaponWithCheck(EquipSlot.OffHand, equip.OffHand, CharacterEquipMask.OffHand, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Head, equip.Head, CharacterEquipMask.Head, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Body, equip.Body, CharacterEquipMask.Body, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Hands, equip.Hands, CharacterEquipMask.Hands, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Legs, equip.Legs, CharacterEquipMask.Legs, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Feet, equip.Feet, CharacterEquipMask.Feet, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Ears, equip.Ears, CharacterEquipMask.Ears, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Neck, equip.Neck, CharacterEquipMask.Neck, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.Wrists, equip.Wrists, CharacterEquipMask.Wrists, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.RFinger, equip.RFinger, CharacterEquipMask.RFinger, ref mask);
ret |= DrawEquipSlotWithCheck(EquipSlot.LFinger, equip.LFinger, CharacterEquipMask.LFinger, ref mask);
}
return ret;
}
} }
} }

View file

@ -6,8 +6,8 @@
"Description": "Adds functionality to change and store appearance of players, customization and equip. Requires Penumbra to be installed and activated to work. Can also add preview options to the Changed Items tab for Penumbra.", "Description": "Adds functionality to change and store appearance of players, customization and equip. Requires Penumbra to be installed and activated to work. Can also add preview options to the Changed Items tab for Penumbra.",
"Tags": [ "Appearance", "Glamour", "Race", "Outfit", "Armor", "Clothes", "Skins", "Customization", "Design", "Character" ], "Tags": [ "Appearance", "Glamour", "Race", "Outfit", "Armor", "Clothes", "Skins", "Customization", "Design", "Character" ],
"InternalName": "Glamourer", "InternalName": "Glamourer",
"AssemblyVersion": "0.1.3.0", "AssemblyVersion": "0.1.3.1",
"TestingAssemblyVersion": "0.1.3.0", "TestingAssemblyVersion": "0.1.3.1",
"RepoUrl": "https://github.com/Ottermandias/Glamourer", "RepoUrl": "https://github.com/Ottermandias/Glamourer",
"ApplicableVersion": "any", "ApplicableVersion": "any",
"DalamudApiLevel": 8, "DalamudApiLevel": 8,