示例#1
0
 /// <summary>
 /// Add a control to the accessory selection and settings window.
 /// For editable controls that depend on the selected accessory use <see cref="AddEditableAccessoryWindowControl{T,TVal}"/>.
 /// </summary>
 public static T AddAccessoryWindowControl <T>(T control) where T : BaseGuiEntry
 {
     if (control == null)
     {
         throw new ArgumentNullException(nameof(control));
     }
     control.ThrowIfDisposed(nameof(control));
     MakerInterfaceCreator.AddAccessoryWindowControl(control);
     return(control);
 }
示例#2
0
 /// <summary>
 /// Add a control to the accessory selection and settings window. The control is wrapped to properly respond to changes in selected accessory slot (has unique values for each slot).
 /// </summary>
 public static AccessoryControlWrapper <T, TVal> AddEditableAccessoryWindowControl <T, TVal>(T control) where T : BaseEditableGuiEntry <TVal>
 {
     if (control == null)
     {
         throw new ArgumentNullException(nameof(control));
     }
     control.ThrowIfDisposed(nameof(control));
     MakerInterfaceCreator.AddAccessoryWindowControl(control);
     return(new AccessoryControlWrapper <T, TVal>(control));
 }
示例#3
0
        private static void OnCreateCustomControls()
        {
            MakerInterfaceCreator.CreateCustomControls();

#if KK
            // Fix some plugins failing to update interface and losing state
            if (IsInsideClassMaker())
            {
                OnChaFileLoaded(new ChaFileLoadedEventArgs(null, (byte)GetMakerSex(), true, true, true, true, true, GetCharacterControl().chaFile, LastLoadedChaFile));
                OnReloadInterface(new CharaReloadEventArgs(GetCharacterControl()));
            }
#endif
        }
示例#4
0
            public static void CvsSelectWindowStart(CvsSelectWindow __instance)
            {
                if (!_makerStarting)
                {
                    CoordinateButtonClicked = 3;
                    InsideMaker             = true;
                    _makerStarting          = true;
                    OnRegisterCustomSubCategories();
                    KoikatuAPI.Instance.StartCoroutine(OnMakerLoadingCo());
                }

                // Have to add missing subcategories now, before UI_ToggleGroupCtrl.Start runs
                MakerInterfaceCreator.AddMissingSubCategories(__instance);
            }
示例#5
0
        internal static void AutomaticControlVisibility()
        {
            var slot = SelectedMakerAccSlot;

            if (slot < 0)
            {
                return;
            }
            var partsinfo = GetPartsInfo(slot);

            var accessoryExists = partsinfo.type != 120;

            MakerInterfaceCreator.AutomaticAccessoryControlVisibility(accessoryExists);
        }
 private static void MakerAPI_InsideMakerChanged(object sender, EventArgs e)
 {
     if (MakerAPI.InsideMaker)
     {
         var ace = MakerInterfaceCreator.GetAccessoryCustomEdit();
         _accCustomEdit         = Traverse.Create(ace);
         _accessoryWindowObject = ((AccessoryCustomEdit)ace).gameObject;
         SelectedMakerAccSlot   = 0;
     }
     else
     {
         _accessoryWindowObject = null;
         _accCustomEdit         = null;
         SelectedMakerAccSlot   = -1;
     }
 }
示例#7
0
            public static void HBeforeToggleGroupStart(UI_ToggleGroupCtrl __instance)
            {
                var categoryTransfrom = __instance.transform;

                if (categoryTransfrom?.parent != null && categoryTransfrom.parent.name == "CvsMenuTree")
                {
                    if (!_makerStarting)
                    {
                        InsideMaker    = true;
                        _makerStarting = true;
                        OnRegisterCustomSubCategories();
                        KoikatuAPI.Instance.StartCoroutine(OnMakerLoadingCo());
                    }

                    // Have to add missing subcategories now, before UI_ToggleGroupCtrl.Start runs
                    MakerInterfaceCreator.AddMissingSubCategories(__instance);
                }
            }
