public void RandomWardrobeSlotGUI(RandomAvatar ra, RandomWardrobeSlot rws)
 {
     // do random colors
     // show each possible item.
     GUIHelper.FoldoutBar(ref rws.GuiFoldout, rws.WardrobeSlot.name + " (" + rws.WardrobeSlot.wardrobeSlot + ")", out rws.Delete);
     if (rws.GuiFoldout)
     {
         GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.75f, 0.75f));
         rws.Chance = EditorGUILayout.IntSlider("Weighted Chance", rws.Chance, 1, 100);
         if (rws.PossibleColors.Length > 0)
         {
             if (GUILayout.Button("Add Shared Color"))
             {
                 rws.AddColorTable = true;
             }
             foreach (RandomColors rc in rws.Colors)
             {
                 RandomColorsGUI(ra, rws, rc);
             }
         }
         else
         {
             GUILayout.Label("Wardrobe Recipe has no Shared Colors");
         }
         GUIHelper.EndVerticalPadded(10);
     }
 }
Esempio n. 2
0
 public void RandomColorsGUI(RandomAvatar ra, RandomColors rc)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField("Shared Color", GUILayout.Width(80));
     EditorGUILayout.LabelField(rc.ColorName, EditorStyles.textField, GUILayout.Width(80));
     EditorGUILayout.LabelField("Color Table", GUILayout.Width(80));
     rc.ColorTable = (SharedColorTable)EditorGUILayout.ObjectField(rc.ColorTable, typeof(SharedColorTable), false, GUILayout.ExpandWidth(true));
     EditorGUILayout.EndHorizontal();
 }
 public void RandomColorsGUI(RandomAvatar ra, RandomWardrobeSlot rws, RandomColors rc)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField("Shared Color", GUILayout.Width(80));
     rc.CurrentColor = EditorGUILayout.Popup(rc.CurrentColor, rws.PossibleColors, GUILayout.Width(80));
     rc.ColorName    = rws.PossibleColors[rc.CurrentColor];
     EditorGUILayout.LabelField("Color Table", GUILayout.Width(80));
     rc.ColorTable = (SharedColorTable)EditorGUILayout.ObjectField(rc.ColorTable, typeof(SharedColorTable), false, GUILayout.ExpandWidth(true));
     EditorGUILayout.EndHorizontal();
 }
Esempio n. 4
0
        public bool RandomColorsGUI(RandomAvatar ra, RandomWardrobeSlot rws, RandomColors rc)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Shared Color", GUILayout.Width(80));
            rc.CurrentColor = EditorGUILayout.Popup(rc.CurrentColor, rws.PossibleColors, GUILayout.Width(80));
            rc.ColorName    = rws.PossibleColors[rc.CurrentColor];
            EditorGUILayout.LabelField("Color Table", GUILayout.Width(80));
            rc.ColorTable = (SharedColorTable)EditorGUILayout.ObjectField(rc.ColorTable, typeof(SharedColorTable), false, GUILayout.ExpandWidth(true));
            bool retval = GUILayout.Button("\u0078", EditorStyles.miniButton, GUILayout.ExpandWidth(false));

            EditorGUILayout.EndHorizontal();
            return(retval);
        }
Esempio n. 5
0
        private RandomAvatar FindAvatar(RaceData raceData)
        {
            // Is the current race defined?
            foreach (RandomAvatar ra in currentTarget.RandomAvatars)
            {
                if (raceData.raceName == ra.RaceName)
                {
                    return(ra);
                }
            }
            RandomAvatar rav = new RandomAvatar(raceData);

            currentTarget.RandomAvatars.Add(rav);
            return(rav);
        }
