< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Awake()0%110100%
OnDestroy()0%110100%
SetActive(...)0%220100%
OnControlsClick(...)0%220100%
OnHideUIClick(...)0%220100%
OnTutorialClick()0%220100%
OnResetClick(...)0%220100%
OnResetCameraClick(...)0%220100%
SetResetButtonInteractable(...)0%330100%

File(s)

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

#LineLine coverage
 1using System;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6public interface IExtraActionsView
 7{
 8    event Action OnControlsClicked,
 9                 OnHideUIClicked,
 10                 OnTutorialClicked,
 11                 OnResetClicked,
 12                 OnResetCameraClicked;
 13
 14    void OnControlsClick(DCLAction_Trigger action);
 15    void OnHideUIClick(DCLAction_Trigger action);
 16    void OnTutorialClick();
 17    void SetActive(bool isActive);
 18    void OnResetClick(DCLAction_Trigger action);
 19    void OnResetCameraClick(DCLAction_Trigger action);
 20    void SetResetButtonInteractable(bool isInteractable);
 21}
 22
 23public class ExtraActionsView : MonoBehaviour, IExtraActionsView
 24{
 25    public event Action OnControlsClicked,
 26                        OnHideUIClicked,
 27                        OnTutorialClicked,
 28                        OnResetClicked,
 29                        OnResetCameraClicked;
 30
 31    [Header("Buttons")]
 32    [SerializeField] internal Button hideUIBtn;
 33    [SerializeField] internal Button controlsBtn;
 34    [SerializeField] internal Button tutorialBtn;
 35    [SerializeField] internal Button resetBtn;
 36    [SerializeField] internal TMP_Text resetBtnText;
 37    [SerializeField] internal Button resetCameraBtn;
 38
 39    [Header("Input Actions")]
 40    [SerializeField] internal InputAction_Trigger toggleUIVisibilityInputAction;
 41    [SerializeField] internal InputAction_Trigger toggleControlsVisibilityInputAction;
 42    [SerializeField] internal InputAction_Trigger toggleResetInputAction;
 43    [SerializeField] internal InputAction_Trigger toggleResetCameraInputAction;
 44
 45    [Header("Other Configurations")]
 46    [SerializeField] internal Color disabledButtonTextColor;
 47
 48    private DCLAction_Trigger dummyActionTrigger = new DCLAction_Trigger();
 49    private Color originalResetBtnColor;
 50
 51    private const string VIEW_PATH = "GodMode/TopActionsButtons/ExtraActionsView";
 52
 53    internal static ExtraActionsView Create()
 54    {
 955        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<ExtraActionsView>();
 956        view.gameObject.name = "_ExtraActionsView";
 57
 958        return view;
 59    }
 60
 61    private void Awake()
 62    {
 4763        hideUIBtn.onClick.AddListener(() => OnHideUIClick(dummyActionTrigger));
 4764        controlsBtn.onClick.AddListener(() => OnControlsClick(dummyActionTrigger));
 4765        resetBtn.onClick.AddListener(() => OnResetClick(dummyActionTrigger));
 4766        resetCameraBtn.onClick.AddListener(() => OnResetCameraClick(dummyActionTrigger));
 4767        tutorialBtn.onClick.AddListener(OnTutorialClick);
 68
 4769        toggleUIVisibilityInputAction.OnTriggered += OnHideUIClick;
 4770        toggleControlsVisibilityInputAction.OnTriggered += OnControlsClick;
 4771        toggleResetInputAction.OnTriggered += OnResetClick;
 4772        toggleResetCameraInputAction.OnTriggered += OnResetCameraClick;
 73
 4774        originalResetBtnColor = resetBtnText.color;
 4775        SetResetButtonInteractable(true);
 4776    }
 77
 78    private void OnDestroy()
 79    {
 4780        hideUIBtn.onClick.RemoveAllListeners();
 4781        controlsBtn.onClick.RemoveAllListeners();
 4782        resetBtn.onClick.RemoveAllListeners();
 4783        resetCameraBtn.onClick.RemoveAllListeners();
 4784        tutorialBtn.onClick.RemoveListener(OnTutorialClick);
 85
 4786        toggleUIVisibilityInputAction.OnTriggered -= OnHideUIClick;
 4787        toggleControlsVisibilityInputAction.OnTriggered -= OnControlsClick;
 4788        toggleResetInputAction.OnTriggered -= OnResetClick;
 4789        toggleResetCameraInputAction.OnTriggered -= OnResetCameraClick;
 4790    }
 91
 92    public void SetActive(bool isActive)
 93    {
 294        if (gameObject.activeSelf != isActive)
 295            gameObject.SetActive(isActive);
 296    }
 97
 298    public void OnControlsClick(DCLAction_Trigger action) { OnControlsClicked?.Invoke(); }
 99
 2100    public void OnHideUIClick(DCLAction_Trigger action) { OnHideUIClicked?.Invoke(); }
 101
 2102    public void OnTutorialClick() { OnTutorialClicked?.Invoke(); }
 103
 2104    public void OnResetClick(DCLAction_Trigger action) { OnResetClicked?.Invoke(); }
 105
 2106    public void OnResetCameraClick(DCLAction_Trigger action) { OnResetCameraClicked?.Invoke(); }
 107
 108    public void SetResetButtonInteractable(bool isInteractable)
 109    {
 49110        resetBtn.interactable = isInteractable;
 49111        resetBtnText.color = isInteractable ? originalResetBtnColor : disabledButtonTextColor;
 49112    }
 113}