< Summary

Class:BuildModeHUDView
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/BuildModeHUDView.cs
Covered lines:68
Uncovered lines:14
Coverable lines:82
Total lines:188
Line coverage:82.9% (68 of 82)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Initialize(...)0%110100%
OnDestroy()0%110100%
SetPublishBtnAvailability(...)0%110100%
RefreshCatalogAssetPack()0%110100%
RefreshCatalogContent()0%110100%
SetVisibilityOfCatalog(...)0%220100%
SetVisibilityOfSceneInfo(...)0%220100%
SetVisibilityOfControls(...)0%110100%
SetVisibilityOfExtraBtns(...)0%110100%
SetFirstPersonView()0%110100%
SetGodModeView()0%2100%
HideToolTip()0%110100%
SetActive(...)0%110100%
AnimatorShow(...)0%6200%
SetVisibilityOfInspector(...)0%220100%

File(s)

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

#LineLine coverage
 1using UnityEngine;
 2using UnityEngine.EventSystems;
 3using UnityEngine.Serialization;
 4using UnityEngine.UI;
 5
 6public interface IBuildModeHUDView
 7{
 8    GameObject viewGO { get; }
 9    SaveHUDView saveHud { get; }
 10    SceneCatalogView sceneCatalog { get; }
 11    EntityInformationView entityInformation { get; }
 12    bool isShowHideAnimatorVisible { get; }
 13
 14    void AnimatorShow(bool isVisible);
 15    void HideToolTip();
 16    void Initialize(BuildModeHUDInitializationModel controllers);
 17    void RefreshCatalogAssetPack();
 18    void RefreshCatalogContent();
 19    void SetActive(bool isActive);
 20    void SetFirstPersonView();
 21    void SetGodModeView();
 22    void SetPublishBtnAvailability(bool isAvailable, string feedbackMessage = "");
 23    void SetVisibilityOfCatalog(bool isVisible);
 24    void SetVisibilityOfControls(bool isVisible);
 25    void SetVisibilityOfExtraBtns(bool isVisible);
 26    void SetVisibilityOfSceneInfo(bool isVisible);
 27    void SetVisibilityOfInspector(bool isVisible);
 28}
 29
 30public class BuildModeHUDView : MonoBehaviour, IBuildModeHUDView
 31{
 032    public GameObject viewGO => !isDestroyed ? gameObject : null;
 033    public SaveHUDView saveHud  => saveView;
 034    public SceneCatalogView sceneCatalog => sceneCatalogView;
 035    public EntityInformationView entityInformation => entityInformationView;
 036    public bool isShowHideAnimatorVisible => showHideAnimator.isVisible;
 37
 38    [Header("Main Containers")]
 39    [SerializeField] internal GameObject firstPersonCanvasGO;
 40    [SerializeField] internal GameObject godModeCanvasGO;
 41
 42    [Header("Animator")]
 43    [SerializeField] internal ShowHideAnimator showHideAnimator;
 44
 45    [Header("UI Modules")]
 46    [SerializeField] internal TooltipView tooltipView;
 47    [SerializeField] internal TooltipView feedbackTtooltipView;
 48    [SerializeField] internal QuickBarView quickBarView;
 49    [SerializeField] internal SceneCatalogView sceneCatalogView;
 50    [SerializeField] internal EntityInformationView entityInformationView;
 51    [SerializeField] internal FirstPersonModeView firstPersonModeView;
 52    [SerializeField] internal ShortcutsView shortcutsView;
 53    [SerializeField] internal PublishPopupView publishPopupView;
 54    [SerializeField] internal DragAndDropSceneObjectView dragAndDropSceneObjectView;
 55    [SerializeField] internal PublishBtnView publishBtnView;
 56    [SerializeField] internal InspectorBtnView inspectorBtnView;
 57    [SerializeField] internal CatalogBtnView catalogBtnView;
 58    [SerializeField] internal InspectorView inspectorView;
 59    [SerializeField] internal TopActionsButtonsView topActionsButtonsView;
 60    [SerializeField] internal BuildModeConfirmationModalView buildModeConfirmationModalView;
 61    [SerializeField] internal SaveHUDView saveView;
 62    [SerializeField] internal PublicationDetailsView newProjectDetailsView;
 63    [SerializeField] internal PublicationDetailsView publicationDetailsView;
 64
 65    private bool isDestroyed = false;
 66    internal BuildModeHUDInitializationModel controllers;
 67
 68    private const string VIEW_PATH = "BuildModeHUD";
 69
 70    internal static BuildModeHUDView Create()
 71    {
 1972        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<BuildModeHUDView>();
 1973        view.gameObject.name = "_BuildModeHUD";
 74
 1975        return view;
 76    }
 77
 78    public void Initialize(BuildModeHUDInitializationModel controllers)
 79    {
 1980        this.controllers = controllers;
 1981        this.controllers.tooltipController.Initialize(tooltipView);
 1982        this.controllers.feedbackTooltipController.Initialize(feedbackTtooltipView);
 1983        this.controllers.sceneCatalogController.Initialize(sceneCatalogView, this.controllers.quickBarController);
 1984        this.controllers.quickBarController.Initialize(quickBarView, this.controllers.dragAndDropSceneObjectController);
 1985        this.controllers.entityInformationController.Initialize(entityInformationView);
 1986        this.controllers.firstPersonModeController.Initialize(firstPersonModeView, this.controllers.tooltipController);
 1987        this.controllers.shortcutsController.Initialize(shortcutsView);
 1988        this.controllers.publishPopupController.Initialize(publishPopupView);
 1989        this.controllers.dragAndDropSceneObjectController.Initialize(this.controllers.sceneCatalogController, dragAndDro
 1990        this.controllers.publishBtnController.Initialize(publishBtnView, this.controllers.tooltipController, this.contro
 1991        this.controllers.inspectorBtnController.Initialize(inspectorBtnView, this.controllers.tooltipController);
 1992        this.controllers.catalogBtnController.Initialize(catalogBtnView, this.controllers.tooltipController);
 1993        this.controllers.inspectorController.Initialize(inspectorView);
 1994        this.controllers.buildModeConfirmationModalController.Initialize(buildModeConfirmationModalView);
 1995        this.controllers.topActionsButtonsController.Initialize(topActionsButtonsView, this.controllers.tooltipControlle
 1996        this.controllers.saveHUDController.Initialize(saveView);
 1997        this.controllers.newProjectDetailsController.Initialize(newProjectDetailsView);
 1998        this.controllers.publicationDetailsController.Initialize(publicationDetailsView);
 1999    }
 100
 101    private void OnDestroy()
 102    {
 19103        isDestroyed = true;
 19104        controllers.tooltipController.Dispose();
 19105        controllers.quickBarController.Dispose();
 19106        controllers.sceneCatalogController.Dispose();
 19107        controllers.entityInformationController.Dispose();
 19108        controllers.firstPersonModeController.Dispose();
 19109        controllers.shortcutsController.Dispose();
 19110        controllers.publishPopupController.Dispose();
 19111        controllers.dragAndDropSceneObjectController.Dispose();
 19112        controllers.publishBtnController.Dispose();
 19113        controllers.inspectorBtnController.Dispose();
 19114        controllers.catalogBtnController.Dispose();
 19115        controllers.inspectorController.Dispose();
 19116        controllers.buildModeConfirmationModalController.Dispose();
 19117        controllers.topActionsButtonsController.Dispose();
 19118        controllers.saveHUDController.Dispose();
 19119        controllers.newProjectDetailsController.Dispose();
 19120        controllers.publicationDetailsController.Dispose();
 19121    }
 122
 123    public void SetPublishBtnAvailability(bool isAvailable, string feedbackMessage = "")
 124    {
 2125        controllers.publishBtnController.SetInteractable(isAvailable);
 2126        controllers.publishBtnController.SetFeedbackMessage(feedbackMessage);
 2127    }
 128
 2129    public void RefreshCatalogAssetPack() { controllers.sceneCatalogController.RefreshAssetPack(); }
 130
 2131    public void RefreshCatalogContent() { controllers.sceneCatalogController.RefreshCatalog(); }
 132
 133    public void SetVisibilityOfCatalog(bool isVisible)
 134    {
 2135        if (isVisible)
 1136            controllers.sceneCatalogController.OpenCatalog();
 137        else
 1138            controllers.sceneCatalogController.CloseCatalog();
 1139    }
 140
 141    public void SetVisibilityOfSceneInfo(bool isVisible)
 142    {
 2143        if (isVisible)
 1144            controllers.inspectorController.sceneLimitsController.Enable();
 145        else
 1146            controllers.inspectorController.sceneLimitsController.Disable();
 1147    }
 148
 4149    public void SetVisibilityOfControls(bool isVisible) { controllers.shortcutsController.SetActive(isVisible); }
 150
 4151    public void SetVisibilityOfExtraBtns(bool isVisible) { controllers.topActionsButtonsController.SetExtraActionsActive
 152
 153    public void SetFirstPersonView()
 154    {
 1155        firstPersonCanvasGO.SetActive(true);
 1156        godModeCanvasGO.SetActive(false);
 1157        saveView.SetFirstPersonView();
 1158        HideToolTip();
 1159    }
 160
 161    public void SetGodModeView()
 162    {
 0163        firstPersonCanvasGO.SetActive(false);
 0164        godModeCanvasGO.SetActive(true);
 0165        saveView.SetGodModeView();
 0166        HideToolTip();
 0167    }
 168
 4169    public void HideToolTip() { controllers.tooltipController.HideTooltip(); }
 170
 4171    public void SetActive(bool isActive) { gameObject.SetActive(isActive); }
 172
 173    public void AnimatorShow(bool isVisible)
 174    {
 0175        if (isVisible)
 0176            showHideAnimator.Show();
 177        else
 0178            showHideAnimator.Hide();
 0179    }
 180
 181    public void SetVisibilityOfInspector(bool isVisible)
 182    {
 2183        if (isVisible)
 1184            controllers.inspectorController.OpenEntityList();
 185        else
 1186            controllers.inspectorController.CloseList();
 1187    }
 188}