< Summary

Class:MinimapHUDView
Assembly:MinimapHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Minimap/MinimapHUDView.cs
Covered lines:24
Uncovered lines:3
Coverable lines:27
Total lines:77
Line coverage:88.8% (24 of 27)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
MinimapHUDView()0%110100%
Initialize(...)0%220100%
Create(...)0%110100%
UpdateData(...)0%220100%
ToggleOptions()0%2100%
SetVisibility(...)0%6.65060%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Minimap/MinimapHUDView.cs

#LineLine coverage
 1using DCL;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6public class MinimapHUDView : MonoBehaviour
 7{
 8    public const string VIEW_PATH = "MinimapHUD";
 9    public const string VIEW_OBJECT_NAME = "_MinimapHUD";
 10
 1011    private int START_MENU_HOVER_BOOL = Animator.StringToHash("hover");
 1012    private int START_MENU_PRESSED_TRIGGER = Animator.StringToHash("pressed");
 13
 14    [Header("Information")] [SerializeField]
 15    private TextMeshProUGUI sceneNameText;
 16
 17    [SerializeField] private TextMeshProUGUI playerPositionText;
 18
 19    [Header("Options")] [SerializeField] private Button optionsButton;
 20    [SerializeField] private GameObject optionsPanel;
 21    [SerializeField] private Button addBookmarkButton;
 22    [SerializeField] private Button reportSceneButton;
 23    [SerializeField] internal UsersAroundListHUDButtonView usersAroundListHudButton;
 24
 25    [Header("Map Renderer")] public RectTransform mapRenderContainer;
 26    public RectTransform mapViewport;
 27    [SerializeField] private Button openNavmapButton;
 28
 29    public static System.Action<MinimapHUDModel> OnUpdateData;
 30    public static System.Action OnOpenNavmapClicked;
 31    public InputAction_Trigger toggleNavMapAction;
 32    [SerializeField] internal ShowHideAnimator mainShowHideAnimator;
 33
 34    public void Initialize(MinimapHUDController controller)
 35    {
 936        gameObject.name = VIEW_OBJECT_NAME;
 937        optionsPanel.SetActive(false);
 38
 939        optionsButton.onClick.AddListener(controller.ToggleOptions);
 940        addBookmarkButton.onClick.AddListener(controller.AddBookmark);
 941        reportSceneButton.onClick.AddListener(controller.ReportScene);
 942        openNavmapButton.onClick.AddListener(toggleNavMapAction.RaiseOnTriggered);
 43
 944        var renderer = MapRenderer.i;
 45
 946        if (renderer != null)
 47        {
 948            renderer.atlas.viewport = mapViewport;
 949            renderer.transform.SetParent(mapRenderContainer);
 950            renderer.transform.SetAsFirstSibling();
 51        }
 952        usersAroundListHudButton.gameObject.SetActive(false);
 953    }
 54
 55    internal static MinimapHUDView Create(MinimapHUDController controller)
 56    {
 957        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<MinimapHUDView>();
 958        view.Initialize(controller);
 959        return view;
 60    }
 61
 62    internal void UpdateData(MinimapHUDModel model)
 63    {
 1264        sceneNameText.text = string.IsNullOrEmpty(model.sceneName) ? "Unnamed" : model.sceneName;
 1265        playerPositionText.text = model.playerPosition;
 1266    }
 67
 068    public void ToggleOptions() { optionsPanel.SetActive(!optionsPanel.activeSelf); }
 69
 70    public void SetVisibility(bool visible)
 71    {
 172        if (visible && !mainShowHideAnimator.isVisible)
 073            mainShowHideAnimator.Show();
 174        else if (!visible && mainShowHideAnimator.isVisible)
 075            mainShowHideAnimator.Hide();
 176    }
 77}