Example #1
0
 public static void PopulatePieMenuPickerWithOutfits(CustomPedestal pedestal, Sim actor, out List <ObjectPicker.TabInfo> listObjs, out List <ObjectPicker.HeaderInfo> headers, out int NumSelectableRows, OutfitUtils.GreyedOutOutfitCallback greyed)
 {
     if (pedestal == null)
     {
         CMShopping.PrintMessage("Pedestal null");
     }
     NumSelectableRows = 1;
     headers           = new List <ObjectPicker.HeaderInfo>();
     listObjs          = new List <ObjectPicker.TabInfo>();
     headers.Add(new ObjectPicker.HeaderInfo("Ui/Caption/ObjectPicker:Outfit", "Ui/Tooltip/ObjectPicker:Outfit"));
     headers[0].Width = 250;
     if (actor != null)
     {
         SimDescription simDescription = actor.SimDescription;
         ResourceKey    resourceKey    = CASUtils.GetOutfitInGameObject(actor.ObjectId);
         if (simDescription.HasSupernaturalOutfit(resourceKey) && simDescription.CreatedSim != null)
         {
             OutfitCategories currentOutfitCategory = simDescription.CreatedSim.CurrentOutfitCategory;
             int       currentOutfitIndex           = simDescription.CreatedSim.CurrentOutfitIndex;
             SimOutfit outfit = simDescription.GetOutfit(currentOutfitCategory, currentOutfitIndex);
             if (outfit != null && outfit.Key != ResourceKey.kInvalidResourceKey)
             {
                 resourceKey = outfit.Key;
             }
         }
         ObjectPicker.TabInfo tabInfo = new ObjectPicker.TabInfo("glb_all_r2", Localization.LocalizeString("Ui/Caption/ObjectPicker:All", new object[0]), new List <ObjectPicker.RowInfo>());
         string text   = Localization.LocalizeString("Ui/Caption/ObjectPicker:Everyday", new object[0]);
         string text2  = Localization.LocalizeString("Ui/Caption/ObjectPicker:Formalwear", new object[0]);
         string text3  = Localization.LocalizeString("Ui/Caption/ObjectPicker:Sleepwear", new object[0]);
         string text4  = null;
         string text5  = null;
         string text6  = null;
         string text7  = null;
         string text8  = null;
         string text9  = null;
         string text10 = null;
         ObjectPicker.TabInfo tabInfo2  = new ObjectPicker.TabInfo(actor.IsHorse ? "cas_acc_riding" : "shopping_clothing_everyday_r2", text, new List <ObjectPicker.RowInfo>());
         ObjectPicker.TabInfo tabInfo3  = new ObjectPicker.TabInfo("shopping_clothing_formal_r2", text2, new List <ObjectPicker.RowInfo>());
         ObjectPicker.TabInfo tabInfo4  = new ObjectPicker.TabInfo("shopping_clothing_sleepwear_r2", text3, new List <ObjectPicker.RowInfo>());
         ObjectPicker.TabInfo tabInfo5  = null;
         ObjectPicker.TabInfo tabInfo6  = null;
         ObjectPicker.TabInfo tabInfo7  = null;
         ObjectPicker.TabInfo tabInfo8  = null;
         ObjectPicker.TabInfo tabInfo9  = null;
         ObjectPicker.TabInfo tabInfo10 = null;
         ObjectPicker.TabInfo tabInfo11 = null;
         ObjectPicker.TabInfo tabInfo12 = null;
         if (simDescription.ToddlerOrAbove)
         {
             if (!simDescription.Toddler)
             {
                 text4    = Localization.LocalizeString("Ui/Caption/ObjectPicker:Swimwear", new object[0]);
                 text5    = Localization.LocalizeString("Ui/Caption/ObjectPicker:Athletic", new object[0]);
                 tabInfo5 = new ObjectPicker.TabInfo("shopping_clothing_swimwear_r2", text4, new List <ObjectPicker.RowInfo>());
                 tabInfo6 = new ObjectPicker.TabInfo("shopping_clothing_athletic_r2", text5, new List <ObjectPicker.RowInfo>());
             }
             if (GameUtils.IsInstalled(ProductVersion.EP8))
             {
                 text10    = Localization.LocalizeString("Ui/Caption/ObjectPicker:Outerwear", new object[0]);
                 tabInfo12 = new ObjectPicker.TabInfo("cas_clothing_i_outerwear", text10, new List <ObjectPicker.RowInfo>());
             }
         }
         if (simDescription.IsHorse)
         {
             text7     = Localization.LocalizeString("Ui/Caption/ObjectPicker:Racing", new object[0]);
             tabInfo9  = new ObjectPicker.TabInfo("cas_acc_racing", text7, new List <ObjectPicker.RowInfo>());
             text8     = Localization.LocalizeString("Ui/Caption/ObjectPicker:Jumping", new object[0]);
             tabInfo10 = new ObjectPicker.TabInfo("cas_acc_jumping", text8, new List <ObjectPicker.RowInfo>());
             text9     = Localization.LocalizeString("Ui/Caption/ObjectPicker:BridleOnly", new object[0]);
             tabInfo11 = new ObjectPicker.TabInfo("cas_acc_horse_bridles", text9, new List <ObjectPicker.RowInfo>());
         }
         SkillManager skillManager = actor.SkillManager;
         if (skillManager != null && skillManager.HasElement(SkillNames.MartialArts) && !simDescription.IsVisuallyPregnant)
         {
             headers[0].Width += 50;
             text6             = Localization.LocalizeString("Ui/Caption/ObjectPicker:MartialArts", new object[0]);
             tabInfo7          = new ObjectPicker.TabInfo("w_simple_martialarts_skill_s", text6, new List <ObjectPicker.RowInfo>());
         }
         if (actor.Occupation != null)
         {
             SimOutfit outfit2 = simDescription.GetOutfit(OutfitCategories.Career, 0);
             if (outfit2 != null)
             {
                 headers[0].Width += 50;
                 string tabText = Localization.LocalizeString("Ui/Caption/ObjectPicker:Miscellaneous", new object[0]);
                 tabInfo8 = new ObjectPicker.TabInfo("glb_i_options32", tabText, new List <ObjectPicker.RowInfo>());
             }
         }
         string textLabel = Localization.LocalizeString("Ui/Caption/ObjectPicker:Career", new object[0]);
         if (!actor.IsFoal)
         {
             OutfitPicker.PopulatePieMenuPickerWithCategoryOutfits(pedestal, simDescription, resourceKey, tabInfo, OutfitCategories.Everyday, text, tabInfo2, greyed);
         }
         OutfitPicker.PopulatePieMenuPickerWithCategoryOutfits(pedestal, simDescription, resourceKey, tabInfo, OutfitCategories.Formalwear, text2, tabInfo3, greyed);
         OutfitPicker.PopulatePieMenuPickerWithCategoryOutfits(pedestal, simDescription, resourceKey, tabInfo, OutfitCategories.Sleepwear, text3, tabInfo4, greyed);
         OutfitPicker.PopulatePieMenuPickerWithCategoryOutfits(pedestal, simDescription, resourceKey, tabInfo, OutfitCategories.Swimwear, text4, tabInfo5, greyed);
         OutfitPicker.PopulatePieMenuPickerWithCategoryOutfits(pedestal, simDescription, resourceKey, tabInfo, OutfitCategories.Athletic, text5, tabInfo6, greyed);
         if (tabInfo12 != null)
         {
             OutfitPicker.PopulatePieMenuPickerWithCategoryOutfits(pedestal, simDescription, resourceKey, tabInfo, OutfitCategories.Outerwear, text10, tabInfo12, greyed);
         }
         OutfitPicker.PopulatePieMenuPickerWithCategoryOutfits(pedestal, simDescription, resourceKey, tabInfo, OutfitCategories.MartialArts, text6, tabInfo7, greyed);
         OutfitPicker.PopulatePieMenuPickerWithCategoryOutfits(pedestal, simDescription, resourceKey, tabInfo, OutfitCategories.Career, textLabel, tabInfo8, greyed);
         OutfitPicker.PopulatePieMenuPickerWithCategoryOutfits(pedestal, simDescription, resourceKey, tabInfo, OutfitCategories.Bridle, text9, tabInfo11, greyed);
         Racing racing = skillManager.GetElement(SkillNames.Racing) as Racing;
         if (racing != null && racing.HasRacingSaddleOutfit)
         {
             OutfitPicker.PopulatePieMenuPickerWithCategoryOutfits(pedestal, simDescription, resourceKey, tabInfo, OutfitCategories.Racing, text7, tabInfo9, greyed);
         }
         Jumping jumping = skillManager.GetElement(SkillNames.Jumping) as Jumping;
         if (jumping != null && jumping.HasJumpOutfit)
         {
             OutfitPicker.PopulatePieMenuPickerWithCategoryOutfits(pedestal, simDescription, resourceKey, tabInfo, OutfitCategories.Jumping, text8, tabInfo10, greyed);
         }
         listObjs.Add(tabInfo);
         if (tabInfo2.RowInfo.Count > 0)
         {
             listObjs.Add(tabInfo2);
         }
         if (tabInfo3.RowInfo.Count > 0)
         {
             listObjs.Add(tabInfo3);
         }
         if (tabInfo4.RowInfo.Count > 0)
         {
             listObjs.Add(tabInfo4);
         }
         if (tabInfo5 != null && tabInfo5.RowInfo.Count > 0)
         {
             listObjs.Add(tabInfo5);
         }
         if (tabInfo6 != null && tabInfo6.RowInfo.Count > 0)
         {
             listObjs.Add(tabInfo6);
         }
         if (tabInfo12 != null && tabInfo12.RowInfo.Count > 0)
         {
             listObjs.Add(tabInfo12);
         }
         if (tabInfo7 != null && tabInfo7.RowInfo.Count > 0)
         {
             listObjs.Add(tabInfo7);
         }
         if (tabInfo11 != null && tabInfo11.RowInfo.Count > 0)
         {
             listObjs.Add(tabInfo11);
         }
         if (tabInfo9 != null && tabInfo9.RowInfo.Count > 0)
         {
             listObjs.Add(tabInfo9);
         }
         if (tabInfo10 != null && tabInfo10.RowInfo.Count > 0)
         {
             listObjs.Add(tabInfo10);
         }
         if (tabInfo8 != null && tabInfo8.RowInfo.Count > 0)
         {
             listObjs.Add(tabInfo8);
         }
     }
 }
