Skip to content

Commit

Permalink
[SVS] Translate character names
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Sep 30, 2024
1 parent f0abd46 commit f54b914
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions SVS_CheatTools/CheatToolsWindowInit.SVS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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] };
}

Expand Down Expand Up @@ -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"))
{
Expand All @@ -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"))
//{
Expand Down

0 comments on commit f54b914

Please sign in to comment.