| | 1 | | using DCL.Helpers; |
| | 2 | | using DCLServices.Lambdas.LandsService; |
| | 3 | | using DCLServices.Lambdas.NamesService; |
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Linq; |
| | 7 | | using TMPro; |
| | 8 | | using UIComponents.Scripts.Utils; |
| | 9 | | using UnityEngine; |
| | 10 | | using UnityEngine.EventSystems; |
| | 11 | | using UnityEngine.Networking; |
| | 12 | | using UnityEngine.UI; |
| | 13 | |
|
| | 14 | | namespace DCL.Social.Passports |
| | 15 | | { |
| | 16 | | [Serializable] |
| | 17 | | internal class AdditionalInfoIconMapping |
| | 18 | | { |
| | 19 | | public AdditionalInfoField name; |
| | 20 | | public Sprite icon; |
| | 21 | | } |
| | 22 | |
|
| | 23 | | public class PassportNavigationComponentView : BaseComponentView, IPassportNavigationComponentView, IAdditionalInfoF |
| | 24 | | { |
| | 25 | | private const string GUEST_TEXT = "is a guest"; |
| | 26 | | private const string BLOCKED_TEXT = "blocked you!"; |
| | 27 | | private const string OWN_PLAYER = "\n You don't "; |
| | 28 | | private const string OTHER_PLAYERS = "\n This person doesn't "; |
| | 29 | | private const string NO_WEARABLES_TEXT = "own any Wearables yet."; |
| | 30 | | private const string NO_EMOTES_TEXT = "own any Emotes yet."; |
| | 31 | | private const string NO_NAMES_TEXT = "own any NAMEs yet."; |
| | 32 | | private const string NO_LANDS_TEXT = "own any LANDs yet."; |
| | 33 | | private const string NAME_TYPE = "name"; |
| | 34 | | private const string EMOTE_TYPE = "emote"; |
| | 35 | | private const string LAND_RARITY = "land"; |
| | 36 | | private const int PAGE_SIZE = 4; |
| | 37 | |
|
| | 38 | | [SerializeField] private GameObject aboutPanel; |
| | 39 | | [SerializeField] private RectTransform aboutContainerTransform; |
| | 40 | | [SerializeField] private GameObject wearablesPanel; |
| | 41 | | [SerializeField] private Toggle aboutToggle; |
| | 42 | | [SerializeField] private Toggle collectiblesToggle; |
| | 43 | | [SerializeField] private GameObject guestPanel; |
| | 44 | | [SerializeField] private GameObject normalPanel; |
| | 45 | | [SerializeField] private GameObject hasBlockedPanel; |
| | 46 | | [SerializeField] private Transform equippedWearablesContainer; |
| | 47 | | [SerializeField] private TextMeshProUGUI usernameText; |
| | 48 | | [SerializeField] private TextMeshProUGUI blockedUsernameText; |
| | 49 | | [SerializeField] private TextMeshProUGUI descriptionText; |
| | 50 | | [SerializeField] private GameObject emptyDescriptionGO; |
| | 51 | | [SerializeField] private CarouselComponentView nftWearablesCarousel; |
| | 52 | | [SerializeField] private TMP_Text emptyWearablesText; |
| | 53 | | [SerializeField] private GameObject nftWearablesLoadingSpinner; |
| | 54 | | [SerializeField] private CarouselComponentView nftEmotesCarousel; |
| | 55 | | [SerializeField] private TMP_Text emptyEmotesText; |
| | 56 | | [SerializeField] private GameObject nftEmotesLoadingSpinner; |
| | 57 | | [SerializeField] private CarouselComponentView nftNamesCarousel; |
| | 58 | | [SerializeField] private TMP_Text emptyNamesText; |
| | 59 | | [SerializeField] private GameObject nftNamesLoadingSpinner; |
| | 60 | | [SerializeField] private CarouselComponentView nftLandsCarousel; |
| | 61 | | [SerializeField] private TMP_Text emptyLandsText; |
| | 62 | | [SerializeField] private GameObject nftLandsLoadingSpinner; |
| | 63 | | [SerializeField] private Transform nftWearablesCarouselContent; |
| | 64 | | [SerializeField] private Transform nftEmotesCarouselContent; |
| | 65 | | [SerializeField] private Transform nftNamesCarouselContent; |
| | 66 | | [SerializeField] private Transform nftLandsCarouselContent; |
| | 67 | | [SerializeField] private GameObject wearableUIReferenceObject; |
| | 68 | | [SerializeField] private GameObject nftPageUIReferenceObject; |
| | 69 | | [SerializeField] private GameObject additionalInfoContainer; |
| | 70 | | [SerializeField] private GameObject additionalInfoPrefabReference; |
| | 71 | | [SerializeField] internal List<AdditionalInfoIconMapping> additionalInfoIconsMapping; |
| | 72 | | [SerializeField] private GameObject linksContainer; |
| | 73 | | [SerializeField] private GameObject linksTitle; |
| | 74 | | [SerializeField] private GameObject linkPrefabReference; |
| | 75 | | [SerializeField] private GameObject aboutToggleOn; |
| | 76 | | [SerializeField] private GameObject aboutToggleOff; |
| | 77 | | [SerializeField] private GameObject collectiblesToggleOn; |
| | 78 | | [SerializeField] private GameObject collectiblesToggleOff; |
| | 79 | | [SerializeField] private TMP_Text aboutText; |
| | 80 | | [SerializeField] private TMP_Text collectiblesText; |
| | 81 | | [SerializeField] private OpenUrlView openUrlView; |
| | 82 | | [SerializeField] internal NFTItemInfo nftItemInfo; |
| | 83 | | [SerializeField] internal ScrollRect nftWearablesScrollRect; |
| | 84 | | [SerializeField] internal ScrollRect nftEmotesScrollRect; |
| | 85 | | [SerializeField] internal ScrollRect nftNamesScrollRect; |
| | 86 | | [SerializeField] internal ScrollRect nftLandsScrollRect; |
| | 87 | | [SerializeField] internal ScrollRect collectiblesMainScrollRect; |
| | 88 | |
|
| | 89 | | [SerializeField] private ButtonComponentView viewAllWearables; |
| | 90 | | [SerializeField] private ButtonComponentView viewAllEmotes; |
| | 91 | | [SerializeField] private ButtonComponentView viewAllNAMEs; |
| | 92 | | [SerializeField] private ButtonComponentView viewAllLANDs; |
| | 93 | | [SerializeField] private Button copyDescriptionButton; |
| | 94 | | [SerializeField] private ShowHideAnimator copyDescriptionToast; |
| | 95 | |
|
| 0 | 96 | | private static readonly Vector3 NFT_ICON_SCALE = new Vector3(0.75f, 0.75f, 0.75f); |
| | 97 | | public event Action<string, string> OnClickBuyNft; |
| | 98 | | public event Action OnClickedLink; |
| | 99 | | public event Action OnClickCollectibles; |
| | 100 | | public event Action<PassportSection> OnClickedViewAll; |
| | 101 | | public event Action<ParcelCoordinates> OnClickDescriptionCoordinates; |
| | 102 | | public event Action OnCopyDescription; |
| | 103 | |
|
| | 104 | | private const string NFT_ICON_POOL_NAME_PREFIX = "NFTIconsEntriesPool_Passport_"; |
| | 105 | | private const string NFT_PAGES_POOL_NAME_PREFIX = "NFTPagesEntriesPool_Passport_"; |
| | 106 | | private const int MAX_NFT_ICON_ENTRIES = 20; |
| | 107 | | private const int MAX_NFT_PAGES_ENTRIES = 20; |
| | 108 | | private const string COORD_LINK_ID = "coord://"; |
| | 109 | |
|
| 0 | 110 | | private List<PoolableObject> nftIconPoolableQueue = new (); |
| 0 | 111 | | private List<PoolableObject> nftWearablesPagesPoolableQueue = new (); |
| 0 | 112 | | private List<PoolableObject> nftEmotesPagesPoolableQueue = new (); |
| 0 | 113 | | private List<PoolableObject> nftNamesPagesPoolableQueue = new (); |
| 0 | 114 | | private List<PoolableObject> nftLandsPagesPoolableQueue = new (); |
| 0 | 115 | | private List<PoolableObject> linksPoolObjects = new (); |
| 0 | 116 | | private List<PoolableObject> additionalInfoFieldsPoolObjects = new (); |
| | 117 | |
|
| | 118 | | private Pool nftIconsEntryPool; |
| | 119 | | private Pool nftWearablesPagesEntryPool; |
| | 120 | | private Pool nftEmotesPagesEntryPool; |
| | 121 | | private Pool nftNamesPagesEntryPool; |
| | 122 | | private Pool nftLandsPagesEntryPool; |
| | 123 | | private Pool linksEntryPool; |
| | 124 | | private Pool additionalInfoFieldsEntryPool; |
| 0 | 125 | | private readonly List<NFTIconComponentView> equippedNftWearableViews = new (); |
| 0 | 126 | | private readonly List<NftPageView> ownedNftWearablePageViews = new (); |
| 0 | 127 | | private readonly List<NftPageView> ownedNftEmotePageViews = new (); |
| | 128 | |
|
| | 129 | | public void Start() |
| | 130 | | { |
| 0 | 131 | | collectiblesToggle.isOn = false; |
| 0 | 132 | | aboutToggle.isOn = true; |
| 0 | 133 | | aboutToggle.onValueChanged.AddListener(EnableAboutSection); |
| 0 | 134 | | collectiblesToggle.onValueChanged.AddListener(EnableCollectiblesSection); |
| 0 | 135 | | nftWearablesScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos()); |
| 0 | 136 | | nftEmotesScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos()); |
| 0 | 137 | | nftNamesScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos()); |
| 0 | 138 | | nftLandsScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos()); |
| 0 | 139 | | collectiblesMainScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos()); |
| | 140 | |
|
| 0 | 141 | | viewAllWearables.onClick.AddListener(() => OpenViewAllSection(PassportSection.Wearables)); |
| 0 | 142 | | viewAllEmotes.onClick.AddListener(() => OpenViewAllSection(PassportSection.Emotes)); |
| 0 | 143 | | viewAllNAMEs.onClick.AddListener(() => OpenViewAllSection(PassportSection.Names)); |
| 0 | 144 | | viewAllLANDs.onClick.AddListener(() => OpenViewAllSection(PassportSection.Lands)); |
| 0 | 145 | | copyDescriptionButton.onClick.AddListener(() => |
| | 146 | | { |
| 0 | 147 | | OnCopyDescription?.Invoke(); |
| 0 | 148 | | copyDescriptionToast.gameObject.SetActive(true); |
| 0 | 149 | | copyDescriptionToast.ShowDelayHide(3); |
| 0 | 150 | | }); |
| | 151 | |
|
| 0 | 152 | | descriptionText.SubscribeToClickEvents(OnDescriptionClicked); |
| 0 | 153 | | nftWearablesPagesEntryPool = GetNftPagesEntryPool(NFT_PAGES_POOL_NAME_PREFIX + "Wearables"); |
| 0 | 154 | | nftEmotesPagesEntryPool = GetNftPagesEntryPool(NFT_PAGES_POOL_NAME_PREFIX + "Emotes"); |
| 0 | 155 | | nftNamesPagesEntryPool = GetNftPagesEntryPool(NFT_PAGES_POOL_NAME_PREFIX + "Names"); |
| 0 | 156 | | nftLandsPagesEntryPool = GetNftPagesEntryPool(NFT_PAGES_POOL_NAME_PREFIX + "Lands"); |
| 0 | 157 | | nftIconsEntryPool = GetNftIconEntryPool(); |
| 0 | 158 | | linksEntryPool = GetLinkEntryPool(); |
| 0 | 159 | | additionalInfoFieldsEntryPool = GetAdditionalInfoFieldEntryPool(); |
| 0 | 160 | | } |
| | 161 | |
|
| | 162 | | private void OpenViewAllSection(PassportSection section) |
| | 163 | | { |
| 0 | 164 | | CloseAllNFTItemInfos(); |
| 0 | 165 | | OnClickedViewAll?.Invoke(section); |
| 0 | 166 | | } |
| | 167 | |
|
| | 168 | | public void CloseAllSections() |
| | 169 | | { |
| 0 | 170 | | aboutPanel.SetActive(false); |
| 0 | 171 | | wearablesPanel.SetActive(false); |
| 0 | 172 | | } |
| | 173 | |
|
| | 174 | | private void EnableAboutSection(bool isActive) |
| | 175 | | { |
| 0 | 176 | | aboutPanel.SetActive(isActive); |
| 0 | 177 | | aboutText.color = Color.white; |
| 0 | 178 | | collectiblesText.color = Color.black; |
| 0 | 179 | | aboutToggleOn.SetActive(true); |
| 0 | 180 | | aboutToggleOff.SetActive(false); |
| 0 | 181 | | collectiblesToggleOn.SetActive(false); |
| 0 | 182 | | collectiblesToggleOff.SetActive(true); |
| 0 | 183 | | CloseAllNFTItemInfos(); |
| 0 | 184 | | } |
| | 185 | |
|
| | 186 | | private void EnableCollectiblesSection(bool isActive) |
| | 187 | | { |
| 0 | 188 | | OnClickCollectibles?.Invoke(); |
| 0 | 189 | | wearablesPanel.SetActive(isActive); |
| 0 | 190 | | aboutText.color = Color.black; |
| 0 | 191 | | collectiblesText.color = Color.white; |
| 0 | 192 | | aboutToggleOn.SetActive(false); |
| 0 | 193 | | aboutToggleOff.SetActive(true); |
| 0 | 194 | | collectiblesToggleOn.SetActive(true); |
| 0 | 195 | | collectiblesToggleOff.SetActive(false); |
| 0 | 196 | | nftWearablesCarousel.ResetManualCarousel(); |
| 0 | 197 | | nftEmotesCarousel.ResetManualCarousel(); |
| 0 | 198 | | nftNamesCarousel.ResetManualCarousel(); |
| 0 | 199 | | nftLandsCarousel.ResetManualCarousel(); |
| 0 | 200 | | CloseAllNFTItemInfos(); |
| 0 | 201 | | } |
| | 202 | |
|
| | 203 | | public void InitializeView() |
| | 204 | | { |
| 0 | 205 | | ReleaseAllNftPagesPoolObjects(); |
| 0 | 206 | | ReleaseAllNftIconsPoolObjects(); |
| 0 | 207 | | SetInitialPage(); |
| 0 | 208 | | } |
| | 209 | |
|
| | 210 | | public void SetGuestUser(bool isGuest) |
| | 211 | | { |
| 0 | 212 | | guestPanel.SetActive(isGuest); |
| 0 | 213 | | normalPanel.SetActive(!isGuest); |
| 0 | 214 | | hasBlockedPanel.SetActive(false); |
| 0 | 215 | | } |
| | 216 | |
|
| | 217 | | public void SetName(string username) |
| | 218 | | { |
| 0 | 219 | | usernameText.text = $"{username} {GUEST_TEXT}"; |
| 0 | 220 | | blockedUsernameText.text = $"{username} {BLOCKED_TEXT}"; |
| 0 | 221 | | } |
| | 222 | |
|
| | 223 | | public void SetOwnUserTexts(bool isOwnUser) |
| | 224 | | { |
| 0 | 225 | | string prefix = isOwnUser ? OWN_PLAYER : OTHER_PLAYERS; |
| 0 | 226 | | emptyWearablesText.text = $"{prefix}{NO_WEARABLES_TEXT}"; |
| 0 | 227 | | emptyEmotesText.text = $"{prefix}{NO_EMOTES_TEXT}"; |
| 0 | 228 | | emptyNamesText.text = $"{prefix}{NO_NAMES_TEXT}"; |
| 0 | 229 | | emptyLandsText.text = $"{prefix}{NO_LANDS_TEXT}"; |
| 0 | 230 | | } |
| | 231 | |
|
| | 232 | | public void SetDescription(string description) |
| | 233 | | { |
| 0 | 234 | | if (string.IsNullOrEmpty(description)) |
| | 235 | | { |
| 0 | 236 | | emptyDescriptionGO.SetActive(true); |
| 0 | 237 | | descriptionText.gameObject.SetActive(false); |
| | 238 | | } |
| | 239 | | else |
| | 240 | | { |
| 0 | 241 | | emptyDescriptionGO.SetActive(false); |
| 0 | 242 | | descriptionText.gameObject.SetActive(true); |
| 0 | 243 | | description = AddCoordinateLinks(description); |
| 0 | 244 | | descriptionText.text = description; |
| | 245 | | } |
| 0 | 246 | | } |
| | 247 | |
|
| | 248 | | public Sprite Get(AdditionalInfoField field) |
| | 249 | | { |
| 0 | 250 | | foreach (AdditionalInfoIconMapping iconMapping in additionalInfoIconsMapping) |
| 0 | 251 | | if (iconMapping.name == field) |
| 0 | 252 | | return iconMapping.icon; |
| | 253 | |
|
| 0 | 254 | | return null; |
| 0 | 255 | | } |
| | 256 | |
|
| | 257 | | public void SetAdditionalInfo(List<(Sprite logo, string title, string value)> additionalFields) |
| | 258 | | { |
| 0 | 259 | | additionalInfoContainer.SetActive(additionalFields.Count > 0); |
| | 260 | |
|
| 0 | 261 | | foreach (PoolableObject poolObj in additionalInfoFieldsPoolObjects) |
| 0 | 262 | | poolObj.Release(); |
| | 263 | |
|
| 0 | 264 | | additionalInfoFieldsPoolObjects.Clear(); |
| | 265 | |
|
| 0 | 266 | | foreach (var additionalField in additionalFields) |
| | 267 | | { |
| 0 | 268 | | PoolableObject poolObj = additionalInfoFieldsEntryPool.Get(); |
| 0 | 269 | | additionalInfoFieldsPoolObjects.Add(poolObj); |
| 0 | 270 | | AdditionalInfoEntryView newAdditionalField = poolObj.gameObject.GetComponent<AdditionalInfoEntryView>(); |
| 0 | 271 | | newAdditionalField.transform.SetParent(additionalInfoContainer.transform, false); |
| 0 | 272 | | newAdditionalField.SetInfo(additionalField.logo, additionalField.title, additionalField.value); |
| | 273 | | } |
| 0 | 274 | | } |
| | 275 | |
|
| | 276 | | public void SetLinks(List<UserProfileModel.Link> links) |
| | 277 | | { |
| 0 | 278 | | linksTitle.SetActive(links.Count > 0); |
| 0 | 279 | | linksContainer.SetActive(links.Count > 0); |
| | 280 | |
|
| 0 | 281 | | foreach (PoolableObject poolObj in linksPoolObjects) |
| 0 | 282 | | poolObj.Release(); |
| | 283 | |
|
| 0 | 284 | | linksPoolObjects.Clear(); |
| | 285 | |
|
| 0 | 286 | | foreach (var link in links) |
| | 287 | | { |
| 0 | 288 | | PoolableObject poolObj = linksEntryPool.Get(); |
| 0 | 289 | | linksPoolObjects.Add(poolObj); |
| 0 | 290 | | PassportLinkView newLink = poolObj.gameObject.GetComponent<PassportLinkView>(); |
| 0 | 291 | | newLink.transform.SetParent(linksContainer.transform, false); |
| 0 | 292 | | newLink.OnClickLink -= ClickedLink; |
| 0 | 293 | | newLink.SetLinkTitle(link.title); |
| 0 | 294 | | newLink.SetLink(link.url); |
| 0 | 295 | | newLink.OnClickLink += ClickedLink; |
| | 296 | | } |
| 0 | 297 | | } |
| | 298 | |
|
| | 299 | | private string AddCoordinateLinks(string description) |
| | 300 | | { |
| 0 | 301 | | return CoordinateUtils.ReplaceTextCoordinates(description, (text, coordinates) => |
| 0 | 302 | | $"<link=coord://{text}><color=#4886E3><u>{text}</u></color></link>"); |
| | 303 | | } |
| | 304 | |
|
| | 305 | | private void OnDescriptionClicked(PointerEventData clickData) |
| | 306 | | { |
| 0 | 307 | | if (clickData.button != PointerEventData.InputButton.Left) return; |
| | 308 | |
|
| 0 | 309 | | int linkIndex = TMP_TextUtilities.FindIntersectingLink(descriptionText, clickData.position, descriptionText. |
| 0 | 310 | | if (linkIndex == -1) return; |
| | 311 | |
|
| 0 | 312 | | string link = descriptionText.textInfo.linkInfo[linkIndex].GetLinkID(); |
| 0 | 313 | | if (!link.StartsWith(COORD_LINK_ID)) return; |
| | 314 | |
|
| 0 | 315 | | string coordText = link[COORD_LINK_ID.Length..]; |
| 0 | 316 | | ParcelCoordinates coordinates = CoordinateUtils.ParseCoordinatesString(coordText); |
| 0 | 317 | | OnClickDescriptionCoordinates?.Invoke(coordinates); |
| 0 | 318 | | } |
| | 319 | |
|
| | 320 | | private void ClickedLink(string obj) |
| | 321 | | { |
| 0 | 322 | | openUrlView.SetUrlInfo(UnityWebRequest.UnEscapeURL(obj), obj); |
| 0 | 323 | | openUrlView.SetVisibility(true); |
| 0 | 324 | | OnClickedLink?.Invoke(); |
| 0 | 325 | | } |
| | 326 | |
|
| | 327 | | public void SetEquippedWearables(WearableItem[] wearables, string bodyShapeId) |
| | 328 | | { |
| 0 | 329 | | HashSet<string> hidesList = WearableItem.ComposeHiddenCategories(bodyShapeId, wearables.ToList()); |
| | 330 | |
|
| 0 | 331 | | equippedNftWearableViews.Clear(); |
| | 332 | |
|
| 0 | 333 | | foreach (var wearable in wearables) |
| | 334 | | { |
| 0 | 335 | | if (wearable == null) |
| | 336 | | continue; |
| | 337 | |
|
| 0 | 338 | | if (!hidesList.Contains(wearable.data.category)) |
| | 339 | | { |
| 0 | 340 | | PoolableObject poolableObject = nftIconsEntryPool.Get(); |
| 0 | 341 | | nftIconPoolableQueue.Add(poolableObject); |
| 0 | 342 | | poolableObject.gameObject.transform.SetParent(equippedWearablesContainer, false); |
| 0 | 343 | | poolableObject.gameObject.transform.localScale = NFT_ICON_SCALE; |
| 0 | 344 | | NFTIconComponentView nftIconComponentView = poolableObject.gameObject.GetComponent<NFTIconComponentV |
| 0 | 345 | | nftIconComponentView.onMarketplaceButtonClick.RemoveAllListeners(); |
| 0 | 346 | | nftIconComponentView.onDetailInfoButtonClick.RemoveAllListeners(); |
| 0 | 347 | | nftIconComponentView.onFocused -= FocusEquippedNftItem; |
| 0 | 348 | | nftIconComponentView.onMarketplaceButtonClick.AddListener(() => ClickOnBuyWearable(wearable.id, wear |
| 0 | 349 | | nftIconComponentView.onDetailInfoButtonClick.AddListener(() => nftIconComponentView.SetNFTItemInfoAc |
| 0 | 350 | | nftIconComponentView.onFocused += FocusEquippedNftItem; |
| | 351 | |
|
| 0 | 352 | | NFTIconComponentModel nftModel = new NFTIconComponentModel() |
| | 353 | | { |
| | 354 | | showMarketplaceButton = wearable.IsCollectible(), |
| | 355 | | showType = wearable.IsCollectible(), |
| | 356 | | type = wearable.data.category, |
| | 357 | | marketplaceURI = "", |
| | 358 | | name = wearable.GetName(), |
| | 359 | | rarity = wearable.rarity, |
| | 360 | | imageURI = wearable.ComposeThumbnailUrl() |
| | 361 | | }; |
| | 362 | |
|
| 0 | 363 | | nftIconComponentView.Configure(nftModel); |
| 0 | 364 | | nftIconComponentView.ConfigureNFTItemInfo(nftItemInfo, wearable, true); |
| 0 | 365 | | equippedNftWearableViews.Add(nftIconComponentView); |
| | 366 | | } |
| | 367 | | } |
| | 368 | |
|
| 0 | 369 | | Utils.ForceRebuildLayoutImmediate(aboutContainerTransform); |
| 0 | 370 | | } |
| | 371 | |
|
| | 372 | | public void SetCollectibleWearables(WearableItem[] wearables) |
| | 373 | | { |
| 0 | 374 | | nftWearablesCarousel.gameObject.SetActive(wearables.Length > 0); |
| 0 | 375 | | nftWearablesCarousel.ExtractItems(); |
| 0 | 376 | | nftWearablesPagesEntryPool.ReleaseAll(); |
| 0 | 377 | | emptyWearablesText.gameObject.SetActive(wearables.Length <= 0); |
| 0 | 378 | | ownedNftWearablePageViews.Clear(); |
| | 379 | |
|
| 0 | 380 | | for (int i = 0; i < wearables.Length; i += PAGE_SIZE) |
| | 381 | | { |
| 0 | 382 | | NftPageView nftPageView = CreateWearablePageView(wearables, i); |
| 0 | 383 | | ownedNftWearablePageViews.Add(nftPageView); |
| 0 | 384 | | nftWearablesCarousel.AddItem(nftPageView); |
| | 385 | | } |
| | 386 | |
|
| 0 | 387 | | nftWearablesCarousel.SetManualControlsActive(); |
| 0 | 388 | | nftWearablesCarousel.GenerateDotsSelector(); |
| 0 | 389 | | } |
| | 390 | |
|
| | 391 | | public void SetCollectibleEmotes(WearableItem[] wearables) |
| | 392 | | { |
| 0 | 393 | | nftEmotesCarousel.gameObject.SetActive(wearables.Length > 0); |
| 0 | 394 | | nftEmotesCarousel.ExtractItems(); |
| 0 | 395 | | nftEmotesPagesEntryPool.ReleaseAll(); |
| 0 | 396 | | emptyEmotesText.gameObject.SetActive(wearables.Length <= 0); |
| | 397 | |
|
| 0 | 398 | | for (int i = 0; i < wearables.Length; i += PAGE_SIZE) |
| | 399 | | { |
| 0 | 400 | | NftPageView nftPageView = CreateEmotePageView(wearables, i); |
| 0 | 401 | | ownedNftEmotePageViews.Add(nftPageView); |
| 0 | 402 | | nftEmotesCarousel.AddItem(nftPageView); |
| | 403 | | } |
| | 404 | |
|
| 0 | 405 | | nftEmotesCarousel.SetManualControlsActive(); |
| 0 | 406 | | nftEmotesCarousel.GenerateDotsSelector(); |
| 0 | 407 | | } |
| | 408 | |
|
| | 409 | | public void SetCollectibleNames(NamesResponse.NameEntry[] names) |
| | 410 | | { |
| 0 | 411 | | nftNamesCarousel.gameObject.SetActive(names.Length > 0); |
| 0 | 412 | | nftNamesCarousel.ExtractItems(); |
| 0 | 413 | | nftNamesPagesEntryPool.ReleaseAll(); |
| 0 | 414 | | emptyNamesText.gameObject.SetActive(names.Length <= 0); |
| | 415 | |
|
| 0 | 416 | | for (int i = 0; i < names.Length; i += PAGE_SIZE) |
| | 417 | | { |
| 0 | 418 | | PoolableObject nftPagePoolElement = nftNamesPagesEntryPool.Get(); |
| 0 | 419 | | nftNamesPagesPoolableQueue.Add(nftPagePoolElement); |
| 0 | 420 | | nftPagePoolElement.gameObject.transform.SetParent(nftNamesCarouselContent, false); |
| 0 | 421 | | NftPageView nftPageView = CreateNamePageView(names, nftPagePoolElement, i); |
| 0 | 422 | | nftNamesCarousel.AddItem(nftPageView); |
| | 423 | | } |
| | 424 | |
|
| 0 | 425 | | nftNamesCarousel.SetManualControlsActive(); |
| 0 | 426 | | nftNamesCarousel.GenerateDotsSelector(); |
| 0 | 427 | | } |
| | 428 | |
|
| | 429 | | public void SetCollectibleLands(LandsResponse.LandEntry[] lands) |
| | 430 | | { |
| 0 | 431 | | nftLandsCarousel.gameObject.SetActive(lands.Length > 0); |
| 0 | 432 | | nftLandsCarousel.ExtractItems(); |
| 0 | 433 | | nftLandsPagesEntryPool.ReleaseAll(); |
| 0 | 434 | | emptyLandsText.gameObject.SetActive(lands.Length <= 0); |
| | 435 | |
|
| 0 | 436 | | for (int i = 0; i < lands.Length; i += PAGE_SIZE) |
| | 437 | | { |
| 0 | 438 | | NftPageView nftPageView = CreateLandPageView(lands, i); |
| 0 | 439 | | nftLandsCarousel.AddItem(nftPageView); |
| | 440 | | } |
| | 441 | |
|
| 0 | 442 | | nftLandsCarousel.SetManualControlsActive(); |
| 0 | 443 | | nftLandsCarousel.GenerateDotsSelector(); |
| 0 | 444 | | } |
| | 445 | |
|
| | 446 | | public void SetHasBlockedOwnUser(bool isBlocked) |
| | 447 | | { |
| 0 | 448 | | hasBlockedPanel.SetActive(isBlocked); |
| 0 | 449 | | } |
| | 450 | |
|
| | 451 | | public void OpenCollectiblesTab() |
| | 452 | | { |
| 0 | 453 | | wearablesPanel.SetActive(true); |
| 0 | 454 | | } |
| | 455 | |
|
| | 456 | | public void SetInitialPage() |
| | 457 | | { |
| 0 | 458 | | aboutToggle.isOn = true; |
| 0 | 459 | | } |
| | 460 | |
|
| | 461 | | public void SetViewAllButtonActive(PassportSection section, bool isActive) |
| | 462 | | { |
| | 463 | | switch (section) |
| | 464 | | { |
| | 465 | | case PassportSection.Wearables: |
| 0 | 466 | | viewAllWearables.gameObject.SetActive(isActive); |
| 0 | 467 | | break; |
| | 468 | | case PassportSection.Emotes: |
| 0 | 469 | | viewAllEmotes.gameObject.SetActive(isActive); |
| 0 | 470 | | break; |
| | 471 | | case PassportSection.Names: |
| 0 | 472 | | viewAllNAMEs.gameObject.SetActive(isActive); |
| 0 | 473 | | break; |
| | 474 | | case PassportSection.Lands: |
| 0 | 475 | | viewAllLANDs.gameObject.SetActive(isActive); |
| | 476 | | break; |
| | 477 | | } |
| 0 | 478 | | } |
| | 479 | |
|
| | 480 | | public void CloseAllNFTItemInfos() |
| | 481 | | { |
| 0 | 482 | | for (int i = 0; i < equippedNftWearableViews.Count; i++) |
| 0 | 483 | | equippedNftWearableViews[i].SetNFTItemInfoActive(false); |
| | 484 | |
|
| 0 | 485 | | for (int i = 0; i < ownedNftWearablePageViews.Count; i++) |
| 0 | 486 | | ownedNftWearablePageViews[i].CloseAllNFTItemInfos(); |
| | 487 | |
|
| 0 | 488 | | for (int i = 0; i < ownedNftEmotePageViews.Count; i++) |
| 0 | 489 | | ownedNftEmotePageViews[i].CloseAllNFTItemInfos(); |
| 0 | 490 | | } |
| | 491 | |
|
| | 492 | | private void ClickOnBuyWearable(string wearableId, string wearableType) |
| | 493 | | { |
| 0 | 494 | | OnClickBuyNft?.Invoke(wearableId, wearableType); |
| 0 | 495 | | } |
| | 496 | |
|
| | 497 | | private void FocusEquippedNftItem(bool isFocused) |
| | 498 | | { |
| 0 | 499 | | if (!isFocused) |
| 0 | 500 | | return; |
| | 501 | |
|
| 0 | 502 | | FocusAnyNtfItem(); |
| 0 | 503 | | } |
| | 504 | |
|
| | 505 | | private void FocusAnyNtfItem() => |
| 0 | 506 | | CloseAllNFTItemInfos(); |
| | 507 | |
|
| | 508 | | private void ReleaseAllNftIconsPoolObjects() |
| | 509 | | { |
| 0 | 510 | | ReleaseNftIconsPoolObjects(nftIconPoolableQueue); |
| 0 | 511 | | } |
| | 512 | |
|
| | 513 | | private void ReleaseNftIconsPoolObjects(List<PoolableObject> nftIconsPoolableQueue) |
| | 514 | | { |
| 0 | 515 | | foreach (var poolObject in nftIconsPoolableQueue) |
| 0 | 516 | | poolObject.Release(); |
| | 517 | |
|
| 0 | 518 | | nftIconsPoolableQueue.Clear(); |
| 0 | 519 | | } |
| | 520 | |
|
| | 521 | | private void ReleaseAllNftPagesPoolObjects() |
| | 522 | | { |
| 0 | 523 | | nftWearablesPagesEntryPool.ReleaseAll(); |
| 0 | 524 | | nftEmotesPagesEntryPool.ReleaseAll(); |
| 0 | 525 | | nftNamesPagesEntryPool.ReleaseAll(); |
| 0 | 526 | | nftLandsPagesEntryPool.ReleaseAll(); |
| 0 | 527 | | } |
| | 528 | |
|
| | 529 | | private Pool GetNftIconEntryPool() => |
| 0 | 530 | | GetNftEntryPool(NFT_ICON_POOL_NAME_PREFIX + name + GetInstanceID(), wearableUIReferenceObject, MAX_NFT_ICON_ |
| | 531 | |
|
| | 532 | | private Pool GetLinkEntryPool() |
| | 533 | | { |
| 0 | 534 | | object poolId = $"LinkEntries_Passport_{name}{GetInstanceID()}"; |
| 0 | 535 | | var pool = PoolManager.i.GetPool(poolId); |
| 0 | 536 | | if (pool != null) return pool; |
| | 537 | |
|
| 0 | 538 | | pool = PoolManager.i.AddPool( |
| | 539 | | poolId, |
| | 540 | | Instantiate(linkPrefabReference), |
| | 541 | | maxPrewarmCount: 5, |
| | 542 | | isPersistent: true); |
| | 543 | |
|
| 0 | 544 | | return pool; |
| | 545 | | } |
| | 546 | |
|
| | 547 | | private Pool GetAdditionalInfoFieldEntryPool() |
| | 548 | | { |
| 0 | 549 | | object poolId = $"AdditionalInfoEntries_Passport_{name}{GetInstanceID()}"; |
| 0 | 550 | | var pool = PoolManager.i.GetPool(poolId); |
| 0 | 551 | | if (pool != null) return pool; |
| | 552 | |
|
| 0 | 553 | | pool = PoolManager.i.AddPool( |
| | 554 | | poolId, |
| | 555 | | Instantiate(additionalInfoPrefabReference), |
| | 556 | | maxPrewarmCount: 5, |
| | 557 | | isPersistent: true); |
| | 558 | |
|
| 0 | 559 | | return pool; |
| | 560 | | } |
| | 561 | |
|
| | 562 | | private Pool GetNftPagesEntryPool(string poolId) => |
| 0 | 563 | | GetNftEntryPool(poolId, nftPageUIReferenceObject, MAX_NFT_PAGES_ENTRIES); |
| | 564 | |
|
| | 565 | | private static Pool GetNftEntryPool(string poolId, GameObject referenceObject, int maxPrewarmCount) |
| | 566 | | { |
| 0 | 567 | | var pool = PoolManager.i.GetPool(poolId); |
| 0 | 568 | | if (pool != null) return pool; |
| | 569 | |
|
| 0 | 570 | | pool = PoolManager.i.AddPool( |
| | 571 | | poolId, |
| | 572 | | Instantiate(referenceObject).gameObject, |
| | 573 | | maxPrewarmCount: maxPrewarmCount, |
| | 574 | | isPersistent: true); |
| | 575 | |
|
| 0 | 576 | | pool.ForcePrewarm(forceActive: false); |
| | 577 | |
|
| 0 | 578 | | return pool; |
| | 579 | | } |
| | 580 | |
|
| 0 | 581 | | public override void RefreshControl() { } |
| | 582 | |
|
| | 583 | | public void SetCollectibleWearablesLoadingActive(bool isActive) => |
| 0 | 584 | | SetCollectibleSectionLoadingActive(isActive, nftWearablesCarousel, emptyWearablesText.gameObject, nftWearabl |
| | 585 | |
|
| | 586 | | public void SetCollectibleEmotesLoadingActive(bool isActive) => |
| 0 | 587 | | SetCollectibleSectionLoadingActive(isActive, nftEmotesCarousel, emptyEmotesText.gameObject, nftEmotesLoading |
| | 588 | |
|
| | 589 | | public void SetCollectibleNamesLoadingActive(bool isActive) => |
| 0 | 590 | | SetCollectibleSectionLoadingActive(isActive, nftNamesCarousel, emptyNamesText.gameObject, nftNamesLoadingSpi |
| | 591 | |
|
| | 592 | | public void SetCollectibleLandsLoadingActive(bool isActive) => |
| 0 | 593 | | SetCollectibleSectionLoadingActive(isActive, nftLandsCarousel, emptyLandsText.gameObject, nftLandsLoadingSpi |
| | 594 | |
|
| | 595 | | private void SetCollectibleSectionLoadingActive( |
| | 596 | | bool isActive, |
| | 597 | | CarouselComponentView carousel, |
| | 598 | | GameObject emptyText, |
| | 599 | | GameObject loadingSpinner) |
| | 600 | | { |
| 0 | 601 | | if (isActive) |
| | 602 | | { |
| 0 | 603 | | carousel.gameObject.SetActive(false); |
| 0 | 604 | | emptyText.SetActive(false); |
| | 605 | | } |
| | 606 | |
|
| 0 | 607 | | loadingSpinner.SetActive(isActive); |
| 0 | 608 | | } |
| | 609 | |
|
| | 610 | | private NftPageView CreateNamePageView(NamesResponse.NameEntry[] names, PoolableObject nftPagePoolElement, int i |
| | 611 | | { |
| 0 | 612 | | NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>(); |
| 0 | 613 | | nftPageView.OnClickBuyNft -= ClickOnBuyWearable; |
| 0 | 614 | | nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem; |
| 0 | 615 | | NFTIconComponentModel[] pageElements = CreateNamePageElements(names, i); |
| 0 | 616 | | nftPageView.SetPageElementsContent(pageElements); |
| 0 | 617 | | nftPageView.IsNftInfoActived = false; |
| 0 | 618 | | nftPageView.OnClickBuyNft += ClickOnBuyWearable; |
| 0 | 619 | | nftPageView.OnFocusAnyNtf += FocusAnyNtfItem; |
| 0 | 620 | | return nftPageView; |
| | 621 | | } |
| | 622 | |
|
| | 623 | | private static NFTIconComponentModel[] CreateNamePageElements(NamesResponse.NameEntry[] names, int i) |
| | 624 | | { |
| 0 | 625 | | NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE]; |
| | 626 | |
|
| 0 | 627 | | for (var j = 0; j < PAGE_SIZE; j++) |
| | 628 | | { |
| 0 | 629 | | if (names.Length > i + j && names[i + j] != null) |
| | 630 | | { |
| 0 | 631 | | pageElements[j] = new NFTIconComponentModel |
| | 632 | | { |
| | 633 | | showMarketplaceButton = true, |
| | 634 | | showType = true, |
| | 635 | | type = NAME_TYPE, |
| | 636 | | marketplaceURI = "", |
| | 637 | | name = names[i + j].Name, |
| | 638 | | rarity = NAME_TYPE, |
| | 639 | | imageURI = "", |
| | 640 | | nftInfo = names[i + j].GetNftInfo(), |
| | 641 | | }; |
| | 642 | | } |
| 0 | 643 | | else { pageElements[j] = null; } |
| | 644 | | } |
| | 645 | |
|
| 0 | 646 | | return pageElements; |
| | 647 | | } |
| | 648 | |
|
| | 649 | | private NftPageView CreateWearablePageView(WearableItem[] wearables, int i) |
| | 650 | | { |
| 0 | 651 | | PoolableObject nftPagePoolElement = nftWearablesPagesEntryPool.Get(); |
| 0 | 652 | | nftWearablesPagesPoolableQueue.Add(nftPagePoolElement); |
| 0 | 653 | | nftPagePoolElement.gameObject.transform.SetParent(nftWearablesCarouselContent, false); |
| 0 | 654 | | NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>(); |
| 0 | 655 | | nftPageView.OnClickBuyNft -= ClickOnBuyWearable; |
| 0 | 656 | | nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem; |
| 0 | 657 | | NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE]; |
| 0 | 658 | | WearableItem[] wearableItemsForThisPage = new WearableItem[PAGE_SIZE]; |
| | 659 | |
|
| 0 | 660 | | for (int j = 0; j < PAGE_SIZE; j++) |
| | 661 | | { |
| 0 | 662 | | if (wearables.Length > i + j && wearables[i + j] != null) |
| | 663 | | { |
| 0 | 664 | | pageElements[j] = new () |
| | 665 | | { |
| | 666 | | showMarketplaceButton = true, |
| | 667 | | showType = true, |
| | 668 | | type = wearables[i + j].data.category, |
| | 669 | | marketplaceURI = "", |
| | 670 | | name = wearables[i + j].GetName(), |
| | 671 | | rarity = wearables[i + j].rarity, |
| | 672 | | imageURI = wearables[i + j].ComposeThumbnailUrl(), |
| | 673 | | nftInfo = wearables[i + j].GetNftInfo(), |
| | 674 | | }; |
| | 675 | |
|
| 0 | 676 | | wearableItemsForThisPage[j] = wearables[i + j]; |
| | 677 | | } |
| | 678 | | else |
| | 679 | | { |
| 0 | 680 | | pageElements[j] = null; |
| 0 | 681 | | wearableItemsForThisPage[j] = null; |
| | 682 | | } |
| | 683 | | } |
| | 684 | |
|
| 0 | 685 | | nftPageView.SetPageElementsContent(pageElements); |
| 0 | 686 | | nftPageView.IsNftInfoActived = true; |
| 0 | 687 | | nftPageView.ConfigureNFTItemInfo(nftItemInfo, wearableItemsForThisPage, true); |
| 0 | 688 | | nftPageView.OnClickBuyNft += ClickOnBuyWearable; |
| 0 | 689 | | nftPageView.OnFocusAnyNtf += FocusAnyNtfItem; |
| 0 | 690 | | return nftPageView; |
| | 691 | | } |
| | 692 | |
|
| | 693 | | private NftPageView CreateEmotePageView(WearableItem[] wearables, int i) |
| | 694 | | { |
| 0 | 695 | | PoolableObject nftPagePoolElement = nftEmotesPagesEntryPool.Get(); |
| 0 | 696 | | nftEmotesPagesPoolableQueue.Add(nftPagePoolElement); |
| 0 | 697 | | nftPagePoolElement.gameObject.transform.SetParent(nftEmotesCarouselContent, false); |
| 0 | 698 | | NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>(); |
| 0 | 699 | | nftPageView.OnClickBuyNft -= ClickOnBuyWearable; |
| 0 | 700 | | nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem; |
| 0 | 701 | | NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE]; |
| 0 | 702 | | WearableItem[] wearableItemsForThisPage = new WearableItem[PAGE_SIZE]; |
| | 703 | |
|
| 0 | 704 | | for (var j = 0; j < PAGE_SIZE; j++) |
| | 705 | | { |
| 0 | 706 | | if (wearables.Length > i + j && wearables[i + j] != null) |
| | 707 | | { |
| 0 | 708 | | pageElements[j] = new NFTIconComponentModel |
| | 709 | | { |
| | 710 | | showMarketplaceButton = true, |
| | 711 | | showType = true, |
| | 712 | | type = EMOTE_TYPE, |
| | 713 | | marketplaceURI = "", |
| | 714 | | name = wearables[i + j].GetName(), |
| | 715 | | rarity = wearables[i + j].rarity, |
| | 716 | | imageURI = wearables[i + j].ComposeThumbnailUrl(), |
| | 717 | | nftInfo = wearables[i + j].GetNftInfo(), |
| | 718 | | }; |
| | 719 | |
|
| 0 | 720 | | wearableItemsForThisPage[j] = wearables[i + j]; |
| | 721 | | } |
| | 722 | | else |
| | 723 | | { |
| 0 | 724 | | pageElements[j] = null; |
| 0 | 725 | | wearableItemsForThisPage[j] = null; |
| | 726 | | } |
| | 727 | | } |
| | 728 | |
|
| 0 | 729 | | nftPageView.SetPageElementsContent(pageElements); |
| 0 | 730 | | nftPageView.IsNftInfoActived = true; |
| 0 | 731 | | nftPageView.ConfigureNFTItemInfo(nftItemInfo, wearableItemsForThisPage, false); |
| 0 | 732 | | nftPageView.OnClickBuyNft += ClickOnBuyWearable; |
| 0 | 733 | | nftPageView.OnFocusAnyNtf += FocusAnyNtfItem; |
| 0 | 734 | | return nftPageView; |
| | 735 | | } |
| | 736 | |
|
| | 737 | | private NftPageView CreateLandPageView(LandsResponse.LandEntry[] lands, int i) |
| | 738 | | { |
| 0 | 739 | | PoolableObject nftPagePoolElement = nftLandsPagesEntryPool.Get(); |
| 0 | 740 | | nftLandsPagesPoolableQueue.Add(nftPagePoolElement); |
| 0 | 741 | | nftPagePoolElement.gameObject.transform.SetParent(nftLandsCarouselContent, false); |
| 0 | 742 | | NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>(); |
| 0 | 743 | | nftPageView.OnClickBuyNft -= ClickOnBuyWearable; |
| 0 | 744 | | nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem; |
| 0 | 745 | | NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE]; |
| | 746 | |
|
| 0 | 747 | | for (int j = 0; j < PAGE_SIZE; j++) |
| | 748 | | { |
| 0 | 749 | | if (lands.Length > i + j && lands[i + j] != null) |
| | 750 | | { |
| 0 | 751 | | pageElements[j] = new () |
| | 752 | | { |
| | 753 | | showMarketplaceButton = true, |
| | 754 | | showType = true, |
| | 755 | | type = lands[i + j].Category, |
| | 756 | | marketplaceURI = "", |
| | 757 | | name = !string.IsNullOrEmpty(lands[i + j].Name) ? lands[i + j].Name : lands[i + j].Category, |
| | 758 | | rarity = LAND_RARITY, |
| | 759 | | imageURI = lands[i + j].Image, |
| | 760 | | nftInfo = lands[i + j].GetNftInfo(), |
| | 761 | | }; |
| | 762 | | } |
| 0 | 763 | | else { pageElements[j] = null; } |
| | 764 | | } |
| | 765 | |
|
| 0 | 766 | | nftPageView.SetPageElementsContent(pageElements); |
| 0 | 767 | | nftPageView.IsNftInfoActived = false; |
| 0 | 768 | | nftPageView.OnClickBuyNft += ClickOnBuyWearable; |
| 0 | 769 | | nftPageView.OnFocusAnyNtf += FocusAnyNtfItem; |
| 0 | 770 | | return nftPageView; |
| | 771 | | } |
| | 772 | | } |
| | 773 | | } |