| | 1 | | using System; |
| | 2 | | using DCL.Builder; |
| | 3 | | using DCL.Interface; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | internal class SceneContextMenuHandler : IDisposable |
| | 7 | | { |
| | 8 | | private readonly SceneCardViewContextMenu contextMenu; |
| | 9 | | private readonly ISectionsController sectionsController; |
| | 10 | | private readonly IScenesViewController scenesViewController; |
| | 11 | | private readonly UnpublishPopupController unpublishPopupController; |
| | 12 | |
|
| | 13 | | private Vector2Int sceneCoords; |
| | 14 | | private Scene.Source sceneSource; |
| | 15 | |
|
| 17 | 16 | | public SceneContextMenuHandler(SceneCardViewContextMenu contextMenu, ISectionsController sectionsController, |
| | 17 | | IScenesViewController scenesViewController, UnpublishPopupController unpublishPopupController) |
| | 18 | | { |
| 17 | 19 | | this.contextMenu = contextMenu; |
| 17 | 20 | | this.sectionsController = sectionsController; |
| 17 | 21 | | this.scenesViewController = scenesViewController; |
| 17 | 22 | | this.unpublishPopupController = unpublishPopupController; |
| | 23 | |
|
| 17 | 24 | | sectionsController.OnRequestContextMenuHide += OnRequestContextMenuHide; |
| | 25 | |
|
| 17 | 26 | | scenesViewController.OnContextMenuPressed += OnContextMenuOpen; |
| | 27 | |
|
| 17 | 28 | | contextMenu.OnSettingsPressed += OnContextMenuSettingsPressed; |
| 17 | 29 | | contextMenu.OnDuplicatePressed += OnContextMenuDuplicatePressed; |
| 17 | 30 | | contextMenu.OnDownloadPressed += OnContextMenuDownloadPressed; |
| 17 | 31 | | contextMenu.OnSharePressed += OnContextMenuSharePressed; |
| 17 | 32 | | contextMenu.OnUnpublishPressed += OnContextMenuUnpublishPressed; |
| 17 | 33 | | contextMenu.OnDeletePressed += OnContextMenuDeletePressed; |
| 17 | 34 | | contextMenu.OnQuitContributorPressed += OnContextMenuQuitContributorPressed; |
| 17 | 35 | | } |
| | 36 | |
|
| | 37 | | public void Dispose() |
| | 38 | | { |
| 17 | 39 | | sectionsController.OnRequestContextMenuHide -= OnRequestContextMenuHide; |
| | 40 | |
|
| 17 | 41 | | scenesViewController.OnContextMenuPressed -= OnContextMenuOpen; |
| | 42 | |
|
| 17 | 43 | | contextMenu.OnSettingsPressed -= OnContextMenuSettingsPressed; |
| 17 | 44 | | contextMenu.OnDuplicatePressed -= OnContextMenuDuplicatePressed; |
| 17 | 45 | | contextMenu.OnDownloadPressed -= OnContextMenuDownloadPressed; |
| 17 | 46 | | contextMenu.OnSharePressed -= OnContextMenuSharePressed; |
| 17 | 47 | | contextMenu.OnUnpublishPressed -= OnContextMenuUnpublishPressed; |
| 17 | 48 | | contextMenu.OnDeletePressed -= OnContextMenuDeletePressed; |
| 17 | 49 | | contextMenu.OnQuitContributorPressed -= OnContextMenuQuitContributorPressed; |
| 17 | 50 | | } |
| | 51 | |
|
| | 52 | | void OnContextMenuOpen(ISceneData sceneData, ISceneCardView sceneCard) |
| | 53 | | { |
| 0 | 54 | | contextMenu.transform.position = sceneCard.contextMenuButtonPosition; |
| 0 | 55 | | contextMenu.Show(sceneData.id, sceneData.isDeployed, |
| | 56 | | sceneData.isOwner || sceneData.isOperator, sceneData.isContributor); |
| 0 | 57 | | sceneCoords = sceneData.coords; |
| 0 | 58 | | sceneSource = sceneData.source; |
| 0 | 59 | | } |
| | 60 | |
|
| 2 | 61 | | void OnRequestContextMenuHide() { contextMenu.Hide(); } |
| | 62 | |
|
| 0 | 63 | | void OnContextMenuSettingsPressed(string id) { scenesViewController.SelectScene(id); } |
| | 64 | |
|
| 0 | 65 | | void OnContextMenuDuplicatePressed(string id) { } |
| | 66 | |
|
| 0 | 67 | | void OnContextMenuDownloadPressed(string id) { } |
| | 68 | |
|
| 0 | 69 | | void OnContextMenuSharePressed(string id) { } |
| | 70 | |
|
| 0 | 71 | | void OnContextMenuUnpublishPressed(string id) { unpublishPopupController.Show(sceneCoords, sceneSource); } |
| | 72 | |
|
| 0 | 73 | | void OnContextMenuDeletePressed(string id) { } |
| | 74 | |
|
| 0 | 75 | | void OnContextMenuQuitContributorPressed(string id) { } |
| | 76 | | } |