Ejemplo n.º 1
0
        public void BePopulatedCorrectlyWithNullOrEmptyElements()
        {
            var sceneInfo = new MinimapMetadata.MinimapSceneInfo()
            {
                name        = "foo",
                owner       = null,
                description = "",
                isPOI       = false,
                parcels     = new List <Vector2Int>()
                {
                    new Vector2Int(10, 10), new Vector2Int(10, 11), new Vector2Int(10, 12)
                }
            };

            MinimapMetadata.GetMetadata().Clear();
            MinimapMetadata.GetMetadata().AddSceneInfo(sceneInfo);

            navmapToastView.Populate(new Vector2Int(10, 11), sceneInfo);
            Assert.IsTrue(navmapToastView.gameObject.activeSelf);

            Assert.IsTrue(navmapToastView.sceneLocationText.transform.parent.gameObject.activeInHierarchy);
            Assert.AreEqual("10, 11", navmapToastView.sceneLocationText.text);

            Assert.IsTrue(navmapToastView.sceneTitleText.transform.parent.gameObject.activeInHierarchy);
            Assert.IsFalse(navmapToastView.sceneOwnerText.transform.parent.gameObject.activeInHierarchy);
            Assert.IsFalse(navmapToastView.scenePreviewContainer.gameObject.activeInHierarchy);
        }
Ejemplo n.º 2
0
        public void BePopulatedCorrectly()
        {
            var sceneInfo = new MinimapMetadata.MinimapSceneInfo()
            {
                name        = "foo",
                owner       = "bar",
                description = "foobar",
                isPOI       = false,
                parcels     = new List <Vector2Int>()
                {
                    new Vector2Int(10, 10), new Vector2Int(10, 11), new Vector2Int(10, 12)
                }
            };

            MinimapMetadata.GetMetadata().Clear();
            MinimapMetadata.GetMetadata().AddSceneInfo(sceneInfo);

            navmapToastView.Populate(new Vector2Int(10, 10), sceneInfo);
            Assert.IsTrue(navmapToastView.gameObject.activeSelf);

            Assert.AreEqual(sceneInfo.name, navmapToastView.sceneTitleText.text);
            Assert.AreEqual($"Created by: {sceneInfo.owner}", navmapToastView.sceneOwnerText.text);
            Assert.AreEqual("10, 10", navmapToastView.sceneLocationText.text);

            Assert.IsTrue(navmapToastView.sceneTitleText.gameObject.activeInHierarchy);
            Assert.IsTrue(navmapToastView.sceneOwnerText.gameObject.activeInHierarchy);
        }
Ejemplo n.º 3
0
    void OnSceneInfoUpdated(MinimapMetadata.MinimapSceneInfo info)
    {
        if (pendingSceneData.Count == 0)
        {
            return;
        }

        Vector2Int?keyToRemove = null;

        using (var iterator = pendingSceneData.GetEnumerator())
        {
            while (iterator.MoveNext())
            {
                if (info.parcels.Contains(iterator.Current.Key))
                {
                    iterator.Current.Value.Resolve(info);
                    keyToRemove = iterator.Current.Key;
                    break;
                }
            }
        }
        if (keyToRemove != null)
        {
            pendingSceneData.Remove(keyToRemove.Value);
        }
    }
Ejemplo n.º 4
0
        private void MapRenderer_OnSceneInfoUpdated(MinimapMetadata.MinimapSceneInfo sceneInfo)
        {
            if (!sceneInfo.isPOI)
            {
                return;
            }

            if (scenesOfInterest.Contains(sceneInfo))
            {
                return;
            }

            scenesOfInterest.Add(sceneInfo);

            GameObject go = Object.Instantiate(scenesOfInterestIconPrefab.gameObject, overlayContainer.transform);

            Vector2 centerTile = Vector2.zero;

            foreach (var parcel in sceneInfo.parcels)
            {
                centerTile += parcel;
            }

            centerTile /= (float)sceneInfo.parcels.Count;

            (go.transform as RectTransform).anchoredPosition = MapUtils.GetTileToLocalPosition(centerTile.x, centerTile.y);

            MapSceneIcon icon = go.GetComponent <MapSceneIcon>();

            icon.title.text = sceneInfo.name;

            scenesOfInterestMarkers.Add(sceneInfo, go);
        }
