Example #1
0
        internal static void ProcessQueue(List <QueueItem> Queue)
        {
            ChaControl chaCtrl       = MakerAPI.GetCharacterControl();
            object     MEpluginCtrl  = MaterialEditor.GetController(chaCtrl);
            object     HACpluginCtrl = HairAccessoryCustomizer.GetController(chaCtrl);
            object     ASSpluginCtrl = AccStateSync.GetController(chaCtrl);
            object     MRpluginCtrl  = MaterialRouter.GetController(chaCtrl);
            object     DBEpluginCtrl = DynamicBoneEditor.GetController(chaCtrl);
            object     APKpluginCtrl = AAAPK.GetController(chaCtrl);

            HairAccessoryCustomizer.HairAccessoryInfos = new Dictionary <int, HairAccessoryCustomizer.HairAccessoryInfo>();
            int Coordinate = chaCtrl.fileStatus.coordinateType;

            foreach (QueueItem item in Queue)
            {
                Logger.LogDebug($"{item.srcSlot} -> {item.dstSlot}");
                HairAccessoryCustomizer.StoreSetting(chaCtrl, HACpluginCtrl, item.srcSlot);                 // need to do this before move PartsInfo
                MoreAccessories.ModifyPartsInfo(chaCtrl, Coordinate, item.srcSlot, item.dstSlot);
                MaterialEditor.ModifySetting(MEpluginCtrl, Coordinate, item.srcSlot, item.dstSlot);
                AccStateSync.ModifySetting(ASSpluginCtrl, Coordinate, item.srcSlot, item.dstSlot);
                MaterialRouter.ModifySetting(MRpluginCtrl, Coordinate, item.srcSlot, item.dstSlot);
                DynamicBoneEditor.ModifySetting(DBEpluginCtrl, Coordinate, item.srcSlot, item.dstSlot);
                AAAPK.ModifySetting(APKpluginCtrl, Coordinate, item.srcSlot, item.dstSlot);
            }

            ChaCustom.CustomBase.Instance.chaCtrl.ChangeCoordinateTypeAndReload(false);
            ChaCustom.CustomBase.Instance.updateCustomUI = true;

            foreach (QueueItem item in Queue)
            {
                HairAccessoryCustomizer.ModifySetting(HACpluginCtrl, item.srcSlot, item.dstSlot);                 // need to do this after updateCustomUI
            }
        }
Example #2
0
        internal void CatTrimMoreacc(RegisterSubCategoriesEvent ev, MakerCategory category)
        {
            ev.AddControl(new MakerText("Trim down unused MoreAccessories slots", category, this));

            MakerButton btnMoreAccApply = ev.AddControl(new MakerButton("Go", category, this));

            btnMoreAccApply.OnClick.AddListener(delegate
            {
                MoreAccessories.TrimUnusedSlots();
            });
        }
Example #3
0
            internal static IEnumerator StatusPanelUpdateCoroutine()
            {
                yield return(JetPack.Toolbox.WaitForEndOfFrame);

                yield return(JetPack.Toolbox.WaitForEndOfFrame);

                AccStateSyncController _pluginCtrl = GetController(_curOCIChar);

                if (_pluginCtrl != null && _pluginCtrl.TriggerEnabled)
                {
                    if (JetPack.CharaStudio.RefreshCharaStatePanel())
                    {
                        MoreAccessories.UpdateUI();
                    }
                }
            }
Example #4
0
        private void Start()
        {
            Instance = this;
            Logger   = base.Logger;

            IsDark = typeof(ChaControl).GetProperties(AccessTools.all).Any(x => x.Name == "exType");

            MoreAccessories.InitSupport();
            MaterialEditor.InitSupport();
            HairAccessoryCustomizer.InitSupport();
            AccStateSync.InitSupport();
            MaterialRouter.InitSupport();
            DynamicBoneEditor.InitSupport();
            AAAPK.InitSupport();

            MakerAPI.RegisterCustomSubCategories += (sender, ev) =>
            {
                HooksInstance = Harmony.CreateAndPatchAll(typeof(Hooks));
                MaterialEditor.HookInit();

                MakerCategory category = new MakerCategory("05_ParameterTop", "tglMovUrAcc", MakerConstants.Parameter.Attribute.Position + 1, "MovUrAcc");

                CatBatchTransfer(ev, category);
                ev.AddControl(new MakerSeparator(category, this));

                CatBatchRemove(ev, category);
                ev.AddControl(new MakerSeparator(category, this));

                CatParentSort(ev, category);
                ev.AddControl(new MakerSeparator(category, this));

                CatPacking(ev, category);
                ev.AddControl(new MakerSeparator(category, this));

                CatTrimMoreacc(ev, category);

                ev.AddSubCategory(category);

                btnLock = false;
            };

            MakerAPI.MakerExiting += (sender, ev) =>
            {
                HooksInstance.UnpatchAll(HooksInstance.Id);
                HooksInstance = null;
            };
        }
