| | 1 | | using UnityEngine; |
| | 2 | | using UnityEngine.EventSystems; |
| | 3 | | using UnityEngine.Serialization; |
| | 4 | | using UnityEngine.UI; |
| | 5 | |
|
| | 6 | | public 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 | |
|
| | 30 | | public class BuildModeHUDView : MonoBehaviour, IBuildModeHUDView |
| | 31 | | { |
| 0 | 32 | | public GameObject viewGO => !isDestroyed ? gameObject : null; |
| 0 | 33 | | public SaveHUDView saveHud => saveView; |
| 0 | 34 | | public SceneCatalogView sceneCatalog => sceneCatalogView; |
| 0 | 35 | | public EntityInformationView entityInformation => entityInformationView; |
| 0 | 36 | | 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 | | { |
| 19 | 72 | | var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<BuildModeHUDView>(); |
| 19 | 73 | | view.gameObject.name = "_BuildModeHUD"; |
| | 74 | |
|
| 19 | 75 | | return view; |
| | 76 | | } |
| | 77 | |
|
| | 78 | | public void Initialize(BuildModeHUDInitializationModel controllers) |
| | 79 | | { |
| 19 | 80 | | this.controllers = controllers; |
| 19 | 81 | | this.controllers.tooltipController.Initialize(tooltipView); |
| 19 | 82 | | this.controllers.feedbackTooltipController.Initialize(feedbackTtooltipView); |
| 19 | 83 | | this.controllers.sceneCatalogController.Initialize(sceneCatalogView, this.controllers.quickBarController); |
| 19 | 84 | | this.controllers.quickBarController.Initialize(quickBarView, this.controllers.dragAndDropSceneObjectController); |
| 19 | 85 | | this.controllers.entityInformationController.Initialize(entityInformationView); |
| 19 | 86 | | this.controllers.firstPersonModeController.Initialize(firstPersonModeView, this.controllers.tooltipController); |
| 19 | 87 | | this.controllers.shortcutsController.Initialize(shortcutsView); |
| 19 | 88 | | this.controllers.publishPopupController.Initialize(publishPopupView); |
| 19 | 89 | | this.controllers.dragAndDropSceneObjectController.Initialize(this.controllers.sceneCatalogController, dragAndDro |
| 19 | 90 | | this.controllers.publishBtnController.Initialize(publishBtnView, this.controllers.tooltipController, this.contro |
| 19 | 91 | | this.controllers.inspectorBtnController.Initialize(inspectorBtnView, this.controllers.tooltipController); |
| 19 | 92 | | this.controllers.catalogBtnController.Initialize(catalogBtnView, this.controllers.tooltipController); |
| 19 | 93 | | this.controllers.inspectorController.Initialize(inspectorView); |
| 19 | 94 | | this.controllers.buildModeConfirmationModalController.Initialize(buildModeConfirmationModalView); |
| 19 | 95 | | this.controllers.topActionsButtonsController.Initialize(topActionsButtonsView, this.controllers.tooltipControlle |
| 19 | 96 | | this.controllers.saveHUDController.Initialize(saveView); |
| 19 | 97 | | this.controllers.newProjectDetailsController.Initialize(newProjectDetailsView); |
| 19 | 98 | | this.controllers.publicationDetailsController.Initialize(publicationDetailsView); |
| 19 | 99 | | } |
| | 100 | |
|
| | 101 | | private void OnDestroy() |
| | 102 | | { |
| 19 | 103 | | isDestroyed = true; |
| 19 | 104 | | controllers.tooltipController.Dispose(); |
| 19 | 105 | | controllers.quickBarController.Dispose(); |
| 19 | 106 | | controllers.sceneCatalogController.Dispose(); |
| 19 | 107 | | controllers.entityInformationController.Dispose(); |
| 19 | 108 | | controllers.firstPersonModeController.Dispose(); |
| 19 | 109 | | controllers.shortcutsController.Dispose(); |
| 19 | 110 | | controllers.publishPopupController.Dispose(); |
| 19 | 111 | | controllers.dragAndDropSceneObjectController.Dispose(); |
| 19 | 112 | | controllers.publishBtnController.Dispose(); |
| 19 | 113 | | controllers.inspectorBtnController.Dispose(); |
| 19 | 114 | | controllers.catalogBtnController.Dispose(); |
| 19 | 115 | | controllers.inspectorController.Dispose(); |
| 19 | 116 | | controllers.buildModeConfirmationModalController.Dispose(); |
| 19 | 117 | | controllers.topActionsButtonsController.Dispose(); |
| 19 | 118 | | controllers.saveHUDController.Dispose(); |
| 19 | 119 | | controllers.newProjectDetailsController.Dispose(); |
| 19 | 120 | | controllers.publicationDetailsController.Dispose(); |
| 19 | 121 | | } |
| | 122 | |
|
| | 123 | | public void SetPublishBtnAvailability(bool isAvailable, string feedbackMessage = "") |
| | 124 | | { |
| 2 | 125 | | controllers.publishBtnController.SetInteractable(isAvailable); |
| 2 | 126 | | controllers.publishBtnController.SetFeedbackMessage(feedbackMessage); |
| 2 | 127 | | } |
| | 128 | |
|
| 2 | 129 | | public void RefreshCatalogAssetPack() { controllers.sceneCatalogController.RefreshAssetPack(); } |
| | 130 | |
|
| 2 | 131 | | public void RefreshCatalogContent() { controllers.sceneCatalogController.RefreshCatalog(); } |
| | 132 | |
|
| | 133 | | public void SetVisibilityOfCatalog(bool isVisible) |
| | 134 | | { |
| 2 | 135 | | if (isVisible) |
| 1 | 136 | | controllers.sceneCatalogController.OpenCatalog(); |
| | 137 | | else |
| 1 | 138 | | controllers.sceneCatalogController.CloseCatalog(); |
| 1 | 139 | | } |
| | 140 | |
|
| | 141 | | public void SetVisibilityOfSceneInfo(bool isVisible) |
| | 142 | | { |
| 2 | 143 | | if (isVisible) |
| 1 | 144 | | controllers.inspectorController.sceneLimitsController.Enable(); |
| | 145 | | else |
| 1 | 146 | | controllers.inspectorController.sceneLimitsController.Disable(); |
| 1 | 147 | | } |
| | 148 | |
|
| 4 | 149 | | public void SetVisibilityOfControls(bool isVisible) { controllers.shortcutsController.SetActive(isVisible); } |
| | 150 | |
|
| 4 | 151 | | public void SetVisibilityOfExtraBtns(bool isVisible) { controllers.topActionsButtonsController.SetExtraActionsActive |
| | 152 | |
|
| | 153 | | public void SetFirstPersonView() |
| | 154 | | { |
| 1 | 155 | | firstPersonCanvasGO.SetActive(true); |
| 1 | 156 | | godModeCanvasGO.SetActive(false); |
| 1 | 157 | | saveView.SetFirstPersonView(); |
| 1 | 158 | | HideToolTip(); |
| 1 | 159 | | } |
| | 160 | |
|
| | 161 | | public void SetGodModeView() |
| | 162 | | { |
| 0 | 163 | | firstPersonCanvasGO.SetActive(false); |
| 0 | 164 | | godModeCanvasGO.SetActive(true); |
| 0 | 165 | | saveView.SetGodModeView(); |
| 0 | 166 | | HideToolTip(); |
| 0 | 167 | | } |
| | 168 | |
|
| 4 | 169 | | public void HideToolTip() { controllers.tooltipController.HideTooltip(); } |
| | 170 | |
|
| 4 | 171 | | public void SetActive(bool isActive) { gameObject.SetActive(isActive); } |
| | 172 | |
|
| | 173 | | public void AnimatorShow(bool isVisible) |
| | 174 | | { |
| 0 | 175 | | if (isVisible) |
| 0 | 176 | | showHideAnimator.Show(); |
| | 177 | | else |
| 0 | 178 | | showHideAnimator.Hide(); |
| 0 | 179 | | } |
| | 180 | |
|
| | 181 | | public void SetVisibilityOfInspector(bool isVisible) |
| | 182 | | { |
| 2 | 183 | | if (isVisible) |
| 1 | 184 | | controllers.inspectorController.OpenEntityList(); |
| | 185 | | else |
| 1 | 186 | | controllers.inspectorController.CloseList(); |
| 1 | 187 | | } |
| | 188 | | } |