From ec7a53bee228c89e4c690c5a3fc7cf2ae520f281 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 16 Nov 2023 18:21:50 +0100 Subject: [PATCH] Improve (hopefully) some handling of options and stuff. Remove localization because wonky. --- .../Customization/CustomName.cs | 7 ---- .../Customization/CustomizationOptions.cs | 37 +++++++++---------- .../Customization/CustomizeIndex.cs | 6 +-- .../CustomizationDrawer.GenderRace.cs | 4 +- .../Customization/CustomizationDrawer.Icon.cs | 31 ++++++++++++++-- .../Gui/Customization/CustomizationDrawer.cs | 2 +- .../DesignTab/DesignFileSystemSelector.cs | 1 + 7 files changed, 52 insertions(+), 36 deletions(-) diff --git a/Glamourer.GameData/Customization/CustomName.cs b/Glamourer.GameData/Customization/CustomName.cs index 6bff835..040c476 100644 --- a/Glamourer.GameData/Customization/CustomName.cs +++ b/Glamourer.GameData/Customization/CustomName.cs @@ -3,13 +3,6 @@ // Localization from the game files directly. public enum CustomName { - Clan = 0, - Gender, - Reverse, - OddEyes, - IrisSmall, - IrisLarge, - IrisSize, MidlanderM, HighlanderM, WildwoodM, diff --git a/Glamourer.GameData/Customization/CustomizationOptions.cs b/Glamourer.GameData/Customization/CustomizationOptions.cs index a3e04f5..fdbac65 100644 --- a/Glamourer.GameData/Customization/CustomizationOptions.cs +++ b/Glamourer.GameData/Customization/CustomizationOptions.cs @@ -72,6 +72,7 @@ public partial class CustomizationOptions foreach (var gender in Genders) _customizationSets[ToIndex(race, gender)] = tmp.GetSet(race, gender); } + tmp.SetNpcData(_customizationSets); } @@ -85,13 +86,6 @@ public partial class CustomizationOptions void Set(CustomName id, Lumina.Text.SeString? s, string def) => _names[(int)id] = s?.ToDalamudString().TextValue ?? def; - Set(CustomName.Clan, tmp.Lobby.GetRow(102)?.Text, "Clan"); - Set(CustomName.Gender, tmp.Lobby.GetRow(103)?.Text, "Gender"); - Set(CustomName.Reverse, tmp.Lobby.GetRow(2135)?.Text, "Reverse"); - Set(CustomName.OddEyes, tmp.Lobby.GetRow(2125)?.Text, "Odd Eyes"); - Set(CustomName.IrisSmall, tmp.Lobby.GetRow(1076)?.Text, "Small"); - Set(CustomName.IrisLarge, tmp.Lobby.GetRow(1075)?.Text, "Large"); - Set(CustomName.IrisSize, tmp.Lobby.GetRow(244)?.Text, "Iris Size"); Set(CustomName.MidlanderM, subRace.GetRow((int)SubRace.Midlander)?.Masculine, SubRace.Midlander.ToName()); Set(CustomName.MidlanderF, subRace.GetRow((int)SubRace.Midlander)?.Feminine, SubRace.Midlander.ToName()); Set(CustomName.HighlanderM, subRace.GetRow((int)SubRace.Highlander)?.Masculine, SubRace.Highlander.ToName()); @@ -184,10 +178,10 @@ public partial class CustomizationOptions { _options = options; _cmpFile = new CmpFile(gameData, log); - _customizeSheet = gameData.GetExcelSheet()!; - _bnpcCustomize = gameData.GetExcelSheet()!; - _enpcBase = gameData.GetExcelSheet()!; - Lobby = gameData.GetExcelSheet()!; + _customizeSheet = gameData.GetExcelSheet(ClientLanguage.English)!; + _bnpcCustomize = gameData.GetExcelSheet(ClientLanguage.English)!; + _enpcBase = gameData.GetExcelSheet(ClientLanguage.English)!; + Lobby = gameData.GetExcelSheet(ClientLanguage.English)!; var tmp = gameData.Excel.GetType().GetMethod("GetSheet", BindingFlags.Instance | BindingFlags.NonPublic)? .MakeGenericMethod(typeof(CharaMakeParams)).Invoke(gameData.Excel, new object?[] { @@ -401,20 +395,25 @@ public partial class CustomizationOptions return c.ToDefaultName(); } - // Facial Features and Tattoos is created by combining two strings. - if (c is >= CustomizeIndex.FacialFeature1 and <= CustomizeIndex.LegacyTattoo) - return - $"{Lobby.GetRow(1741)?.Text.ToDalamudString().ToString() ?? "Facial Features"} & {Lobby.GetRow(1742)?.Text.ToDalamudString().ToString() ?? "Tattoos"}"; - // Otherwise all is normal, get the menu name or if it does not work the default name. var textRow = Lobby.GetRow(menu.Value.Id); return textRow?.Text.ToDalamudString().ToString() ?? c.ToDefaultName(); }).ToArray(); // Add names for both eye colors. - nameArray[(int)CustomizeIndex.EyeColorLeft] = nameArray[(int)CustomizeIndex.EyeColorRight]; - nameArray[(int)CustomizeIndex.EyeColorRight] = _options.GetName(CustomName.OddEyes); - + nameArray[(int)CustomizeIndex.EyeColorLeft] = CustomizeIndex.EyeColorLeft.ToDefaultName(); + nameArray[(int)CustomizeIndex.EyeColorRight] = CustomizeIndex.EyeColorRight.ToDefaultName(); + nameArray[(int)CustomizeIndex.FacialFeature1] = CustomizeIndex.FacialFeature1.ToDefaultName(); + nameArray[(int)CustomizeIndex.FacialFeature2] = CustomizeIndex.FacialFeature2.ToDefaultName(); + nameArray[(int)CustomizeIndex.FacialFeature3] = CustomizeIndex.FacialFeature3.ToDefaultName(); + nameArray[(int)CustomizeIndex.FacialFeature4] = CustomizeIndex.FacialFeature4.ToDefaultName(); + nameArray[(int)CustomizeIndex.FacialFeature5] = CustomizeIndex.FacialFeature5.ToDefaultName(); + nameArray[(int)CustomizeIndex.FacialFeature6] = CustomizeIndex.FacialFeature6.ToDefaultName(); + nameArray[(int)CustomizeIndex.FacialFeature7] = CustomizeIndex.FacialFeature7.ToDefaultName(); + nameArray[(int)CustomizeIndex.LegacyTattoo] = CustomizeIndex.LegacyTattoo.ToDefaultName(); + nameArray[(int)CustomizeIndex.SmallIris] = CustomizeIndex.SmallIris.ToDefaultName(); + nameArray[(int)CustomizeIndex.Lipstick] = CustomizeIndex.Lipstick.ToDefaultName(); + nameArray[(int)CustomizeIndex.FacePaintReversed] = CustomizeIndex.FacePaintReversed.ToDefaultName(); set.OptionName = nameArray; } diff --git a/Glamourer.GameData/Customization/CustomizeIndex.cs b/Glamourer.GameData/Customization/CustomizeIndex.cs index 1c03dd1..38aca21 100644 --- a/Glamourer.GameData/Customization/CustomizeIndex.cs +++ b/Glamourer.GameData/Customization/CustomizeIndex.cs @@ -111,14 +111,14 @@ public static class CustomizationExtensions CustomizeIndex.Clan => "Clan", CustomizeIndex.Face => "Head Style", CustomizeIndex.Hairstyle => "Hair Style", - CustomizeIndex.Highlights => "Highlights", + CustomizeIndex.Highlights => "Enable Highlights", CustomizeIndex.SkinColor => "Skin Color", - CustomizeIndex.EyeColorRight => "Right Eye Color", + CustomizeIndex.EyeColorRight => "Left Eye", // inverted due to compatibility fuckup. CustomizeIndex.HairColor => "Hair Color", CustomizeIndex.HighlightsColor => "Highlights Color", CustomizeIndex.TattooColor => "Tattoo Color", CustomizeIndex.Eyebrows => "Eyebrow Style", - CustomizeIndex.EyeColorLeft => "Left Eye Color", + CustomizeIndex.EyeColorLeft => "Right Eye", // inverted due to compatibility fuckup. CustomizeIndex.EyeShape => "Small Pupils", CustomizeIndex.Nose => "Nose Style", CustomizeIndex.Jaw => "Jaw Style", diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs index 5528f44..7866bda 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs @@ -17,8 +17,6 @@ public partial class CustomizationDrawer ImGui.SameLine(); using var group = ImRaii.Group(); DrawRaceCombo(); - var gender = _service.AwaitedService.GetName(CustomName.Gender); - var clan = _service.AwaitedService.GetName(CustomName.Clan); if (_withApply) { using var disabled = ImRaii.Disabled(_locked); @@ -33,7 +31,7 @@ public partial class CustomizationDrawer } ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted($"{gender} & {clan}"); + ImGui.TextUnformatted("Gender & Clan"); } private void DrawGenderSelector() diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs index cabd2d5..e4c15d4 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs @@ -1,4 +1,5 @@ -using System.Numerics; +using System; +using System.Numerics; using Dalamud.Interface.Utility; using Glamourer.Customization; using ImGuiNET; @@ -113,8 +114,32 @@ public partial class CustomizationDrawer ImGui.SameLine(); ApplyCheckbox(CustomizeIndex.FacialFeature4); } + else + { + ImGui.Dummy(new Vector2(ImGui.GetFrameHeight())); + } + + var oldValue = _customize.Data.At(_currentIndex.ToByteAndMask().ByteIdx); + var tmp = (int)oldValue; + ImGui.SetNextItemWidth(_inputIntSize); + if (ImGui.InputInt("##text", ref tmp, 1, 1)) + { + tmp = Math.Clamp(tmp, 0, byte.MaxValue); + if (tmp != oldValue) + { + _customize.Data.Set(_currentIndex.ToByteAndMask().ByteIdx, (byte)tmp); + var changes = (byte)tmp ^ oldValue; + Changed |= ((changes & 0x01) == 0x01 ? CustomizeFlag.FacialFeature1 : 0) + | ((changes & 0x02) == 0x02 ? CustomizeFlag.FacialFeature2 : 0) + | ((changes & 0x04) == 0x04 ? CustomizeFlag.FacialFeature3 : 0) + | ((changes & 0x08) == 0x08 ? CustomizeFlag.FacialFeature4 : 0) + | ((changes & 0x10) == 0x10 ? CustomizeFlag.FacialFeature5 : 0) + | ((changes & 0x20) == 0x20 ? CustomizeFlag.FacialFeature6 : 0) + | ((changes & 0x40) == 0x40 ? CustomizeFlag.FacialFeature7 : 0) + | ((changes & 0x80) == 0x80 ? CustomizeFlag.LegacyTattoo : 0); + } + } - PercentageInputInt(); if (_set.DataByValue(CustomizeIndex.Face, _customize.Face, out _, _customize.Face) < 0) { ImGui.SameLine(); @@ -127,7 +152,7 @@ public partial class CustomizationDrawer ImGui.AlignTextToFramePadding(); using (var _ = ImRaii.Enabled()) { - ImGui.TextUnformatted(_set.Option(CustomizeIndex.LegacyTattoo)); + ImGui.TextUnformatted("Facial Features & Tattoos"); } if (_withApply) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.cs b/Glamourer/Gui/Customization/CustomizationDrawer.cs index 364b469..0f76b62 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.cs @@ -200,7 +200,7 @@ public partial class CustomizationDrawer : IDisposable private void UpdateSizes() { _spacing = ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemInnerSpacing.X }; - _iconSize = new Vector2(ImGui.GetTextLineHeight() * 2 + ImGui.GetStyle().ItemSpacing.Y + 2 * ImGui.GetStyle().FramePadding.Y); + _iconSize = new Vector2(ImGui.GetTextLineHeight() * 2 + _spacing.Y + 2 * ImGui.GetStyle().FramePadding.Y); _framedIconSize = _iconSize + 2 * ImGui.GetStyle().FramePadding; _inputIntSize = 2 * _framedIconSize.X + 1 * _spacing.X; _inputIntSizeNoButtons = _inputIntSize - 2 * _spacing.X - 2 * ImGui.GetFrameHeight(); diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs index 0127cdb..1de6ebd 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs @@ -118,6 +118,7 @@ public sealed class DesignFileSystemSelector : FileSystemSelector