| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | public enum BuildModeModalType |
| | 5 | | { |
| | 6 | | EXIT, |
| | 7 | | PUBLISH |
| | 8 | | } |
| | 9 | |
|
| | 10 | | public interface IBuildModeConfirmationModalController |
| | 11 | | { |
| | 12 | | event Action<BuildModeModalType> OnCancelExit; |
| | 13 | | event Action<BuildModeModalType> OnConfirmExit; |
| | 14 | |
|
| | 15 | | bool IsViewActive(); |
| | 16 | | void Initialize(IBuildModeConfirmationModalView exitFromBiWModalView); |
| | 17 | | void Dispose(); |
| | 18 | | void Configure(string titleText, string subTitleText, string cancelBtnText, string confirmBtnText); |
| | 19 | | void SetActive(bool isActive, BuildModeModalType modalType); |
| | 20 | | void CancelExit(); |
| | 21 | | void ConfirmExit(); |
| | 22 | | } |
| | 23 | |
|
| | 24 | | public class BuildModeConfirmationModalController : IBuildModeConfirmationModalController |
| | 25 | | { |
| | 26 | | public event Action<BuildModeModalType> OnCancelExit; |
| | 27 | | public event Action<BuildModeModalType> OnConfirmExit; |
| | 28 | |
|
| | 29 | | internal IBuildModeConfirmationModalView exitFromBiWModalView; |
| | 30 | | internal BuildModeModalType modalType; |
| | 31 | |
|
| | 32 | | public void Initialize(IBuildModeConfirmationModalView exitFromBiWModalView) |
| | 33 | | { |
| 6 | 34 | | this.exitFromBiWModalView = exitFromBiWModalView; |
| | 35 | |
|
| 6 | 36 | | exitFromBiWModalView.OnCancelExit += CancelExit; |
| 6 | 37 | | exitFromBiWModalView.OnConfirmExit += ConfirmExit; |
| 6 | 38 | | } |
| | 39 | |
|
| | 40 | | public void Dispose() |
| | 41 | | { |
| 6 | 42 | | exitFromBiWModalView.OnCancelExit -= CancelExit; |
| 6 | 43 | | exitFromBiWModalView.OnConfirmExit -= ConfirmExit; |
| 6 | 44 | | } |
| | 45 | |
|
| | 46 | | public void Configure(string titleText, string subTitleText, string cancelBtnText, string confirmBtnText) |
| | 47 | | { |
| 1 | 48 | | exitFromBiWModalView.SetTitle(titleText); |
| 1 | 49 | | exitFromBiWModalView.SetSubTitle(subTitleText); |
| 1 | 50 | | exitFromBiWModalView.SetCancelButtonText(cancelBtnText); |
| 1 | 51 | | exitFromBiWModalView.SetConfirmButtonText(confirmBtnText); |
| 1 | 52 | | } |
| | 53 | |
|
| 1 | 54 | | public bool IsViewActive() { return exitFromBiWModalView.IsActive(); } |
| | 55 | |
|
| | 56 | | public void SetActive(bool isActive, BuildModeModalType modalType) |
| | 57 | | { |
| 4 | 58 | | this.modalType = modalType; |
| 4 | 59 | | exitFromBiWModalView.SetActive(isActive); |
| 4 | 60 | | } |
| | 61 | |
|
| | 62 | | public void CancelExit() |
| | 63 | | { |
| 1 | 64 | | SetActive(false, modalType); |
| 1 | 65 | | OnCancelExit?.Invoke(modalType); |
| 1 | 66 | | } |
| | 67 | |
|
| | 68 | | public void ConfirmExit() |
| | 69 | | { |
| 1 | 70 | | SetActive(false, modalType); |
| 1 | 71 | | OnConfirmExit?.Invoke(modalType); |
| 1 | 72 | | } |
| | 73 | | } |