public static void OnPointerEnterPostfix(CustomFileListCtrl __instance, GameObject obj) { if (obj == null) { return; } var component = obj.GetComponent <CustomFileInfoComponent>(); if (component == null) { return; } var textDrawName = Traverse.Create(__instance)?.Field <Text>("textDrawName")?.Value; var name = component.info.name; if (Configuration.ListInfoNameTranslatedMap.TryGetValue(component.info.FullPath, out var tmpName)) { component.info.name = tmpName; if (textDrawName != null) { textDrawName.text = tmpName; } return; } var sex = GuessSex(component.info.club, component.info.personality); void Handler(ITranslationResult result) { var newName = Configuration.ListInfoNameTranslatedMap[component.info.FullPath] = result.TranslatedText; component.info.name = newName; if (!result.Succeeded) { return; } if (textDrawName == null) { return; } textDrawName.text = newName; } if (textDrawName != null) { textDrawName.text = name; } PointerEnterCoroutine = TranslationHelper.Instance.StartCoroutine( TranslationHelper.CardNameManager.TranslateCardName(name, new NameScope((CharacterSex)sex), CardNameTranslationManager.CanForceSplitNameString(name), Handler, _ => PointerEnterCoroutine = null)); }
internal static void FileListCtrlAddListPrefix(CustomFileListCtrl __instance, int index, ref string name, string club, string personality, string fullpath) { if (Configuration.ListInfoNameTranslatedMap.TryGetValue(fullpath, out var tmpName)) { name = tmpName; return; } if (TranslationHelper.Instance == null || string.IsNullOrEmpty(club) || TranslationHelper.Instance.CurrentCardLoadTranslationMode < CardLoadTranslationMode.CacheOnly) { return; } var sex = GuessSex(club, personality); void Handler(ITranslationResult result) { var newName = Configuration.ListInfoNameTranslatedMap[fullpath] = result.TranslatedText; var lstFileInfo = Traverse.Create(__instance)?.Field <List <CustomFileInfo> >("lstFileInfo")?.Value; var entry = lstFileInfo?.FirstOrDefault(x => x.index == index); if (entry == null) { return; } entry.name = newName; } TranslationHelper.Instance.StartCoroutine( TranslationHelper.CardNameManager.TranslateCardName(name, new NameScope((CharacterSex)sex), CardNameTranslationManager.CanForceSplitNameString(name), Handler)); }
private static void TranslateDisplayList(CharaList charaList) { if (charaList == null || TranslationHelper.Instance == null || !TranslationHelper.Instance.CurrentCardLoadTranslationEnabled) { return; } var cfiList = Traverse.Create(charaList)?.Field <CharaFileSort>("charaFileSort")?.Value?.cfiList; if (cfiList == null) { return; } var sex = Traverse.Create(charaList)?.Field <int>("sex")?.Value ?? -1; if (sex == -1) { return; } void HandleResult(CharaFileInfo charaFileInfo, ITranslationResult result) { if (!result.Succeeded) { return; } charaFileInfo.name = charaFileInfo.node.text = result.TranslatedText; } var scope = new NameScope((CharacterSex)sex); foreach (var entry in cfiList) { var origName = entry.name; if (TryApplyAlternateTranslation(entry, origName)) { TreeNodeLimiter.EndImmediately(); return; } void Handler(ITranslationResult result) { HandleResult(entry, result); if (TryApplyAlternateTranslation(entry, origName)) { TreeNodeLimiter.EndImmediately(); } TreeNodeLimiter.EndImmediately(); } TranslationHelper.Instance.StartCoroutine(TreeNodeLimiter.Start().AppendCo( TranslationHelper.CardNameManager.TranslateCardName(origName, scope, CardNameTranslationManager.CanForceSplitNameString(origName), Handler))); } }