| | 1 | | using System; |
| | 2 | | using UnityEngine.EventSystems; |
| | 3 | |
|
| | 4 | | public interface ITopActionsButtonsController |
| | 5 | | { |
| | 6 | | event Action OnChangeModeClick; |
| | 7 | | event Action OnExtraClick; |
| | 8 | | event Action OnTranslateClick; |
| | 9 | | event Action OnRotateClick; |
| | 10 | | event Action OnScaleClick; |
| | 11 | | event Action OnUndoClick; |
| | 12 | | event Action OnRedoClick; |
| | 13 | | event Action OnDuplicateClick; |
| | 14 | | event Action OnDeleteClick; |
| | 15 | | event Action OnLogOutClick; |
| | 16 | | event Action OnSnapModeClick; |
| | 17 | |
|
| | 18 | | IExtraActionsController extraActionsController { get; } |
| | 19 | |
|
| | 20 | | void Initialize(ITopActionsButtonsView topActionsButtonsView, ITooltipController tooltipController); |
| | 21 | | void Dispose(); |
| | 22 | | void ChangeModeClicked(); |
| | 23 | | void ExtraClicked(); |
| | 24 | | void TranslateClicked(); |
| | 25 | | void RotateClicked(); |
| | 26 | | void ScaleClicked(); |
| | 27 | | void UndoClicked(); |
| | 28 | | void RedoClicked(); |
| | 29 | | void DuplicateClicked(); |
| | 30 | | void DeleteClicked(); |
| | 31 | | void LogoutClicked(); |
| | 32 | | void ConfirmLogout(BuildModeModalType modalType); |
| | 33 | | void TooltipPointerEntered(BaseEventData eventData, string tooltipText); |
| | 34 | | void TooltipPointerExited(); |
| | 35 | | void SetExtraActionsActive(bool isActive); |
| | 36 | | void SetGizmosActive(string gizmos); |
| | 37 | | void SetActionsInteractable(bool isActive); |
| | 38 | | void SetSnapActive(bool isActive); |
| | 39 | | void SetUndoInteractable(bool isActive); |
| | 40 | | void SetRedoInteractable(bool isActive); |
| | 41 | | } |
| | 42 | |
|
| | 43 | | public class TopActionsButtonsController : ITopActionsButtonsController |
| | 44 | | { |
| | 45 | | public event Action OnChangeModeClick; |
| | 46 | | public event Action OnExtraClick; |
| | 47 | | public event Action OnTranslateClick; |
| | 48 | | public event Action OnRotateClick; |
| | 49 | | public event Action OnScaleClick; |
| | 50 | | public event Action OnUndoClick; |
| | 51 | | public event Action OnRedoClick; |
| | 52 | | public event Action OnDuplicateClick; |
| | 53 | | public event Action OnDeleteClick; |
| | 54 | | public event Action OnLogOutClick; |
| | 55 | | public event Action OnSnapModeClick; |
| | 56 | |
|
| 0 | 57 | | public IExtraActionsController extraActionsController { get; private set; } |
| | 58 | |
|
| | 59 | | internal ITopActionsButtonsView topActionsButtonsView; |
| | 60 | | internal ITooltipController tooltipController; |
| | 61 | |
|
| | 62 | | public void Initialize(ITopActionsButtonsView topActionsButtonsView, ITooltipController tooltipController) |
| | 63 | | { |
| 18 | 64 | | this.topActionsButtonsView = topActionsButtonsView; |
| 18 | 65 | | this.tooltipController = tooltipController; |
| | 66 | |
|
| 18 | 67 | | topActionsButtonsView.OnChangeModeClicked += ChangeModeClicked; |
| 18 | 68 | | topActionsButtonsView.OnExtraClicked += ExtraClicked; |
| 18 | 69 | | topActionsButtonsView.OnTranslateClicked += TranslateClicked; |
| 18 | 70 | | topActionsButtonsView.OnRotateClicked += RotateClicked; |
| 18 | 71 | | topActionsButtonsView.OnScaleClicked += ScaleClicked; |
| 18 | 72 | | topActionsButtonsView.OnUndoClicked += UndoClicked; |
| 18 | 73 | | topActionsButtonsView.OnRedoClicked += RedoClicked; |
| 18 | 74 | | topActionsButtonsView.OnDuplicateClicked += DuplicateClicked; |
| 18 | 75 | | topActionsButtonsView.OnDeleteClicked += DeleteClicked; |
| 18 | 76 | | topActionsButtonsView.OnLogOutClicked += LogoutClicked; |
| 18 | 77 | | topActionsButtonsView.OnPointerExit += TooltipPointerExited; |
| 18 | 78 | | topActionsButtonsView.OnChangeCameraModePointerEnter += TooltipPointerEntered; |
| 18 | 79 | | topActionsButtonsView.OnTranslatePointerEnter += TooltipPointerEntered; |
| 18 | 80 | | topActionsButtonsView.OnRotatePointerEnter += TooltipPointerEntered; |
| 18 | 81 | | topActionsButtonsView.OnScalePointerEnter += TooltipPointerEntered; |
| 18 | 82 | | topActionsButtonsView.OnUndoPointerEnter += TooltipPointerEntered; |
| 18 | 83 | | topActionsButtonsView.OnRedoPointerEnter += TooltipPointerEntered; |
| 18 | 84 | | topActionsButtonsView.OnDuplicatePointerEnter += TooltipPointerEntered; |
| 18 | 85 | | topActionsButtonsView.OnDeletePointerEnter += TooltipPointerEntered; |
| 18 | 86 | | topActionsButtonsView.OnMoreActionsPointerEnter += TooltipPointerEntered; |
| 18 | 87 | | topActionsButtonsView.OnLogoutPointerEnter += TooltipPointerEntered; |
| 18 | 88 | | topActionsButtonsView.OnSnapModePointerEnter += TooltipPointerEntered; |
| 18 | 89 | | topActionsButtonsView.OnSnapModeClicked += SnapModeClicked; |
| | 90 | |
|
| 18 | 91 | | extraActionsController = new ExtraActionsController(); |
| 18 | 92 | | topActionsButtonsView.ConfigureExtraActions(extraActionsController); |
| 18 | 93 | | extraActionsController.SetActive(false); |
| 18 | 94 | | } |
| | 95 | |
|
| | 96 | | public void Dispose() |
| | 97 | | { |
| 18 | 98 | | topActionsButtonsView.OnChangeModeClicked -= ChangeModeClicked; |
| 18 | 99 | | topActionsButtonsView.OnExtraClicked -= ExtraClicked; |
| 18 | 100 | | topActionsButtonsView.OnTranslateClicked -= TranslateClicked; |
| 18 | 101 | | topActionsButtonsView.OnRotateClicked -= RotateClicked; |
| 18 | 102 | | topActionsButtonsView.OnScaleClicked -= ScaleClicked; |
| 18 | 103 | | topActionsButtonsView.OnUndoClicked -= UndoClicked; |
| 18 | 104 | | topActionsButtonsView.OnRedoClicked -= RedoClicked; |
| 18 | 105 | | topActionsButtonsView.OnDuplicateClicked -= DuplicateClicked; |
| 18 | 106 | | topActionsButtonsView.OnDeleteClicked -= DeleteClicked; |
| 18 | 107 | | topActionsButtonsView.OnLogOutClicked -= LogoutClicked; |
| 18 | 108 | | topActionsButtonsView.OnPointerExit -= TooltipPointerExited; |
| 18 | 109 | | topActionsButtonsView.OnChangeCameraModePointerEnter -= TooltipPointerEntered; |
| 18 | 110 | | topActionsButtonsView.OnTranslatePointerEnter -= TooltipPointerEntered; |
| 18 | 111 | | topActionsButtonsView.OnRotatePointerEnter -= TooltipPointerEntered; |
| 18 | 112 | | topActionsButtonsView.OnScalePointerEnter -= TooltipPointerEntered; |
| 18 | 113 | | topActionsButtonsView.OnUndoPointerEnter -= TooltipPointerEntered; |
| 18 | 114 | | topActionsButtonsView.OnRedoPointerEnter -= TooltipPointerEntered; |
| 18 | 115 | | topActionsButtonsView.OnDuplicatePointerEnter -= TooltipPointerEntered; |
| 18 | 116 | | topActionsButtonsView.OnDeletePointerEnter -= TooltipPointerEntered; |
| 18 | 117 | | topActionsButtonsView.OnMoreActionsPointerEnter -= TooltipPointerEntered; |
| 18 | 118 | | topActionsButtonsView.OnLogoutPointerEnter -= TooltipPointerEntered; |
| 18 | 119 | | topActionsButtonsView.OnSnapModePointerEnter -= TooltipPointerEntered; |
| 18 | 120 | | } |
| | 121 | |
|
| 2 | 122 | | public void ChangeModeClicked() { OnChangeModeClick?.Invoke(); } |
| | 123 | |
|
| 2 | 124 | | public void ExtraClicked() { OnExtraClick?.Invoke(); } |
| | 125 | |
|
| 2 | 126 | | public void TranslateClicked() { OnTranslateClick?.Invoke(); } |
| | 127 | |
|
| 2 | 128 | | public void RotateClicked() { OnRotateClick?.Invoke(); } |
| | 129 | |
|
| 2 | 130 | | public void ScaleClicked() { OnScaleClick?.Invoke(); } |
| | 131 | |
|
| 2 | 132 | | public void UndoClicked() { OnUndoClick?.Invoke(); } |
| | 133 | |
|
| 2 | 134 | | public void RedoClicked() { OnRedoClick?.Invoke(); } |
| | 135 | |
|
| 2 | 136 | | public void DuplicateClicked() { OnDuplicateClick?.Invoke(); } |
| | 137 | |
|
| 2 | 138 | | public void DeleteClicked() { OnDeleteClick?.Invoke(); } |
| | 139 | |
|
| 2 | 140 | | public void LogoutClicked() { OnLogOutClick?.Invoke(); } |
| | 141 | |
|
| 0 | 142 | | public void SnapModeClicked() { OnSnapModeClick?.Invoke(); } |
| | 143 | |
|
| | 144 | | public void ConfirmLogout(BuildModeModalType modalType) |
| | 145 | | { |
| 1 | 146 | | if (modalType != BuildModeModalType.EXIT) |
| 0 | 147 | | return; |
| | 148 | |
|
| 1 | 149 | | OnLogOutClick?.Invoke(); |
| 1 | 150 | | } |
| | 151 | |
|
| | 152 | | public void TooltipPointerEntered(BaseEventData eventData, string tooltipText) |
| | 153 | | { |
| 1 | 154 | | tooltipController.ShowTooltip(eventData); |
| 1 | 155 | | tooltipController.SetTooltipText(tooltipText); |
| 1 | 156 | | } |
| | 157 | |
|
| 2 | 158 | | public void TooltipPointerExited() { tooltipController.HideTooltip(); } |
| | 159 | |
|
| 0 | 160 | | public void SetExtraActionsActive(bool isActive) { extraActionsController.SetActive(isActive); } |
| 2 | 161 | | public void SetGizmosActive(string gizmos) { topActionsButtonsView.SetGizmosActive(gizmos); } |
| 4 | 162 | | public void SetActionsInteractable(bool isActive) { topActionsButtonsView.SetActionsInteractable(isActive); } |
| 4 | 163 | | public void SetSnapActive(bool isActive) { topActionsButtonsView.SetSnapActive(isActive); } |
| 0 | 164 | | public void SetUndoInteractable(bool isActive) { topActionsButtonsView.SetUndoInteractable(isActive); } |
| | 165 | |
|
| 0 | 166 | | public void SetRedoInteractable(bool isActive) { topActionsButtonsView.SetRedoInteractable(isActive); } |
| | 167 | | } |