< Summary

Class:PlaceCardComponentView
Assembly:ExploreV2
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/Sections/PlacesAndEventsSection/SubSections/PlacesSubSection/PlaceCard/PlaceCardComponentView.cs
Covered lines:259
Uncovered lines:78
Coverable lines:337
Total lines:722
Line coverage:76.8% (259 of 337)
Covered branches:0
Total branches:0
Covered methods:47
Total methods:55
Method coverage:85.4% (47 of 55)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PlaceCardComponentView()0%110100%
Awake()0%12120100%
ToggleContextMenu()0%2100%
CopiedLink()0%6200%
ClickedTwitter()0%6200%
ChangeVote(...)0%1101000%
Configure(...)0%220100%
RefreshControl()0%7.047090.62%
SetFavoriteButton(...)0%22090%
SetVoteButtons(...)0%5.035088.89%
SetTotalVotes(...)0%220100%
SetNumberOfFavorites(...)0%220100%
SetDeployedAt(...)0%440100%
SetIsPOI(...)0%2.262060%
SetActive(...)0%6200%
SetAgeRating(...)0%5.275077.78%
SetAllPlaceCategories(...)0%2100%
SetAppearsOn(...)0%50.479020%
FavoriteValueChanged(...)0%20400%
OnFocus()0%330100%
OnLoseFocus()0%330100%
Show(...)0%110100%
Hide(...)0%110100%
Dispose()0%10100100%
ShowFavoriteButton(...)0%330100%
SetPlacePicture(...)0%4.374071.43%
SetPlacePicture(...)0%6.65060%
SetPlacePicture(...)0%6.65060%
SetPlaceName(...)0%330100%
SetPlaceDescription(...)0%440100%
SetPlaceAuthor(...)0%330100%
SetUserVisits(...)0%220100%
SetUserRating(...)0%440100%
SetNumberOfUsers(...)0%330100%
SetCoords(...)0%220100%
SetParcels(...)0%110100%
SetLoadingIndicatorVisible(...)0%110100%
OnPlaceImageLoaded(...)0%12300%
InitializeFriendsTracker()0%330100%
OnFriendAdded(...)0%3.033085.71%
OnFriendRemoved(...)0%3.043083.33%
CleanFriendHeadsItems()0%220100%
InstantiateAndConfigureFriendHead(...)0%110100%
RebuildCardLayouts()0%550100%
CloseModal()0%110100%
OnCloseActionTriggered(...)0%110100%
FormatNumber(...)0%2.862040%
ResetScrollPosition()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/ExploreV2/Scripts/Sections/PlacesAndEventsSection/SubSections/PlacesSubSection/PlaceCard/PlaceCardComponentView.cs