示例#8
0
            public static void EditModeSetup(EditMode __instance)
            {
                var initRequired = currenEditMode != __instance;

                currenEditMode = __instance;
                InsideMaker    = true;

                if (!initRequired)
                {
                    return;
                }

                KoikatuAPI.Logger.LogDebug("Entering character maker");

                void OnMakerExit()
                {
                    OnMakerExiting();
                    InsideMaker = false;
                    InternalLastLoadedChaFile = null;
                }

                __instance.OnDestroyAsObservable().Subscribe(unit => OnMakerExit());
                //var categoryTransfrom = __instance.transform;

                KoikatuAPI.Instance.StartCoroutine(OnMakerLoadingCo());

                OnRegisterCustomSubCategories();

                MakerInterfaceCreator.AddMissingSubCategories();

                //if (categoryTransfrom?.parent != null && categoryTransfrom.parent.name == "CvsMenuTree")
                //{
                //    if (!_makerStarting)
                //    {
                //        InsideMaker = true;
                //        _makerStarting = true;
                //        OnRegisterCustomSubCategories();
                //        KoikatuAPI.Instance.StartCoroutine(OnMakerLoadingCo());
                //    }
                //
                //    // Have to add missing subcategories now, before UI_ToggleGroupCtrl.Start runs
                //    MakerInterfaceCreator.AddMissingSubCategories(__instance);
                //}
            }
示例#9
0
        private static void OnMakerExiting()
        {
            if (MakerExiting != null)
            {
                foreach (var handler in MakerExiting.GetInvocationList())
                {
                    try
                    {
                        ((EventHandler)handler).Invoke(KoikatuAPI.Instance, EventArgs.Empty);
                    }
                    catch (Exception e)
                    {
                        KoikatuAPI.Logger.LogError(e);
                    }
                }
            }

            MakerInterfaceCreator.RemoveCustomControls();
        }
示例#10
0
        private static void OnMakerBaseLoaded()
        {
            if (MakerBaseLoaded != null)
            {
                var args = new RegisterCustomControlsEvent();
                foreach (var handler in MakerBaseLoaded.GetInvocationList())
                {
                    try
                    {
                        ((EventHandler <RegisterCustomControlsEvent>)handler).Invoke(KoikatuAPI.Instance, args);
                    }
                    catch (Exception e)
                    {
                        KoikatuAPI.Logger.LogError(e);
                    }
                }
            }

            MakerInterfaceCreator.InitializeGuiEntries();
        }
示例#11
0
        private static void OnRegisterCustomSubCategories()
        {
            MakerInterfaceCreator.InitializeMaker();

            if (RegisterCustomSubCategories != null)
            {
                var args = new RegisterSubCategoriesEvent();
                foreach (var handler in RegisterCustomSubCategories.GetInvocationList())
                {
                    try
                    {
                        ((EventHandler <RegisterSubCategoriesEvent>)handler).Invoke(KoikatuAPI.Instance, args);
                    }
                    catch (Exception e)
                    {
                        KoikatuAPI.Logger.LogError(e);
                    }
                }
            }
        }
示例#12
0
        private static void OnMakerAccSlotAdded(object source, int newSlotIndex, Transform newSlotTransform)
        {
            if (KoikatuAPI.EnableDebugLogging)
            {
                KoikatuAPI.Logger.LogMessage("MakerAccSlotAdded - slot:" + newSlotIndex);
            }

            MakerInterfaceCreator.OnMakerAccSlotAdded(newSlotTransform);

            if (MakerAccSlotAdded == null)
            {
                return;
            }
            try
            {
                MakerAccSlotAdded(source, new AccessorySlotEventArgs(newSlotIndex));
            }
            catch (Exception ex)
            {
                KoikatuAPI.Logger.LogError("Subscription to SelectedMakerSlot crashed: " + ex);
            }
        }