Esempio n. 6
0
        public void RandomWardrobeSlotGUI(RandomAvatar ra, RandomWardrobeSlot rws)
        {
            // do random colors
            // show each possible item.
            string name = "<null>";

            if (rws.WardrobeSlot != null)
            {
                name = rws.WardrobeSlot.name;
            }

            GUIHelper.FoldoutBar(ref rws.GuiFoldout, name + " (" + rws.Chance + ")", out rws.Delete);
            if (rws.GuiFoldout)
            {
                GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.75f, 0.75f));
                rws.Chance = EditorGUILayout.IntSlider("Weighted Chance", rws.Chance, 1, 100);
                if (rws.PossibleColors.Length > 0)
                {
                    if (GUILayout.Button("Add Shared Color"))
                    {
                        rws.AddColorTable = true;
                    }
                    RandomColors delme = null;
                    foreach (RandomColors rc in rws.Colors)
                    {
                        if (RandomColorsGUI(ra, rws, rc))
                        {
                            delme = rc;
                        }
                    }
                    if (delme != null)
                    {
                        rws.Colors.Remove(delme);
                        EditorUtility.SetDirty(this.target);
                        AssetDatabase.SaveAssets();
                    }
                }
                else
                {
                    GUILayout.Label("Wardrobe Recipe has no Shared Colors");
                }
                GUIHelper.EndVerticalPadded(10);
            }
        }
Esempio n. 7
0
        private void UpdateObject()
        {
            // Add any dropped items.
            int ChangeCount = currentTarget.droppedItems.Count;

            if (currentTarget.droppedItems.Count > 0)
            {
                foreach (RandomAvatar rv in currentTarget.RandomAvatars)
                {
                    rv.GuiFoldout = false;
                    foreach (RandomWardrobeSlot rws in rv.RandomWardrobeSlots)
                    {
                        rws.GuiFoldout = false;
                    }
                }

                RandomAvatar ra = FindAvatar(currentTarget.raceDatas[currentTarget.currentRace]);

                // Add all the wardrobe items.
                foreach (UMAWardrobeRecipe uwr in currentTarget.droppedItems)
                {
                    if (RecipeCompatible(uwr, currentTarget.raceDatas[currentTarget.currentRace]))
                    {
                        RandomWardrobeSlot rws = new RandomWardrobeSlot(uwr, uwr.wardrobeSlot);
                        ra.GuiFoldout = true;
                        ra.RandomWardrobeSlots.Add(rws);
                    }
                }
                // sort the wardrobe slots
                ra.RandomWardrobeSlots.Sort((x, y) => x.SortName.CompareTo(y.SortName));
                currentTarget.droppedItems.Clear();
            }

            ChangeCount += currentTarget.RandomAvatars.RemoveAll(x => x.Delete);
            foreach (RandomAvatar ra in currentTarget.RandomAvatars)
            {
                if (!string.IsNullOrEmpty(ra.DNAAdd))
                {
                    ra.DnaChanged = true;
                    ra.RandomDna.Add(new RandomDNA(ra.DNAAdd));
                    ra.DNAAdd = "";
                    ChangeCount++;
                }

                int DNAChangeCount = ra.RandomDna.RemoveAll(x => x.Delete);
                if (DNAChangeCount > 0)
                {
                    ra.DnaChanged = true;
                    ChangeCount++;
                }
                ChangeCount += ra.SharedColors.RemoveAll(x => x.Delete);
                ChangeCount += ra.RandomWardrobeSlots.RemoveAll(x => x.Delete);
                foreach (RandomWardrobeSlot rws in ra.RandomWardrobeSlots)
                {
                    ChangeCount += rws.Colors.RemoveAll(x => x.Delete);
                    if (rws.AddColorTable)
                    {
                        rws.Colors.Add(new RandomColors(rws));
                        rws.AddColorTable = false;
                        ChangeCount++;
                    }
                }
            }

            if (ChangeCount > 0)
            {
                EditorUtility.SetDirty(currentTarget);
                AssetDatabase.SaveAssets();
            }
        }
