|
- using System;
- using System.Collections;
- using CIG.Translation;
- using SUISS.Cloud;
- using SUISS.Core;
-
- public class SparkSocCreatePopupState : PopupBaseState
- {
- public void TryCreate(string username, string password)
- {
- if (this.IsValidInput(username, password))
- {
- base.StartCoroutine(this.DoCreate(username, password));
- }
- }
-
- public bool IsValidInput(string username, string password)
- {
- return SingletonMonobehaviour<CIGSparkSocServices>.Instance.IsValidUsernameAndPassword(username, password);
- }
-
- public void SetLoggedInCallback(Action loggedInCallback)
- {
- this._loggedInCallback = loggedInCallback;
- }
-
- private IEnumerator DoCreate(string username, string password)
- {
- CIGSparkSocServices sparkSocServices = SingletonMonobehaviour<CIGSparkSocServices>.Instance;
- ((SparkSocCreatePopupView)this.View).SparkSocIsBusy(true);
- CloudRequest<PlayernameErrors?> create = sparkSocServices.CreateSparkSocPlayer(username, password);
- yield return create;
- ((SparkSocCreatePopupView)this.View).SparkSocIsBusy(false);
- if (create.Error != null)
- {
- this.ShowErrorPopup(sparkSocServices.LocalizedServerErrorCode(create.Error.Value));
- }
- else
- {
- base.ClosePopup();
- if (this._loggedInCallback != null)
- {
- this._loggedInCallback();
- }
- }
- yield break;
- }
-
- private void ShowErrorPopup(ILocalizedString text)
- {
- this._fsm.SwitchState<GenericPopupState>().UpdateInfo(null, Localization.Key("oops_something_went_wrong"), text, Localization.Key("ok"), null, null, null, null, true);
- }
-
- private Action _loggedInCallback;
- }
|