示例#1
0
 private static void CustomFileListCtrl_Start(CustomFileListCtrl __instance)
 {
     if (!DefaultAdditionalInfo.Value)
     {
         __instance.tglAddInfo.isOn = DefaultAdditionalInfo.Value;
     }
 }
示例#2
0
        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));
            }
        }
示例#3
0
        /*
         * [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));
            }
        }
示例#4
0
        public static void ChangeItemPostfix(CustomFileListCtrl __instance, GameObject obj)
        {
            try
            {
                if (!TranslationHelper.Instance.CurrentCardLoadTranslationEnabled)
                {
                    return;
                }
                if (obj == null)
                {
                    return;
                }
                var component = obj.GetComponent <CustomFileInfoComponent>();
                if (component == null)
                {
                    return;
                }

                var name = component.info.name;

                var selectDrawName = Traverse.Create(__instance)?.Field("selectDrawName");
                if (Configuration.ListInfoNameTranslatedMap.TryGetValue(component.info.FullPath, out var tmpName))
                {
                    component.info.name = tmpName;
                    if (selectDrawName != null && selectDrawName.FieldExists())
                    {
                        selectDrawName.SetValue(tmpName);
                    }
                    return;
                }


                var sex = Configuration.GuessSex(component.info.club, component.info.personality);

                void Handler(ITranslationResult result)
                {
                    var newName = result.TranslatedText;

                    component.info.name = Configuration.ListInfoNameTranslatedMap[component.info.FullPath] = newName;
                    if (!result.Succeeded)
                    {
                        return;
                    }
                    if (selectDrawName != null && selectDrawName.FieldExists())
                    {
                        selectDrawName.SetValue(newName);
                    }
                }

                TranslationHelper.Instance.StartCoroutine(
                    TranslationHelper.CardNameManager.TranslateFullName(
                        name, new NameScope((CharacterSex)sex), Handler));
            }

            catch (Exception err)
            {
                Logger.LogException(err, __instance, nameof(ChangeItemPostfix));
            }
        }
示例#5
0
 void Start()
 {
     customCharaFile = FindObjectOfType <CustomCharaFile>();
     listCtrl        = Traverse.Create(customCharaFile).Field("listCtrl").GetValue <CustomFileListCtrl>();
     BepInEx.Config.ReloadConfig();
     folderName = BepInEx.Config.GetEntry("FolderName", "", CardOrganizer.configName);
     StartCoroutine(SetListFolderDelayed());
 }
示例#6
0
        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));
        }
示例#7
0
        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));
            }
        }
示例#8
0
        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));
        }
示例#9
0
        public static bool InitializePrehook(CustomCharaFile __instance)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();


            int          modeSex      = Singleton <CustomBase> .Instance.modeSex;
            FolderAssist folderAssist = new FolderAssist();

            string[] searchPattern = new string[]
            {
                "*.png"
            };
            string folder = UserData.Path + ((modeSex != 0) ? "chara/female/" : "chara/male/");

            folderAssist.CreateFolderInfoEx(folder, searchPattern, true);

            CustomFileListCtrl listCtrl = (CustomFileListCtrl)listCtrl_info.GetValue(__instance);

            listCtrl.ClearList();
            int fileCount = folderAssist.GetFileCount();
            int num       = 0;

            for (int i = 0; i < fileCount; i++)
            {
                ChaFileControl chaFileControl = new ChaFileControl();
                if (!chaFileControl.LoadCharaFile(folderAssist.lstFile[i].FullPath, 255, false, true))
                {
                    int lastErrorCode = chaFileControl.GetLastErrorCode();
                }
                else
                {
                    string club        = string.Empty;
                    string personality = string.Empty;
                    if (modeSex != 0)
                    {
                        VoiceInfo.Param param;
                        if (!Singleton <Voice> .Instance.voiceInfoDic.TryGetValue(chaFileControl.parameter.personality, out param))
                        {
                            personality = "不明";
                        }
                        else
                        {
                            personality = param.Personality;
                        }
                        ClubInfo.Param param2;
                        if (!Game.ClubInfos.TryGetValue((int)chaFileControl.parameter.clubActivities, out param2))
                        {
                            club = "不明";
                        }
                        else
                        {
                            club = param2.Name;
                        }
                    }
                    else
                    {
                        listCtrl.DisableAddInfo();
                    }
                    listCtrl.AddList(num, chaFileControl.parameter.fullname, club, personality, folderAssist.lstFile[i].FullPath, folderAssist.lstFile[i].FileName, folderAssist.lstFile[i].time, false);
                    num++;
                }
            }
            stopwatch.Stop();
            Logger.Log(LogLevel.Error, $"Cards load stage 1: [{fileCount}] {stopwatch.Elapsed}");

            stopwatch.Reset();
            stopwatch.Start();
            listCtrl.Create(__instance.OnChangeSelect);
            Logger.Log(LogLevel.Error, $"Cards load stage 2: {stopwatch.Elapsed}");
            stopwatch.Stop();

            return(false);
        }
示例#10
0
        internal static void FileListCtrlAddListPrefix(CustomFileListCtrl __instance, ICharaFileInfo info)
        {
            if (!TranslationHelper.Instance.CurrentCardLoadTranslationEnabled)
            {
                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);

                void Handler(ITranslationResult result)
                {
                    if (__instance == null)
                    {
                        return;
                    }

                    var newName = ProcessTranslationResult(scope, origName, info.FullPath, result);

                    if (TranslationHelper.NameStringComparer.Equals(origName, newName))
                    {
                        return;
                    }

                    var lstFileInfo = __instance.lstFileInfo;

                    var entry = lstFileInfo?.FirstOrDefault(x =>
                    {
                        int index;
                        try
                        {
                            index = x.index;
                        }
                        catch
                        {
                            index = -1;
                        }

                        if (index == -1)
                        {
                            index = Traverse.Create(x).Property <int>("index")?.Value ?? -1;
                        }

                        return(info.Index == index);
                    });

                    if (entry == null)
                    {
                        return;
                    }
                    entry.name = newName;
                }

                TranslationHelper.Instance.StartCoroutine(
                    TranslationHelper.TranslateFileInfo(info, Handler));
            }
            catch (Exception err)
            {
                Logger.LogException(err, __instance, nameof(FileListCtrlAddListPrefix));
            }
            finally
            {
                Logger.DebugLogDebug($"FileListCtrlAddListPrefix: {Time.realtimeSinceStartup - start:000.0000000000}");
            }
        }