コード例 #1
0
ファイル: TestCustomizerDD.cs プロジェクト: grendelbiter/UMA
    //Decided this may be more confusing than useful...Just left here in case I change my mind...
    public void UpdateSuppressedWardrobeDropdowns(UMATextRecipe suppressedBy)
    {
        if (suppressedBy.suppressWardrobeSlots == null)
        {
            return;
        }
        var suppressedSlots = suppressedBy.suppressWardrobeSlots;

        foreach (Transform child in wardrobeDropdownPanel.transform)
        {
            child.GetComponent <Dropdown>().captionImage.overrideSprite = null;
            var thisSlot = child.GetComponent <CSWardrobeSlotChangerDD>().wardrobeSlotToChange;
            if (suppressedSlots.Contains(thisSlot))
            {
                child.GetComponent <Dropdown>().value = 0;
                //make the suppressed slot show the image of the item it is being suppressed by
                child.GetComponent <Dropdown>().captionImage.overrideSprite = suppressedBy.GetWardrobeRecipeThumbFor(thisRace);
            }
        }
    }
コード例 #2
0
 public void SetUpWardrobeDropdowns()
 {
     if (Avatar != null)
     {
         thisRace = Avatar.activeRace.name;
     }
     InitializeWardrobeDropDowns();
     foreach (Transform child in wardrobeDropdownPanel.transform)
     {
         child.gameObject.SetActive(true);
         var thisDD = child.GetComponent <Dropdown>();
         thisDD.captionImage.overrideSprite = null;
         var thisSlot = child.GetComponent <CSWardrobeSlotChangerDD>().wardrobeSlotToChange;
         //We want to have the option of being able to write limitWardrobeOptions and hideWardrobeOptions like raceName:wrdrobeSlot
         bool showOption = false;
         if (!hideWardrobeOptions.Contains(thisSlot) && !hideWardrobeOptions.Contains(thisRace + ":" + thisSlot))
         {
             showOption = true;
         }
         if (limitWardrobeOptions.Contains(thisSlot) || limitWardrobeOptions.Contains(thisRace + ":" + thisSlot))
         {
             showOption = true;
         }
         if (characterSystem.Recipes.ContainsKey(thisRace) && characterSystem.Recipes[thisRace].ContainsKey(thisSlot) && showOption)
         {
             if (thisSlot == "WardrobeCollection")
             {
                 SetUpWardrobeCollectionDropdown(child, thisDD);
             }
             else
             {
                 thisDD.options.Clear();
                 thisDD.onValueChanged.RemoveAllListeners();
                 var wardrobeOptions = new List <UMATextRecipe>(characterSystem.Recipes[thisRace][thisSlot]);
                 var thisUnsetThumb  = Avatar.activeRace.racedata.raceThumbnails.GetThumbFor(thisSlot);
                 var thisUnsetOption = new Dropdown.OptionData();
                 thisUnsetOption.text  = thisSlot == "Face" ? "Standard" : "None";
                 thisUnsetOption.image = thisUnsetThumb;
                 thisDD.options.Add(thisUnsetOption);
                 for (int i = 0; i < wardrobeOptions.Count; i++)
                 {
                     var thisddOption = new Dropdown.OptionData();
                     thisddOption.text  = wardrobeOptions[i].DisplayValue != "" ? wardrobeOptions[i].DisplayValue : wardrobeOptions[i].name;
                     thisddOption.image = wardrobeOptions[i].GetWardrobeRecipeThumbFor(thisRace);
                     thisDD.options.Add(thisddOption);
                 }
                 int           selected     = 0;
                 UMATextRecipe thisDDRecipe = null;
                 if (Avatar.WardrobeRecipes.Count > 0)
                 {
                     foreach (KeyValuePair <string, UMATextRecipe> kp in Avatar.WardrobeRecipes)
                     {
                         var recipeSlotName = kp.Value.wardrobeSlot;
                         if (recipeSlotName == thisSlot && kp.Value.compatibleRaces.Contains(thisRace))
                         {
                             for (int ri = 0; ri < characterSystem.Recipes[thisRace][recipeSlotName].Count; ri++)
                             {
                                 if (characterSystem.Recipes[thisRace][recipeSlotName][ri].name == kp.Value.name)
                                 {
                                     //we could do alot more checks here to check equalness if this is the only way to make this work...
                                     selected = ri + 1;
                                 }
                             }
                             thisDDRecipe = kp.Value;
                         }
                         else if (recipeSlotName == thisSlot && (Avatar.activeRace.racedata.IsCrossCompatibleWith(kp.Value.compatibleRaces) && Avatar.activeRace.racedata.wardrobeSlots.Contains(thisSlot)))
                         {
                             //for cross compatible Races- races can be cross compatible with other races (set in the Race itself) and this enables one race to wear anothers wardrobe (if that race has the same wardrobe slots)
                             selected     = (characterSystem.Recipes[thisRace][recipeSlotName].FindIndex(s => s.Equals(kp.Value)) + 1);
                             thisDDRecipe = kp.Value;
                         }
                     }
                 }
                 thisDD.value = selected;
                 if (selected == 0)
                 {
                     thisDD.captionImage.sprite  = thisUnsetThumb;
                     thisDD.captionImage.enabled = true;
                 }
                 else
                 {
                     thisDD.captionImage.sprite  = thisDDRecipe.GetWardrobeRecipeThumbFor(thisRace);
                     thisDD.captionImage.enabled = true;
                 }
                 thisDD.onValueChanged.AddListener(child.GetComponent <CSWardrobeSlotChangerDD>().ChangeWardrobeSlot);
                 var thisSuppressedTextGO = thisDD.gameObject.transform.Find("ActiveWSlot").Find("SuppressedIndicator");
                 thisDD.interactable = true;
                 if (thisSuppressedTextGO)
                 {
                     thisSuppressedTextGO.GetComponent <Image>().enabled       = false;
                     thisSuppressedTextGO.GetComponentInChildren <Text>().text = "";
                 }
             }
         }
         else
         {
             child.gameObject.SetActive(false);
         }
     }
     if (Avatar != null)
     {
         UpdateSuppressedWardrobeDropdowns();
     }
 }