Ejemplo n.º 5
0
 void SetMapInfoData(IMapDataView mapInfoView)
 {
     MinimapMetadata.MinimapSceneInfo mapInfo = mapInfoView.GetMinimapSceneInfo();
     sceneName.text   = mapInfo.name;
     coordinates.text = $"{mapInfoView.GetBaseCoord().x},{mapInfoView.GetBaseCoord().y}";
     creatorName.text = mapInfo.owner;
     description.text = mapInfo.description;
 }
Ejemplo n.º 6
0
    private void OnMapInfoUpdated(MinimapMetadata.MinimapSceneInfo info)
    {
        sceneName.text = info.name;

        FetchThumbnail(info.previewImageUrl,
                       onFail: () => FetchThumbnail(MapUtils.GetMarketPlaceThumbnailUrl(info, THMBL_MARKETPLACE_WIDTH, THMBL_MARKETPLACE_HEIGHT, THMBL_MARKETPLACE_SIZEFACTOR),
                                                    onFail: () => SetThumbnail(errorThumbnail.texture)));
    }
        public void Populate(Vector2Int coordinates, MinimapMetadata.MinimapSceneInfo sceneInfo)
        {
            if (!gameObject.activeSelf)
            {
                AudioScriptableObjects.dialogOpen.Play(true);
            }

            bool sceneInfoExists = sceneInfo != null;

            gameObject.SetActive(true);
            scenePreviewImage.gameObject.SetActive(false);
            location = coordinates;

            PositionToast(coordinates);

            sceneLocationText.text = $"{coordinates.x}, {coordinates.y}";

            sceneOwnerText.transform.parent.gameObject.SetActive(sceneInfoExists && !string.IsNullOrEmpty(sceneInfo.owner));
            sceneTitleText.text = "Untitled Scene";

            bool useDefaultThumbnail =
                !sceneInfoExists || (sceneInfoExists && string.IsNullOrEmpty(sceneInfo.previewImageUrl));

            if (useDefaultThumbnail)
            {
                DisplayThumbnail(scenePreviewFailImage.texture);
                currentImageUrl = "";
            }

            if (sceneInfoExists)
            {
                sceneTitleText.text = sceneInfo.name;
                sceneOwnerText.text = $"Created by: {sceneInfo.owner}";

                if (currentImageUrl == sceneInfo.previewImageUrl)
                {
                    DisplayThumbnail(texturePromise.asset.texture);
                    return;
                }

                if (texturePromise != null)
                {
                    AssetPromiseKeeper_Texture.i.Forget(texturePromise);
                    texturePromise = null;
                }


                if (!string.IsNullOrEmpty(sceneInfo.previewImageUrl))
                {
                    texturePromise = new AssetPromise_Texture(sceneInfo.previewImageUrl, storeTexAsNonReadable: false);
                    texturePromise.OnSuccessEvent += (textureAsset) => { DisplayThumbnail(textureAsset.texture); };
                    texturePromise.OnFailEvent    += (textureAsset) => { DisplayThumbnail(scenePreviewFailImage.texture); };
                    AssetPromiseKeeper_Texture.i.Keep(texturePromise);
                }

                currentImageUrl = sceneInfoExists ? sceneInfo.previewImageUrl : "";
            }
        }
Ejemplo n.º 8
0
    public void Resolve(MinimapMetadata.MinimapSceneInfo info)
    {
        MapDataToResolve toResolve;

        for (int i = 0; i < infoToResolve.Count; i++)
        {
            toResolve = infoToResolve[i];
            toResolve.view.SetMinimapSceneInfo(info);
            toResolve.onResolveCallback?.Invoke(toResolve.view);
        }
        infoToResolve.Clear();
    }
