Exemple #1
0
        static void AddPartToList(PartBundleDescriptor partBundleDesc, PartDescriptor partDesc)
        {
            PartEditor.PartList partList = null;

            //add to the right list
            switch (partDesc.partType)
            {
            case (PartInfo.PartType.Blade):
                partList = PartEditor.BladeList;
                break;

            case (PartInfo.PartType.Guard):
                partList = PartEditor.GuardList;
                break;

            case (PartInfo.PartType.FingerGuard):
                partList = PartEditor.GuardList;
                break;

            case (PartInfo.PartType.Handle):
                partList = PartEditor.HandleList;
                break;

            case (PartInfo.PartType.Pommel):
                partList = PartEditor.PommelList;
                break;

            case (PartInfo.PartType.Accessory):
                partList = PartEditor.AccAList;
                break;
            }

            //create part key
            string partRefName = partBundleDesc.partBundleAuthor + "." + partBundleDesc.partBundleName + "." + partDesc.partType.ToString() + "." + partDesc.partName;

            foreach (PartInfo part in partList.parts)
            {
                if (part.partReferenceName == partRefName)
                {
                    Logger.log.Debug("A part with the name " + part.partReferenceName + " has already been added - skipping. Make sure all part and bundle names are unique!");
                    return;
                }
            }

            PartInfo newPart = new PartInfo(partDesc.partType, partDesc.gameObject, partRefName, partDesc.partDisplayName);

            partList.parts.Add(newPart);
            Logger.log.Debug("Added " + partRefName + " to the list of " + partDesc.partType.ToString());;
        }
        //check to ensure saved part actually exists in the loaded assets and sets list index. Might not exist if part bundles are removed
        static void SetPartListIndexFromConfig(string partName, PartEditor.PartList partList)
        {
            int partIndex = -1;

            for (int i = 0; i < partList.parts.Count; i++)
            {
                if (partList.parts[i].partReferenceName == partName)
                {
                    partIndex = i;
                }
            }

            if (partIndex == -1)
            {
                Logger.log.Debug("Could not find saved part in loaded lists! Setting to default");
                partIndex = 0;
            }

            partList.index = partIndex;
        }
Exemple #3
0
        public static GameObject CreateModelSwapPanel(Transform parent, PartEditor.PartList partList, string panelLabel)
        {
            RectTransform newPanel = CreateRectPanel(parent, panelLabel);

            TextMeshProUGUI partNameText = BeatSaberUI.CreateText(newPanel, "part name", new Vector2(20, 0), new Vector2(30, 10));

            partNameText.alignment = TextAlignmentOptions.Center;
            partNameText.fontSize  = 4;

            HoverHint modelHoverHint = BeatSaberUI.AddHintText(partNameText.gameObject.GetComponent <RectTransform>(), "hint");

            LabelTextGroup textGroup = new LabelTextGroup(partNameText, modelHoverHint, partList);

            partTextGroups.Add(textGroup);

            //cry delegate won't let me pass int as a ref, hence faff with index arrays
            BeatSaberUI.CreateUIButton(newPanel, "DecButton", new Vector2(0, 0), new Vector2(8, 8), delegate { PartEditor.MoveThroughPartList(-1, partList); });
            BeatSaberUI.CreateUIButton(newPanel, "IncButton", new Vector2(50, 0), new Vector2(8, 8), delegate { PartEditor.MoveThroughPartList(1, partList); });

            //to set name and hint strings
            UpdatePartLabelText(textGroup);

            return(newPanel.gameObject);
        }
Exemple #4
0
            // public int listIndex;

            public LabelTextGroup(TextMeshProUGUI label, HoverHint hint, PartEditor.PartList list)
            {
                labelTMP  = label;
                hoverHint = hint;
                partList  = list;
            }