| | 1 | | using DCL.Configuration; |
| | 2 | | using DCL.Controllers; |
| | 3 | | using System; |
| | 4 | | using System.Collections; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Runtime.Remoting.Contexts; |
| | 7 | | using DCL; |
| | 8 | | using DCL.Builder; |
| | 9 | | using UnityEngine; |
| | 10 | | using UnityEngine.EventSystems; |
| | 11 | |
|
| | 12 | | public class BuilderEditorHUDController : IHUD, IBuilderEditorHUDController |
| | 13 | | { |
| | 14 | | public event Action OnChangeModeAction; |
| | 15 | | public event Action OnTranslateSelectedAction; |
| | 16 | | public event Action OnRotateSelectedAction; |
| | 17 | | public event Action OnScaleSelectedAction; |
| | 18 | | public event Action OnResetAction; |
| | 19 | | public event Action OnResetCameraAction; |
| | 20 | | public event Action OnUndoAction; |
| | 21 | | public event Action OnRedoAction; |
| | 22 | | public event Action OnDuplicateSelectedAction; |
| | 23 | | public event Action OnDeleteSelectedAction; |
| | 24 | | public event Action OnEntityListVisible; |
| | 25 | | public event Action OnStopInput; |
| | 26 | | public event Action OnResumeInput; |
| | 27 | | public event Action OnTutorialAction; |
| | 28 | | public event Action OnPublishAction; |
| | 29 | | public event Action<string, string, string> OnSaveSceneInfoAction; |
| | 30 | | public event Action<string, string, string> OnConfirmPublishAction; |
| | 31 | | public event Action OnStartExitAction; |
| | 32 | | public event Action OnLogoutAction; |
| | 33 | | public event Action OnChangeSnapModeAction; |
| | 34 | | public event Action<CatalogItem> OnCatalogItemSelected; |
| | 35 | | public event Action<CatalogItem> OnCatalogItemDropped; |
| | 36 | | public event Action<BIWEntity> OnEntityClick; |
| | 37 | | public event Action<BIWEntity> OnEntityDelete; |
| | 38 | | public event Action<BIWEntity> OnEntityLock; |
| | 39 | | public event Action<BIWEntity> OnEntityChangeVisibility; |
| | 40 | | public event Action<BIWEntity, string> OnEntityRename; |
| | 41 | | public event Action<BIWEntity> OnEntitySmartItemComponentUpdate; |
| | 42 | | public event Action<Vector3> OnSelectedObjectPositionChange; |
| | 43 | | public event Action<Vector3> OnSelectedObjectRotationChange; |
| | 44 | | public event Action<Vector3> OnSelectedObjectScaleChange; |
| | 45 | | public event Action OnCatalogOpen; // Note(Adrian): This is used right now for tutorial purposes |
| | 46 | |
|
| | 47 | | internal IBuildModeHUDView view; |
| | 48 | |
|
| | 49 | | internal bool areExtraButtonsVisible = false; |
| | 50 | | internal bool isControlsVisible = false; |
| | 51 | | internal bool isEntityListVisible = false; |
| | 52 | | internal bool isSceneLimitInfoVisibile = false; |
| | 53 | | internal bool isCatalogOpen = false; |
| | 54 | |
|
| | 55 | | internal BuildModeHUDInitializationModel controllers; |
| | 56 | |
|
| | 57 | | private Coroutine publishProgressCoroutine = null; |
| | 58 | | private float timeFromLastClickOnExtraButtons = 0f; |
| | 59 | | internal IContext context; |
| | 60 | |
|
| | 61 | | public void Initialize(IContext context) |
| | 62 | | { |
| 0 | 63 | | this.context = context; |
| 0 | 64 | | CreateBuildModeControllers(); |
| 0 | 65 | | CreateMainView(); |
| 0 | 66 | | ConfigureSceneCatalogController(); |
| 0 | 67 | | ConfigureEntityInformationController(); |
| 0 | 68 | | ConfigureFirstPersonModeController(); |
| 0 | 69 | | ConfigureShortcutsController(); |
| 0 | 70 | | ConfigureDragAndDropSceneObjectController(); |
| 0 | 71 | | ConfigurePublishBtnController(); |
| 0 | 72 | | ConfigureInspectorBtnController(); |
| 0 | 73 | | ConfigureCatalogBtnController(); |
| 0 | 74 | | ConfigureInspectorController(); |
| 0 | 75 | | ConfigureTopActionsButtonsController(); |
| 0 | 76 | | ConfigureSaveHUDController(); |
| 0 | 77 | | ConfigureNewProjectDetailsController(); |
| 0 | 78 | | ConfigurePublicationDetailsController(); |
| 0 | 79 | | ConfigureQuickBarController(); |
| 0 | 80 | | } |
| | 81 | |
|
| | 82 | | public void Initialize(BuildModeHUDInitializationModel controllers,IContext context) |
| | 83 | | { |
| 45 | 84 | | this.context = context; |
| 45 | 85 | | this.controllers = controllers; |
| | 86 | |
|
| 45 | 87 | | CreateMainView(); |
| 45 | 88 | | } |
| | 89 | |
|
| | 90 | | internal void CreateBuildModeControllers() |
| | 91 | | { |
| 1 | 92 | | controllers = new BuildModeHUDInitializationModel |
| | 93 | | { |
| | 94 | | tooltipController = new TooltipController(), |
| | 95 | | feedbackTooltipController = new TooltipController(), |
| | 96 | | sceneCatalogController = new SceneCatalogController(), |
| | 97 | | quickBarController = new QuickBarController(), |
| | 98 | | entityInformationController = new EntityInformationController(), |
| | 99 | | firstPersonModeController = new FirstPersonModeController(), |
| | 100 | | shortcutsController = new ShortcutsController(), |
| | 101 | | publishPopupController = new PublishPopupController(), |
| | 102 | | dragAndDropSceneObjectController = new DragAndDropSceneObjectController(), |
| | 103 | | publishBtnController = new PublishBtnController(), |
| | 104 | | inspectorBtnController = new InspectorBtnController(), |
| | 105 | | catalogBtnController = new CatalogBtnController(), |
| | 106 | | inspectorController = new InspectorController(), |
| | 107 | | buildModeConfirmationModalController = new BuildModeConfirmationModalController(), |
| | 108 | | topActionsButtonsController = new TopActionsButtonsController(), |
| | 109 | | saveHUDController = new SaveHUDController(), |
| | 110 | | newProjectDetailsController = new PublicationDetailsController(), |
| | 111 | | publicationDetailsController = new PublicationDetailsController() |
| | 112 | | }; |
| 1 | 113 | | } |
| | 114 | |
|
| | 115 | | internal void CreateMainView() |
| | 116 | | { |
| 46 | 117 | | view = CreateView(); |
| | 118 | |
|
| 46 | 119 | | if (view.viewGO != null) |
| 0 | 120 | | view.viewGO.SetActive(false); |
| | 121 | |
|
| 46 | 122 | | view.Initialize(controllers); |
| 46 | 123 | | } |
| | 124 | |
|
| | 125 | | private void ConfigureSceneCatalogController() |
| | 126 | | { |
| 0 | 127 | | controllers.sceneCatalogController.OnHideCatalogClicked += ChangeVisibilityOfCatalog; |
| 0 | 128 | | controllers.sceneCatalogController.OnCatalogItemSelected += CatalogItemSelected; |
| 0 | 129 | | controllers.sceneCatalogController.OnStopInput += StopInput; |
| | 130 | |
|
| 0 | 131 | | controllers.sceneCatalogController.OnResumeInput += () => OnResumeInput?.Invoke(); |
| 0 | 132 | | controllers.sceneCatalogController.OnPointerEnterInCatalogItemAdapter += ShowTooltipForCatalogItemAdapter; |
| 0 | 133 | | controllers.sceneCatalogController.OnPointerExitInCatalogItemAdapter += (x, y) => controllers.tooltipController. |
| 0 | 134 | | } |
| | 135 | |
|
| | 136 | | private void ConfigureEntityInformationController() |
| | 137 | | { |
| 0 | 138 | | controllers.entityInformationController.OnPositionChange += (x) => OnSelectedObjectPositionChange?.Invoke(x); |
| 0 | 139 | | controllers.entityInformationController.OnRotationChange += (x) => OnSelectedObjectRotationChange?.Invoke(x); |
| 0 | 140 | | controllers.entityInformationController.OnScaleChange += (x) => OnSelectedObjectScaleChange?.Invoke(x); |
| 0 | 141 | | controllers.entityInformationController.OnNameChange += (entity, newName) => OnEntityRename?.Invoke(entity, newN |
| 0 | 142 | | controllers.entityInformationController.OnSmartItemComponentUpdate += (entity) => OnEntitySmartItemComponentUpda |
| 0 | 143 | | controllers.entityInformationController.OnDisable += OnEntityInformationDisable; |
| 0 | 144 | | } |
| | 145 | |
|
| 0 | 146 | | private void ConfigureFirstPersonModeController() { controllers.firstPersonModeController.OnClick += () => OnChangeM |
| | 147 | |
|
| 0 | 148 | | private void ConfigureShortcutsController() { controllers.shortcutsController.OnCloseClick += ChangeVisibilityOfCont |
| | 149 | |
|
| | 150 | | private void ConfigureDragAndDropSceneObjectController() |
| | 151 | | { |
| 0 | 152 | | controllers.dragAndDropSceneObjectController.OnStopInput += StopInput; |
| 0 | 153 | | controllers.dragAndDropSceneObjectController.OnResumeInput += () => OnResumeInput?.Invoke(); |
| 0 | 154 | | controllers.dragAndDropSceneObjectController.OnCatalogItemDropped += CatalogItemDropped; |
| 0 | 155 | | } |
| | 156 | |
|
| 0 | 157 | | private void ConfigurePublishBtnController() { controllers.publishBtnController.OnClick += () => OnPublishAction?.In |
| | 158 | |
|
| 0 | 159 | | private void ConfigureInspectorBtnController() { controllers.inspectorBtnController.OnClick += () => ChangeVisibilit |
| | 160 | |
|
| 0 | 161 | | private void ConfigureCatalogBtnController() { controllers.catalogBtnController.OnClick += ChangeVisibilityOfCatalog |
| | 162 | |
|
| | 163 | | private void ConfigureInspectorController() |
| | 164 | | { |
| 0 | 165 | | controllers.inspectorController.OnEntityClick += (x) => OnEntityClick(x); |
| 0 | 166 | | controllers.inspectorController.OnEntityDelete += (x) => OnEntityDelete(x); |
| 0 | 167 | | controllers.inspectorController.OnEntityLock += (x) => OnEntityLock(x); |
| 0 | 168 | | controllers.inspectorController.OnEntityChangeVisibility += (x) => OnEntityChangeVisibility(x); |
| 0 | 169 | | controllers.inspectorController.OnEntityRename += (entity, newName) => OnEntityRename(entity, newName); |
| 0 | 170 | | controllers.inspectorController.SetCloseButtonsAction(ChangeVisibilityOfEntityList); |
| 0 | 171 | | } |
| | 172 | |
|
| | 173 | | private void ConfigureTopActionsButtonsController() |
| | 174 | | { |
| 0 | 175 | | controllers.topActionsButtonsController.OnChangeModeClick += () => OnChangeModeAction?.Invoke(); |
| 0 | 176 | | controllers.topActionsButtonsController.OnExtraClick += ChangeVisibilityOfExtraBtns; |
| 0 | 177 | | controllers.topActionsButtonsController.OnTranslateClick += () => OnTranslateSelectedAction?.Invoke(); |
| 0 | 178 | | controllers.topActionsButtonsController.OnRotateClick += () => OnRotateSelectedAction?.Invoke(); |
| 0 | 179 | | controllers.topActionsButtonsController.OnScaleClick += () => OnScaleSelectedAction?.Invoke(); |
| 0 | 180 | | controllers.topActionsButtonsController.OnUndoClick += () => OnUndoAction?.Invoke(); |
| 0 | 181 | | controllers.topActionsButtonsController.OnRedoClick += () => OnRedoAction?.Invoke(); |
| 0 | 182 | | controllers.topActionsButtonsController.OnDuplicateClick += () => OnDuplicateSelectedAction?.Invoke(); |
| 0 | 183 | | controllers.topActionsButtonsController.OnDeleteClick += () => OnDeleteSelectedAction?.Invoke(); |
| 0 | 184 | | controllers.topActionsButtonsController.OnSnapModeClick += () => OnChangeSnapModeAction?.Invoke(); |
| 0 | 185 | | controllers.topActionsButtonsController.OnLogOutClick += ExitStart; |
| 0 | 186 | | controllers.topActionsButtonsController.extraActionsController.OnControlsClick += ChangeVisibilityOfControls; |
| 0 | 187 | | controllers.topActionsButtonsController.extraActionsController.OnHideUIClick += ChangeVisibilityOfUI; |
| 0 | 188 | | controllers.topActionsButtonsController.extraActionsController.OnResetClick += () => OnResetAction?.Invoke(); |
| 0 | 189 | | controllers.topActionsButtonsController.extraActionsController.OnTutorialClick += () => OnTutorialAction?.Invoke |
| 0 | 190 | | controllers.topActionsButtonsController.extraActionsController.OnResetCameraClick += () => OnResetCameraAction?. |
| | 191 | |
|
| 0 | 192 | | controllers.topActionsButtonsController.extraActionsController.SetResetButtonInteractable(false); |
| 0 | 193 | | } |
| | 194 | |
|
| 0 | 195 | | private void ConfigureSaveHUDController() { OnLogoutAction += controllers.saveHUDController.StopAnimation; } |
| | 196 | |
|
| | 197 | | private void ConfigureNewProjectDetailsController() |
| | 198 | | { |
| 0 | 199 | | controllers.newProjectDetailsController.OnCancel += CancelNewProjectDetails; |
| 0 | 200 | | controllers.newProjectDetailsController.OnConfirm += SaveSceneInfo; |
| 0 | 201 | | } |
| | 202 | |
|
| | 203 | | private void ConfigurePublicationDetailsController() |
| | 204 | | { |
| 0 | 205 | | controllers.publicationDetailsController.OnCancel += CancelPublicationDetails; |
| 0 | 206 | | controllers.publicationDetailsController.OnConfirm += ConfirmPublicationDetails; |
| 0 | 207 | | } |
| | 208 | |
|
| 0 | 209 | | private void ConfigureQuickBarController() { controllers.quickBarController.OnCatalogItemAssigned += QuickBarCatalog |
| | 210 | |
|
| 0 | 211 | | private void QuickBarCatalogItemAssigned(CatalogItem item) { BIWAnalytics.QuickAccessAssigned(item, GetCatalogSectio |
| | 212 | |
|
| 0 | 213 | | public void SceneSaved() { controllers.saveHUDController.SceneStateSave(); } |
| | 214 | |
|
| | 215 | | public void SetBuilderProjectInfo(string projectName, string projectDescription) |
| | 216 | | { |
| 2 | 217 | | if (!string.IsNullOrEmpty(projectName)) |
| | 218 | | { |
| 1 | 219 | | controllers.newProjectDetailsController.SetCustomPublicationInfo(projectName, projectDescription); |
| 1 | 220 | | controllers.publicationDetailsController.SetCustomPublicationInfo(projectName, projectDescription); |
| 1 | 221 | | } |
| | 222 | | else |
| | 223 | | { |
| 1 | 224 | | controllers.newProjectDetailsController.SetDefaultPublicationInfo(); |
| 1 | 225 | | controllers.publicationDetailsController.SetDefaultPublicationInfo(); |
| | 226 | | } |
| 1 | 227 | | } |
| | 228 | |
|
| | 229 | | public void NewProjectStart(Texture2D screenshot) |
| | 230 | | { |
| 1 | 231 | | controllers.newProjectDetailsController.SetPublicationScreenshot(screenshot); |
| | 232 | |
|
| | 233 | | // TODO: This is temporal until we add the Welcome panel where the user will be able to edit the project info |
| | 234 | | //controllers.newProjectDetailsController.SetActive(true); |
| 1 | 235 | | SaveSceneInfo(); |
| 1 | 236 | | } |
| | 237 | |
|
| | 238 | | public void SaveSceneInfo() |
| | 239 | | { |
| 2 | 240 | | Texture2D newSceneScreenshotTexture = context.cameraController.GetLastScreenshot(); |
| 2 | 241 | | string newSceneName = controllers.newProjectDetailsController.GetSceneName(); |
| 2 | 242 | | string newSceneDescription = controllers.newProjectDetailsController.GetSceneDescription(); |
| | 243 | |
|
| 2 | 244 | | controllers.publicationDetailsController.SetCustomPublicationInfo(newSceneName, newSceneDescription); |
| 2 | 245 | | controllers.newProjectDetailsController.SetActive(false); |
| | 246 | |
|
| 2 | 247 | | OnSaveSceneInfoAction?.Invoke( |
| | 248 | | newSceneName, |
| | 249 | | newSceneDescription, |
| | 250 | | newSceneScreenshotTexture != null ? Convert.ToBase64String(newSceneScreenshotTexture.EncodeToJPG(90)) : ""); |
| 1 | 251 | | } |
| | 252 | |
|
| 2 | 253 | | internal void CancelNewProjectDetails() { controllers.newProjectDetailsController.SetActive(false); } |
| | 254 | |
|
| | 255 | | public void SetBuilderProjectScreenshot(Texture2D screenshot) |
| | 256 | | { |
| 0 | 257 | | controllers.publicationDetailsController.SetPublicationScreenshot(screenshot); |
| 0 | 258 | | controllers.newProjectDetailsController.SetPublicationScreenshot(screenshot); |
| 0 | 259 | | } |
| | 260 | |
|
| 2 | 261 | | public void PublishStart() { controllers.publicationDetailsController.SetActive(true); } |
| | 262 | |
|
| | 263 | | public void ConfigureConfirmationModal(string title, string subTitle, string cancelButtonText, string confirmButtonT |
| | 264 | | { |
| 2 | 265 | | controllers.buildModeConfirmationModalController.Configure( |
| | 266 | | title, |
| | 267 | | subTitle, |
| | 268 | | cancelButtonText, |
| | 269 | | confirmButtonText); |
| 2 | 270 | | } |
| | 271 | |
|
| | 272 | | internal void ConfirmPublicationDetails() |
| | 273 | | { |
| 1 | 274 | | UnsubscribeConfirmationModal(); |
| | 275 | |
|
| 1 | 276 | | controllers.buildModeConfirmationModalController.OnCancelExit += CancelPublishModal; |
| 1 | 277 | | controllers.buildModeConfirmationModalController.OnConfirmExit += ConfirmPublishModal; |
| | 278 | |
|
| 1 | 279 | | ConfigureConfirmationModal( |
| | 280 | | BIWSettings.PUBLISH_MODAL_TITLE, |
| | 281 | | BIWSettings.PUBLISH_MODAL_SUBTITLE, |
| | 282 | | BIWSettings.PUBLISH_MODAL_CANCEL_BUTTON, |
| | 283 | | BIWSettings.PUBLISH_MODAL_CONFIRM_BUTTON); |
| | 284 | |
|
| 1 | 285 | | controllers.buildModeConfirmationModalController.SetActive(true, BuildModeModalType.PUBLISH); |
| 1 | 286 | | controllers.publicationDetailsController.SetActive(false); |
| 1 | 287 | | } |
| | 288 | |
|
| 2 | 289 | | internal void CancelPublicationDetails() { controllers.publicationDetailsController.SetActive(false); } |
| | 290 | |
|
| | 291 | | internal void CancelPublishModal(BuildModeModalType modalType) |
| | 292 | | { |
| 1 | 293 | | if (modalType != BuildModeModalType.PUBLISH) |
| 0 | 294 | | return; |
| | 295 | |
|
| 1 | 296 | | controllers.buildModeConfirmationModalController.SetActive(false, BuildModeModalType.PUBLISH); |
| 1 | 297 | | controllers.publicationDetailsController.SetActive(true); |
| | 298 | |
|
| 1 | 299 | | controllers.buildModeConfirmationModalController.OnCancelExit -= CancelPublishModal; |
| 1 | 300 | | controllers.buildModeConfirmationModalController.OnConfirmExit -= ConfirmPublishModal; |
| 1 | 301 | | } |
| | 302 | |
|
| | 303 | | internal void ConfirmPublishModal(BuildModeModalType modalType) |
| | 304 | | { |
| 1 | 305 | | if (modalType != BuildModeModalType.PUBLISH) |
| 0 | 306 | | return; |
| | 307 | |
|
| 1 | 308 | | controllers.publishPopupController.PublishStart(); |
| | 309 | |
|
| 1 | 310 | | Texture2D sceneScreenshotTexture = controllers.publicationDetailsController.GetSceneScreenshotTexture(); |
| 1 | 311 | | string sceneName = controllers.publicationDetailsController.GetSceneName(); |
| 1 | 312 | | string sceneDescription = controllers.publicationDetailsController.GetSceneDescription(); |
| | 313 | |
|
| 1 | 314 | | OnConfirmPublishAction?.Invoke( |
| | 315 | | sceneName, |
| | 316 | | sceneDescription, |
| | 317 | | sceneScreenshotTexture != null ? Convert.ToBase64String(sceneScreenshotTexture.EncodeToJPG(90)) : ""); |
| | 318 | |
|
| 1 | 319 | | controllers.newProjectDetailsController.SetCustomPublicationInfo(sceneName, sceneDescription); |
| | 320 | |
|
| | 321 | | // NOTE (Santi): This is temporal until we implement the way of return the publish progress from the kernel side |
| | 322 | | // Meanwhile we will display a fake progress. |
| 1 | 323 | | publishProgressCoroutine = CoroutineStarter.Start(FakePublishProgress()); |
| | 324 | |
|
| 1 | 325 | | controllers.buildModeConfirmationModalController.OnCancelExit -= CancelPublishModal; |
| 1 | 326 | | controllers.buildModeConfirmationModalController.OnConfirmExit -= ConfirmPublishModal; |
| 1 | 327 | | } |
| | 328 | |
|
| | 329 | | private IEnumerator FakePublishProgress() |
| | 330 | | { |
| 0 | 331 | | while (true) |
| | 332 | | { |
| 1 | 333 | | float newPercentage = Mathf.Clamp( |
| | 334 | | controllers.publishPopupController.currentProgress + UnityEngine.Random.Range(10f, 30f), |
| | 335 | | controllers.publishPopupController.currentProgress, |
| | 336 | | 99f); |
| | 337 | |
|
| 1 | 338 | | controllers.publishPopupController.SetPercentage(newPercentage); |
| | 339 | |
|
| 1 | 340 | | yield return new WaitForSeconds(UnityEngine.Random.Range(0f, 0.5f)); |
| | 341 | | } |
| | 342 | | } |
| | 343 | |
|
| | 344 | | public void ExitStart() |
| | 345 | | { |
| 1 | 346 | | if (controllers.buildModeConfirmationModalController.IsViewActive()) |
| 0 | 347 | | return; |
| 1 | 348 | | UnsubscribeConfirmationModal(); |
| | 349 | |
|
| 1 | 350 | | controllers.buildModeConfirmationModalController.OnCancelExit += CancelExitModal; |
| 1 | 351 | | controllers.buildModeConfirmationModalController.OnConfirmExit += ConfirmExitModal; |
| | 352 | |
|
| 1 | 353 | | controllers.buildModeConfirmationModalController.SetActive(true, BuildModeModalType.EXIT); |
| | 354 | |
|
| 1 | 355 | | OnStartExitAction?.Invoke(); |
| 0 | 356 | | } |
| | 357 | |
|
| | 358 | | internal void CancelExitModal(BuildModeModalType modalType) |
| | 359 | | { |
| 1 | 360 | | if (modalType != BuildModeModalType.EXIT) |
| 0 | 361 | | return; |
| | 362 | |
|
| 1 | 363 | | controllers.buildModeConfirmationModalController.SetActive(false, BuildModeModalType.EXIT); |
| | 364 | |
|
| 1 | 365 | | controllers.buildModeConfirmationModalController.OnCancelExit -= CancelExitModal; |
| 1 | 366 | | controllers.buildModeConfirmationModalController.OnConfirmExit -= ConfirmExitModal; |
| 1 | 367 | | } |
| | 368 | |
|
| | 369 | | internal void ConfirmExitModal(BuildModeModalType modalType) |
| | 370 | | { |
| 1 | 371 | | if (modalType != BuildModeModalType.EXIT) |
| 0 | 372 | | return; |
| | 373 | |
|
| 1 | 374 | | OnLogoutAction?.Invoke(); |
| | 375 | |
|
| 1 | 376 | | controllers.buildModeConfirmationModalController.OnCancelExit -= CancelExitModal; |
| 1 | 377 | | controllers.buildModeConfirmationModalController.OnConfirmExit -= ConfirmExitModal; |
| | 378 | |
|
| 1 | 379 | | controllers.publicationDetailsController.SetDefaultPublicationInfo(); |
| 1 | 380 | | } |
| | 381 | |
|
| | 382 | | private void UnsubscribeConfirmationModal() |
| | 383 | | { |
| 2 | 384 | | controllers.buildModeConfirmationModalController.OnCancelExit -= CancelPublishModal; |
| 2 | 385 | | controllers.buildModeConfirmationModalController.OnCancelExit -= CancelExitModal; |
| 2 | 386 | | controllers.buildModeConfirmationModalController.OnConfirmExit -= ConfirmPublishModal; |
| 2 | 387 | | controllers.buildModeConfirmationModalController.OnConfirmExit -= ConfirmExitModal; |
| 2 | 388 | | } |
| | 389 | |
|
| | 390 | | public void PublishEnd(bool isOk, string message) |
| | 391 | | { |
| 2 | 392 | | if (publishProgressCoroutine != null) |
| | 393 | | { |
| 0 | 394 | | CoroutineStarter.Stop(publishProgressCoroutine); |
| 0 | 395 | | publishProgressCoroutine = null; |
| | 396 | | } |
| | 397 | |
|
| 2 | 398 | | controllers.publishPopupController.PublishEnd(isOk, message); |
| 2 | 399 | | } |
| | 400 | |
|
| 0 | 401 | | public void SetGizmosActive(string gizmos) { controllers.topActionsButtonsController.SetGizmosActive(gizmos); } |
| 2 | 402 | | public void SetParcelScene(IParcelScene IParcelScene) { controllers.inspectorController.sceneLimitsController.SetPar |
| | 403 | |
|
| 4 | 404 | | public void SetPublishBtnAvailability(bool isAvailable, string feedbackMessage = "") { view.SetPublishBtnAvailabilit |
| | 405 | |
|
| | 406 | | #region Catalog |
| | 407 | |
|
| 0 | 408 | | public BuildModeCatalogSection GetCatalogSectionSelected() { return controllers.sceneCatalogController.GetCurrentSec |
| | 409 | |
|
| | 410 | | private void ShowTooltipForCatalogItemAdapter(PointerEventData data, CatalogItemAdapter adapter) |
| | 411 | | { |
| 0 | 412 | | controllers.tooltipController.SetTooltipText(adapter.GetContent().name); |
| 0 | 413 | | controllers.tooltipController.ShowTooltip(data); |
| 0 | 414 | | } |
| | 415 | |
|
| 2 | 416 | | public void RefreshCatalogAssetPack() { view.RefreshCatalogAssetPack(); } |
| | 417 | |
|
| 2 | 418 | | public void RefreshCatalogContent() { view.RefreshCatalogContent(); } |
| | 419 | |
|
| | 420 | | public void StopInput() |
| | 421 | | { |
| 0 | 422 | | OnStopInput?.Invoke(); |
| 0 | 423 | | ToggleCatalogIfExpanded(); |
| 0 | 424 | | } |
| | 425 | |
|
| | 426 | | public void CatalogItemSelected(CatalogItem catalogItem) |
| | 427 | | { |
| 1 | 428 | | OnCatalogItemSelected?.Invoke(catalogItem); |
| 1 | 429 | | ToggleCatalogIfExpanded(); |
| 1 | 430 | | } |
| | 431 | |
|
| | 432 | | public void CatalogItemDropped(CatalogItem catalogItem) |
| | 433 | | { |
| 0 | 434 | | OnCatalogItemDropped?.Invoke(catalogItem); |
| 0 | 435 | | ToggleCatalogIfExpanded(); |
| 0 | 436 | | } |
| | 437 | |
|
| | 438 | | private void ToggleCatalogIfExpanded() |
| | 439 | | { |
| 1 | 440 | | if (controllers.sceneCatalogController.IsCatalogExpanded()) |
| 0 | 441 | | controllers.sceneCatalogController.ToggleCatalogExpanse(); |
| 1 | 442 | | } |
| | 443 | |
|
| | 444 | | public void SetVisibilityOfCatalog(bool isVisible) |
| | 445 | | { |
| 3 | 446 | | isCatalogOpen = isVisible; |
| 3 | 447 | | view.SetVisibilityOfCatalog(isCatalogOpen); |
| | 448 | |
|
| 3 | 449 | | if (isVisible) |
| 2 | 450 | | OnCatalogOpen?.Invoke(); |
| 2 | 451 | | } |
| | 452 | |
|
| | 453 | | public void ChangeVisibilityOfCatalog() |
| | 454 | | { |
| 1 | 455 | | isCatalogOpen = !controllers.sceneCatalogController.IsCatalogOpen(); |
| 1 | 456 | | SetVisibilityOfCatalog(isCatalogOpen); |
| 1 | 457 | | } |
| | 458 | |
|
| | 459 | | #endregion |
| | 460 | |
|
| | 461 | | #region SceneLimitInfo |
| | 462 | |
|
| | 463 | | public void ShowSceneLimitsPassed() |
| | 464 | | { |
| 0 | 465 | | if (!isSceneLimitInfoVisibile) |
| 0 | 466 | | ChangeVisibilityOfSceneInfo(); |
| 0 | 467 | | } |
| | 468 | |
|
| 2 | 469 | | public void UpdateSceneLimitInfo() { controllers.inspectorController.sceneLimitsController.UpdateInfo(); } |
| | 470 | |
|
| | 471 | | public void ChangeVisibilityOfSceneInfo(bool shouldBeVisibile) |
| | 472 | | { |
| 2 | 473 | | isSceneLimitInfoVisibile = shouldBeVisibile; |
| 2 | 474 | | view.SetVisibilityOfSceneInfo(isSceneLimitInfoVisibile); |
| 2 | 475 | | } |
| | 476 | |
|
| | 477 | | public void ChangeVisibilityOfSceneInfo() |
| | 478 | | { |
| 1 | 479 | | isSceneLimitInfoVisibile = !isSceneLimitInfoVisibile; |
| 1 | 480 | | view.SetVisibilityOfSceneInfo(isSceneLimitInfoVisibile); |
| 1 | 481 | | } |
| | 482 | |
|
| | 483 | | #endregion |
| | 484 | |
|
| | 485 | | public void ActivateFirstPersonModeUI() |
| | 486 | | { |
| 1 | 487 | | if (view != null) |
| 1 | 488 | | view.SetFirstPersonView(); |
| 1 | 489 | | } |
| | 490 | |
|
| | 491 | | public void ActivateGodModeUI() |
| | 492 | | { |
| 1 | 493 | | if (view != null) |
| 1 | 494 | | view.SetGodModeView(); |
| 1 | 495 | | } |
| | 496 | |
|
| | 497 | | #region EntityInformation |
| | 498 | |
|
| 2 | 499 | | public void EntityInformationSetEntity(BIWEntity entity, IParcelScene scene) { controllers.entityInformationControll |
| | 500 | |
|
| | 501 | | public void ShowEntityInformation(bool activateTransparencyMode = false) |
| | 502 | | { |
| 2 | 503 | | controllers.entityInformationController.Enable(); |
| 2 | 504 | | controllers.entityInformationController.SetTransparencyMode(activateTransparencyMode); |
| 2 | 505 | | controllers.sceneCatalogController.CloseCatalog(); |
| 2 | 506 | | controllers.tooltipController.HideTooltip(); |
| | 507 | |
|
| 2 | 508 | | if (activateTransparencyMode) |
| 1 | 509 | | controllers.catalogBtnController.SetActive(false); |
| 2 | 510 | | } |
| | 511 | |
|
| | 512 | | public void HideEntityInformation() |
| | 513 | | { |
| 1 | 514 | | controllers.entityInformationController.Disable(); |
| 1 | 515 | | controllers.catalogBtnController.SetActive(true); |
| | 516 | |
|
| 1 | 517 | | if (isCatalogOpen) |
| 0 | 518 | | controllers.sceneCatalogController.SetActive(true); |
| 1 | 519 | | } |
| | 520 | |
|
| | 521 | | private void OnEntityInformationDisable() |
| | 522 | | { |
| 0 | 523 | | if (isCatalogOpen) |
| 0 | 524 | | controllers.sceneCatalogController.SetActive(true); |
| 0 | 525 | | } |
| | 526 | |
|
| | 527 | | #endregion |
| | 528 | |
|
| | 529 | | public void SetEntityList(List<BIWEntity> entityList) |
| | 530 | | { |
| 1 | 531 | | controllers.inspectorController.SetEntityList(entityList); |
| | 532 | |
|
| 1 | 533 | | if (view.entityInformation != null) |
| 0 | 534 | | view.entityInformation.smartItemListView.SetEntityList(entityList); |
| 1 | 535 | | } |
| | 536 | |
|
| | 537 | | public void ChangeVisibilityOfEntityList() |
| | 538 | | { |
| 2 | 539 | | isEntityListVisible = !isEntityListVisible; |
| 2 | 540 | | controllers.saveHUDController?.SetSaveViewByEntityListOpen(isEntityListVisible); |
| 2 | 541 | | if (isEntityListVisible) |
| | 542 | | { |
| 1 | 543 | | OnEntityListVisible?.Invoke(); |
| 1 | 544 | | controllers.inspectorController.OpenEntityList(); |
| 1 | 545 | | } |
| | 546 | | else |
| | 547 | | { |
| 1 | 548 | | controllers.inspectorController.CloseList(); |
| | 549 | | } |
| 1 | 550 | | } |
| | 551 | |
|
| 2 | 552 | | public void ClearEntityList() { controllers.inspectorController.ClearList(); } |
| | 553 | |
|
| | 554 | | public void ChangeVisibilityOfControls() |
| | 555 | | { |
| 1 | 556 | | isControlsVisible = !isControlsVisible; |
| 1 | 557 | | view.SetVisibilityOfControls(isControlsVisible); |
| 1 | 558 | | } |
| | 559 | |
|
| | 560 | | public void ChangeVisibilityOfUI() |
| | 561 | | { |
| 0 | 562 | | DataStore.i.builderInWorld.showTaskBar.Set(!IsVisible()); |
| 0 | 563 | | SetVisibility(!IsVisible()); |
| 0 | 564 | | } |
| | 565 | |
|
| | 566 | | #region TopButtons |
| | 567 | |
|
| | 568 | | public void ChangeVisibilityOfExtraBtns() |
| | 569 | | { |
| 1 | 570 | | areExtraButtonsVisible = !areExtraButtonsVisible; |
| 1 | 571 | | view.SetVisibilityOfExtraBtns(areExtraButtonsVisible); |
| 1 | 572 | | timeFromLastClickOnExtraButtons = Time.realtimeSinceStartup; |
| 1 | 573 | | } |
| | 574 | |
|
| | 575 | | public void HideExtraBtns() |
| | 576 | | { |
| 0 | 577 | | if ((Time.realtimeSinceStartup - timeFromLastClickOnExtraButtons) <= 0.1f) |
| 0 | 578 | | return; |
| | 579 | |
|
| 0 | 580 | | areExtraButtonsVisible = false; |
| 0 | 581 | | controllers.topActionsButtonsController.extraActionsController.SetActive(areExtraButtonsVisible); |
| 0 | 582 | | } |
| | 583 | |
|
| 0 | 584 | | public void SetActionsButtonsInteractable(bool isInteractable) { controllers.topActionsButtonsController.SetActionsI |
| | 585 | |
|
| 0 | 586 | | public void SetSnapModeActive(bool isActive) { controllers.topActionsButtonsController.SetSnapActive(isActive); } |
| | 587 | |
|
| 0 | 588 | | public void SetUndoButtonInteractable(bool isInteractable) { controllers.topActionsButtonsController.SetUndoInteract |
| 0 | 589 | | public void SetRedoButtonInteractable(bool isInteractable) { controllers.topActionsButtonsController.SetRedoInteract |
| | 590 | |
|
| | 591 | | #endregion |
| | 592 | |
|
| | 593 | | public void SetVisibility(bool visible) |
| | 594 | | { |
| 0 | 595 | | if (view == null) |
| 0 | 596 | | return; |
| | 597 | |
|
| 0 | 598 | | if (IsVisible() && !visible) |
| | 599 | | { |
| 0 | 600 | | view.AnimatorShow(false); |
| 0 | 601 | | AudioScriptableObjects.fadeOut.Play(true); |
| 0 | 602 | | } |
| 0 | 603 | | else if (!IsVisible() && visible) |
| | 604 | | { |
| 0 | 605 | | view.SetActive(true); |
| 0 | 606 | | view.AnimatorShow(true); |
| 0 | 607 | | AudioScriptableObjects.fadeIn.Play(true); |
| | 608 | | } |
| 0 | 609 | | } |
| | 610 | |
|
| | 611 | | public void Dispose() |
| | 612 | | { |
| 45 | 613 | | if (view == null) |
| 0 | 614 | | return; |
| 45 | 615 | | else if (view.viewGO != null) |
| 0 | 616 | | UnityEngine.Object.Destroy(view.viewGO); |
| 45 | 617 | | } |
| | 618 | |
|
| 0 | 619 | | public void ToggleVisibility() { SetVisibility(!IsVisible()); } |
| | 620 | |
|
| | 621 | | public bool IsVisible() |
| | 622 | | { |
| 0 | 623 | | if (view == null) |
| 0 | 624 | | return false; |
| | 625 | |
|
| 0 | 626 | | return view.isShowHideAnimatorVisible; |
| | 627 | | } |
| | 628 | |
|
| 0 | 629 | | internal virtual IBuildModeHUDView CreateView() => BuildModeHUDView.Create(); |
| | 630 | |
|
| | 631 | | public void UpdateEntitiesSelection(int numberOfSelectedEntities) |
| | 632 | | { |
| 0 | 633 | | controllers.entityInformationController.UpdateEntitiesSelection(numberOfSelectedEntities); |
| 0 | 634 | | controllers.topActionsButtonsController.extraActionsController.SetResetButtonInteractable(numberOfSelectedEntiti |
| 0 | 635 | | } |
| | 636 | |
|
| | 637 | | #region Inspector |
| | 638 | |
|
| | 639 | | public void SetVisibilityOfInspector(bool isVisible) |
| | 640 | | { |
| 2 | 641 | | isEntityListVisible = isVisible; |
| 2 | 642 | | view.SetVisibilityOfInspector(isVisible); |
| 2 | 643 | | } |
| | 644 | |
|
| | 645 | | #endregion |
| | 646 | |
|
| | 647 | | } |