Exemplo n.º 1
0
        public static List <bool> ListAccessoryVisibility(ChaControl _chaCtrl)
        {
            List <bool> _parts = _chaCtrl.fileStatus.showAccessory.ToList();
            object      _charAdditionalData = MoreAccessories.GetCharAdditionalData(_chaCtrl);

            _parts.AddRange(Traverse.Create(_charAdditionalData).Field("showAccessories").GetValue <List <bool> >() ?? new List <bool>());
            return(_parts);
        }
Exemplo n.º 2
0
        public static List <GameObject> ListObjAccessory(ChaControl _chaCtrl)
        {
            List <GameObject> _parts = _chaCtrl.objAccessory.ToList();

            if (MoreAccessories.Installed)
            {
                _parts.AddRange(MoreAccessories.ListMoreObjAccessory(_chaCtrl));
            }
            return(_parts);
        }
Exemplo n.º 3
0
        public static List <ChaFileAccessory.PartsInfo> ListPartsInfo(ChaControl _chaCtrl, int _coordinateIndex)
        {
            List <ChaFileAccessory.PartsInfo> _partInfo = _chaCtrl.chaFile.coordinate[_coordinateIndex].accessory.parts.ToList();

            if (MoreAccessories.Installed)
            {
                _partInfo.AddRange(MoreAccessories.ListMorePartsInfo(_chaCtrl, _coordinateIndex) ?? new List <ChaFileAccessory.PartsInfo>());
            }
            return(_partInfo);
        }
Exemplo n.º 4
0
        public static bool GetAccessoryVisibility(ChaControl _chaCtrl, int _slotIndex)
        {
            if (_slotIndex < 0)
            {
                return(false);
            }
            if (_slotIndex >= 20 && !MoreAccessories.Installed)
            {
                return(false);
            }

            if (_slotIndex < 20)
            {
                return(_chaCtrl.fileStatus.showAccessory[_slotIndex]);
            }
            object      _charAdditionalData = MoreAccessories.GetCharAdditionalData(_chaCtrl);
            List <bool> _showAccessories    = Traverse.Create(_charAdditionalData).Field("showAccessories").GetValue <List <bool> >();

            return(_showAccessories.RefElementAt <bool>(_slotIndex - 20));
        }
Exemplo n.º 5
0
        public static void SetPartsInfo(ChaControl _chaCtrl, int _coordinateIndex, int _slotIndex, ChaFileAccessory.PartsInfo _partInfo)
        {
            if (_slotIndex < 0)
            {
                return;
            }
            if (_slotIndex >= 20 && !MoreAccessories.Installed)
            {
                return;
            }

            if (_slotIndex < 20)
            {
                _chaCtrl.chaFile.coordinate[_coordinateIndex].accessory.parts[_slotIndex] = _partInfo;
            }
            else
            {
                MoreAccessories.CheckAndPadPartInfo(_chaCtrl, _coordinateIndex, _slotIndex - 20);
                MoreAccessories.ListMorePartsInfo(_chaCtrl, _coordinateIndex)[_slotIndex - 20] = _partInfo;
            }
        }
Exemplo n.º 6
0
        public static ChaFileAccessory.PartsInfo GetPartsInfo(ChaControl _chaCtrl, int _coordinateIndex, int _slotIndex)
        {
            if (_slotIndex < 0)
            {
                return(null);
            }
            if (_slotIndex >= 20 && !MoreAccessories.Installed)
            {
                return(null);
            }

            if (_slotIndex < 20)
            {
                if (_chaCtrl.chaFile.coordinate.ElementAtOrDefault(_coordinateIndex) == null)
                {
                    return(null);
                }
                return(_chaCtrl.chaFile.coordinate[_coordinateIndex].accessory.parts.ElementAtOrDefault(_slotIndex));
            }
            return(MoreAccessories.ListMorePartsInfo(_chaCtrl, _coordinateIndex).ElementAtOrDefault(_slotIndex - 20));
        }
Exemplo n.º 7
0
        private void Start()
        {
            Game.HasDarkness = typeof(ChaControl).GetProperties(AccessTools.all).Any(x => x.Name == "exType");

            _hookInstance = Harmony.CreateAndPatchAll(typeof(Hooks));

            Chara.Init();
            KKAPI.Init();
            MoreAccessories.Init();
            MaterialEditor.Init();

            if (CharaStudio.Running)
            {
                CharaStudio.OnStudioLoaded += CharaStudio.RegisterControls;
                SceneManager.sceneLoaded   += CharaStudio.SceneLoaded;
            }
            else
            {
                SceneManager.sceneLoaded += SceneLoaded;
                CharaMaker.Init();
                CharaHscene.Init();
            }
        }
