| | 1 | | using DCLServices.Lambdas.LandsService; |
| | 2 | | using DCLServices.Lambdas.NamesService; |
| | 3 | | using System; |
| | 4 | | using System.Collections.Generic; |
| | 5 | | using System.Linq; |
| | 6 | | using System.Text.RegularExpressions; |
| | 7 | | using TMPro; |
| | 8 | | using UnityEngine; |
| | 9 | | using UnityEngine.UI; |
| | 10 | |
|
| | 11 | | namespace DCL.Social.Passports |
| | 12 | | { |
| | 13 | | public class PassportNavigationComponentView : BaseComponentView, IPassportNavigationComponentView |
| | 14 | | { |
| | 15 | | private const string GUEST_TEXT = "is a guest"; |
| | 16 | | private const string BLOCKED_TEXT = "blocked you!"; |
| | 17 | | private const string LINKS_REGEX = @"\[(.*?)\)"; |
| | 18 | | private const string LINK_TITLE_REGEX = @"(?<=\[).+?(?=\])"; |
| | 19 | | private const string LINK_REGEX = @"(?<=\().+?(?=\))"; |
| | 20 | | private const string OWN_PLAYER = "\n You don't "; |
| | 21 | | private const string OTHER_PLAYERS = "\n This person doesn't "; |
| | 22 | | private const string NO_WEARABLES_TEXT = "own any Wearables yet."; |
| | 23 | | private const string NO_EMOTES_TEXT = "own any Emotes yet."; |
| | 24 | | private const string NO_NAMES_TEXT = "own any NAMEs yet."; |
| | 25 | | private const string NO_LANDS_TEXT = "own any LANDs yet."; |
| | 26 | | private const string NAME_TYPE = "name"; |
| | 27 | | private const string EMOTE_TYPE = "emote"; |
| | 28 | | private const string LEGENDARY_RARITY = "legendary"; |
| | 29 | | private const string LAND_RARITY = "land"; |
| | 30 | | private const int PAGE_SIZE = 4; |
| | 31 | |
|
| | 32 | | [SerializeField] private GameObject aboutPanel; |
| | 33 | | [SerializeField] private GameObject wearablesPanel; |
| | 34 | | [SerializeField] private Toggle aboutToggle; |
| | 35 | | [SerializeField] private Toggle collectiblesToggle; |
| | 36 | | [SerializeField] private GameObject guestPanel; |
| | 37 | | [SerializeField] private GameObject normalPanel; |
| | 38 | | [SerializeField] private GameObject hasBlockedPanel; |
| | 39 | | [SerializeField] private Transform equippedWearablesContainer; |
| | 40 | | [SerializeField] private TextMeshProUGUI usernameText; |
| | 41 | | [SerializeField] private TextMeshProUGUI blockedUsernameText; |
| | 42 | | [SerializeField] private TextMeshProUGUI descriptionText; |
| | 43 | | [SerializeField] private GameObject emptyDescriptionGO; |
| | 44 | | [SerializeField] private CarouselComponentView nftWearablesCarousel; |
| | 45 | | [SerializeField] private TMP_Text emptyWearablesText; |
| | 46 | | [SerializeField] private GameObject nftWearablesLoadingSpinner; |
| | 47 | | [SerializeField] private CarouselComponentView nftEmotesCarousel; |
| | 48 | | [SerializeField] private TMP_Text emptyEmotesText; |
| | 49 | | [SerializeField] private GameObject nftEmotesLoadingSpinner; |
| | 50 | | [SerializeField] private CarouselComponentView nftNamesCarousel; |
| | 51 | | [SerializeField] private TMP_Text emptyNamesText; |
| | 52 | | [SerializeField] private GameObject nftNamesLoadingSpinner; |
| | 53 | | [SerializeField] private CarouselComponentView nftLandsCarousel; |
| | 54 | | [SerializeField] private TMP_Text emptyLandsText; |
| | 55 | | [SerializeField] private GameObject nftLandsLoadingSpinner; |
| | 56 | | [SerializeField] private Transform nftWearablesCarouselContent; |
| | 57 | | [SerializeField] private Transform nftEmotesCarouselContent; |
| | 58 | | [SerializeField] private Transform nftNamesCarouselContent; |
| | 59 | | [SerializeField] private Transform nftLandsCarouselContent; |
| | 60 | | [SerializeField] private GameObject wearableUIReferenceObject; |
| | 61 | | [SerializeField] private GameObject nftPageUIReferenceObject; |
| | 62 | | [SerializeField] private GameObject linksContainer; |
| | 63 | | [SerializeField] private GameObject linksTitle; |
| | 64 | | [SerializeField] private GameObject linkPrefabReference; |
| | 65 | | [SerializeField] private GameObject aboutToggleOn; |
| | 66 | | [SerializeField] private GameObject aboutToggleOff; |
| | 67 | | [SerializeField] private GameObject collectiblesToggleOn; |
| | 68 | | [SerializeField] private GameObject collectiblesToggleOff; |
| | 69 | | [SerializeField] private TMP_Text aboutText; |
| | 70 | | [SerializeField] private TMP_Text collectiblesText; |
| | 71 | | [SerializeField] private OpenUrlView openUrlView; |
| | 72 | | [SerializeField] internal NFTItemInfo nftItemInfo; |
| | 73 | | [SerializeField] internal ScrollRect nftWearablesScrollRect; |
| | 74 | | [SerializeField] internal ScrollRect nftEmotesScrollRect; |
| | 75 | | [SerializeField] internal ScrollRect nftNamesScrollRect; |
| | 76 | | [SerializeField] internal ScrollRect nftLandsScrollRect; |
| | 77 | | [SerializeField] internal ScrollRect collectiblesMainScrollRect; |
| | 78 | |
|
| 1 | 79 | | private static readonly Vector3 NFT_ICON_SCALE = new Vector3(0.75f, 0.75f, 0.75f); |
| | 80 | | public event Action<string, string> OnClickBuyNft; |
| | 81 | | public event Action OnClickedLink; |
| | 82 | | public event Action OnClickCollectibles; |
| | 83 | |
|
| | 84 | | private const string NFT_ICON_POOL_NAME_PREFIX = "NFTIconsEntriesPool_"; |
| | 85 | | private const string NFT_PAGES_POOL_NAME_PREFIX = "NFTPagesEntriesPool_"; |
| | 86 | | private const int MAX_NFT_ICON_ENTRIES = 20; |
| | 87 | | private const int MAX_NFT_PAGES_ENTRIES = 20; |
| | 88 | |
|
| 1 | 89 | | private List<PoolableObject> nftIconPoolableQueue = new List<PoolableObject>(); |
| 1 | 90 | | private List<PoolableObject> nftPagesPoolableQueue = new List<PoolableObject>(); |
| | 91 | | private Pool nftIconsEntryPool; |
| | 92 | | private Pool nftPagesEntryPool; |
| 1 | 93 | | private readonly List<NFTIconComponentView> equippedNftWearableViews = new List<NFTIconComponentView>(); |
| 1 | 94 | | private readonly List<NftPageView> ownedNftWearablePageViews = new List<NftPageView>(); |
| 1 | 95 | | private readonly List<NftPageView> ownedNftEmotePageViews = new List<NftPageView>(); |
| | 96 | |
|
| | 97 | | public override void Start() |
| | 98 | | { |
| 0 | 99 | | collectiblesToggle.isOn = false; |
| 0 | 100 | | aboutToggle.isOn = true; |
| 0 | 101 | | aboutToggle.onValueChanged.AddListener(EnableAboutSection); |
| 0 | 102 | | collectiblesToggle.onValueChanged.AddListener(EnableCollectiblesSection); |
| 0 | 103 | | nftWearablesScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos()); |
| 0 | 104 | | nftEmotesScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos()); |
| 0 | 105 | | nftNamesScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos()); |
| 0 | 106 | | nftLandsScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos()); |
| 0 | 107 | | collectiblesMainScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos()); |
| 0 | 108 | | } |
| | 109 | |
|
| | 110 | | private void EnableAboutSection(bool isActive) |
| | 111 | | { |
| 0 | 112 | | aboutPanel.SetActive(isActive); |
| 0 | 113 | | aboutText.color = Color.white; |
| 0 | 114 | | collectiblesText.color = Color.black; |
| 0 | 115 | | aboutToggleOn.SetActive(true); |
| 0 | 116 | | aboutToggleOff.SetActive(false); |
| 0 | 117 | | collectiblesToggleOn.SetActive(false); |
| 0 | 118 | | collectiblesToggleOff.SetActive(true); |
| 0 | 119 | | CloseAllNFTItemInfos(); |
| 0 | 120 | | } |
| | 121 | |
|
| | 122 | | private void EnableCollectiblesSection(bool isActive) |
| | 123 | | { |
| 0 | 124 | | OnClickCollectibles?.Invoke(); |
| 0 | 125 | | wearablesPanel.SetActive(isActive); |
| 0 | 126 | | aboutText.color = Color.black; |
| 0 | 127 | | collectiblesText.color = Color.white; |
| 0 | 128 | | aboutToggleOn.SetActive(false); |
| 0 | 129 | | aboutToggleOff.SetActive(true); |
| 0 | 130 | | collectiblesToggleOn.SetActive(true); |
| 0 | 131 | | collectiblesToggleOff.SetActive(false); |
| 0 | 132 | | nftWearablesCarousel.ResetManualCarousel(); |
| 0 | 133 | | nftEmotesCarousel.ResetManualCarousel(); |
| 0 | 134 | | nftNamesCarousel.ResetManualCarousel(); |
| 0 | 135 | | nftLandsCarousel.ResetManualCarousel(); |
| 0 | 136 | | CloseAllNFTItemInfos(); |
| 0 | 137 | | } |
| | 138 | |
|
| | 139 | | public void InitializeView() |
| | 140 | | { |
| 0 | 141 | | nftPagesEntryPool = GetNftPagesEntryPool(); |
| 0 | 142 | | nftIconsEntryPool = GetNftIconEntryPool(); |
| 0 | 143 | | CleanWearables(); |
| 0 | 144 | | CleanEquippedWearables(); |
| 0 | 145 | | SetInitialPage(); |
| 0 | 146 | | } |
| | 147 | |
|
| | 148 | | public void SetGuestUser(bool isGuest) |
| | 149 | | { |
| 0 | 150 | | guestPanel.SetActive(isGuest); |
| 0 | 151 | | normalPanel.SetActive(!isGuest); |
| 0 | 152 | | hasBlockedPanel.SetActive(false); |
| 0 | 153 | | } |
| | 154 | |
|
| | 155 | | public void SetName(string username) |
| | 156 | | { |
| 0 | 157 | | usernameText.text = $"{username} {GUEST_TEXT}"; |
| 0 | 158 | | blockedUsernameText.text = $"{username} {BLOCKED_TEXT}"; |
| 0 | 159 | | } |
| | 160 | |
|
| | 161 | | public void SetOwnUserTexts(bool isOwnUser) |
| | 162 | | { |
| 0 | 163 | | string prefix = isOwnUser ? OWN_PLAYER : OTHER_PLAYERS; |
| 0 | 164 | | emptyWearablesText.text = $"{prefix}{NO_WEARABLES_TEXT}"; |
| 0 | 165 | | emptyEmotesText.text = $"{prefix}{NO_EMOTES_TEXT}"; |
| 0 | 166 | | emptyNamesText.text = $"{prefix}{NO_NAMES_TEXT}"; |
| 0 | 167 | | emptyLandsText.text = $"{prefix}{NO_LANDS_TEXT}"; |
| 0 | 168 | | } |
| | 169 | |
|
| | 170 | | public void SetDescription(string description) |
| | 171 | | { |
| 0 | 172 | | MatchCollection matchCollection = Regex.Matches(description, LINKS_REGEX, RegexOptions.IgnoreCase); |
| 0 | 173 | | List<string> links = new List<string>(); |
| | 174 | |
|
| 0 | 175 | | foreach (Match link in matchCollection) |
| | 176 | | { |
| 0 | 177 | | description = description.Replace(link.Value, ""); |
| 0 | 178 | | links.Add(link.Value); |
| | 179 | | } |
| | 180 | |
|
| 0 | 181 | | linksTitle.SetActive(links.Count > 0); |
| 0 | 182 | | linksContainer.SetActive(links.Count > 0); |
| | 183 | |
|
| 0 | 184 | | if (string.IsNullOrEmpty(description)) |
| | 185 | | { |
| 0 | 186 | | emptyDescriptionGO.SetActive(true); |
| 0 | 187 | | descriptionText.gameObject.SetActive(false); |
| | 188 | | } |
| | 189 | | else |
| | 190 | | { |
| 0 | 191 | | emptyDescriptionGO.SetActive(false); |
| 0 | 192 | | descriptionText.gameObject.SetActive(true); |
| 0 | 193 | | descriptionText.text = description; |
| | 194 | | } |
| | 195 | |
|
| 0 | 196 | | SetLinks(links); |
| 0 | 197 | | } |
| | 198 | |
|
| | 199 | | private void SetLinks(List<string> links) |
| | 200 | | { |
| 0 | 201 | | foreach (Transform child in linksContainer.transform) { Destroy(child.gameObject); } |
| | 202 | |
|
| 0 | 203 | | foreach (string link in links) |
| | 204 | | { |
| 0 | 205 | | PassportLinkView newLink = Instantiate(linkPrefabReference, linksContainer.transform).GetComponent<Passp |
| 0 | 206 | | newLink.OnClickLink -= ClickedLink; |
| 0 | 207 | | newLink.SetLinkTitle(Regex.Matches(link, LINK_TITLE_REGEX, RegexOptions.IgnoreCase)[0].Value); |
| 0 | 208 | | newLink.SetLink(Regex.Matches(link, LINK_REGEX, RegexOptions.IgnoreCase)[0].Value); |
| 0 | 209 | | newLink.OnClickLink += ClickedLink; |
| | 210 | | } |
| 0 | 211 | | } |
| | 212 | |
|
| | 213 | | private void ClickedLink(string obj) |
| | 214 | | { |
| 0 | 215 | | openUrlView.SetUrlInfo(obj, obj); |
| 0 | 216 | | openUrlView.SetVisibility(true); |
| 0 | 217 | | OnClickedLink?.Invoke(); |
| 0 | 218 | | } |
| | 219 | |
|
| | 220 | | public void SetEquippedWearables(WearableItem[] wearables, string bodyShapeId) |
| | 221 | | { |
| 0 | 222 | | HashSet<string> hidesList = WearableItem.ComposeHiddenCategories(bodyShapeId, wearables.ToList()); |
| | 223 | |
|
| 0 | 224 | | equippedNftWearableViews.Clear(); |
| | 225 | |
|
| 0 | 226 | | foreach (var wearable in wearables) |
| | 227 | | { |
| 0 | 228 | | if (!hidesList.Contains(wearable.data.category)) |
| | 229 | | { |
| 0 | 230 | | PoolableObject poolableObject = nftIconsEntryPool.Get(); |
| 0 | 231 | | nftIconPoolableQueue.Add(poolableObject); |
| 0 | 232 | | poolableObject.gameObject.transform.SetParent(equippedWearablesContainer, false); |
| 0 | 233 | | poolableObject.gameObject.transform.localScale = NFT_ICON_SCALE; |
| 0 | 234 | | NFTIconComponentView nftIconComponentView = poolableObject.gameObject.GetComponent<NFTIconComponentV |
| 0 | 235 | | nftIconComponentView.onMarketplaceButtonClick.RemoveAllListeners(); |
| 0 | 236 | | nftIconComponentView.onDetailInfoButtonClick.RemoveAllListeners(); |
| 0 | 237 | | nftIconComponentView.onFocused -= FocusEquippedNftItem; |
| 0 | 238 | | nftIconComponentView.onMarketplaceButtonClick.AddListener(() => ClickOnBuyWearable(wearable.id, wear |
| 0 | 239 | | nftIconComponentView.onDetailInfoButtonClick.AddListener(() => nftIconComponentView.SetNFTItemInfoAc |
| 0 | 240 | | nftIconComponentView.onFocused += FocusEquippedNftItem; |
| | 241 | |
|
| 0 | 242 | | NFTIconComponentModel nftModel = new NFTIconComponentModel() |
| | 243 | | { |
| | 244 | | showMarketplaceButton = wearable.IsCollectible(), |
| | 245 | | showType = wearable.IsCollectible(), |
| | 246 | | type = wearable.data.category, |
| | 247 | | marketplaceURI = "", |
| | 248 | | name = wearable.GetName(), |
| | 249 | | rarity = wearable.rarity, |
| | 250 | | imageURI = wearable.ComposeThumbnailUrl() |
| | 251 | | }; |
| | 252 | |
|
| 0 | 253 | | nftIconComponentView.Configure(nftModel); |
| 0 | 254 | | nftIconComponentView.ConfigureNFTItemInfo(nftItemInfo, wearable, true); |
| 0 | 255 | | equippedNftWearableViews.Add(nftIconComponentView); |
| | 256 | | } |
| | 257 | | } |
| 0 | 258 | | } |
| | 259 | |
|
| | 260 | | public void SetCollectibleWearables(WearableItem[] wearables) |
| | 261 | | { |
| 0 | 262 | | nftWearablesCarousel.gameObject.SetActive(wearables.Length > 0); |
| 0 | 263 | | nftWearablesCarousel.CleanInstantiatedItems(); |
| 0 | 264 | | emptyWearablesText.gameObject.SetActive(wearables.Length <= 0); |
| 0 | 265 | | ownedNftWearablePageViews.Clear(); |
| | 266 | |
|
| 0 | 267 | | for (int i = 0; i < wearables.Length; i += PAGE_SIZE) |
| | 268 | | { |
| 0 | 269 | | NftPageView nftPageView = CreateWearablePageView(wearables, i); |
| 0 | 270 | | ownedNftWearablePageViews.Add(nftPageView); |
| 0 | 271 | | nftWearablesCarousel.AddItem(nftPageView); |
| | 272 | | } |
| | 273 | |
|
| 0 | 274 | | nftWearablesCarousel.SetManualControlsActive(); |
| 0 | 275 | | nftWearablesCarousel.GenerateDotsSelector(); |
| 0 | 276 | | } |
| | 277 | |
|
| | 278 | | public void SetCollectibleEmotes(WearableItem[] wearables) |
| | 279 | | { |
| 0 | 280 | | nftEmotesCarousel.gameObject.SetActive(wearables.Length > 0); |
| 0 | 281 | | nftEmotesCarousel.CleanInstantiatedItems(); |
| 0 | 282 | | emptyEmotesText.gameObject.SetActive(wearables.Length <= 0); |
| | 283 | |
|
| 0 | 284 | | for (int i = 0; i < wearables.Length; i += PAGE_SIZE) |
| | 285 | | { |
| 0 | 286 | | NftPageView nftPageView = CreateEmotePageView(wearables, i); |
| 0 | 287 | | ownedNftEmotePageViews.Add(nftPageView); |
| 0 | 288 | | nftEmotesCarousel.AddItem(nftPageView); |
| | 289 | | } |
| | 290 | |
|
| 0 | 291 | | nftEmotesCarousel.SetManualControlsActive(); |
| 0 | 292 | | nftEmotesCarousel.GenerateDotsSelector(); |
| 0 | 293 | | } |
| | 294 | |
|
| | 295 | | public void SetCollectibleNames(NamesResponse.NameEntry[] names) |
| | 296 | | { |
| 0 | 297 | | nftNamesCarousel.gameObject.SetActive(names.Length > 0); |
| 0 | 298 | | nftNamesCarousel.CleanInstantiatedItems(); |
| 0 | 299 | | emptyNamesText.gameObject.SetActive(names.Length <= 0); |
| | 300 | |
|
| 0 | 301 | | for (int i = 0; i < names.Length; i += PAGE_SIZE) |
| | 302 | | { |
| 0 | 303 | | PoolableObject nftPagePoolElement = nftPagesEntryPool.Get(); |
| 0 | 304 | | nftPagesPoolableQueue.Add(nftPagePoolElement); |
| 0 | 305 | | nftPagePoolElement.gameObject.transform.SetParent(nftNamesCarouselContent, false); |
| 0 | 306 | | NftPageView nftPageView = CreateNamePageView(names, nftPagePoolElement, i); |
| 0 | 307 | | nftNamesCarousel.AddItem(nftPageView); |
| | 308 | | } |
| | 309 | |
|
| 0 | 310 | | nftNamesCarousel.SetManualControlsActive(); |
| 0 | 311 | | nftNamesCarousel.GenerateDotsSelector(); |
| 0 | 312 | | } |
| | 313 | |
|
| | 314 | | public void SetCollectibleLands(LandsResponse.LandEntry[] lands) |
| | 315 | | { |
| 0 | 316 | | nftLandsCarousel.gameObject.SetActive(lands.Length > 0); |
| 0 | 317 | | nftLandsCarousel.CleanInstantiatedItems(); |
| 0 | 318 | | emptyLandsText.gameObject.SetActive(lands.Length <= 0); |
| | 319 | |
|
| 0 | 320 | | for (int i = 0; i < lands.Length; i += PAGE_SIZE) |
| | 321 | | { |
| 0 | 322 | | NftPageView nftPageView = CreateLandPageView(lands, i); |
| 0 | 323 | | nftLandsCarousel.AddItem(nftPageView); |
| | 324 | | } |
| | 325 | |
|
| 0 | 326 | | nftLandsCarousel.SetManualControlsActive(); |
| 0 | 327 | | nftLandsCarousel.GenerateDotsSelector(); |
| 0 | 328 | | } |
| | 329 | |
|
| | 330 | | public void SetHasBlockedOwnUser(bool isBlocked) |
| | 331 | | { |
| 0 | 332 | | hasBlockedPanel.SetActive(isBlocked); |
| 0 | 333 | | } |
| | 334 | |
|
| | 335 | | public void SetInitialPage() |
| | 336 | | { |
| 0 | 337 | | aboutToggle.isOn = true; |
| 0 | 338 | | } |
| | 339 | |
|
| | 340 | | public void CloseAllNFTItemInfos() |
| | 341 | | { |
| 0 | 342 | | for (int i = 0; i < equippedNftWearableViews.Count; i++) |
| 0 | 343 | | equippedNftWearableViews[i].SetNFTItemInfoActive(false); |
| | 344 | |
|
| 0 | 345 | | for (int i = 0; i < ownedNftWearablePageViews.Count; i++) |
| 0 | 346 | | ownedNftWearablePageViews[i].CloseAllNFTItemInfos(); |
| | 347 | |
|
| 0 | 348 | | for (int i = 0; i < ownedNftEmotePageViews.Count; i++) |
| 0 | 349 | | ownedNftEmotePageViews[i].CloseAllNFTItemInfos(); |
| 0 | 350 | | } |
| | 351 | |
|
| | 352 | | private void ClickOnBuyWearable(string wearableId, string wearableType) |
| | 353 | | { |
| 0 | 354 | | OnClickBuyNft?.Invoke(wearableId, wearableType); |
| 0 | 355 | | } |
| | 356 | |
|
| | 357 | | private void FocusEquippedNftItem(bool isFocused) |
| | 358 | | { |
| 0 | 359 | | if (!isFocused) |
| 0 | 360 | | return; |
| | 361 | |
|
| 0 | 362 | | FocusAnyNtfItem(); |
| 0 | 363 | | } |
| | 364 | |
|
| | 365 | | private void FocusAnyNtfItem() => |
| 0 | 366 | | CloseAllNFTItemInfos(); |
| | 367 | |
|
| | 368 | | private void CleanEquippedWearables() |
| | 369 | | { |
| 0 | 370 | | foreach (var poolObject in nftIconPoolableQueue) { nftIconsEntryPool.Release(poolObject); } |
| | 371 | |
|
| 0 | 372 | | nftIconPoolableQueue = new List<PoolableObject>(); |
| 0 | 373 | | } |
| | 374 | |
|
| | 375 | | private void CleanWearables() |
| | 376 | | { |
| 0 | 377 | | foreach (var poolObject in nftPagesPoolableQueue) { nftPagesEntryPool.Release(poolObject); } |
| | 378 | |
|
| 0 | 379 | | nftPagesPoolableQueue = new List<PoolableObject>(); |
| 0 | 380 | | } |
| | 381 | |
|
| | 382 | | private Pool GetNftIconEntryPool() |
| | 383 | | { |
| 0 | 384 | | var pool = PoolManager.i.GetPool(NFT_ICON_POOL_NAME_PREFIX + name + GetInstanceID()); |
| 0 | 385 | | if (pool != null) return pool; |
| | 386 | |
|
| 0 | 387 | | pool = PoolManager.i.AddPool( |
| | 388 | | NFT_ICON_POOL_NAME_PREFIX + name + GetInstanceID(), |
| | 389 | | Instantiate(wearableUIReferenceObject).gameObject, |
| | 390 | | maxPrewarmCount: MAX_NFT_ICON_ENTRIES, |
| | 391 | | isPersistent: true); |
| | 392 | |
|
| 0 | 393 | | pool.ForcePrewarm(); |
| | 394 | |
|
| 0 | 395 | | return pool; |
| | 396 | | } |
| | 397 | |
|
| | 398 | | private Pool GetNftPagesEntryPool() |
| | 399 | | { |
| 0 | 400 | | var pool = PoolManager.i.GetPool(NFT_PAGES_POOL_NAME_PREFIX + name + GetInstanceID()); |
| 0 | 401 | | if (pool != null) return pool; |
| | 402 | |
|
| 0 | 403 | | pool = PoolManager.i.AddPool( |
| | 404 | | NFT_PAGES_POOL_NAME_PREFIX + name + GetInstanceID(), |
| | 405 | | Instantiate(nftPageUIReferenceObject).gameObject, |
| | 406 | | maxPrewarmCount: MAX_NFT_PAGES_ENTRIES, |
| | 407 | | isPersistent: true); |
| | 408 | |
|
| 0 | 409 | | pool.ForcePrewarm(); |
| | 410 | |
|
| 0 | 411 | | return pool; |
| | 412 | | } |
| | 413 | |
|
| 0 | 414 | | public override void RefreshControl() { } |
| | 415 | |
|
| | 416 | | public void SetCollectibleWearablesLoadingActive(bool isActive) => |
| 0 | 417 | | SetCollectibleSectionLoadingActive(isActive, nftWearablesCarousel, emptyWearablesText.gameObject, nftWearabl |
| | 418 | |
|
| | 419 | | public void SetCollectibleEmotesLoadingActive(bool isActive) => |
| 0 | 420 | | SetCollectibleSectionLoadingActive(isActive, nftEmotesCarousel, emptyEmotesText.gameObject, nftEmotesLoading |
| | 421 | |
|
| | 422 | | public void SetCollectibleNamesLoadingActive(bool isActive) => |
| 0 | 423 | | SetCollectibleSectionLoadingActive(isActive, nftNamesCarousel, emptyNamesText.gameObject, nftNamesLoadingSpi |
| | 424 | |
|
| | 425 | | public void SetCollectibleLandsLoadingActive(bool isActive) => |
| 0 | 426 | | SetCollectibleSectionLoadingActive(isActive, nftLandsCarousel, emptyLandsText.gameObject, nftLandsLoadingSpi |
| | 427 | |
|
| | 428 | | private void SetCollectibleSectionLoadingActive( |
| | 429 | | bool isActive, |
| | 430 | | CarouselComponentView carousel, |
| | 431 | | GameObject emptyText, |
| | 432 | | GameObject loadingSpinner) |
| | 433 | | { |
| 0 | 434 | | if (isActive) |
| | 435 | | { |
| 0 | 436 | | carousel.gameObject.SetActive(false); |
| 0 | 437 | | emptyText.SetActive(false); |
| | 438 | | } |
| | 439 | |
|
| 0 | 440 | | loadingSpinner.SetActive(isActive); |
| 0 | 441 | | } |
| | 442 | |
|
| | 443 | | private NftPageView CreateNamePageView(NamesResponse.NameEntry[] names, PoolableObject nftPagePoolElement, int i |
| | 444 | | { |
| 0 | 445 | | NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>(); |
| 0 | 446 | | nftPageView.OnClickBuyNft -= ClickOnBuyWearable; |
| 0 | 447 | | nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem; |
| 0 | 448 | | NFTIconComponentModel[] pageElements = CreateNamePageElements(names, i); |
| 0 | 449 | | nftPageView.SetPageElementsContent(pageElements); |
| 0 | 450 | | nftPageView.IsNftInfoActived = false; |
| 0 | 451 | | nftPageView.OnClickBuyNft += ClickOnBuyWearable; |
| 0 | 452 | | nftPageView.OnFocusAnyNtf += FocusAnyNtfItem; |
| 0 | 453 | | return nftPageView; |
| | 454 | | } |
| | 455 | |
|
| | 456 | | private static NFTIconComponentModel[] CreateNamePageElements(NamesResponse.NameEntry[] names, int i) |
| | 457 | | { |
| 0 | 458 | | NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE]; |
| | 459 | |
|
| 0 | 460 | | for (var j = 0; j < PAGE_SIZE; j++) |
| | 461 | | { |
| 0 | 462 | | if (names.Length > i + j && names[i + j] != null) |
| | 463 | | { |
| 0 | 464 | | pageElements[j] = new NFTIconComponentModel |
| | 465 | | { |
| | 466 | | showMarketplaceButton = true, |
| | 467 | | showType = true, |
| | 468 | | type = NAME_TYPE, |
| | 469 | | marketplaceURI = "", |
| | 470 | | name = names[i + j].Name, |
| | 471 | | rarity = LEGENDARY_RARITY, |
| | 472 | | imageURI = "", |
| | 473 | | nftId = (names[i + j].ContractAddress, NAME_TYPE) |
| | 474 | | }; |
| | 475 | | } |
| | 476 | | else |
| | 477 | | { |
| 0 | 478 | | pageElements[j] = null; |
| | 479 | | } |
| | 480 | | } |
| | 481 | |
|
| 0 | 482 | | return pageElements; |
| | 483 | | } |
| | 484 | |
|
| | 485 | | private NftPageView CreateWearablePageView(WearableItem[] wearables, int i) |
| | 486 | | { |
| 0 | 487 | | PoolableObject nftPagePoolElement = nftPagesEntryPool.Get(); |
| 0 | 488 | | nftPagesPoolableQueue.Add(nftPagePoolElement); |
| 0 | 489 | | nftPagePoolElement.gameObject.transform.SetParent(nftWearablesCarouselContent, false); |
| 0 | 490 | | NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>(); |
| 0 | 491 | | nftPageView.OnClickBuyNft -= ClickOnBuyWearable; |
| 0 | 492 | | nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem; |
| 0 | 493 | | NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE]; |
| 0 | 494 | | WearableItem[] wearableItemsForThisPage = new WearableItem[PAGE_SIZE]; |
| | 495 | |
|
| 0 | 496 | | for (int j = 0; j < PAGE_SIZE; j++) |
| | 497 | | { |
| 0 | 498 | | if (wearables.Length > i + j && wearables[i + j] != null) |
| | 499 | | { |
| 0 | 500 | | pageElements[j] = new() |
| | 501 | | { |
| | 502 | | showMarketplaceButton = true, |
| | 503 | | showType = true, |
| | 504 | | type = wearables[i + j].data.category, |
| | 505 | | marketplaceURI = "", |
| | 506 | | name = wearables[i + j].GetName(), |
| | 507 | | rarity = wearables[i + j].rarity, |
| | 508 | | imageURI = wearables[i + j].ComposeThumbnailUrl(), |
| | 509 | | nftId = (wearables[i + j].id, wearables[i + j].data.category) |
| | 510 | | }; |
| 0 | 511 | | wearableItemsForThisPage[j] = wearables[i + j]; |
| | 512 | | } |
| | 513 | | else |
| | 514 | | { |
| 0 | 515 | | pageElements[j] = null; |
| 0 | 516 | | wearableItemsForThisPage[j] = null; |
| | 517 | | } |
| | 518 | | } |
| | 519 | |
|
| 0 | 520 | | nftPageView.SetPageElementsContent(pageElements); |
| 0 | 521 | | nftPageView.IsNftInfoActived = true; |
| 0 | 522 | | nftPageView.ConfigureNFTItemInfo(nftItemInfo, wearableItemsForThisPage, true); |
| 0 | 523 | | nftPageView.OnClickBuyNft += ClickOnBuyWearable; |
| 0 | 524 | | nftPageView.OnFocusAnyNtf += FocusAnyNtfItem; |
| 0 | 525 | | return nftPageView; |
| | 526 | | } |
| | 527 | |
|
| | 528 | | private NftPageView CreateEmotePageView(WearableItem[] wearables, int i) |
| | 529 | | { |
| 0 | 530 | | PoolableObject nftPagePoolElement = nftPagesEntryPool.Get(); |
| 0 | 531 | | nftPagesPoolableQueue.Add(nftPagePoolElement); |
| 0 | 532 | | nftPagePoolElement.gameObject.transform.SetParent(nftEmotesCarouselContent, false); |
| 0 | 533 | | NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>(); |
| 0 | 534 | | nftPageView.OnClickBuyNft -= ClickOnBuyWearable; |
| 0 | 535 | | nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem; |
| 0 | 536 | | NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE]; |
| 0 | 537 | | WearableItem[] wearableItemsForThisPage = new WearableItem[PAGE_SIZE]; |
| | 538 | |
|
| 0 | 539 | | for (var j = 0; j < PAGE_SIZE; j++) |
| | 540 | | { |
| 0 | 541 | | if (wearables.Length > i + j && wearables[i + j] != null) |
| | 542 | | { |
| 0 | 543 | | pageElements[j] = new NFTIconComponentModel |
| | 544 | | { |
| | 545 | | showMarketplaceButton = true, |
| | 546 | | showType = true, |
| | 547 | | type = EMOTE_TYPE, |
| | 548 | | marketplaceURI = "", |
| | 549 | | name = wearables[i + j].GetName(), |
| | 550 | | rarity = wearables[i + j].rarity, |
| | 551 | | imageURI = wearables[i + j].ComposeThumbnailUrl(), |
| | 552 | | nftId = (wearables[i + j].id, EMOTE_TYPE) |
| | 553 | | }; |
| | 554 | |
|
| 0 | 555 | | wearableItemsForThisPage[j] = wearables[i + j]; |
| | 556 | | } |
| | 557 | | else |
| | 558 | | { |
| 0 | 559 | | pageElements[j] = null; |
| 0 | 560 | | wearableItemsForThisPage[j] = null; |
| | 561 | | } |
| | 562 | | } |
| | 563 | |
|
| 0 | 564 | | nftPageView.SetPageElementsContent(pageElements); |
| 0 | 565 | | nftPageView.IsNftInfoActived = true; |
| 0 | 566 | | nftPageView.ConfigureNFTItemInfo(nftItemInfo, wearableItemsForThisPage, false); |
| 0 | 567 | | nftPageView.OnClickBuyNft += ClickOnBuyWearable; |
| 0 | 568 | | nftPageView.OnFocusAnyNtf += FocusAnyNtfItem; |
| 0 | 569 | | return nftPageView; |
| | 570 | | } |
| | 571 | |
|
| | 572 | | private NftPageView CreateLandPageView(LandsResponse.LandEntry[] lands, int i) |
| | 573 | | { |
| 0 | 574 | | PoolableObject nftPagePoolElement = nftPagesEntryPool.Get(); |
| 0 | 575 | | nftPagesPoolableQueue.Add(nftPagePoolElement); |
| 0 | 576 | | nftPagePoolElement.gameObject.transform.SetParent(nftLandsCarouselContent, false); |
| 0 | 577 | | NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>(); |
| 0 | 578 | | nftPageView.OnClickBuyNft -= ClickOnBuyWearable; |
| 0 | 579 | | nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem; |
| 0 | 580 | | NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE]; |
| | 581 | |
|
| 0 | 582 | | for (int j = 0; j < PAGE_SIZE; j++) |
| | 583 | | { |
| 0 | 584 | | if (lands.Length > i + j && lands[i + j] != null) |
| | 585 | | { |
| 0 | 586 | | pageElements[j] = new() |
| | 587 | | { |
| | 588 | | showMarketplaceButton = true, |
| | 589 | | showType = true, |
| | 590 | | type = lands[i + j].Category, |
| | 591 | | marketplaceURI = "", |
| | 592 | | name = !string.IsNullOrEmpty(lands[i + j].Name) ? lands[i + j].Name : lands[i + j].Category, |
| | 593 | | rarity = LAND_RARITY, |
| | 594 | | imageURI = lands[i + j].Image, |
| | 595 | | nftId = (lands[i + j].ContractAddress, lands[i + j].Category) |
| | 596 | | }; |
| | 597 | | } |
| | 598 | | else |
| | 599 | | { |
| 0 | 600 | | pageElements[j] = null; |
| | 601 | | } |
| | 602 | | } |
| | 603 | |
|
| 0 | 604 | | nftPageView.SetPageElementsContent(pageElements); |
| 0 | 605 | | nftPageView.IsNftInfoActived = false; |
| 0 | 606 | | nftPageView.OnClickBuyNft += ClickOnBuyWearable; |
| 0 | 607 | | nftPageView.OnFocusAnyNtf += FocusAnyNtfItem; |
| 0 | 608 | | return nftPageView; |
| | 609 | | } |
| | 610 | | } |
| | 611 | | } |