< Summary

Class:CatalogBtnView
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/GodMode/CatalogBtnView.cs
Covered lines:18
Uncovered lines:0
Coverable lines:18
Total lines:64
Line coverage:100% (18 of 18)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CatalogBtnView()0%110100%
Create()0%110100%
Awake()0%110100%
OnDestroy()0%110100%
OnPointerClick(...)0%220100%
OnPointerEnter(...)0%220100%
OnPointerExit()0%220100%
SetActive(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/GodMode/CatalogBtnView.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3using UnityEngine.EventSystems;
 4using UnityEngine.UI;
 5
 6public interface ICatalogBtnView
 7{
 8    event Action OnCatalogButtonClick;
 9    event Action OnHideTooltip;
 10    event Action<BaseEventData, string> OnShowTooltip;
 11
 12    void OnPointerClick(DCLAction_Trigger action);
 13    void OnPointerEnter(PointerEventData eventData);
 14    void OnPointerExit();
 15    void SetActive(bool isActive);
 16}
 17
 18public class CatalogBtnView : MonoBehaviour, ICatalogBtnView
 19{
 20    public event Action OnCatalogButtonClick;
 21    public event Action<BaseEventData, string> OnShowTooltip;
 22    public event Action OnHideTooltip;
 23
 24    [SerializeField] internal Button mainButton;
 2625    [SerializeField] internal string tooltipText = "Open Catalog (C)";
 26    [SerializeField] internal EventTrigger catalogButtonEventTrigger;
 27    [SerializeField] internal InputAction_Trigger toggleCatalogInputAction;
 28
 29    private DCLAction_Trigger dummyActionTrigger = new DCLAction_Trigger();
 30
 31    private const string VIEW_PATH = "GodMode/CatalogBtnView";
 32
 33    internal static CatalogBtnView Create()
 34    {
 535        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<CatalogBtnView>();
 536        view.gameObject.name = "_CatalogBtnView";
 37
 538        return view;
 39    }
 40
 41    private void Awake()
 42    {
 2443        mainButton.onClick.AddListener(() => OnPointerClick(dummyActionTrigger));
 2444        toggleCatalogInputAction.OnTriggered += OnPointerClick;
 2445        BIWUtils.ConfigureEventTrigger(catalogButtonEventTrigger, EventTriggerType.PointerEnter, (eventData) => OnPointe
 2446        BIWUtils.ConfigureEventTrigger(catalogButtonEventTrigger, EventTriggerType.PointerExit, (eventData) => OnPointer
 2447    }
 48
 49    private void OnDestroy()
 50    {
 2451        mainButton.onClick.RemoveAllListeners();
 2452        toggleCatalogInputAction.OnTriggered -= OnPointerClick;
 2453        BIWUtils.RemoveEventTrigger(catalogButtonEventTrigger, EventTriggerType.PointerEnter);
 2454        BIWUtils.RemoveEventTrigger(catalogButtonEventTrigger, EventTriggerType.PointerExit);
 2455    }
 56
 257    public void OnPointerClick(DCLAction_Trigger action) { OnCatalogButtonClick?.Invoke(); }
 58
 259    public void OnPointerEnter(PointerEventData eventData) { OnShowTooltip?.Invoke(eventData, tooltipText); }
 60
 261    public void OnPointerExit() { OnHideTooltip?.Invoke(); }
 62
 463    public void SetActive(bool isActive) { gameObject.SetActive(isActive); }
 64}