From b834ebe339f6702d92af80b1465a1738c32db1ea Mon Sep 17 00:00:00 2001 From: Adrienne Walker Date: Sun, 17 Apr 2022 12:30:32 -0700 Subject: [PATCH] Update OverlayPlugin to support newer ffxiv plugin versions Remove Language.Unknown and calls to ToProperCase. Additionally, stop proper casing 6.x versions (intl and chinese) as the ffxiv plugin has stopped proper casing names there. This caused problems in cactbot where names no longer matched, so doing it here as well for consistency. Split from #235 to make this easier to land. --- OverlayPlugin.Core/Integration/FFXIVRepository.cs | 5 ++++- OverlayPlugin.Core/MemoryProcessors/FFXIVProcess.cs | 7 +++++++ OverlayPlugin.Core/MemoryProcessors/FFXIVProcessCn.cs | 3 +-- OverlayPlugin.Core/MemoryProcessors/FFXIVProcessIntl.cs | 3 +-- OverlayPlugin.Core/MemoryProcessors/FFXIVProcessKo.cs | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/OverlayPlugin.Core/Integration/FFXIVRepository.cs b/OverlayPlugin.Core/Integration/FFXIVRepository.cs index 40a970e55..62537d97c 100644 --- a/OverlayPlugin.Core/Integration/FFXIVRepository.cs +++ b/OverlayPlugin.Core/Integration/FFXIVRepository.cs @@ -246,7 +246,10 @@ public Language GetLanguage() { var repo = GetRepository(); if (repo == null) - return Language.Unknown; + { + // Defaults to English + return Language.English; + } return repo.GetSelectedLanguageID(); } diff --git a/OverlayPlugin.Core/MemoryProcessors/FFXIVProcess.cs b/OverlayPlugin.Core/MemoryProcessors/FFXIVProcess.cs index 3f1bc8cd2..eae250e9d 100644 --- a/OverlayPlugin.Core/MemoryProcessors/FFXIVProcess.cs +++ b/OverlayPlugin.Core/MemoryProcessors/FFXIVProcess.cs @@ -133,6 +133,13 @@ static internal bool IsCrafter(EntityJob job) job == EntityJob.CUL; } + static internal string ToProperCase(string name) + { + System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; + System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; + return textInfo.ToTitleCase(name); + } + [Serializable] public class EntityData { diff --git a/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessCn.cs b/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessCn.cs index 97cea5235..c0492662f 100644 --- a/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessCn.cs +++ b/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessCn.cs @@ -180,10 +180,9 @@ public unsafe override EntityData GetEntityDataFromByteArray(byte[] source) { // dump '\0' string terminators var memoryName = System.Text.Encoding.UTF8.GetString(mem.Name, EntityMemory.nameBytes).Split(new[] { '\0' }, 2)[0]; - var capitalizedName = FFXIV_ACT_Plugin.Common.StringHelper.ToProperCase(memoryName); EntityData entity = new EntityData() { - name = capitalizedName, + name = memoryName, id = mem.id, type = mem.type, distance = mem.distance, diff --git a/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessIntl.cs b/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessIntl.cs index 12168625d..d2280423c 100644 --- a/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessIntl.cs +++ b/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessIntl.cs @@ -178,10 +178,9 @@ public unsafe override EntityData GetEntityDataFromByteArray(byte[] source) { // dump '\0' string terminators var memoryName = System.Text.Encoding.UTF8.GetString(mem.Name, EntityMemory.nameBytes).Split(new[] { '\0' }, 2)[0]; - var capitalizedName = FFXIV_ACT_Plugin.Common.StringHelper.ToProperCase(memoryName); EntityData entity = new EntityData() { - name = capitalizedName, + name = memoryName, id = mem.id, type = mem.type, distance = mem.distance, diff --git a/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessKo.cs b/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessKo.cs index d5a00a1fd..5dcd72ab1 100644 --- a/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessKo.cs +++ b/OverlayPlugin.Core/MemoryProcessors/FFXIVProcessKo.cs @@ -167,7 +167,7 @@ public unsafe override EntityData GetEntityDataFromByteArray(byte[] source) { // dump '\0' string terminators var memoryName = System.Text.Encoding.UTF8.GetString(mem.Name, EntityMemory.nameBytes).Split(new[] { '\0' }, 2)[0]; - var capitalizedName = FFXIV_ACT_Plugin.Common.StringHelper.ToProperCase(memoryName); + var capitalizedName = ToProperCase(memoryName); EntityData entity = new EntityData() { name = capitalizedName,