public static void OnPointerEnterPostfix(CustomFileListCtrl __instance, GameObject obj) { try { if (!TranslationHelper.Instance.CurrentCardLoadTranslationEnabled) { return; } if (obj == null) { return; } var component = obj.GetComponent <CustomFileInfoComponent>(); if (component == null) { return; } var wrapper = CharaFileInfoWrapper.CreateWrapper(component.info); Translation.Hooks.OnPointerEnterPostfix(__instance, wrapper); } catch (Exception err) { Logger.LogException(err, __instance, nameof(OnPointerEnterPostfix)); } }
/* * [HarmonyPostfix] * [HarmonyPatch(typeof(CustomFileListCtrl), nameof(CustomFileListCtrl.OnPointerEnter))] */ public static void OnPointerEnterPostfix(CustomFileListCtrl __instance, MonoBehaviour fic) { try { if (!TranslationHelper.Instance.CurrentCardLoadTranslationEnabled) { return; } if (fic == null) { return; } var info = Traverse.Create(fic).Property("info").GetValue(); if (info == null) { return; } var infoType = Traverse.Create(fic).Property("info").GetValueType(); Translation.Hooks.OnPointerEnterPostfix(__instance, CharaFileInfoWrapper.CreateWrapper(infoType, info)); } catch (Exception err) { Logger.LogException(err, fic, nameof(OnPointerEnterPostfix)); } }
internal static void TranslateFileInfo(CustomCharaFileInfo info, params TranslationResultHandler[] handlers) { if (info == null || !TranslationHelper.Instance.CurrentCardLoadTranslationEnabled) { return; } var wrapper = CharaFileInfoWrapper.CreateWrapper(info); TranslationHelper.Instance.StartCoroutine( TranslationHelper.Instance.FileInfoTranslationManager.TranslateFileInfo(wrapper, handlers)); }
internal static void PartyFileListCtrlAddListPrefix(CustomFileListCtrl __instance, CustomFileInfo info) { try { Translation.Hooks.FileListCtrlAddListPrefix(__instance, CharaFileInfoWrapper.CreateWrapper(info)); } catch (Exception err) { Logger.LogException(err, __instance, nameof(PartyFileListCtrlAddListPrefix)); } }
public static void ClassRoomFileListCtrlCreatePostfix(ClassRoomFileListCtrl __instance) { void OnEnter(CustomFileInfo info) { var wrapper = CharaFileInfoWrapper.CreateWrapper(info); Translation.Hooks.OnPointerEnterPostfix(__instance, wrapper); } void OnExit(CustomFileInfo info) { Translation.Hooks.OnPointerExitPrefix(); } __instance.OnPointerEnter += OnEnter; __instance.OnPointerExit += OnExit; }
internal static void FileListCtrlAddListPrefix(MonoBehaviour fileListCtrl, ICharaFileInfo info) { if (!TranslationHelper.Instance.CurrentCardLoadTranslationEnabled || fileListCtrl == null) { return; } // ReSharper disable once RedundantAssignment - used in DEBUG var start = Time.realtimeSinceStartup; try { var origName = info.Name; var sex = Configuration.GuessSex(info.Club, info.Personality); var scope = new NameScope((CharacterSex)sex); var path = info.FullPath; void Handler(ITranslationResult result) { var newName = ProcessTranslationResult(scope, origName, path, result); if (fileListCtrl == null) { return; } if (TranslationHelper.NameStringComparer.Equals(origName, newName)) { return; } var lstFileInfo = Traverse.Create(fileListCtrl)?.Field <List <CustomFileInfo> >("lstFileInfo")?.Value; if (lstFileInfo == null) { return; } Logger.DebugLogDebug($"{nameof(FileListCtrlAddListPrefix)}.{nameof(Handler)}: {lstFileInfo}"); var entry = lstFileInfo?.FirstOrDefault(x => { int index; try { index = CharaFileInfoWrapper.CreateWrapper(x).Index; } catch { index = -1; } return(info.Index == index); }); if (entry == null) { return; } entry.SafeNameUpdate(path, origName, newName); } //TranslationHelper.Instance.StartCoroutine( fileListCtrl.StartCoroutine(TranslationHelper.TranslateFileInfo(info, Handler)); } catch (Exception err) { Logger.LogException(err, fileListCtrl, nameof(FileListCtrlAddListPrefix)); } finally { Logger.DebugLogDebug($"FileListCtrlAddListPrefix: {Time.realtimeSinceStartup - start:000.0000000000}"); } }