Ejemplo n.º 9
0
        void SimulateMinimapUpdate()
        {
            var scenes = new MinimapMetadata.MinimapSceneInfo[] {
                new MinimapMetadata.MinimapSceneInfo()
                {
                    name        = "Temptation",
                    description = "It was great...",
                    isPOI       = true,
                    parcels     = new List <Vector2Int>()
                    {
                        BASECOORD_TEMPTATION,
                        BASECOORD_TEMPTATION + new Vector2Int(0, 1),
                        BASECOORD_TEMPTATION + new Vector2Int(0, 2)
                    }
                },
                new MinimapMetadata.MinimapSceneInfo()
                {
                    name        = "First Cell",
                    description = "",
                    isPOI       = true,
                    parcels     = new List <Vector2Int>()
                    {
                        BASECOORD_FIRST_CELL, BASECOORD_FIRST_CELL + new Vector2Int(0, 1)
                    }
                },
                new MinimapMetadata.MinimapSceneInfo()
                {
                    name        = "The one in the middle!",
                    description = "",
                    isPOI       = true,
                    parcels     = new List <Vector2Int>()
                    {
                        BASECOORD_SECOND_CELL
                    }
                }
            };

            string json = "[";

            for (int i = 0; i < scenes.Length; i++)
            {
                json += JsonUtility.ToJson(scenes[i]);
                if (i != scenes.Length - 1)
                {
                    json += ",";
                }
            }
            json += "]";

            MinimapMetadataController.i.UpdateMinimapSceneInformation(json);
        }
Ejemplo n.º 10
0
        public IEnumerator DisplayParcelOfInterestIconsProperly()
        {
            var sceneInfo = new MinimapMetadata.MinimapSceneInfo();

            sceneInfo.name    = "important scene";
            sceneInfo.isPOI   = true;
            sceneInfo.parcels = new List <Vector2Int>()
            {
                new Vector2Int()
                {
                    x = 0, y = 0
                },
                new Vector2Int()
                {
                    x = 0, y = 1
                },
                new Vector2Int()
                {
                    x = 1, y = 0
                },
                new Vector2Int()
                {
                    x = 1, y = 1
                }
            };

            MinimapMetadata.GetMetadata().AddSceneInfo(sceneInfo);

            var sceneInfo2 = new MinimapMetadata.MinimapSceneInfo();

            sceneInfo2.name    = "non-important scene";
            sceneInfo2.isPOI   = false;
            sceneInfo2.parcels = new List <Vector2Int>()
            {
                new Vector2Int()
                {
                    x = 5, y = 0
                },
            };

            MinimapMetadata.GetMetadata().AddSceneInfo(sceneInfo2);

            MapSceneIcon[] icons = MapRenderer.i.GetComponentsInChildren <MapSceneIcon>();

            Assert.AreEqual(1, icons.Length, "Only 1 icon is marked as POI, but 2 icons were spawned");
            Assert.AreEqual(sceneInfo.name, icons[0].title.text);
            Assert.AreEqual(new Vector3(3010, 3010, 0), icons[0].transform.localPosition);

            yield return(null);
        }
Ejemplo n.º 11
0
        public void Populate(Vector2Int coordinates, MinimapMetadata.MinimapSceneInfo sceneInfo)
        {
            bool sceneInfoExists = sceneInfo != null;

            MapRenderer.i.showCursorCoords = false;

            gameObject.SetActive(true);
            location = coordinates;

            PositionToast(coordinates);

            sceneLocationText.text = $"{coordinates.x}, {coordinates.y}";

            sceneOwnerText.transform.parent.gameObject.SetActive(sceneInfoExists && !string.IsNullOrEmpty(sceneInfo.owner));
            sceneDescriptionText.transform.parent.gameObject.SetActive(sceneInfoExists && !string.IsNullOrEmpty(sceneInfo.description));
            sceneTitleText.transform.parent.gameObject.SetActive(sceneInfoExists && !string.IsNullOrEmpty(sceneInfo.name));
            scenePreviewImage.gameObject.SetActive(sceneInfoExists && !string.IsNullOrEmpty(sceneInfo.previewImageUrl));

            if (sceneInfoExists)
            {
                sceneTitleText.text       = sceneInfo.name;
                sceneOwnerText.text       = $"Created by: {sceneInfo.owner}";
                sceneDescriptionText.text = sceneInfo.description;

                if (currentImageUrl == sceneInfo.previewImageUrl)
                {
                    return;
                }

                if (currentImage != null)
                {
                    Destroy(currentImage);
                }

                if (downloadCoroutine != null)
                {
                    CoroutineStarter.Stop(downloadCoroutine);
                }

                if (sceneInfoExists && !string.IsNullOrEmpty(sceneInfo.previewImageUrl))
                {
                    downloadCoroutine = CoroutineStarter.Start(Download(sceneInfo.previewImageUrl));
                }

                currentImageUrl = sceneInfoExists ? sceneInfo.previewImageUrl : "";
            }
        }
