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