| | 1 | | using DCL.Configuration; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | public class CatalogAssetPackListView : ListView<CatalogItemPack> |
| | 5 | | { |
| | 6 | | public GameObject categoryListView; |
| | 7 | | public GameObject assetPackListView; |
| | 8 | | public DynamicScrollSensitivity dynamicScrollSensitivity; |
| | 9 | |
|
| | 10 | | public Transform categoryContentTransform; |
| | 11 | | public CatalogAssetPackAdapter categoryAssetPackItemAdapterPrefab; |
| | 12 | | public CatalogAssetPackAdapter catalogAssetPackItemAdapterPrefab; |
| | 13 | | public System.Action<CatalogItemPack> OnCatalogPackClick; |
| | 14 | |
|
| 36 | 15 | | bool useAssetPackStyle = true; |
| | 16 | |
|
| | 17 | | public override void AddAdapters() |
| | 18 | | { |
| 0 | 19 | | base.AddAdapters(); |
| | 20 | |
|
| 0 | 21 | | Transform transformToUse = contentPanelTransform; |
| 0 | 22 | | CatalogAssetPackAdapter prefabToUse = catalogAssetPackItemAdapterPrefab; |
| | 23 | |
|
| 0 | 24 | | if (!useAssetPackStyle) |
| | 25 | | { |
| 0 | 26 | | transformToUse = categoryContentTransform; |
| 0 | 27 | | prefabToUse = categoryAssetPackItemAdapterPrefab; |
| 0 | 28 | | categoryListView.SetActive(true); |
| 0 | 29 | | assetPackListView.SetActive(false); |
| 0 | 30 | | } |
| | 31 | | else |
| | 32 | | { |
| 0 | 33 | | categoryListView.SetActive(false); |
| 0 | 34 | | assetPackListView.SetActive(true); |
| | 35 | | } |
| | 36 | |
|
| 0 | 37 | | if (contentPanelTransform == null) |
| 0 | 38 | | return; |
| | 39 | |
|
| 0 | 40 | | foreach (CatalogItemPack catalogItemPack in contentList) |
| | 41 | | { |
| | 42 | | //TODO: SmartItems This quit all the smart items from the catalog |
| 0 | 43 | | if (catalogItemPack.id == BIWSettings.SMART_ITEM_ASSETS_PACK_ID) |
| | 44 | | continue; |
| | 45 | |
|
| 0 | 46 | | CatalogAssetPackAdapter adapter = Instantiate(prefabToUse, transformToUse).GetComponent<CatalogAssetPackAdap |
| 0 | 47 | | adapter.SetContent(catalogItemPack); |
| 0 | 48 | | adapter.OnCatalogItemPackClick += SceneAssetPackClick; |
| | 49 | | } |
| | 50 | |
|
| 0 | 51 | | if (dynamicScrollSensitivity != null) |
| 0 | 52 | | dynamicScrollSensitivity.RecalculateSensitivity(); |
| | 53 | |
|
| 0 | 54 | | AudioScriptableObjects.listItemAppear.ResetPitch(); |
| 0 | 55 | | } |
| | 56 | |
|
| | 57 | | public override void RemoveAdapters() |
| | 58 | | { |
| 0 | 59 | | Transform transformToUse = contentPanelTransform; |
| 0 | 60 | | if (!useAssetPackStyle) |
| 0 | 61 | | transformToUse = categoryContentTransform; |
| | 62 | |
|
| 0 | 63 | | for (int i = 0; i < transformToUse.childCount; i++) |
| | 64 | | { |
| 0 | 65 | | GameObject toRemove = transformToUse.GetChild(i).gameObject; |
| 0 | 66 | | Destroy(toRemove); |
| | 67 | | } |
| | 68 | |
|
| 0 | 69 | | if (dynamicScrollSensitivity != null) |
| 0 | 70 | | dynamicScrollSensitivity.RecalculateSensitivity(); |
| 0 | 71 | | } |
| | 72 | |
|
| 0 | 73 | | public void SetCategoryStyle() { useAssetPackStyle = false; } |
| | 74 | |
|
| 0 | 75 | | public void SetAssetPackStyle() { useAssetPackStyle = true; } |
| | 76 | |
|
| 0 | 77 | | void SceneAssetPackClick(CatalogItemPack sceneAssetPack) { OnCatalogPackClick?.Invoke(sceneAssetPack); } |
| | 78 | | } |