Example #5
0
        private void Start()
        {
            _logger   = base.Logger;
            _instance = this;

            InitConfig();
            InitConstants();

            MoreAccessories.Init();

            CharacterApi.RegisterExtraBehaviour <AccStateSyncController>(GUID);

            Harmony.CreateAndPatchAll(typeof(Hooks));
#if KK
            if (Application.dataPath.EndsWith("CharaStudio_Data"))
            {
                StudioAPI.StudioLoadedChanged += (_sender, _args) => CharaStudio.RegisterControls();
            }
            else
            {
                {
                    BaseUnityPlugin _instance = JetPack.Toolbox.GetPluginInstance("madevil.kk.MovUrAcc");
                    if (_instance != null && !JetPack.Toolbox.PluginVersionCompare(_instance, "1.7.0.0"))
                    {
                        _logger.LogError($"MovUrAcc 1.7+ is required to work properly, version {_instance.Info.Metadata.Version} detected");
                    }
                }
                {
                    BaseUnityPlugin _instance = JetPack.Toolbox.GetPluginInstance("madevil.kk.ca");
                    if (_instance != null && !JetPack.Toolbox.PluginVersionCompare(_instance, "1.2.0.0"))
                    {
                        _logger.LogError($"Character Accessory 1.2+ is required to work properly, version {_instance.Info.Metadata.Version} detected");
                    }
                }
                CharaHscene.RegisterEvents();
                CharaMaker.RegisterControls();
            }
#elif KKS
            CharaMaker.RegisterControls();
#endif
        }
Example #6
0
        internal static void ActPacking()
        {
            if (btnLock)
            {
                return;
            }
            btnLock = true;

            List <QueueItem> Queue = new List <QueueItem>();
            int nowAccCount        = MoreAccessories.PluginInstance._charaMakerData.nowAccessories.Count;
            int dstSlot            = 0;

            for (int srcSlot = 0; srcSlot < (20 + nowAccCount); srcSlot++)
            {
                ChaFileAccessory.PartsInfo part = MoreAccessories.GetPartsInfo(srcSlot);
                if (part.type == 120)
                {
                    continue;
                }

                if (srcSlot != dstSlot)
                {
                    Queue.Add(new QueueItem(srcSlot, dstSlot));
                }

                dstSlot++;
            }

            if (Queue.Count == 0)
            {
                Logger.LogMessage("Nothing to do");
                btnLock = false;
                return;
            }

            ProcessQueue(Queue);

            btnLock = false;
            ChaCustom.CustomBase.Instance.chaCtrl.ChangeCoordinateTypeAndReload(false);
        }
Example #7
0
        internal static void ActParentSort()
        {
            if (btnLock)
            {
                return;
            }
            btnLock = true;

            int nowAccCount = MoreAccessories.PluginInstance._charaMakerData.nowAccessories.Count;
            int dstSlot     = -1;

            Dictionary <int, string> parts = new Dictionary <int, string>();

            for (int i = 0; i < (20 + nowAccCount); i++)
            {
                ChaFileAccessory.PartsInfo part = MoreAccessories.GetPartsInfo(i);
                if (part.type == 120)
                {
                    continue;
                }

                parts[i] = part.parentKey;
                dstSlot  = i;
            }

            if (parts.Count == 0)
            {
                Logger.LogMessage("Nothing to do");
                btnLock = false;
                return;
            }

            dstSlot++;

            HashSet <string> parentsUsed    = new HashSet <string>(parts.OrderBy(x => x.Value).Select(x => x.Value));
            HashSet <string> parentsDefined = new HashSet <string>(Enum.GetNames(typeof(ChaAccessoryDefine.AccessoryParentKey)).Where(x => x.StartsWith("a_n_")));

            parentsDefined.IntersectWith(parentsUsed);
            List <string> parentSorted = parentsDefined.ToList();

            parentSorted.AddRange(parentsUsed.Where(x => !x.StartsWith("a_n_")));

            List <QueueItem> Queue   = new List <QueueItem>();
            bool             changed = false;
            int max = -1;

            foreach (string parent in parentSorted)
            {
                foreach (KeyValuePair <int, string> part in parts)
                {
                    if (part.Value != parent)
                    {
                        continue;
                    }

                    if (max > part.Key)
                    {
                        changed = true;
                    }
                    max = part.Key;

                    Queue.Add(new QueueItem(part.Key, dstSlot));
                    dstSlot++;
                }
            }

            if (!changed)
            {
                Logger.LogMessage("Same order, nothing to do");
                btnLock = false;
                return;
            }

            if (dstSlot - 19 > nowAccCount)
            {
                for (int i = 1; i < (dstSlot - 19 - nowAccCount); i++)
                {
                    Traverse.Create(MoreAccessories.PluginInstance).Method("AddSlot").GetValue();
                }
            }

            ProcessQueue(Queue);

            btnLock = false;
            ChaCustom.CustomBase.Instance.chaCtrl.ChangeCoordinateTypeAndReload(false);
        }
