/// <summary>
        /// Refresh the list
        /// </summary>
        private static void RefreshList()
        {
            try
            {
                //Turn off resolving to prevent spam since modded stuff isn't relevent for making this list.
                Sideloader.AutoResolver.Hooks.IsResolving = false;
                switch (EventType)
                {
                case CardEventType.CharaMakerCharacter:
                    typeof(CustomCharaFile).GetMethod("Initialize", AccessTools.all)?.Invoke(CustomCharaFileInstance, null);
                    break;

                case CardEventType.CharaMakerCoordinate:
                    typeof(CustomCoordinateFile).GetMethod("Initialize", AccessTools.all)?.Invoke(CustomCoordinateFileInstance, null);
                    break;

                case CardEventType.StudioFemale:
                    StudioFemaleListInstance.InitCharaList(true);
                    break;

                case CardEventType.StudioMale:
                    StudioMaleListInstance.InitCharaList(true);
                    break;

                case CardEventType.StudioCoordinate:
                    var sex = Traverse.Create(StudioCoordinateListInstance).Field("sex").GetValue();
                    typeof(Studio.MPCharCtrl).GetNestedType("CostumeInfo", BindingFlags.NonPublic).GetMethod("InitList", AccessTools.all)?.Invoke(StudioCoordinateListInstance, new object[] { 100 });
                    Traverse.Create(StudioCoordinateListInstance).Field("sex").SetValue(sex);
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error | LogLevel.Message, "An error occured attempting to refresh the list.");
                Logger.Log(LogLevel.Error, $"KK_ReloadCharaListOnChange error: {ex.Message}");
                Logger.Log(LogLevel.Error, ex);
            }
            finally
            {
                Sideloader.AutoResolver.Hooks.IsResolving = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Refresh the list
        /// </summary>
        private static void RefreshList()
        {
            try
            {
                //Turn off resolving to prevent spam since modded stuff isn't relevant for making this list.
                ExtendedSave.LoadEventsEnabled = false;
                switch (EventType)
                {
                case CardEventType.CharaMakerCharacter:
                    var initializeChara = typeof(CustomCharaFile).GetMethod("Initialize", AccessTools.all);
                    if (initializeChara != null)
                    {
                        if (initializeChara.GetParameters().Length == 0)
                        {
                            initializeChara.Invoke(FindObjectOfType <CustomCharaFile>(), null);
                        }
                        else
                        {
                            initializeChara.Invoke(FindObjectOfType <CustomCharaFile>(), new object[] { true, false });
                        }
                    }
                    break;

                case CardEventType.CharaMakerCoordinate:
                    var initializeCoordinate = typeof(CustomCoordinateFile).GetMethod("Initialize", AccessTools.all);
                    if (initializeCoordinate != null)
                    {
                        if (initializeCoordinate.GetParameters().Length == 0)
                        {
                            initializeCoordinate.Invoke(FindObjectOfType <CustomCoordinateFile>(), null);
                        }
                        else
                        {
                            initializeCoordinate.Invoke(FindObjectOfType <CustomCoordinateFile>(), new object[] { true, false });
                        }
                    }
                    break;

                case CardEventType.StudioFemale:
                    StudioFemaleListInstance.InitCharaList(true);
                    break;

                case CardEventType.StudioMale:
                    StudioMaleListInstance.InitCharaList(true);
                    break;

                case CardEventType.StudioCoordinate:
                    var sex = Traverse.Create(StudioCoordinateListInstance).Field("sex").GetValue();
                    typeof(Studio.MPCharCtrl).GetNestedType("CostumeInfo", BindingFlags.NonPublic).GetMethod("InitList", AccessTools.all)?.Invoke(StudioCoordinateListInstance, new object[] { 100 });
                    Traverse.Create(StudioCoordinateListInstance).Field("sex").SetValue(sex);
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error | LogLevel.Message, "An error occured attempting to refresh the list.");
                Logger.Log(LogLevel.Error, $"KK_ReloadCharaListOnChange error: {ex.Message}");
                Logger.Log(LogLevel.Error, ex);
            }
            finally
            {
                ExtendedSave.LoadEventsEnabled = true;
            }
        }