Ejemplo n.º 12
0
        public static string GetMarketPlaceThumbnailUrl(MinimapMetadata.MinimapSceneInfo info, int width, int height, int sizeFactor)
        {
            string     parcels = "";
            Vector2Int min     = new Vector2Int(int.MaxValue, int.MaxValue);
            Vector2Int max     = new Vector2Int(int.MinValue, int.MinValue);
            Vector2Int coord;

            for (int i = 0; i < info.parcels.Count; i++)
            {
                coord    = info.parcels[i];
                parcels += string.Format("{0},{1}", coord.x, coord.y);
                if (i < info.parcels.Count - 1)
                {
                    parcels += ";";
                }

                if (coord.x < min.x)
                {
                    min.x = coord.x;
                }
                if (coord.y < min.y)
                {
                    min.y = coord.y;
                }
                if (coord.x > max.x)
                {
                    max.x = coord.x;
                }
                if (coord.y > max.y)
                {
                    max.y = coord.y;
                }
            }

            int centerX      = (int)(min.x + (max.x - min.x) * 0.5f);
            int centerY      = (int)(min.y + (max.y - min.y) * 0.5f);
            int sceneMaxSize = Mathf.Clamp(Mathf.Max(max.x - min.x, max.y - min.y), 1, int.MaxValue);
            int size         = sizeFactor / sceneMaxSize;

            return($"https://api.decentraland.org/v1/map.png?width={width}&height={height}&size={size}&center={centerX},{centerY}&selected={parcels}");
        }
Ejemplo n.º 13
0
        public void CloseWhenCloseButtonIsClicked()
        {
            var sceneInfo = new MinimapMetadata.MinimapSceneInfo()
            {
                name        = "foo",
                owner       = null,
                description = "",
                isPOI       = false,
                parcels     = new List <Vector2Int>()
                {
                    new Vector2Int(10, 10), new Vector2Int(10, 11), new Vector2Int(10, 12)
                }
            };

            MinimapMetadata.GetMetadata().Clear();
            MinimapMetadata.GetMetadata().AddSceneInfo(sceneInfo);

            navmapToastView.Populate(new Vector2Int(10, 11), sceneInfo);
            Assert.IsTrue(navmapToastView.gameObject.activeSelf);
            navmapToastView.OnCloseClick();
            Assert.IsFalse(navmapToastView.gameObject.activeSelf);
        }
Ejemplo n.º 14
0
        public void OnMapMetadataInfoUpdated(MinimapMetadata.MinimapSceneInfo sceneInfo)
        {
            if (!isOpen)
            {
                return;
            }

            bool updatedCurrentLocationInfo = false;

            foreach (Vector2Int parcel in sceneInfo.parcels)
            {
                if (parcel == location)
                {
                    updatedCurrentLocationInfo = true;
                    break;
                }
            }

            if (updatedCurrentLocationInfo)
            {
                Populate(location, sceneInfo);
            }
        }
Ejemplo n.º 15
0
 public void SetMinimapSceneInfo(MinimapMetadata.MinimapSceneInfo info)
 {
     this.info = info;
     onInfoUpdate?.Invoke(info);
 }