public static SimDescription UnpackSim(MiniSimDescription ths, bool updateGenealogy) { try { if (ths == null) { return(null); } // Calling ImportSimDescription prior to the Aging Manager being available is invalid, don't allow it if (AgingManager.Singleton == null) { return(null); } SimDescription desc = new SimDescription(); ResourceKeyContentCategory installed = ResourceKeyContentCategory.kInstalled; DownloadContent.ImportSimDescription(ths.mTravelKey, desc, ref installed); desc.SimDescriptionId = ths.mSimDescriptionId; if (desc.CareerManager != null) { // Fixup for careers require a household, which is not set until later in this process desc.CareerManager.mJob = null; desc.CareerManager.mSchool = null; } desc.Fixup(); if (updateGenealogy && !GameStates.IsTravelling) { if (desc.DefaultOutfitKey == ResourceKey.kInvalidResourceKey) { SimOutfit outfit = desc.GetOutfit(OutfitCategories.Everyday, 0x0); if ((outfit == null) || (!outfit.IsValid)) { desc.Dispose(false, false); return(null); } desc.UpdateFromOutfit(OutfitCategories.Everyday); } desc.CASGenealogy = ths.CASGenealogy; } Corrections.CleanupBrokenSkills(desc, null); OccultTypeHelper.ValidateOccult(desc, null); return(desc); } catch (Exception e) { Common.Exception(ths.FullName, e); return(null); } }
public Wrapper(CASPart part) { mPart = part; mType = UIUtils.GetCustomContentType(mPart.Key); }
public Wrapper(CASPart part) { mPart = part; mType = UIUtils.GetCustomContentType(mPart.Key); }
public ISimDescription GetSimDescription(ResourceKey key, ref ResourceKeyContentCategory category) { return mCASModel.GetSimDescription(key, ref category); }
public T Get <T>(Common.IStatGenerator stats, string name, TestDelegate <T> test, out int price) where T : class { List <BuildBuyProduct> choices = new List <BuildBuyProduct>(mProducts); RandomUtil.RandomizeListOfObjects(choices); stats.AddStat(name + " Total", choices.Count); foreach (BuildBuyProduct choice in choices) { ResourceKey key = choice.ProductResourceKey; Hashtable overrides = new Hashtable(0x1); IGameObject obj = null; try { obj = GlobalFunctions.CreateObjectInternal(key, overrides, null); } catch (Exception e) { Common.DebugException(key.ToString(), e); continue; } T result = obj as T; if (result == null) { stats.IncStat(name + " Mismatch " + choice.ObjectInstanceName, Common.DebugLevel.High); stats.IncStat(name + " Wrong Type " + obj.GetType().Name, Common.DebugLevel.High); } else if ((test != null) && (!test(result))) { stats.IncStat(name + " Test Fail"); } else { BuildBuyModel model = Sims3.Gameplay.UI.Responder.Instance.BuildBuyModel; List <ResourceKey> presets = new List <ResourceKey>(); uint[] objectPresetIdList = model.GetObjectPresetIdList(obj.ObjectId); for (uint i = 0; i < objectPresetIdList.Length; i++) { ThumbnailKey thumbnail = model.GetObjectProductThumbnailKey(obj.ObjectId, ThumbnailSize.Large); if (thumbnail.mDescKey != ResourceKey.kInvalidResourceKey) { uint id = objectPresetIdList[i]; thumbnail.mDescKey.GroupId = (thumbnail.mDescKey.GroupId & 0xff000000) | (id & 0xffffff); ResourceKeyContentCategory customContentTypeFromKeyAndPresetIndex = UIUtils.GetCustomContentTypeFromKeyAndPresetIndex(model.GetObjectProductKey(obj.ObjectId), i); if (customContentTypeFromKeyAndPresetIndex == ResourceKeyContentCategory.kInstalled) { customContentTypeFromKeyAndPresetIndex = UIUtils.GetCustomContentType(model.GetObjectProductKey(obj.ObjectId)); } string presetString = model.GetPresetString(thumbnail.mDescKey); if (presetString != string.Empty) { KeyValuePair <string, Dictionary <string, Complate> > presetEntryFromPresetString = (KeyValuePair <string, Dictionary <string, Complate> >)SimBuilder.GetPresetEntryFromPresetString(presetString); if ((presetEntryFromPresetString.Value != null) && (presetEntryFromPresetString.Value.Count > 0)) { presets.Add(thumbnail.mDescKey); } } } } if (presets.Count > 0) { ResourceKey preset = RandomUtil.GetRandomObjectFromList(presets); string presetString = model.GetPresetString(preset); if (!string.IsNullOrEmpty(presetString)) { object presetEntryFromPresetString = SimBuilder.GetPresetEntryFromPresetString(presetString); if (presetEntryFromPresetString is KeyValuePair <string, Dictionary <string, Complate> > ) { FinalizePresetTask.Perform(obj.ObjectId, (KeyValuePair <string, Dictionary <string, Complate> >)presetEntryFromPresetString); } } } stats.IncStat(name + " Found"); price = (int)choice.Price; return(result); } obj.Destroy(); } price = 0; return(null); }
private static void PopulateTypesGrid(CASHair ths) { if (ths == null) { return; } ICASModel cASModel = Responder.Instance.CASModel; Color[] colors = new Color[] { new Color(0x0), new Color(0x0), new Color(0x0), new Color(0x0) }; ths.mHairTypesGrid.Clear(); CASPart wornPart = ths.GetWornPart(); ResourceKey resKey = ResourceKey.CreateUILayoutKey("GenericCasItem", 0x0); bool isHat = false; bool flag = false; if (ths.mHairType == CASHair.HairType.Hat) { ths.mHatsShareButton.Enabled = false; ths.mHatsDeleteButton.Enabled = false; ths.mDesignButton.Enabled = CASHair.PartIsHat(wornPart); isHat = true; } bool shouldEnableCatalogProductFilter = false; List <object> objectList = Responder.Instance.StoreUI.GetCASFeaturedStoreItems(BodyTypes.Hair, cASModel.OutfitCategory, (cASModel.Age | cASModel.Species) | cASModel.Gender, isHat); ths.mContentTypeFilter.FilterObjects(objectList, out shouldEnableCatalogProductFilter); if (!MasterController.Settings.mCompactHatCAS) { foreach (object obj2 in objectList) { IFeaturedStoreItem item = obj2 as IFeaturedStoreItem; if ((ths.mHairType == CASHair.HairType.Hat) == (0x0 != (item.CategoryFlags & 0x400000))) { WindowBase windowByExportID = UIManager.LoadLayout(resKey).GetWindowByExportID(0x1); if (windowByExportID != null) { windowByExportID.Tag = item; windowByExportID.GetChildByID(0x23, true); Window childByID = windowByExportID.GetChildByID(0x20, true) as Window; if (childByID != null) { ImageDrawable drawable = childByID.Drawable as ImageDrawable; if (drawable != null) { drawable.Image = UIUtils.GetUIImageFromThumbnailKey(item.ThumbKey); childByID.Invalidate(); } } childByID = windowByExportID.GetChildByID(0x300, true) as Window; childByID.Tag = item; childByID.CreateTooltipCallbackFunction = ths.StoreItemCreateTooltip; childByID.Visible = true; childByID = windowByExportID.GetChildByID(0x303, true) as Window; childByID.Visible = item.IsSale; Button button = windowByExportID.GetChildByID(0x301, true) as Button; button.Caption = item.PriceString; button.Tag = windowByExportID; button.Click += ths.OnBuyButtonClick; button.FocusAcquired += ths.OnBuyButtonFocusAcquired; button.FocusLost += ths.OnBuyButtonFocusLost; ths.mHairTypesGrid.AddItem(new ItemGridCellItem(windowByExportID, item)); } } } } foreach (CASPart part2 in ths.mPartsList) { bool isWardrobePart = Responder.Instance.CASModel.ActiveWardrobeContains(part2); uint num3 = CASUtils.PartDataNumPresets(part2.Key); ResourceKeyContentCategory customContentType = UIUtils.GetCustomContentType(part2.Key); if (!UIUtils.IsContentTypeDisabled(UIUtils.GetCustomContentType(part2.Key))) { ObjectDesigner.SetCASPart(part2.Key); string designPreset = ObjectDesigner.GetDesignPreset(ObjectDesigner.GetDesignPresetIndexFromId(ObjectDesigner.DefaultPresetId)); if (string.IsNullOrEmpty(designPreset)) { ResourceKey key2 = new ResourceKey(part2.Key.InstanceId, 0x333406c, part2.Key.GroupId); designPreset = Simulator.LoadXMLString(key2); } CASPartPreset preset = new CASPartPreset(part2, designPreset); string str2 = ""; string str3 = ""; if (wornPart.Key == preset.mPart.Key) { str2 = Responder.Instance.CASModel.GetDesignPreset(wornPart); str3 = CASUtils.ReplaceHairColors(str2, colors); } if (preset.Valid && ((ths.mHairType == CASHair.HairType.Hair) || (ObjectDesigner.DefaultPresetId == uint.MaxValue))) { ths.AddHairTypeGridItem(ths.mHairTypesGrid, resKey, preset, isWardrobePart, ref shouldEnableCatalogProductFilter); if ((preset.mPart.Key == wornPart.Key) && ((ths.mHairType == CASHair.HairType.Hair) || CASUtils.DesignPresetCompare(str2, designPreset))) { ths.mHairTypesGrid.SelectedItem = ths.mHairTypesGrid.Count - 1; flag = true; } } if (ths.mHairType == CASHair.HairType.Hat) { if (MasterController.Settings.mCompactHatCAS) { num3 = 1; } for (int i = 0x0; i < num3; i++) { uint presetId = CASUtils.PartDataGetPresetId(part2.Key, (uint)i); customContentType = UIUtils.GetCustomContentType(part2.Key, presetId); preset = new CASPartPreset(part2, presetId, CASUtils.PartDataGetPreset(part2.Key, (uint)i)); if (preset.Valid) { bool flag4 = ths.AddHairTypeGridItem(ths.mHairTypesGrid, resKey, preset, isWardrobePart, ref shouldEnableCatalogProductFilter); if ((wornPart.Key == preset.mPart.Key) && CASUtils.DesignPresetCompare(str3, CASUtils.ReplaceHairColors(preset.mPresetString, colors))) { ths.mSavedPresetId = preset.mPresetId; flag = true; if (flag4) { ths.mHairTypesGrid.SelectedItem = ths.mHairTypesGrid.Count - 1; if (ObjectDesigner.IsUserDesignPreset((uint)i)) { ths.mHatsShareButton.Enabled = true; ths.mHatsDeleteButton.Enabled = true; } } } } } } } } ths.mHairTypesGrid.Tag = shouldEnableCatalogProductFilter; if (ths.mHairStylesGrid.Tag == null) { ths.mHairStylesGrid.Tag = false; } ths.mSortButton.Tag = ((bool)ths.mHairTypesGrid.Tag) ? (true) : (bool)ths.mHairStylesGrid.Tag; if (flag) { ths.mSaveButton.Enabled = false; } else if ((ths.mHairType == CASHair.HairType.Hat) && CASHair.PartIsHat(wornPart)) { WindowBase win = UIManager.LoadLayout(resKey).GetWindowByExportID(0x1); if (win != null) { Window window2 = win.GetChildByID(0x20, true) as Window; if (window2 != null) { window2.Visible = false; } window2 = win.GetChildByID(0x24, true) as Window; if (window2 != null) { window2.Visible = true; } ths.mHairTypesGrid.AddTempItem(new ItemGridCellItem(win, null)); } ths.mSaveButton.Enabled = true; } ths.mUndoOnDelete = false; ths.mContentTypeFilter.UpdateFilterButtonState(); }
private void AddPresetGridItem(CASPartPreset preset, Vector3[] colors, ResourceKeyContentCategory contentType) { WindowBase windowByExportID = UIManager.LoadLayout(ResourceKey.CreateUILayoutKey("CASTattooColorGridItem", 0x0)).GetWindowByExportID(0x1); if (windowByExportID != null) { WindowBase childByID = windowByExportID.GetChildByID(0x20, true); int length = colors.Length; for (int i = 0x0; i < 0x4; i++) { WindowBase base4 = childByID.GetChildByID((uint) (0x30 + i), false); if (i < length) { base4.Visible = true; Color color = CompositorUtil.Vector3ToColor(colors[i]); color.Alpha = 0xff; base4.ShadeColor = color; } else { base4.Visible = false; } } CustomContentIcon icon = windowByExportID.GetChildByID(0x23, true) as CustomContentIcon; icon.ContentType = contentType; this.mTattooPresetsGrid.AddItem(new ItemGridCellItem(windowByExportID, preset)); } }
private bool AddPartsGridItem(ItemGrid catalog, ResourceKey layoutKey, CASPart part, ResourceKeyContentCategory contentType) { WindowBase windowByExportID = UIManager.LoadLayout(layoutKey).GetWindowByExportID(0x1); if (windowByExportID == null) { return false; } if (part.Key != this.kInvalidCASPart.Key) { Window childByID = windowByExportID.GetChildByID(0x20, true) as Window; if (childByID != null) { ImageDrawable drawable = childByID.Drawable as ImageDrawable; if (drawable != null) { ThumbnailKey key = new ThumbnailKey(part.Key, (int) CASUtils.PartDataGetPresetId(part.Key, 0x0), (uint) part.BodyType, (uint) part.AgeGenderSpecies, ThumbnailSize.Large); drawable.Image = UIManager.GetCASThumbnailImage(key); childByID.Invalidate(); } } CustomContentIcon icon = windowByExportID.GetChildByID(0x23, true) as CustomContentIcon; if (UIUtils.IsContentTypeDisabled(contentType)) { return false; } if (UIUtils.IsCustomFiltered(contentType)) { this.mFilterButton.Enabled = true; } else if (this.mFilter) { return false; } icon.ContentType = contentType; windowByExportID.TooltipText = this.GetPartName(part); if (Responder.Instance.CASModel.ActiveWardrobeContains(part)) { WindowBase base3 = windowByExportID.GetChildByID(0x29, true); if (base3 != null) { base3.Visible = true; } } } catalog.AddItem(new ItemGridCellItem(windowByExportID, part)); return true; }