< Summary

Class:DCL.NavmapView
Assembly:Navmap
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NavMap/NavmapView.cs
Covered lines:21
Uncovered lines:16
Coverable lines:37
Total lines:93
Line coverage:56.7% (21 of 37)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%110100%
OnEnable()0%110100%
OnDisable()0%110100%
OnDestroy()0%110100%
ConfigureMapInFullscreenMenuChanged(...)0%7.933018.18%
OnScrollValueChanged(...)0%6200%
UpdateCurrentSceneData(...)0%440100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/NavMap/NavmapView.cs

#LineLine coverage
 1using TMPro;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5namespace DCL
 6{
 7
 8    public class NavmapView : MonoBehaviour
 9    {
 10        [SerializeField] internal ScrollRect scrollRect;
 11        [SerializeField] private Transform scrollRectContentTransform;
 12
 13        [Header("TEXT")]
 14        [SerializeField] internal TextMeshProUGUI currentSceneNameText;
 15        [SerializeField] internal TextMeshProUGUI currentSceneCoordsText;
 16
 17        [Space]
 18        [SerializeField] internal NavmapToastView toastView;
 19        [SerializeField] private NavmapZoom zoom;
 20
 21        internal NavmapVisibilityBehaviour navmapVisibilityBehaviour;
 22
 23        private RectTransform rectTransform;
 24
 25
 026        private RectTransform RectTransform => rectTransform ??= transform as RectTransform;
 027        private BaseVariable<bool> navmapVisible => DataStore.i.HUDs.navmapVisible;
 628        private BaseVariable<Transform> configureMapInFullscreenMenu => DataStore.i.exploreV2.configureMapInFullscreenMe
 29
 30        void Start()
 31        {
 232            navmapVisibilityBehaviour = new NavmapVisibilityBehaviour(DataStore.i.HUDs.navmapVisible, scrollRect, scroll
 33
 234            ConfigureMapInFullscreenMenuChanged(configureMapInFullscreenMenu.Get(), null);
 35
 236            scrollRect.gameObject.SetActive(false);
 237            DataStore.i.HUDs.isNavMapInitialized.Set(true);
 238        }
 39
 40        private void OnEnable()
 41        {
 242            configureMapInFullscreenMenu.OnChange += ConfigureMapInFullscreenMenuChanged;
 43
 244            scrollRect.onValueChanged.AddListener(OnScrollValueChanged);
 245            CommonScriptableObjects.playerCoords.OnChange += UpdateCurrentSceneData;
 246        }
 47
 48        private void OnDisable()
 49        {
 250            configureMapInFullscreenMenu.OnChange -= ConfigureMapInFullscreenMenuChanged;
 51
 252            scrollRect.onValueChanged.RemoveListener(OnScrollValueChanged);
 253            CommonScriptableObjects.playerCoords.OnChange -= UpdateCurrentSceneData;
 254        }
 55
 56        private void OnDestroy()
 57        {
 258            navmapVisibilityBehaviour.Dispose();
 259        }
 60
 61        private void ConfigureMapInFullscreenMenuChanged(Transform currentParentTransform, Transform _)
 62        {
 263            if (currentParentTransform == null || transform.parent == currentParentTransform)
 264                return;
 65
 066            transform.SetParent(currentParentTransform);
 067            transform.localScale = Vector3.one;
 68
 069            RectTransform.anchorMin = Vector2.zero;
 070            RectTransform.anchorMax = Vector2.one;
 071            RectTransform.pivot = new Vector2(0.5f, 0.5f);
 072            RectTransform.localPosition = Vector2.zero;
 073            RectTransform.offsetMax = Vector2.zero;
 074            RectTransform.offsetMin = Vector2.zero;
 075        }
 76
 77        private void OnScrollValueChanged(Vector2 _)
 78        {
 079            if (!navmapVisible.Get())
 080                return;
 81
 082            MapRenderer.i.atlas.UpdateCulling();
 083            toastView.Close();
 084        }
 85
 86        private void UpdateCurrentSceneData(Vector2Int current, Vector2Int _)
 87        {
 88            const string format = "{0},{1}";
 189            currentSceneCoordsText.text = string.Format(format, current.x, current.y);
 190            currentSceneNameText.text = MinimapMetadata.GetMetadata().GetSceneInfo(current.x, current.y)?.name ?? "Unnam
 191        }
 92    }
 93}