Esempio n. 8
0
        public void RandomAvatarGUI(RandomAvatar ra)
        {
            bool del = false;

            GUIHelper.FoldoutBar(ref ra.GuiFoldout, ra.RaceName, out del);
            if (ra.GuiFoldout)
            {
                GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));
                if (del)
                {
                    ra.Delete = true;
                }

                ra.Chance = EditorGUILayout.IntSlider("Weighted Chance", ra.Chance, 1, 100);

                ra.ColorsFoldout = GUIHelper.FoldoutBar(ra.ColorsFoldout, "Colors");
                if (ra.ColorsFoldout)
                {
                    GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.75f, 0.75f));
                    if (ra.SharedColors != null && ra.SharedColors.Count > 0)
                    {
                        foreach (RandomColors rc in ra.SharedColors)
                        {
                            RandomColorsGUI(ra, rc);
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("No shared colors found on base race");
                    }
                    GUIHelper.EndVerticalPadded(10);
                }

                ra.DnaFoldout = GUIHelper.FoldoutBar(ra.DnaFoldout, "DNA");
                if (ra.DnaFoldout)
                {
                    GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.75f, 0.75f));
                    // (popup with DNA names) and "Add" button.
                    EditorGUILayout.BeginHorizontal();
                    ra.SelectedDNA = EditorGUILayout.Popup("DNA", ra.SelectedDNA, ra.PossibleDNA);
                    bool pressed = GUILayout.Button("Add DNA", EditorStyles.miniButton);                    // GUIStyles.Popup?
                    EditorGUILayout.EndHorizontal();
                    if (pressed)
                    {
                        ra.DNAAdd = ra.PossibleDNA[ra.SelectedDNA];
                    }
                    if (ra.RandomDna.Count == 0)
                    {
                        EditorGUILayout.LabelField("No Random DNA has been added");
                    }
                    else
                    {
                        foreach (RandomDNA rd in ra.RandomDna)
                        {
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField(rd.DnaName, EditorStyles.miniLabel, GUILayout.Width(100));
                            float lastMin = rd.MinValue;
                            float lastMax = rd.MaxValue;
                            EditorGUILayout.MinMaxSlider(ref rd.MinValue, ref rd.MaxValue, 0.0f, 1.0f);
                            if (rd.MinValue != lastMin || rd.MaxValue != lastMax)
                            {
                                ra.DnaChanged = true;
                            }
                            rd.Delete = GUILayout.Button("\u0078", EditorStyles.miniButton, GUILayout.ExpandWidth(false));
                            string vals = rd.MinValue.ToString("N3") + " - " + rd.MaxValue.ToString("N3");
                            EditorGUILayout.LabelField(vals, EditorStyles.miniTextField, GUILayout.Width(80));
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    GUIHelper.EndVerticalPadded(10);
                }
                ra.WardrobeFoldout = GUIHelper.FoldoutBar(ra.WardrobeFoldout, "Wardrobe");
                if (ra.WardrobeFoldout)
                {
                    // add a null slot for a
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Select Wardrobe Slot", GUILayout.ExpandWidth(false));
                    ra.currentWardrobeSlot = EditorGUILayout.Popup(ra.currentWardrobeSlot, ra.raceData.wardrobeSlots.ToArray(), GUILayout.ExpandWidth(true));
                    if (GUILayout.Button("Add Null", GUILayout.ExpandWidth(false)))
                    {
                        ra.RandomWardrobeSlots.Add(new RandomWardrobeSlot(null, ra.raceData.wardrobeSlots[ra.currentWardrobeSlot]));
                        ra.RandomWardrobeSlots.Sort((x, y) => x.SortName.CompareTo(y.SortName));
                    }
                    GUILayout.EndHorizontal();
                    GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.75f, 0.75f));

                    string lastSlot = "";

                    foreach (RandomWardrobeSlot rws in ra.RandomWardrobeSlots)
                    {
                        if (rws.SlotName != lastSlot)
                        {
                            GUILayout.Label("[" + rws.SlotName + "]");
                            lastSlot = rws.SlotName;
                        }
                        RandomWardrobeSlotGUI(ra, rws);
                    }
                    GUIHelper.EndVerticalPadded(10);
                }
                GUIHelper.EndVerticalPadded(10);
            }
        }