#LineLine coverage
 1using DCL;
 2using DCL.Controllers;
 3using DCL.Helpers;
 4using System;
 5using System.Collections.Generic;
 6using TMPro;
 7using UnityEngine;
 8using UnityEngine.UI;
 9
 10
 11public class PlaceCardComponentView : BaseComponentView, IPlaceCardComponentView, IComponentModelConfig<PlaceCardCompone
 12{
 13    internal const int THMBL_MARKETPLACE_WIDTH = 196;
 14    internal const int THMBL_MARKETPLACE_HEIGHT = 143;
 15    internal const int THMBL_MARKETPLACE_SIZEFACTOR = 50;
 16    private const string NO_DESCRIPTION_TEXT = "No description.";
 17    private const string PLACE_CATEGORIES_POOL_NAME = "PlaceCardModal_CategoriesPool";
 18    private const int PLACE_CATEGORIES_POOL_PREWARM = 5;
 19
 20    [Header("Assets References")]
 21    [SerializeField] internal FriendHeadForPlaceCardComponentView friendHeadPrefab;
 22    [SerializeField] internal UserProfile ownUserProfile;
 23    [SerializeField] internal PlaceCategoryButton placeCategoryLabelPrefab;
 24
 25    [Header("Prefab References")]
 26    [SerializeField] internal GameObject poiMark;
 27    [SerializeField] internal ImageComponentView placeImage;
 28    [SerializeField] internal TMP_Text placeNameOnIdleText;
 29    [SerializeField] internal TMP_Text placeNameOnFocusText;
 30    [SerializeField] internal TMP_Text placeDescText;
 31    [SerializeField] internal TMP_Text placeAuthorOnIdleText;
 32    [SerializeField] internal TMP_Text placeAuthorOnFocusText;
 33    [SerializeField] internal RectTransform userVisitsAndRatingContainer;
 34    [SerializeField] internal TMP_Text userVisitsText;
 35    [SerializeField] internal TMP_Text userRatingText;
 36    [SerializeField] internal RectTransform numberOfUsersContainer;
 37    [SerializeField] internal TMP_Text numberOfUsersText;
 38    [SerializeField] internal TMP_Text coordsText;
 39    [SerializeField] internal Button modalBackgroundButton;
 40    [SerializeField] internal ButtonComponentView closeCardButton;
 41    [SerializeField] internal InputAction_Trigger closeAction;
 42    [SerializeField] internal ButtonComponentView backgroundButton;
 43    [SerializeField] internal ButtonComponentView infoButton;
 44    [SerializeField] internal ButtonComponentView upvoteButton;
 45    [SerializeField] internal ButtonComponentView downvoteButton;
 46    [SerializeField] internal Button shareButton;
 47    [SerializeField] internal GameObject upvoteOff;
 48    [SerializeField] internal GameObject upvoteOn;
 49    [SerializeField] internal GameObject downvoteOff;
 50    [SerializeField] internal GameObject downvoteOn;
 51    [SerializeField] internal TMP_Text totalVotesText;
 52    [SerializeField] internal ButtonComponentView jumpinButton;
 53    [SerializeField] internal GridContainerComponentView friendsGrid;
 54    [SerializeField] internal GameObject imageContainer;
 55    [SerializeField] internal GameObject placeInfoContainer;
 56    [SerializeField] internal GameObject loadingSpinner;
 57    [SerializeField] internal GameObject cardSelectionFrame;
 58    [SerializeField] internal VerticalLayoutGroup contentVerticalLayout;
 59    [SerializeField] internal VerticalLayoutGroup infoVerticalLayout;
 60    [SerializeField] internal PlaceCardAnimatorBase cardAnimator;
 61    [SerializeField] internal FavoriteButtonComponentView favoriteButton;
 62    [SerializeField] internal GameObject favoriteButtonContainer;
 63    [SerializeField] internal TMP_Text numberOfFavoritesText;
 64    [SerializeField] internal TMP_Text updatedAtText;
 65    [SerializeField] internal ScrollRect scroll;
 66    [SerializeField] internal PlaceCopyContextualMenu placeCopyContextualMenu;
 67    [SerializeField] internal TMP_Text ageRatingText;
 68    [SerializeField] internal GameObject ageRatingOutline;
 69    [SerializeField] internal Transform placeCategoriesGrid;
 70    [SerializeField] internal List<GameObject> placeCategoriesGroup;
 71
 72    [Header("Configuration")]
 73    [SerializeField] internal Sprite defaultPicture;
 74    [SerializeField] internal bool isPlaceCardModal;
 75    [SerializeField] internal PlaceCardComponentModel model;
 76
 153477    public IFriendTrackerHandler friendsHandler { get; set; }
 18878    internal MapInfoHandler mapInfoHandler { get; set; }
 79
 221780    internal readonly Dictionary<string, BaseComponentView> currentFriendHeads = new ();
 81
 11982    public Button.ButtonClickedEvent onJumpInClick => jumpinButton != null ? jumpinButton.onClick : new Button.ButtonCli
 11683    public Button.ButtonClickedEvent onInfoClick => infoButton != null ? infoButton.onClick : new Button.ButtonClickedEv
 11684    public Button.ButtonClickedEvent onBackgroundClick => backgroundButton != null ? backgroundButton.onClick : new Butt
 85
 86    public event Action<string, bool> OnFavoriteChanged;
 87
 88    private bool thumbnailFromMarketPlaceRequested;
 221789    private readonly List<(string id, string nameToShow)> allPlaceCategories = new ();
 90    private Pool placeCategoriesPool;
 91
 92    public event Action<string, bool?> OnVoteChanged;
 93    public event Action<Vector2Int> OnPressedLinkCopy;
 94    public event Action<Vector2Int, string> OnPressedTwitterButton;
 95
 96    public override void Awake()
 97    {
 119898        base.Awake();
 99
 1198100        if (placeImage != null)
 1198101            placeImage.OnLoaded += OnPlaceImageLoaded;
 102
 1198103        if (cardSelectionFrame != null)
 1146104            cardSelectionFrame.SetActive(false);
 105
 1198106        if (closeCardButton != null)
 52107            closeCardButton.onClick.AddListener(CloseModal);
 108
 1198109        if (closeAction != null)
 52110            closeAction.OnTriggered += OnCloseActionTriggered;
 111
 1198112        if (modalBackgroundButton != null)
 52113            modalBackgroundButton.onClick.AddListener(CloseModal);
 114
 1198115        if(upvoteButton != null)
 1198116            upvoteButton.onClick.AddListener(() => ChangeVote(true));
 117
 1198118        if(downvoteButton != null)
 1198119            downvoteButton.onClick.AddListener(() => ChangeVote(false));
 120
 1198121        if(shareButton != null)
 1122            shareButton.onClick.AddListener(()=>ToggleContextMenu());
 123
 1198124        if (placeCopyContextualMenu != null)
 1125            placeCopyContextualMenu.OnTwitter += ClickedTwitter;
 126
 1198127        if (placeCopyContextualMenu != null)
 1128            placeCopyContextualMenu.OnPlaceLinkCopied += CopiedLink;
 129
 1198130        CleanFriendHeadsItems();
 131
 1198132        if (placeCategoryLabelPrefab != null)
 39133            placeCategoriesPool = PlacesAndEventsCardsFactory.GetCardsPoolLazy(PLACE_CATEGORIES_POOL_NAME, placeCategory
 1198134    }
 135
 136    private void ToggleContextMenu()
 137    {
 0138        placeCopyContextualMenu.Show();
 0139    }
 140
 141    private void CopiedLink()
 142    {
 0143        OnPressedLinkCopy?.Invoke(model.coords);
 0144    }
 145
 146    private void ClickedTwitter()
 147    {
 0148        OnPressedTwitterButton?.Invoke(model.coords, model.placeInfo.title);
 0149    }
 150
 151    private void ChangeVote(bool upvote)
 152    {
 0153        if (upvote)
 154        {
 0155            OnVoteChanged?.Invoke(model.placeInfo.id, model.isUpvote ? (bool?)null : true);
 156
 0157            if (ownUserProfile != null && ownUserProfile.isGuest)
 0158                return;
 159
 0160            model.isUpvote = !model.isUpvote;
 0161            model.isDownvote = false;
 162        }
 163        else
 164        {
 0165            OnVoteChanged?.Invoke(model.placeInfo.id, model.isDownvote ? (bool?)null : false);
 166
 0167            if (ownUserProfile != null && ownUserProfile.isGuest)
 0168                return;
 169
 0170            model.isDownvote = !model.isDownvote;
 0171            model.isUpvote = false;
 172        }
 0173        SetVoteButtons(model.isUpvote, model.isDownvote);
 0174    }
 175
 176    public void Configure(PlaceCardComponentModel newModel)
 177    {
 51178        model = newModel;
 179
 51180        InitializeFriendsTracker();
 181
 51182        if (mapInfoHandler != null)
 51183            mapInfoHandler.SetMinimapSceneInfo(model.placeInfo);
 184
 51185        RefreshControl();
 51186    }
 187
 188    public override void RefreshControl()
 189    {
 59190        thumbnailFromMarketPlaceRequested = false;
 191
 59192        if (model == null)
 0193            return;
 194
 59195        SetParcels(model.parcels);
 196
 59197        if (model.placePictureSprite != null)
 51198            SetPlacePicture(model.placePictureSprite);
 8199        else if (model.placePictureTexture != null)
 0200            SetPlacePicture(model.placePictureTexture);
 8201        else if (!string.IsNullOrEmpty(model.placePictureUri))
 8202            SetPlacePicture(model.placePictureUri);
 203        else
 0204            OnPlaceImageLoaded(null);
 205
 59206        SetPlaceName(model.placeName);
 59207        SetPlaceDescription(model.placeDescription);
 59208        SetPlaceAuthor(model.placeAuthor);
 59209        SetUserVisits(model.userVisits);
 59210        SetUserRating(model.userRating);
 59211        SetNumberOfUsers(model.numberOfUsers);
 59212        SetCoords(model.coords);
 59213        SetFavoriteButton(model.isFavorite, model.placeInfo.id);
 214
 215        //Temporary untill the release of the functionality
 59216        if (!DataStore.i.HUDs.enableFavoritePlaces.Get())
 217        {
 59218            if(favoriteButtonContainer != null)
 59219                favoriteButtonContainer.SetActive(false);
 220        }
 221
 59222        SetVoteButtons(model.isUpvote, model.isDownvote);
 59223        SetTotalVotes(model.totalVotes);
 59224        SetNumberOfFavorites(model.numberOfFavorites);
 59225        SetDeployedAt(model.deployedAt);
 59226        SetIsPOI(model.isPOI);
 59227        SetAgeRating(model.ageRating);
 59228        SetAppearsOn(model.categories);
 59229        ResetScrollPosition();
 59230        RebuildCardLayouts();
 59231    }
 232
 233    public void SetFavoriteButton(bool isFavorite, string placeId)
 234    {
 59235        model.isFavorite = isFavorite;
 59236        model.placeInfo.id = placeId;
 237
 59238        if (favoriteButton == null)
 0239            return;
 59240        favoriteButton.gameObject.SetActive(true);
 59241        favoriteButton.Configure(new FavoriteButtonComponentModel()
 242        {
 243            isFavorite = isFavorite,
 244            placeUUID = placeId
 245        });
 59246        ShowFavoriteButton(isFavorite);
 247
 59248        favoriteButton.OnFavoriteChange -= FavoriteValueChanged;
 59249        favoriteButton.OnFavoriteChange += FavoriteValueChanged;
 59250    }
 251
 252    public void SetVoteButtons(bool isUpvoted, bool isDownvoted)
 253    {
 59254        model.isUpvote = isUpvoted;
 59255        model.isDownvote = isDownvoted;
 256
 59257        if(upvoteOn == null || upvoteOff == null || downvoteOn == null || downvoteOff == null)
 0258            return;
 259
 59260        upvoteOn.SetActive(isUpvoted);
 59261        upvoteOff.SetActive(!isUpvoted);
 59262        downvoteOn.SetActive(isDownvoted);
 59263        downvoteOff.SetActive(!isDownvoted);
 59264    }
 265
 266    public void SetTotalVotes(int totalVotes)
 267    {
 59268        model.totalVotes = totalVotes;
 269
 59270        if (totalVotesText == null)
 57271            return;
 272
 2273        totalVotesText.text = $"({totalVotes})";
 2274    }
 275
 276    public void SetNumberOfFavorites(int numberOfFavorites)
 277    {
 59278        model.numberOfFavorites = numberOfFavorites;
 279
 59280        if (numberOfFavoritesText != null)
 2281            numberOfFavoritesText.text = FormatNumber(numberOfFavorites);
 59282    }
 283
 284    public void SetDeployedAt(string updatedAt)
 285    {
 59286        model.deployedAt = updatedAt;
 287
 59288        if (updatedAtText == null)
 57289            return;
 290
 2291        updatedAtText.text = DateTime.TryParse(updatedAt, out DateTime updateAtDT) ?
 292            updateAtDT.ToString("dd/MM/yyyy") :
 293            "-";
 2294    }
 295
 296    public void SetIsPOI(bool isPOI)
 297    {
 107298        model.isPOI = isPOI;
 299
 107300        if (poiMark == null)
 107301            return;
 302
 0303        poiMark.SetActive(isPOI);
 0304    }
 305
 306    public void SetActive(bool isActive)
 307    {
 0308        if (isActive)
 309        {
 0310            Show();
 311        }
 312        else
 313        {
 0314            Hide();
 315        }
 0316    }
 317
 318    public void SetAgeRating(SceneContentCategory contentCategory)
 319    {
 59320        model.ageRating = contentCategory;
 321
 59322        if (ageRatingText != null)
 2323            ageRatingText.text = contentCategory switch
 324                                 {
 0325                                     SceneContentCategory.ADULT => "PG 18+",
 0326                                     SceneContentCategory.RESTRICTED => "RESTRICTED",
 2327                                     _ => "PG 13+",
 328                                 };
 329
 59330        if (ageRatingOutline != null)
 2331            ageRatingOutline.SetActive(contentCategory != SceneContentCategory.RESTRICTED);
 59332    }
 333
 334    public void SetAllPlaceCategories(List<(string id, string nameToShow)> placeCategories)
 335    {
 0336        allPlaceCategories.Clear();
 0337        allPlaceCategories.AddRange(placeCategories);
 0338    }
 339
 340    public void SetAppearsOn(string[] categories)
 341    {
 59342        if (placeCategoriesPool == null)
 57343            return;
 344
 2345        placeCategoriesPool.ReleaseAll();
 346
 2347        if (categories == null)
 2348            return;
 349
 0350        foreach (GameObject categoryItem in placeCategoriesGroup)
 351        {
 0352            if (categoryItem == null)
 353                continue;
 354
 0355            categoryItem.SetActive(categories.Length > 0);
 356        }
 357
 0358        if (placeCategoriesGrid == null)
 0359            return;
 360
 0361        foreach (string category in categories)
 362        {
 0363            foreach ((string id, string nameToShow) categoryInfo in allPlaceCategories)
 364            {
 0365                if (categoryInfo.id != category)
 366                    continue;
 367
 0368                var categoryLabel = placeCategoriesPool.Get<PlaceCategoryButton>();
 0369                categoryLabel.transform.SetParent(placeCategoriesGrid.transform, false);
 0370                categoryLabel.SetCategory(categoryInfo.id, categoryInfo.nameToShow);
 0371                categoryLabel.SetStatus(false);
 0372                break;
 373            }
 374        }
 0375    }
 376
 377    private void FavoriteValueChanged(string placeUUID, bool isFavorite)
 378    {
 0379        OnFavoriteChanged?.Invoke(placeUUID, isFavorite);
 380
 0381        if (ownUserProfile != null && ownUserProfile.isGuest)
 382        {
 0383            favoriteButton.Configure(new FavoriteButtonComponentModel
 384            {
 385                placeUUID = placeUUID,
 386                isFavorite = false,
 387            });
 0388            return;
 389        }
 390
 0391        model.isFavorite = true;
 0392        model.placeInfo.id = placeUUID;
 0393    }
 394
 395    public override void OnFocus()
 396    {
 1397        base.OnFocus();
 398
 1399        if (cardSelectionFrame != null)
 1400            cardSelectionFrame.SetActive(true);
 401
 1402        ShowFavoriteButton(true);
 403
 1404        if(cardAnimator != null)
 1405            cardAnimator.Focus();
 1406    }
 407
 408    public override void OnLoseFocus()
 409    {
 1301410        base.OnLoseFocus();
 411
 1301412        if (cardSelectionFrame != null)
 1249413            cardSelectionFrame.SetActive(false);
 414
 1301415        ShowFavoriteButton(false);
 416
 1301417        if(cardAnimator != null)
 1249418            cardAnimator.Idle();
 1301419    }
 420
 421    public override void Show(bool instant = false)
 422    {
 3423        base.Show(instant);
 424
 3425        DataStore.i.exploreV2.isSomeModalOpen.Set(true);
 3426    }
 427
 428    public override void Hide(bool instant = false)
 429    {
 275430        base.Hide(instant);
 431
 275432        DataStore.i.exploreV2.isSomeModalOpen.Set(false);
 275433    }
 434
 435    public override void Dispose()
 436    {
 1390437        base.Dispose();
 438
 1390439        if (placeImage != null)
 440        {
 1389441            placeImage.OnLoaded -= OnPlaceImageLoaded;
 1389442            placeImage.Dispose();
 443        }
 444
 1390445        if (closeCardButton != null)
 222446            closeCardButton.onClick.RemoveAllListeners();
 447
 1390448        if (closeAction != null)
 223449            closeAction.OnTriggered -= OnCloseActionTriggered;
 450
 1390451        if (modalBackgroundButton != null)
 222452            modalBackgroundButton.onClick.RemoveAllListeners();
 453
 1390454        if (friendsHandler != null)
 455        {
 21456            friendsHandler.OnFriendAddedEvent -= OnFriendAdded;
 21457            friendsHandler.OnFriendRemovedEvent -= OnFriendRemoved;
 458        }
 459
 1390460        if (friendsGrid != null)
 1166461            friendsGrid.Dispose();
 462
 1390463        if(favoriteButton != null)
 1389464            favoriteButton.OnFavoriteChange -= FavoriteValueChanged;
 465
 1390466        if (placeCopyContextualMenu != null)
 1467            placeCopyContextualMenu.OnTwitter -= ClickedTwitter;
 468
 1390469        if (placeCopyContextualMenu != null)
 1470            placeCopyContextualMenu.OnPlaceLinkCopied -= CopiedLink;
 1390471    }
 472
 473    private void ShowFavoriteButton(bool show)
 474    {
 1361475        if(favoriteButton != null && !favoriteButton.IsFavorite())
 1303476            favoriteButton.gameObject.SetActive(show);
 1361477    }
 478
 479    public void SetPlacePicture(Sprite sprite)
 480    {
 52481        if (sprite == null && defaultPicture != null)
 0482            sprite = defaultPicture;
 483
 52484        model.placePictureSprite = sprite;
 485
 52486        if (placeImage == null)
 0487            return;
 488
 52489        placeImage.SetImage(sprite);
 52490    }
 491
 492    public void SetPlacePicture(Texture2D texture)
 493    {
 1494        if (texture == null && defaultPicture != null)
 495        {
 0496            SetPlacePicture(defaultPicture);
 0497            return;
 498        }
 499
 1500        model.placePictureTexture = texture;
 501
 1502        if (!Application.isPlaying)
 0503            return;
 504
 1505        if (placeImage == null)
 0506            return;
 507
 1508        placeImage.SetImage(texture);
 1509    }
 510
 511    public void SetPlacePicture(string uri)
 512    {
 9513        if (string.IsNullOrEmpty(uri) && defaultPicture != null)
 514        {
 0515            SetPlacePicture(defaultPicture);
 0516            return;
 517        }
 518
 9519        model.placePictureUri = uri;
 520
 9521        if (!Application.isPlaying)
 0522            return;
 523
 9524        if (placeImage == null)
 0525            return;
 526
 9527        placeImage.SetImage(uri);
 9528    }
 529
 530    public void SetPlaceName(string newText)
 531    {
 60532        model.placeName = newText;
 533
 60534        if (placeNameOnIdleText != null)
 60535            placeNameOnIdleText.text = newText;
 536
 60537        if (placeNameOnFocusText != null)
 58538            placeNameOnFocusText.text = newText;
 60539    }
 540
 541    public void SetPlaceDescription(string newText)
 542    {
 60543        model.placeDescription = newText;
 544
 60545        if (placeDescText == null)
 57546            return;
 547
 3548        placeDescText.text = string.IsNullOrEmpty(newText) ? NO_DESCRIPTION_TEXT : newText;
 3549    }
 550
 551    public void SetPlaceAuthor(string newText)
 552    {
 60553        model.placeAuthor = newText;
 554
 60555        if (placeAuthorOnIdleText != null)
 60556            placeAuthorOnIdleText.text = newText;
 557
 60558        if(placeAuthorOnFocusText != null)
 57559            placeAuthorOnFocusText.text = newText;
 60560    }
 561
 562    public void SetUserVisits(int userVisits)
 563    {
 59564        model.userVisits = userVisits;
 565
 59566        if (userVisitsText != null)
 59567            userVisitsText.text = FormatNumber(userVisits);
 59568    }
 569
 570    public void SetUserRating(float? userRating)
 571    {
 59572        model.userRating = userRating;
 573
 59574        if (userRatingText != null)
 59575            userRatingText.text = userRating != null ? $"{userRating.Value * 100:0}%" : "-%";
 59576    }
 577
 578    public void SetNumberOfUsers(int newNumberOfUsers)
 579    {
 60580        model.numberOfUsers = newNumberOfUsers;
 581
 60582        if (numberOfUsersText != null)
 60583            numberOfUsersText.text = FormatNumber(newNumberOfUsers);
 584
 60585        if (numberOfUsersContainer != null)
 58586            numberOfUsersContainer.gameObject.SetActive(newNumberOfUsers > 0);
 60587    }
 588
 589    public void SetCoords(Vector2Int newCoords)
 590    {
 60591        model.coords = newCoords;
 592
 60593        if (coordsText == null)
 57594            return;
 595
 3596        coordsText.text = $"{newCoords.x},{newCoords.y}";
 3597    }
 598
 120599    public void SetParcels(Vector2Int[] parcels) { model.parcels = parcels; }
 600
 601    public void SetLoadingIndicatorVisible(bool isVisible)
 602    {
 2603        imageContainer.SetActive(!isVisible);
 2604        placeInfoContainer.SetActive(!isVisible);
 2605        loadingSpinner.SetActive(isVisible);
 2606    }
 607
 608    internal void OnPlaceImageLoaded(Sprite sprite)
 609    {
 0610        if (sprite != null)
 0611            return;
 612
 0613        if (!thumbnailFromMarketPlaceRequested)
 614        {
 0615            thumbnailFromMarketPlaceRequested = true;
 0616            SetPlacePicture(MapUtils.GetMarketPlaceThumbnailUrl(model.parcels, THMBL_MARKETPLACE_WIDTH, THMBL_MARKETPLAC
 617        }
 618        else
 619        {
 0620            SetPlacePicture(sprite: null);
 621        }
 0622    }
 623
 624    internal void InitializeFriendsTracker()
 625    {
 52626        CleanFriendHeadsItems();
 627
 52628        if (mapInfoHandler == null)
 16629            mapInfoHandler = new MapInfoHandler();
 630
 52631        if (friendsHandler == null)
 632        {
 16633            friendsHandler = new FriendsHandler(mapInfoHandler);
 16634            friendsHandler.OnFriendAddedEvent += OnFriendAdded;
 16635            friendsHandler.OnFriendRemovedEvent += OnFriendRemoved;
 636        }
 52637    }
 638
 639    internal void OnFriendAdded(UserProfile profile, Color backgroundColor)
 640    {
 3641        if (currentFriendHeads.ContainsKey(profile.userId))
 0642            return;
 643
 3644        BaseComponentView newFriend = InstantiateAndConfigureFriendHead(
 645            new FriendHeadForPlaceCardComponentModel
 646            {
 647                userProfile = profile,
 648                backgroundColor = backgroundColor
 649            },
 650            friendHeadPrefab);
 651
 3652        if (friendsGrid != null)
 3653            friendsGrid.AddItemWithResize(newFriend);
 654
 3655        currentFriendHeads.Add(profile.userId, newFriend);
 3656    }
 657
 658    internal void OnFriendRemoved(UserProfile profile)
 659    {
 1660        if (!currentFriendHeads.ContainsKey(profile.userId))
 0661            return;
 662
 1663        if (friendsGrid != null)
 1664            friendsGrid.RemoveItem(currentFriendHeads[profile.userId]);
 665
 1666        currentFriendHeads.Remove(profile.userId);
 1667    }
 668
 669    internal void CleanFriendHeadsItems()
 670    {
 1251671        if (friendsGrid != null)
 672        {
 1197673            friendsGrid.RemoveItems();
 1197674            currentFriendHeads.Clear();
 675        }
 1251676    }
 677
 678    internal BaseComponentView InstantiateAndConfigureFriendHead(FriendHeadForPlaceCardComponentModel friendInfo, Friend
 679    {
 4680        FriendHeadForPlaceCardComponentView friendHeadGO = GameObject.Instantiate(prefabToUse);
 4681        friendHeadGO.Configure(friendInfo);
 682
 4683        return friendHeadGO;
 684    }
 685
 686    private void RebuildCardLayouts()
 687    {
 59688        if (contentVerticalLayout != null)
 2689            Utils.ForceRebuildLayoutImmediate(contentVerticalLayout.transform as RectTransform);
 690
 59691        if (infoVerticalLayout != null)
 2692            Utils.ForceRebuildLayoutImmediate(infoVerticalLayout.transform as RectTransform);
 693
 59694        if (numberOfUsersContainer != null)
 57695            Utils.ForceRebuildLayoutImmediate(numberOfUsersContainer);
 696
 59697        if (userVisitsAndRatingContainer != null)
 57698            Utils.ForceRebuildLayoutImmediate(userVisitsAndRatingContainer);
 59699    }
 700
 8701    internal void CloseModal() { Hide(); }
 702
 6703    internal void OnCloseActionTriggered(DCLAction_Trigger action) { CloseModal(); }
 704
 705    private static string FormatNumber(int num)
 706    {
 121707        if (num < 1000)
 121708            return num.ToString();
 709
 0710        float divided = num / 1000.0f;
 0711        divided = (int)(divided * 100) / 100f;
 0712        return $"{divided:F2}k";
 713    }
 714
 715    private void ResetScrollPosition()
 716    {
 59717        if (scroll == null)
 57718            return;
 719
 2720        scroll.verticalNormalizedPosition = 1;
 2721    }
 722}

Methods/Properties

friendsHandler()
friendsHandler(IFriendTrackerHandler)
mapInfoHandler()
mapInfoHandler(MapInfoHandler)
PlaceCardComponentView()
onJumpInClick()
onInfoClick()
onBackgroundClick()
Awake()
ToggleContextMenu()
CopiedLink()
ClickedTwitter()
ChangeVote(System.Boolean)
Configure(PlaceCardComponentModel)
RefreshControl()
SetFavoriteButton(System.Boolean, System.String)
SetVoteButtons(System.Boolean, System.Boolean)
SetTotalVotes(System.Int32)
SetNumberOfFavorites(System.Int32)
SetDeployedAt(System.String)
SetIsPOI(System.Boolean)
SetActive(System.Boolean)
SetAgeRating(DCL.Controllers.SceneContentCategory)
SetAllPlaceCategories(System.Collections.Generic.List[ValueTuple`2])
SetAppearsOn(System.String[])
FavoriteValueChanged(System.String, System.Boolean)
OnFocus()
OnLoseFocus()
Show(System.Boolean)
Hide(System.Boolean)
Dispose()
ShowFavoriteButton(System.Boolean)
SetPlacePicture(UnityEngine.Sprite)
SetPlacePicture(UnityEngine.Texture2D)
SetPlacePicture(System.String)
SetPlaceName(System.String)
SetPlaceDescription(System.String)
SetPlaceAuthor(System.String)
SetUserVisits(System.Int32)
SetUserRating(System.Nullable[Single])
SetNumberOfUsers(System.Int32)
SetCoords(UnityEngine.Vector2Int)
SetParcels(UnityEngine.Vector2Int[])
SetLoadingIndicatorVisible(System.Boolean)
OnPlaceImageLoaded(UnityEngine.Sprite)
InitializeFriendsTracker()
OnFriendAdded(UserProfile, UnityEngine.Color)
OnFriendRemoved(UserProfile)
CleanFriendHeadsItems()
InstantiateAndConfigureFriendHead(FriendHeadForPlaceCardComponentModel, FriendHeadForPlaceCardComponentView)
RebuildCardLayouts()
CloseModal()
OnCloseActionTriggered(DCLAction_Trigger)
FormatNumber(System.Int32)
ResetScrollPosition()