| | 1 | | using System; |
| | 2 | | using UnityEngine.EventSystems; |
| | 3 | |
|
| | 4 | | public interface IPublishBtnController |
| | 5 | | { |
| | 6 | | event Action OnClick; |
| | 7 | |
|
| | 8 | | void Initialize(IPublishBtnView publishBtnView, ITooltipController tooltipController, ITooltipController feedbackToo |
| | 9 | | void Dispose(); |
| | 10 | | void Click(); |
| | 11 | | void ShowTooltip(BaseEventData eventData, string tooltipText); |
| | 12 | | void HideTooltip(); |
| | 13 | | void SetFeedbackMessage(string newText); |
| | 14 | | void SetInteractable(bool isInteractable); |
| | 15 | | } |
| | 16 | |
|
| | 17 | | public class PublishBtnController : IPublishBtnController |
| | 18 | | { |
| | 19 | | public event Action OnClick; |
| | 20 | |
|
| | 21 | | internal IPublishBtnView publishBtnView; |
| | 22 | | internal ITooltipController tooltipController; |
| | 23 | | internal ITooltipController feedbackTooltipController; |
| 0 | 24 | | internal string currentFeedbackmessage = string.Empty; |
| | 25 | |
|
| | 26 | | public void Initialize(IPublishBtnView publishBtnView, ITooltipController tooltipController, ITooltipController feed |
| | 27 | | { |
| 6 | 28 | | this.publishBtnView = publishBtnView; |
| 6 | 29 | | this.tooltipController = tooltipController; |
| 6 | 30 | | this.feedbackTooltipController = feedbackTooltipController; |
| | 31 | |
|
| 6 | 32 | | publishBtnView.OnPublishButtonClick += Click; |
| 6 | 33 | | publishBtnView.OnShowTooltip += ShowTooltip; |
| 6 | 34 | | publishBtnView.OnHideTooltip += HideTooltip; |
| 6 | 35 | | } |
| | 36 | |
|
| | 37 | | public void Dispose() |
| | 38 | | { |
| 6 | 39 | | publishBtnView.OnPublishButtonClick -= Click; |
| 6 | 40 | | publishBtnView.OnShowTooltip -= ShowTooltip; |
| 6 | 41 | | publishBtnView.OnHideTooltip -= HideTooltip; |
| 6 | 42 | | } |
| | 43 | |
|
| 2 | 44 | | public void Click() { OnClick?.Invoke(); } |
| | 45 | |
|
| | 46 | | public void ShowTooltip(BaseEventData eventData, string tooltipText) |
| | 47 | | { |
| 1 | 48 | | if (string.IsNullOrEmpty(currentFeedbackmessage)) |
| | 49 | | { |
| 1 | 50 | | tooltipController.SetTooltipText(tooltipText); |
| 1 | 51 | | tooltipController.ShowTooltip(eventData); |
| 1 | 52 | | } |
| | 53 | | else |
| | 54 | | { |
| 0 | 55 | | feedbackTooltipController.SetTooltipText(currentFeedbackmessage); |
| 0 | 56 | | feedbackTooltipController.ShowTooltip(eventData); |
| | 57 | | } |
| 0 | 58 | | } |
| | 59 | |
|
| | 60 | | public void HideTooltip() |
| | 61 | | { |
| 1 | 62 | | tooltipController.HideTooltip(); |
| 1 | 63 | | feedbackTooltipController.HideTooltip(); |
| 1 | 64 | | } |
| | 65 | |
|
| 0 | 66 | | public void SetFeedbackMessage(string newText) { currentFeedbackmessage = newText; } |
| | 67 | |
|
| 4 | 68 | | public void SetInteractable(bool isInteractable) { publishBtnView.SetInteractable(isInteractable); } |
| | 69 | | } |