From f54b914db899afe6704df4c4c5db5483909a7487 Mon Sep 17 00:00:00 2001 From: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:35:10 +0200 Subject: [PATCH] [SVS] Translate character names --- SVS_CheatTools/CheatToolsWindowInit.SVS.cs | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/SVS_CheatTools/CheatToolsWindowInit.SVS.cs b/SVS_CheatTools/CheatToolsWindowInit.SVS.cs index 679ca37..8e8503a 100644 --- a/SVS_CheatTools/CheatToolsWindowInit.SVS.cs +++ b/SVS_CheatTools/CheatToolsWindowInit.SVS.cs @@ -94,11 +94,22 @@ public static void Initialize(CheatToolsPlugin instance) Harmony.CreateAndPatchAll(typeof(Hooks)); } - private static string GetCharaName(this Actor chara) + private static string GetCharaName(this Actor chara, bool translated) { var fullname = chara?.charFile?.Parameter?.fullname; - return !string.IsNullOrEmpty(fullname) ? fullname : chara?.chaCtrl?.name ?? chara?.ToString(); + if (!string.IsNullOrEmpty(fullname)) + { + if (translated) + { + TranslationHelper.TryTranslate(fullname, out var translatedName); + if (!string.IsNullOrEmpty(translatedName)) + return translatedName; + } + return fullname; + } + return chara?.chaCtrl?.name ?? chara?.ToString(); } + private static int GetActorId(this Actor currentAdvChara) { return Manager.Game.Charas.AsManagedEnumerable().Single(x => x.Value.Equals(currentAdvChara)).Key; @@ -276,7 +287,7 @@ private static void DrawGirlCheatMenu(CheatToolsWindow cheatToolsWindow) foreach (var chara in GetVisibleCharas()) { - if (GUILayout.Button($"Select #{chara.Key} - {GetCharaName(chara.Value)}")) + if (GUILayout.Button($"Select #{chara.Key} - {GetCharaName(chara.Value, true)}")) _currentVisibleChara = chara.Value; } @@ -306,7 +317,7 @@ private static void DrawSingleCharaCheats(Actor currentAdvChara, CheatToolsWindo { GUILayout.Label("Selected:", IMGUIUtils.LayoutOptionsExpandWidthFalse); GUILayout.FlexibleSpace(); - GUILayout.Label(GetCharaName(currentAdvChara), IMGUIUtils.LayoutOptionsExpandWidthFalse); + GUILayout.Label(GetCharaName(currentAdvChara, true), IMGUIUtils.LayoutOptionsExpandWidthFalse); GUILayout.FlexibleSpace(); if (GUILayout.Button("Close", IMGUIUtils.LayoutOptionsExpandWidthFalse)) _currentVisibleChara = null; } @@ -408,7 +419,7 @@ private static void DrawSingleCharaCheats(Actor currentAdvChara, CheatToolsWindo if (_otherCharaListIndex >= 0) { - _otherCharaListIndex = _otherCharaDropdown.Show(_otherCharaListIndex, targets.Select(x => new GUIContent(GetCharaName(x))).ToArray(), comboboxMaxY); + _otherCharaListIndex = _otherCharaDropdown.Show(_otherCharaListIndex, targets.Select(x => new GUIContent(GetCharaName(x, true))).ToArray(), comboboxMaxY); targets = new[] { targets[_otherCharaListIndex] }; } @@ -508,10 +519,10 @@ private static void DrawSingleCharaCheats(Actor currentAdvChara, CheatToolsWindo } if (gameParam != null && GUILayout.Button("Inspect GameParameter")) - Inspector.Instance.Push(new InstanceStackEntry(gameParam, "GameParam " + GetCharaName(currentAdvChara)), true); + Inspector.Instance.Push(new InstanceStackEntry(gameParam, "GameParam " + GetCharaName(currentAdvChara, true)), true); if (charasGameParam != null && GUILayout.Button("Inspect CharactersGameParameter")) - Inspector.Instance.Push(new InstanceStackEntry(charasGameParam, "CharaGameParam " + GetCharaName(currentAdvChara)), true); + Inspector.Instance.Push(new InstanceStackEntry(charasGameParam, "CharaGameParam " + GetCharaName(currentAdvChara, true)), true); if (GUILayout.Button("Navigate to Character's GameObject")) { @@ -522,7 +533,7 @@ private static void DrawSingleCharaCheats(Actor currentAdvChara, CheatToolsWindo } if (GUILayout.Button("Open Character in inspector")) - Inspector.Instance.Push(new InstanceStackEntry(currentAdvChara, "Actor " + GetCharaName(currentAdvChara)), true); + Inspector.Instance.Push(new InstanceStackEntry(currentAdvChara, "Actor " + GetCharaName(currentAdvChara, true)), true); //if (GUILayout.Button("Inspect extended data")) //{