< Summary

Class:TaskbarMoreMenuButton
Assembly:TaskbarHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TaskbarHUD/TaskbarMoreMenuButton.cs
Covered lines:15
Uncovered lines:10
Coverable lines:25
Total lines:79
Line coverage:60% (15 of 25)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%220100%
OnDestroy()0%110100%
OnDisable()0%110100%
AppMode_OnChange(...)0%110100%
PlayAnimation(...)0%12.415033.33%
GetAnimationLenght()0%12300%
SetInteractable(...)0%440100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TaskbarHUD/TaskbarMoreMenuButton.cs

#LineLine coverage
 1using DCL;
 2using System.Collections.Generic;
 3using TMPro;
 4using UnityEngine;
 5using UnityEngine.UI;
 6
 7public class TaskbarMoreMenuButton : MonoBehaviour
 8{
 9    internal enum AnimationStatus
 10    {
 11        Hide = 0,
 12        Visible = 1,
 13        In = 2,
 14        Out = 3,
 15    }
 16
 17    [SerializeField] public Button mainButton;
 18    [SerializeField] internal TMP_Text buttonText;
 19    [SerializeField] internal Animator buttonAnimator;
 20    [SerializeField] internal Color notInteractableColor;
 21    [SerializeField] internal List<AppMode> compatibleModes;
 22
 023    internal AnimationStatus lastPlayedAnimation { get; private set; } = AnimationStatus.Hide;
 24
 25    private Color originalTextColor;
 26
 27    private void Start()
 28    {
 7029        if (buttonText != null)
 7030            originalTextColor = buttonText.color;
 31
 7032        DataStore.i.appMode.OnChange += AppMode_OnChange;
 7033        AppMode_OnChange(DataStore.i.appMode.Get(), AppMode.DEFAULT);
 7034    }
 35
 19836    private void OnDestroy() { DataStore.i.appMode.OnChange -= AppMode_OnChange; }
 37
 20638    private void OnDisable() { lastPlayedAnimation = AnimationStatus.Hide; }
 39
 14040    private void AppMode_OnChange(AppMode currentMode, AppMode previousMode) { SetInteractable(compatibleModes.Contains(
 41
 42    internal void PlayAnimation(AnimationStatus newStatus)
 43    {
 44        switch (newStatus)
 45        {
 46            case AnimationStatus.Hide:
 047                buttonAnimator.SetTrigger("Hide");
 048                break;
 49            case AnimationStatus.Visible:
 050                buttonAnimator.SetTrigger("Visible");
 051                break;
 52            case AnimationStatus.In:
 053                buttonAnimator.SetTrigger("In");
 054                break;
 55            case AnimationStatus.Out:
 1156                buttonAnimator.SetTrigger("Out");
 57                break;
 58        }
 59
 1160        lastPlayedAnimation = newStatus;
 1161    }
 62
 63    internal float GetAnimationLenght()
 64    {
 065        if (buttonAnimator.GetCurrentAnimatorClipInfoCount(0) == 0 ||
 66            buttonAnimator.GetCurrentAnimatorClipInfo(0).Length == 0)
 067            return 0f;
 68
 069        return buttonAnimator.GetCurrentAnimatorClipInfo(0)[0].clip.length;
 70    }
 71
 72    private void SetInteractable(bool isInteractable)
 73    {
 7074        mainButton.interactable = isInteractable;
 75
 7076        if (buttonText != null)
 7077            buttonText.color = isInteractable ? originalTextColor : notInteractableColor;
 7078    }
 79}