Example #2
0
        public static int CalculateChangedOutfits(Sim sim, Dictionary <OutfitCategories, List <SimOutfit> > beforeCas)
        {
            int outfitCount = 0;

            //How many parts need to match so we declare it a match
            int kFullPartCount        = 2;
            int kCurrentFullPartCount = kFullPartCount;

            try
            {
                Dictionary <OutfitCategories, List <SimOutfit> > afterCas = ReturnClothingInfo(sim);

                foreach (KeyValuePair <OutfitCategories, List <SimOutfit> > itemBeforeCas in beforeCas)
                {
                    List <ResourceKey> newOutfitsThatMatch = new List <ResourceKey>();

                    if (itemBeforeCas.Key == OutfitCategories.Everyday || itemBeforeCas.Key == OutfitCategories.Formalwear ||
                        itemBeforeCas.Key == OutfitCategories.Sleepwear || itemBeforeCas.Key == OutfitCategories.Athletic ||
                        itemBeforeCas.Key == OutfitCategories.Swimwear || itemBeforeCas.Key == OutfitCategories.Outerwear)
                    {
                        int index      = 0;
                        int matchCount = 0;

                        int numberOfNewOutfits = afterCas[itemBeforeCas.Key].Count;

                        foreach (SimOutfit oldOutfit in itemBeforeCas.Value)
                        {
                            foreach (SimOutfit newOutfit in afterCas[itemBeforeCas.Key])
                            {
                                //Reset values
                                matchCount            = 0;
                                kCurrentFullPartCount = kFullPartCount;

                                for (int i = 0; i < oldOutfit.Parts.Length; i++)
                                {
                                    if (/*oldOutfit.Parts[i].DisplayIndex > 0 && */ (
                                            (oldOutfit.Parts[i].BodyType == BodyTypes.UpperBody) ||
                                            oldOutfit.Parts[i].BodyType == BodyTypes.LowerBody ||
                                            oldOutfit.Parts[i].BodyType == BodyTypes.FullBody))
                                    {
                                        //If full body, there is 1 less part to match
                                        if (oldOutfit.Parts[i].BodyType == BodyTypes.FullBody)
                                        {
                                            kCurrentFullPartCount--;
                                        }

                                        for (int j = 0; j < newOutfit.Parts.Length; j++)
                                        {
                                            if (newOutfit.Parts[j].BodyType == BodyTypes.UpperBody || newOutfit.Parts[j].BodyType == BodyTypes.LowerBody || newOutfit.Parts[j].BodyType == BodyTypes.FullBody)
                                            {
                                                NRaas.CommonSpace.Helpers.CASParts.Wrapper wrapperOld = new NRaas.CommonSpace.Helpers.CASParts.Wrapper(oldOutfit.Parts[i]);
                                                NRaas.CommonSpace.Helpers.CASParts.Wrapper wrapperNew = new NRaas.CommonSpace.Helpers.CASParts.Wrapper(newOutfit.Parts[j]);

                                                if (wrapperNew.mPart.Key == wrapperOld.mPart.Key)
                                                {
                                                    matchCount++;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }

                                //If the outfit is a match
                                if (matchCount >= kCurrentFullPartCount)
                                {
                                    numberOfNewOutfits--;
                                    break;
                                }
                            }
                            //CMShopping.PrintMessage("bare feet: " + barefootOldOutfit + " " + barefootNewOutfit);
                            //CMShopping.PrintMessage(itemBeforeCas.Key.ToString() + ": " + index + ": " + matchCount + " " + kCurrentFullPartCount);

                            index++;
                        }

                        //Number of new outfits
                        outfitCount += numberOfNewOutfits;
                    }
                }
            }
            catch (System.Exception ex)
            {
                CMShopping.PrintMessage(ex.Message);
            }
            if (outfitCount > 0)
            {
                return(outfitCount);
            }
            return(0);
        }