| | 1 | | using System; |
| | 2 | | using UnityEngine.EventSystems; |
| | 3 | |
|
| | 4 | | public interface IInspectorBtnController |
| | 5 | | { |
| | 6 | | event Action OnClick; |
| | 7 | |
|
| | 8 | | void Initialize(IInspectorBtnView inspectorBtnView, ITooltipController tooltipController); |
| | 9 | | void Dispose(); |
| | 10 | | void Click(); |
| | 11 | | void ShowTooltip(BaseEventData eventData, string tooltipText); |
| | 12 | | void HideTooltip(); |
| | 13 | | } |
| | 14 | |
|
| | 15 | | public class InspectorBtnController : IInspectorBtnController |
| | 16 | | { |
| | 17 | | public event Action OnClick; |
| | 18 | |
|
| | 19 | | internal IInspectorBtnView inspectorBtnView; |
| | 20 | | internal ITooltipController tooltipController; |
| | 21 | |
|
| | 22 | | public void Initialize(IInspectorBtnView inspectorBtnView, ITooltipController tooltipController) |
| | 23 | | { |
| 3 | 24 | | this.inspectorBtnView = inspectorBtnView; |
| 3 | 25 | | this.tooltipController = tooltipController; |
| | 26 | |
|
| 3 | 27 | | inspectorBtnView.OnInspectorButtonClick += Click; |
| 3 | 28 | | inspectorBtnView.OnShowTooltip += ShowTooltip; |
| 3 | 29 | | inspectorBtnView.OnHideTooltip += HideTooltip; |
| 3 | 30 | | } |
| | 31 | |
|
| | 32 | | public void Dispose() |
| | 33 | | { |
| 3 | 34 | | inspectorBtnView.OnInspectorButtonClick -= Click; |
| 3 | 35 | | inspectorBtnView.OnShowTooltip -= ShowTooltip; |
| 3 | 36 | | inspectorBtnView.OnHideTooltip -= HideTooltip; |
| 3 | 37 | | } |
| | 38 | |
|
| 2 | 39 | | public void Click() { OnClick?.Invoke(); } |
| | 40 | |
|
| | 41 | | public void ShowTooltip(BaseEventData eventData, string tooltipText) |
| | 42 | | { |
| 1 | 43 | | tooltipController.ShowTooltip(eventData); |
| 1 | 44 | | tooltipController.SetTooltipText(tooltipText); |
| 1 | 45 | | } |
| | 46 | |
|
| 2 | 47 | | public void HideTooltip() { tooltipController.HideTooltip(); } |
| | 48 | | } |