public void GetAssetsListByCategoryCorrectly() { // Arrange string testCategoryA = "test category A"; string testCategoryB = "test category B"; CatalogItemPack testDceneAssetPack = new CatalogItemPack { assets = new List <CatalogItem> { new CatalogItem { id = "testItemId1", categoryName = testCategoryA }, new CatalogItem { id = "testItemId2", categoryName = testCategoryA }, new CatalogItem { id = "testItemId3", categoryName = testCategoryB } } }; // Act List <CatalogItem> result = sceneCatalogController.GetAssetsListByCategory(testCategoryA, testDceneAssetPack); // Assert Assert.AreEqual(2, result.Count(x => x.categoryName == testCategoryA), "The number of returned catalog items does not match!"); Assert.AreEqual(0, result.Count(x => x.categoryName == testCategoryB), "The number of returned catalog items does not match!"); }
public static List <CatalogItemPack> GetCatalogItemPacksFilteredByCategories() { var assetPacks = DataStore.i.dataStoreBuilderInWorld.catalogItemPackDict.GetValues(); Dictionary <string, CatalogItemPack> assetPackDic = new Dictionary <string, CatalogItemPack>(); if (DataStore.i.dataStoreBuilderInWorld.catalogItemPackDict.ContainsKey(BIWSettings.ASSETS_COLLECTIBLES)) { assetPackDic.Add(BIWSettings.ASSETS_COLLECTIBLES, DataStore.i.dataStoreBuilderInWorld.catalogItemPackDict[BIWSettings.ASSETS_COLLECTIBLES]); } else { CreateNewCollectiblePack(); } foreach (CatalogItemPack catalogAssetPack in assetPacks) { foreach (CatalogItem catalogItem in catalogAssetPack.assets) { if (catalogItem.IsNFT()) { continue; } if (!assetPackDic.ContainsKey(catalogItem.category)) { CatalogItemPack categoryAssetPack = new CatalogItemPack(); categoryAssetPack.SetThumbnailULR(catalogItem.thumbnailURL); categoryAssetPack.title = catalogItem.category; categoryAssetPack.assets = new List <CatalogItem>(); catalogItem.categoryName = catalogAssetPack.title; categoryAssetPack.assets.Add(catalogItem); if (!string.IsNullOrEmpty(categoryAssetPack.title)) { if (categoryAssetPack.title.Length == 1) { categoryAssetPack.title = categoryAssetPack.title.ToUpper(); } else { categoryAssetPack.title = char.ToUpper(categoryAssetPack.title[0]) + categoryAssetPack.title.Substring(1); } } assetPackDic.Add(catalogItem.category, categoryAssetPack); continue; } else { catalogItem.categoryName = catalogAssetPack.title; assetPackDic[catalogItem.category].assets.Add(catalogItem); } } } return(assetPackDic.Values.OrderBy(x => x.title).ToList()); }
public static void AddSceneAssetPack(SceneAssetPack sceneAssetPack) { if (DataStore.i.builderInWorld.catalogItemPackDict.ContainsKey(sceneAssetPack.id)) { return; } CatalogItemPack catalogItemPack = CreateCatalogItemPack(sceneAssetPack); DataStore.i.builderInWorld.catalogItemPackDict.Add(catalogItemPack.id, catalogItemPack); }
private static CatalogItemPack CreateNewCollectiblePack() { CatalogItemPack collectiblesItemPack = new CatalogItemPack(); collectiblesItemPack.id = BIWSettings.ASSETS_COLLECTIBLES; collectiblesItemPack.title = BIWSettings.ASSETS_COLLECTIBLES; collectiblesItemPack.assets = new List <CatalogItem>(); if (!DataStore.i.dataStoreBuilderInWorld.catalogItemPackDict.ContainsKey(collectiblesItemPack.id)) { DataStore.i.dataStoreBuilderInWorld.catalogItemPackDict.Add(collectiblesItemPack.id, collectiblesItemPack); } return(collectiblesItemPack); }
internal List <CatalogItem> GetAssetsListByCategory(string category, CatalogItemPack sceneAssetPack) { List <CatalogItem> catalogItemList = new List <CatalogItem>(); foreach (CatalogItem catalogItem in sceneAssetPack.assets) { if (category == catalogItem.categoryName) { catalogItemList.Add(catalogItem); } } return(catalogItemList); }
public void SetContent(CatalogItemPack catalogItemPack) { this.catalogItemPack = catalogItemPack; titleTxt.text = this.catalogItemPack.title; if (catalogItemPack.id != BIWSettings.ASSETS_COLLECTIBLES) { GetThumbnail(); } else { packImg.enabled = true; packImg.texture = collectiblesSprite; } }
public static void AddSceneAssetPack(SceneAssetPack sceneAssetPack) { if (DataStore.i.builderInWorld.catalogItemPackDict.ContainsKey(sceneAssetPack.id)) { return; } CatalogItemPack catalogItemPack = CreateCatalogItemPack(sceneAssetPack); //TODO: SmartItems disabled until kernel has them implemented if (catalogItemPack.assets.Count != 0) { DataStore.i.builderInWorld.catalogItemPackDict.Add(catalogItemPack.id, catalogItemPack); } }
public static CatalogItemPack CreateCatalogItemPack(SceneAssetPack sceneAssetPack) { CatalogItemPack catalogItemPack = new CatalogItemPack(); catalogItemPack.id = sceneAssetPack.id; catalogItemPack.title = sceneAssetPack.title; catalogItemPack.assets = new List <CatalogItem>(); catalogItemPack.SetThumbnailULR(sceneAssetPack.ComposeThumbnailUrl()); foreach (SceneObject sceneObject in sceneAssetPack.assets) { catalogItemPack.assets.Add(CreateCatalogItem(sceneObject)); } return(catalogItemPack); }
public static List <CatalogItemPack> GetCatalogItemPacksFilteredByCategories() { var assetPacks = DataStore.i.builderInWorld.catalogItemPackDict.GetValues(); Dictionary <string, CatalogItemPack> assetPackDic = new Dictionary <string, CatalogItemPack>(); foreach (CatalogItemPack catalogAssetPack in assetPacks) { foreach (CatalogItem catalogItem in catalogAssetPack.assets) { if (!assetPackDic.ContainsKey(catalogItem.category)) { CatalogItemPack categoryAssetPack = new CatalogItemPack(); categoryAssetPack.SetThumbnailULR(catalogItem.thumbnailURL); categoryAssetPack.title = catalogItem.category; categoryAssetPack.assets = new List <CatalogItem>(); catalogItem.categoryName = catalogAssetPack.title; categoryAssetPack.assets.Add(catalogItem); if (!string.IsNullOrEmpty(categoryAssetPack.title)) { if (categoryAssetPack.title.Length == 1) { categoryAssetPack.title = categoryAssetPack.title.ToUpper(); } else { categoryAssetPack.title = char.ToUpper(categoryAssetPack.title[0]) + categoryAssetPack.title.Substring(1); } } assetPackDic.Add(catalogItem.category, categoryAssetPack); continue; } else { catalogItem.categoryName = catalogAssetPack.title; assetPackDic[catalogItem.category].assets.Add(catalogItem); } } } return(assetPackDic.Values.ToList()); }
public static void ConvertCollectiblesPack(List <NFTInfo> nftList) { if (nftList == null) { return; } CatalogItemPack collectiblesItemPack; if (!DataStore.i.builderInWorld.catalogItemPackDict.ContainsKey(BuilderInWorldSettings.ASSETS_COLLECTIBLES)) { collectiblesItemPack = new CatalogItemPack(); collectiblesItemPack.id = BuilderInWorldSettings.ASSETS_COLLECTIBLES; collectiblesItemPack.title = BuilderInWorldSettings.ASSETS_COLLECTIBLES; collectiblesItemPack.assets = new List <CatalogItem>(); DataStore.i.builderInWorld.catalogItemPackDict.Add(collectiblesItemPack.id, collectiblesItemPack); } else { collectiblesItemPack = DataStore.i.builderInWorld.catalogItemPackDict[BuilderInWorldSettings.ASSETS_COLLECTIBLES]; foreach (CatalogItem catalogItem in collectiblesItemPack.assets) { if (DataStore.i.builderInWorld.catalogItemDict.ContainsKey(catalogItem.id)) { DataStore.i.builderInWorld.catalogItemDict.Remove(catalogItem.id); } } collectiblesItemPack.assets.Clear(); } foreach (NFTInfo info in nftList) { CatalogItem catalogItem = CreateCatalogItem(info); if (!DataStore.i.builderInWorld.catalogItemDict.ContainsKey(catalogItem.id)) { DataStore.i.builderInWorld.catalogItemDict.Add(catalogItem.id, catalogItem); } collectiblesItemPack.assets.Add(catalogItem); } }
internal void SetCatalogAssetPackInListView(CatalogItemPack catalogItemPack) { sceneCatalogView.SetCatalogTitle(catalogItemPack.title); Dictionary <string, List <CatalogItem> > groupedCatalogItem = new Dictionary <string, List <CatalogItem> >(); foreach (CatalogItem sceneObject in catalogItemPack.assets) { string titleToUse = sceneObject.categoryName; if (!groupedCatalogItem.ContainsKey(titleToUse)) { groupedCatalogItem.Add(titleToUse, GetAssetsListByCategory(titleToUse, catalogItemPack)); } } List <Dictionary <string, List <CatalogItem> > > contentList = new List <Dictionary <string, List <CatalogItem> > > { groupedCatalogItem }; sceneCatalogView.catalogGroupList.SetContent(contentList); }
public static CatalogItemPack CreateCatalogItemPack(SceneAssetPack sceneAssetPack) { CatalogItemPack catalogItemPack = new CatalogItemPack(); catalogItemPack.id = sceneAssetPack.id; catalogItemPack.title = sceneAssetPack.title; catalogItemPack.assets = new List <CatalogItem>(); catalogItemPack.SetThumbnailULR(sceneAssetPack.ComposeThumbnailUrl()); foreach (SceneObject sceneObject in sceneAssetPack.assets) { //TODO: SmartItems disabled until kernel has them implemented if (!sceneObject.IsSmartItem()) { catalogItemPack.assets.Add(CreateCatalogItem(sceneObject)); } } return(catalogItemPack); }
public void OnCatalogItemPackSelected(CatalogItemPack catalogItemPack) { ShowCatalogContent(); SetCatalogAssetPackInListView(catalogItemPack); sceneCatalogView.ShowBackButton(true); }
public void OnCatalogItemPackSelected(CatalogItemPack catalogItemPack) { ShowCatalogContent(); SetCatalogAssetPackInListView(catalogItemPack); }