| | 1 | | using DCL; |
| | 2 | | using DCL.Interface; |
| | 3 | |
|
| | 4 | | namespace SignupHUD |
| | 5 | | { |
| | 6 | | public class SignupHUDController : IHUD |
| | 7 | | { |
| | 8 | | internal ISignupHUDView view; |
| | 9 | |
|
| | 10 | | internal string name; |
| | 11 | | internal string email; |
| 21 | 12 | | internal BaseVariable<bool> signupVisible => DataStore.i.HUDs.signupVisible; |
| | 13 | | internal IHUD avatarEditorHUD; |
| | 14 | |
|
| 1 | 15 | | internal virtual ISignupHUDView CreateView() => SignupHUDView.CreateView(); |
| | 16 | |
|
| | 17 | | public void Initialize(IHUD avatarEditorHUD) |
| | 18 | | { |
| 9 | 19 | | view = CreateView(); |
| | 20 | |
|
| 9 | 21 | | if (view == null) |
| 0 | 22 | | return; |
| | 23 | |
|
| 9 | 24 | | this.avatarEditorHUD = avatarEditorHUD; |
| | 25 | |
|
| 9 | 26 | | signupVisible.OnChange += OnSignupVisibleChanged; |
| 9 | 27 | | signupVisible.Set(false); |
| | 28 | |
|
| 9 | 29 | | view.OnNameScreenNext += OnNameScreenNext; |
| 9 | 30 | | view.OnEditAvatar += OnEditAvatar; |
| 9 | 31 | | view.OnTermsOfServiceAgreed += OnTermsOfServiceAgreed; |
| 9 | 32 | | view.OnTermsOfServiceBack += OnTermsOfServiceBack; |
| 9 | 33 | | } |
| | 34 | |
|
| 4 | 35 | | private void OnSignupVisibleChanged(bool current, bool previous) { SetVisibility(current); } |
| | 36 | |
|
| | 37 | | internal void StartSignupProcess() |
| | 38 | | { |
| 4 | 39 | | name = null; |
| 4 | 40 | | email = null; |
| 4 | 41 | | view?.ShowNameScreen(); |
| 4 | 42 | | } |
| | 43 | |
|
| | 44 | | internal void OnNameScreenNext(string newName, string newEmail) |
| | 45 | | { |
| 1 | 46 | | name = newName; |
| 1 | 47 | | email = newEmail; |
| 1 | 48 | | view?.ShowTermsOfServiceScreen(); |
| 1 | 49 | | } |
| | 50 | |
|
| | 51 | | internal void OnEditAvatar() |
| | 52 | | { |
| 1 | 53 | | signupVisible.Set(false); |
| 1 | 54 | | avatarEditorHUD?.SetVisibility(true); |
| 1 | 55 | | } |
| | 56 | |
|
| | 57 | | internal void OnTermsOfServiceAgreed() |
| | 58 | | { |
| 1 | 59 | | WebInterface.SendPassport(name, email); |
| 1 | 60 | | DataStore.i.common.isSignUpFlow.Set(false); |
| 1 | 61 | | signupVisible.Set(false); |
| 1 | 62 | | } |
| | 63 | |
|
| 2 | 64 | | internal void OnTermsOfServiceBack() { StartSignupProcess(); } |
| | 65 | |
|
| | 66 | | public void SetVisibility(bool visible) |
| | 67 | | { |
| 3 | 68 | | view?.SetVisibility(visible); |
| 3 | 69 | | if (visible) |
| 2 | 70 | | StartSignupProcess(); |
| 3 | 71 | | } |
| | 72 | |
|
| | 73 | | public void Dispose() |
| | 74 | | { |
| 1 | 75 | | signupVisible.OnChange -= OnSignupVisibleChanged; |
| 1 | 76 | | if (view == null) |
| 0 | 77 | | return; |
| 1 | 78 | | view.OnNameScreenNext -= OnNameScreenNext; |
| 1 | 79 | | view.OnEditAvatar -= OnEditAvatar; |
| 1 | 80 | | view.OnTermsOfServiceAgreed -= OnTermsOfServiceAgreed; |
| 1 | 81 | | view.OnTermsOfServiceBack -= OnTermsOfServiceBack; |
| 1 | 82 | | view.Dispose(); |
| 1 | 83 | | } |
| | 84 | | } |
| | 85 | | } |