Exemplo n.º 8
0
        internal static void Init()
        {
            OnMakerStartLoading += (_sender, _args) =>
            {
                Core.DebugLog($"[OnMakerStartLoading]");
                CurrentAccssoryIndex = -1;
                Inside = true;
                KKAPI.Hooks.OnMakerStartLoadingPatch();

                _hookInstance = Harmony.CreateAndPatchAll(typeof(Hooks));

                if (MoreAccessories.Installed)
                {
                    _hookInstance.Patch(MoreAccessories.Instance.GetType().GetMethod("UpdateMakerUI", AccessTools.all), postfix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MoreAccessories_UpdateMakerUI_Postfix)));
                }
            };

            OnMakerBaseLoaded += (_sender, _args) =>
            {
                Core.DebugLog($"[OnMakerBaseLoaded]");
                if (MoreAccessories.Installed)
                {
                    MoreAccessories.OnMakerBaseLoaded();
                }
            };

            OnMakerFinishedLoading += (_sender, _args) =>
            {
                Core.DebugLog($"[OnMakerFinishedLoading]");
                Loaded = true;

                _hookInstance.Patch(typeof(CvsAccessory).GetMethod("UpdateCustomUI", AccessTools.all), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.CvsAccessory_UpdateCustomUI_Prefix)));

                CvsScrollable = GameObject.Find("tglSlot01/Slot01Top/tglSlot01ScrollView") != null;

                int _onCustomSelectListClickCount = OnCustomSelectListClick?.GetInvocationList()?.Length ?? 0;
                if (_onCustomSelectListClickCount > 0)
                {
                    Core.DebugLog($"[MakerFinishedLoading][(OnCustomSelectListClick: {_onCustomSelectListClickCount}]");
                    _hookInstance.PatchAll(typeof(HooksCustomSelectListCtrl));
                }

                int _onPointerEnterCount = OnPointerEnter?.GetInvocationList()?.Length ?? 0;
                int _onPointerExitCount  = OnPointerExit?.GetInvocationList()?.Length ?? 0;
                if (_onPointerEnterCount + _onPointerExitCount > 0)
                {
                    Core.DebugLog($"[MakerFinishedLoading][(OnPointerEnter + OnPointerExit: {_onPointerEnterCount + _onPointerExitCount}]");
                    _hookInstance.PatchAll(typeof(HooksSelectable));
                }

                CvsNavMenuInit(Singleton <CustomChangeMainMenu> .Instance);
                if (MoreAccessories.Installed)
                {
                    MoreAccessories.OnMakerFinishedLoading();
                }
            };

            OnMakerExiting += (_sender, _args) =>
            {
                Core.DebugLog($"[OnMakerExiting]");

                CurrentAccssoryIndex = -1;
                Inside = false;
                Loaded = false;

                _hookInstance.UnpatchAll(_hookInstance.Id);
                _hookInstance = null;
            };

            OnSelectedMakerSlotChanged += (_sender, _args) =>
            {
                Core.DebugLog($"[OnSelectedMakerSlotChanged][{_args.OldSlotIndex}][{_args.NewSlotIndex}]");
            };

            OnSlotAdded += (_sender, _args) =>
            {
                Core.DebugLog($"[OnSlotAdded][{_args.SlotIndex}][{_args.SlotTemplate.name}]");
                _args.SlotTemplate.GetComponent <CvsNavSideMenuEventHandler>().SlotIndex = _args.SlotIndex;
            };

            OnCvsNavMenuClick += (_sender, _args) =>
            {
                Core.DebugLog($"[OnCvsNavMenuClick][{_args.TopIndex}][{_args.SideToggle.name}][{_args.Changed}]");
            };

            OnClothesCopy += (_sender, _args) =>
            {
                Core.DebugLog($"[OnClothesCopy][{_args.SourceCoordinateIndex}][{_args.DestinationCoordinateIndex}][{_args.DestinationSlotIndex}]");
            };

            if (MoreAccessories.Installed)
            {
                EventInfo _event = MoreAccessories.Instance.GetType().GetEvent("onCharaMakerSlotAdded");
                _event.AddEventHandler(MoreAccessories.Instance, new Action <int, Transform>((_slotIndex, _transform) => OnSlotAdded(null, new SlotAddedEventArgs(_slotIndex, _transform))));
                //(MoreAccessories.Instance as MoreAccessoriesKOI.MoreAccessories).onCharaMakerSlotAdded += new Action<int, Transform>((_slotIndex, _transform) => OnSlotAdded(null, new SlotAddedEventArgs(_slotIndex, _transform)));
            }
        }