Example #8
0
            internal static void RegisterControls()
            {
                _cfgCharaMakerPreview.SettingChanged += (sender, args) =>
                {
                    if (JetPack.CharaMaker.Loaded)
                    {
                        if (_sidebarTogglePreview.Value != _cfgCharaMakerPreview.Value)
                        {
                            _sidebarTogglePreview.Value = _cfgCharaMakerPreview.Value;
                        }
                        if (_sidebarTogglePreview.Value)
                        {
                            _pluginCtrl.RefreshPreview("ToggleForcePreview");
                        }

                        /*
                         * else
                         * {
                         *      _pluginCtrl.SetAccessoryStateCategory(0, _imgTglCol01.isOn);
                         *      _pluginCtrl.SetAccessoryStateCategory(1, _imgTglCol02.isOn);
                         * }
                         */
                    }
                };

                AccessoriesApi.AccessoryTransferred += (_sender, _args) => _pluginCtrl.AccessoryTransferredHandler(_args.SourceSlotIndex, _args.DestinationSlotIndex);
                AccessoriesApi.AccessoriesCopied    += (_sender, _args) => _pluginCtrl.AccessoriesCopiedHandler((int)_args.CopySource, (int)_args.CopyDestination, _args.CopiedSlotIndexes.ToList());

                MakerAPI.RegisterCustomSubCategories += (_sender, _args) =>
                {
                    _makerLoadToggle           = _args.AddLoadToggle(new MakerLoadToggle("AccStateSync"));
                    _makerCoordinateLoadToggle = _args.AddCoordinateLoadToggle(new MakerCoordinateLoadToggle("AccStateSync"));
                    _charaConfigWindow         = _instance.gameObject.AddComponent <AccStateSyncUI>();
                    _sidebarTogglePreview      = _args.AddSidebarControl(new SidebarToggle("A.S.S. Preview", _cfgCharaMakerPreview.Value, _instance));
                    _sidebarTogglePreview.ValueChanged.Subscribe(_value =>
                    {
                        if (_cfgCharaMakerPreview.Value != _value)
                        {
                            _cfgCharaMakerPreview.Value = _value;
                        }
                    });
                    _accWinCtrlEnable = MakerAPI.AddAccessoryWindowControl(new MakerButton("AccStateSync", null, _instance));
                    _accWinCtrlEnable.OnClick.AddListener(() => _charaConfigWindow.enabled = true);
                };
                MakerAPI.MakerFinishedLoading += (_sender, _args) =>
                {
                    PatchMakerToggles();
                    if (MoreAccessories._installed)
                    {
                        _accMenuTree = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsMenuTree/04_AccessoryTop/Slots/Viewport/Content").transform;
                    }
                    else
                    {
                        _accMenuTree = GameObject.Find("CustomScene/CustomRoot/FrontUIGroup/CustomUIGroup/CvsMenuTree/04_AccessoryTop").transform;
                    }
                    MoreAccessories.HarmonyPatch();
                };
                MakerAPI.MakerExiting += (_sender, _args) =>
                {
                    Destroy(_charaConfigWindow);

                    MoreAccessories.HarmonyUnpatch();

                    _sidebarTogglePreview      = null;
                    _makerLoadToggle           = null;
                    _makerCoordinateLoadToggle = null;
                    _accWinCtrlEnable          = null;
                    _imgTglCol01 = null;
                    _imgTglCol02 = null;
                };

                JetPack.CharaMaker.OnCvsNavMenuClick += (_sender, _args) =>
                {
                    if (_args.TopIndex == 4)
                    {
                        if (_args.SideToggle?.GetComponentInChildren <CvsAccessory>(true) == null)
                        {
                            _chaCtrl.StartCoroutine(_pluginCtrl.AccSlotChangedHandlerCoroutine());
                            _charaConfigWindow._onAccTab = false;
                            _pluginCtrl._curPartsInfo    = null;
                            _pluginCtrl._cachedSlotPropertyList.Clear();
                            return;
                        }

                        int _slotIndex = (int)_args.SideToggle.GetComponentInChildren <CvsAccessory>(true)?.slotNo;
                        _chaCtrl.StartCoroutine(_pluginCtrl.AccSlotChangedHandlerCoroutine());
                        _charaConfigWindow._onAccTab = true;
                    }
                    else
                    {
                        _chaCtrl.StartCoroutine(_pluginCtrl.AccSlotChangedHandlerCoroutine());
                        _charaConfigWindow._onAccTab = false;
                    }
                };
                JetPack.CharaMaker.OnAccessoryTypeChanged += (_sender, _args) =>
                {
                    _pluginCtrl.AccessoryTypeChanged(_args);
                };
            }