Ejemplo n.º 1
0
            internal IEnumerator RefreshCoroutine()
            {
                DebugMsg(LogLevel.Warning, $"[RefreshCoroutine][{ChaControl.GetFullname()}] fired");

                yield return(new WaitForEndOfFrame());

                yield return(new WaitForEndOfFrame());

                TaskUnlock();

                if (CharaStudio.Running)
                {
                    if (CfgStudioFallbackReload.Value)
                    {
                        BigReload();
                    }
                    else
                    {
                        FastReload();
                    }
                }
                else
                {
                    ChaControl.ChangeCoordinateTypeAndReload(false);

                    if (MakerAPI.InsideAndLoaded)
                    {
                        CustomBase.Instance.updateCustomUI = true;
                    }
                }
                ChaControl.StartCoroutine(PreviewCoroutine());
            }
Ejemplo n.º 2
0
        private void SetupCoordButtons()
        {
            var position = GetDisplayRect();

            foreach (ChaFileDefine.ClothesKind kind in Enum.GetValues(typeof(ChaFileDefine.ClothesKind)))
            {
                if (kind == ChaFileDefine.ClothesKind.shoes_outer)
                {
                    continue;
                }
                _buttons.Add(new ClothButton(position, kind, _chaCtrl));
                position.y += Height;
            }

            if (MakerAPI.InsideMaker)
            {
                _buttons.Add(new BodyButton(_chaCtrl, position));
            }

            var customControl = MakerAPI.GetMakerBase()?.customCtrl;

            if (customControl != null)
            {
                var coordDropdown = typeof(CustomControl).GetField("ddCoordinate", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(customControl);
                var coordProp     = coordDropdown?.GetType().GetProperty("value", BindingFlags.Instance | BindingFlags.Public);
                _setCoordAction = newVal => coordProp?.SetValue(coordDropdown, newVal, null);
            }
            else
            {
                _setCoordAction = newVal => _chaCtrl.ChangeCoordinateTypeAndReload((ChaFileDefine.CoordinateType)newVal);
            }
        }
Ejemplo n.º 3
0
            internal void RestorePartsInfo()
            {
                DebugMsg(LogLevel.Warning, $"[RestorePartsInfo][{ChaControl.GetFullname()}] fired");

                if (!DuringLoading)
                {
                    return;
                }

                if (!FunctionEnable)
                {
                    TaskUnlock();
                    return;
                }
                if (PartsInfo.Count == 0)
                {
                    Logger.LogMessage($"Nothing to restore");
                    TaskUnlock();
                    return;
                }

                int _coordinateIndex = ChaControl.fileStatus.coordinateType;
                Dictionary <int, ChaFileAccessory.PartsInfo> RefUsedPartsInfo = MoreAccessoriesSupport.ListUsedPartsInfo(ChaControl, _coordinateIndex);

                if (RefUsedPartsInfo.Count > 0 && RefUsedPartsInfo.Keys.Min() <= PartsInfo.Keys.Max())
                {
                    Logger.LogMessage($"Error: parts overlap [RefUsedPartsInfo.Keys.Min(): {RefUsedPartsInfo.Keys.Min()}][PartsInfo.Keys.Max(): {PartsInfo.Keys.Max()}]");
                    TaskUnlock();
                    return;
                }

                DebugMsg(LogLevel.Info, $"[RestorePartsInfo][{ChaControl.GetFullname()}][Slots: {string.Join(",", PartsInfo.Keys.Select(Slot => Slot.ToString()).ToArray())}]");

                foreach (KeyValuePair <int, ChaFileAccessory.PartsInfo> _part in PartsInfo)
                {
                    MoreAccessoriesSupport.SetPartsInfo(ChaControl, _coordinateIndex, _part.Key, _part.Value);
                }

                if (CharaStudio.Running)
                {
                    ChaControl.ChangeCoordinateTypeAndReload(false);
                    ChaControl.StartCoroutine(RestorePluginSettingCoroutine());
                    return;
                }
                else
                {
                    foreach (string _name in SupportList)
                    {
                        Traverse.Create(this).Field(_name).Method("Restore").GetValue();
                    }

                    ChaControl.StartCoroutine(RefreshCoroutine());
                }
            }
Ejemplo n.º 4
0
            internal void CopyPartsInfo()
            {
                DebugMsg(LogLevel.Warning, $"[CopyPartsInfo][{ChaControl.GetFullname()}] fired");

                if (!DuringLoading)
                {
                    TaskUnlock();
                    return;
                }
                if (!FunctionEnable)
                {
                    TaskUnlock();
                    return;
                }
                if (ReferralIndex == CurrentCoordinateIndex)
                {
                    TaskUnlock();
                    return;
                }

                List <ChaFileAccessory.PartsInfo> PartsInfo = MoreAccessoriesSupport.ListPartsInfo(ChaControl, ReferralIndex);
                List <int> SlotIndexes = new List <int>();

                for (int i = 0; i < PartsInfo.Count; i++)
                {
                    if (PartsInfo[i].type > 120)
                    {
                        SlotIndexes.Add(i);
                    }
                }
                DebugMsg(LogLevel.Warning, $"[CopyPartsInfo][{ChaControl.GetFullname()}][Slots: {string.Join(",", SlotIndexes.Select(Slot => Slot.ToString()).ToArray())}]");
                AccessoryCopyEventArgs ev = new AccessoryCopyEventArgs(SlotIndexes, (ChaFileDefine.CoordinateType)ReferralIndex, (ChaFileDefine.CoordinateType)CurrentCoordinateIndex);

                MoreAccessoriesSupport.CopyPartsInfo(ChaControl, ev);

                if (CharaStudio.Running)
                {
                    ChaControl.ChangeCoordinateTypeAndReload(false);
                    ChaControl.StartCoroutine(CopyPluginSettingCoroutine(ev));
                    return;
                }
                else
                {
                    foreach (string _name in SupportList)
                    {
                        Traverse.Create(this).Field(_name).Method("CopyPartsInfo", new object[] { ev }).GetValue();
                    }

                    ChaControl.StartCoroutine(RefreshCoroutine());
                }
            }
Ejemplo n.º 5
0
        private void SetupInterface()
        {
#if KK || EC
            var distanceFromRightEdge = Screen.width / 10f;
#elif KKS
            var distanceFromRightEdge = Screen.width / 8.5f;
#endif
            var x          = Screen.width - distanceFromRightEdge - Width - Margin;
            var windowRect = new Rect(x, Margin, Width, Height);

            // Clothing piece state buttons
            foreach (ChaFileDefine.ClothesKind kind in Enum.GetValues(typeof(ChaFileDefine.ClothesKind)))
            {
#if KK || KKS
                if (kind == ChaFileDefine.ClothesKind.shoes_outer)
                {
                    continue;
                }
#endif
                _buttons.Add(new ClothButton(windowRect, kind, _chaCtrl));
                windowRect.y += Height;
            }
            // Invisible body
            if (MakerAPI.InsideMaker)
            {
                _buttons.Add(new BodyButton(_chaCtrl, windowRect));
            }

            // Accessories
            _accesorySlotsRect        = _buttons.Last().Position;
            _accesorySlotsRect.x     += 7;
            _accesorySlotsRect.width -= 7;
            _accesorySlotsRect.y     += Height + Margin;
            _accesorySlotsRect.height = 300f;

#if KK || KKS
            // Coordinate change buttons
            var customControl = MakerAPI.GetMakerBase()?.customCtrl;
            if (customControl != null)
            {
                var coordDropdown = customControl.ddCoordinate;
                _setCoordAction = newVal => coordDropdown.value = newVal;
            }
            else
            {
                _setCoordAction = newVal => _chaCtrl.ChangeCoordinateTypeAndReload((ChaFileDefine.CoordinateType)newVal);
            }
#endif
        }
Ejemplo n.º 6
0
            internal void TransferPartsInfo()
            {
                DebugMsg(LogLevel.Warning, $"[TransferPartsInfo][{ChaControl.GetFullname()}] fired");

                if (QueueList.Count == 0)
                {
                    TaskUnlock();
                    return;
                }

                for (int i = 0; i < QueueList.Count; i++)
                {
                    int srcIndex = QueueList[i].srcSlot;
                    int dstIndex = QueueList[i].dstSlot;
                    DebugMsg(LogLevel.Warning, $"[TransferPartsInfo][{ChaControl.GetFullname()}][{srcIndex}][{dstIndex}]");
                    AccessoryTransferEventArgs ev = new AccessoryTransferEventArgs(srcIndex, dstIndex);

                    MoreAccessoriesSupport.TransferPartsInfo(ChaControl, ev);
                    MoreAccessoriesSupport.RemovePartsInfo(ChaControl, CurrentCoordinateIndex, srcIndex);

                    foreach (string _name in SupportList)
                    {
                        Traverse.Create(this).Field(_name).Method("TransferPartsInfo", new object[] { ev }).GetValue();
                        Traverse.Create(this).Field(_name).Method("RemovePartsInfo", new object[] { srcIndex }).GetValue();
                    }
                }

                if (ReferralIndex < 7)
                {
                    CopyPartsInfo();
                }
                else
                {
                    ChaControl.ChangeCoordinateTypeAndReload(false);
                    ChaControl.StartCoroutine(RestorePartsInfoCoroutine());
                }
            }
Ejemplo n.º 7
0
            internal void PrepareQueue()
            {
                QueueList = new List <QueueItem>();

                if (ReferralIndex < 0)
                {
                    TaskUnlock();
                    return;
                }
                if (ReferralIndex < 7 && ReferralIndex == CurrentCoordinateIndex)
                {
                    TaskUnlock();
                    return;
                }

                int RefLastNotEmpty = -1;

                if (ReferralIndex < 7)
                {
                    Dictionary <int, ChaFileAccessory.PartsInfo> RefUsedPartsInfo = MoreAccessoriesSupport.ListUsedPartsInfo(ChaControl, ReferralIndex);
                    RefLastNotEmpty = (RefUsedPartsInfo.Count == 0) ? -1 : RefUsedPartsInfo.Keys.Max();
                }
                else
                {
                    RefLastNotEmpty = (PartsInfo.Count == 0) ? -1 : PartsInfo.Keys.Max();
                }

                DebugMsg(LogLevel.Warning, $"[PrepareQueue][{ChaControl.GetFullname()}][ReferralIndex: {ReferralIndex}][SrcLastNotEmpty: Slot{RefLastNotEmpty + 1:00}]");

                if (RefLastNotEmpty < 0)
                {
                    TaskUnlock();
                    return;
                }

                Dictionary <int, ChaFileAccessory.PartsInfo> CurUsedPartsInfo = MoreAccessoriesSupport.ListUsedPartsInfo(ChaControl, CurrentCoordinateIndex);

                if (CurUsedPartsInfo.Count == 0)
                {
                    if (ReferralIndex < 7)
                    {
                        CopyPartsInfo();
                    }
                    else
                    {
                        RestorePartsInfo();
                    }
                    return;
                }

                int ToAdd            = 0;
                int shift            = 0;
                int CurFirstNotEmpty = CurUsedPartsInfo.Keys.Min();
                int CurLastNotEmpty  = CurUsedPartsInfo.Keys.Max();

                List <int> UsedParts    = CurUsedPartsInfo.Keys.ToList();
                List <int> UsedPartsRev = new List <int>();

                UsedPartsRev.AddRange(UsedParts);
                UsedPartsRev.Reverse();
                DebugMsg(LogLevel.Warning, $"[PrepareQueue][{ChaControl.GetFullname()}][CurrentCoordinateIndex: {CurrentCoordinateIndex}][CurFirstNotEmpty: Slot{CurFirstNotEmpty + 1:00}][CurLastNotEmpty: Slot{CurLastNotEmpty + 1:00}]");

                if (CurFirstNotEmpty <= RefLastNotEmpty)
                {
                    shift = RefLastNotEmpty - CurFirstNotEmpty + 1;
                    int NewMaxIndex = CurLastNotEmpty + shift;
                    ToAdd = NewMaxIndex - MoreAccessoriesSupport.GetPartsCount(ChaControl, CurrentCoordinateIndex);
                }

                if (shift > 0)
                {
                    foreach (int _slot in UsedPartsRev)
                    {
                        QueueList.Add(new QueueItem(_slot, _slot + shift));
                    }
                }

                if (ToAdd > 0)
                {
                    MoreAccessoriesSupport.CheckAndPadPartInfo(ChaControl, CurrentCoordinateIndex, CurLastNotEmpty + shift);
                    ChaControl.StartCoroutine(TransferPartsInfoCoroutine());
                }
                else
                {
                    if (QueueList.Count > 0)
                    {
                        TransferPartsInfo();
                    }
                    else
                    {
                        if (ReferralIndex < 7)
                        {
                            CopyPartsInfo();
                        }
                        else
                        {
                            ChaControl.ChangeCoordinateTypeAndReload(false);
                            ChaControl.StartCoroutine(RestorePartsInfoCoroutine());
                        }
                    }
                }
            }