您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

93 行
2.8 KiB

  1. using System;
  2. using CIG.Translation;
  3. using CIGEnums;
  4. using SUISS.Core;
  5. using UnityEngine;
  6. public class SparkSocMenuPopupState : PopupBaseState
  7. {
  8. public override void Enter(State oldState)
  9. {
  10. base.Enter(oldState);
  11. CIGWebService instanceIfAvailable = SingletonMonobehaviour<CIGWebService>.InstanceIfAvailable;
  12. if (instanceIfAvailable != null)
  13. {
  14. string userKey = instanceIfAvailable.UserKey;
  15. ((SparkSocMenuPopupView)this.View).SetFriendCode(userKey);
  16. if (string.IsNullOrEmpty(userKey) && !this._pullRequestHandlerRegistered)
  17. {
  18. instanceIfAvailable.PullRequestCompleted += this.OnPullRequestCompleted;
  19. this._pullRequestHandlerRegistered = true;
  20. }
  21. }
  22. }
  23. public override void Leave(State newState)
  24. {
  25. base.Leave(newState);
  26. if (this._pullRequestHandlerRegistered && SingletonMonobehaviour<CIGWebService>.IsAvailable)
  27. {
  28. SingletonMonobehaviour<CIGWebService>.Instance.PullRequestCompleted -= this.OnPullRequestCompleted;
  29. this._pullRequestHandlerRegistered = false;
  30. }
  31. }
  32. public void OpenYouPopup()
  33. {
  34. CIGSparkSocServices instanceIfAvailable = SingletonMonobehaviour<CIGSparkSocServices>.InstanceIfAvailable;
  35. if (instanceIfAvailable != null)
  36. {
  37. if (instanceIfAvailable.IsLogedInAndLinked())
  38. {
  39. base.SafeSwitchState<GenericPopupState>().UpdateInfo(UISpriteType.SparklingIcon, Localization.Key("SSP_MENU_YOU"), Localization.Format("{0}: {1}", new ILocalizedString[]
  40. {
  41. Localization.Key("settings_sparksoc"),
  42. Localization.Literal(instanceIfAvailable.GetPlayerName())
  43. }), Localization.Key("back"), Localization.Key("settings_logout"), null, new Action(instanceIfAvailable.LogoutSparkSocPlayer), null, true);
  44. }
  45. else
  46. {
  47. base.SafeSwitchState<SparkSocLoginPopupState>();
  48. }
  49. }
  50. }
  51. public void OpenGiftsPopup()
  52. {
  53. base.SafeSwitchState<GiftsPopupState>();
  54. }
  55. public void OpenOtherGamesPopup()
  56. {
  57. base.SafeSwitchState<OtherGamesPopupState>();
  58. }
  59. public void OpenNewsletterPopup()
  60. {
  61. base.SafeSwitchState<SparkSocNewsletterPopupState>().SetCallbacks(delegate
  62. {
  63. SingletonMonobehaviour<CIGNewsletterRequester>.Instance.Subscribed = true;
  64. }, null);
  65. }
  66. protected void OnPullRequestCompleted()
  67. {
  68. CIGWebService instanceIfAvailable = SingletonMonobehaviour<CIGWebService>.InstanceIfAvailable;
  69. if (instanceIfAvailable != null && !string.IsNullOrEmpty(instanceIfAvailable.UserKey))
  70. {
  71. ((SparkSocMenuPopupView)this.View).SetFriendCode(instanceIfAvailable.UserKey);
  72. if (this._pullRequestHandlerRegistered)
  73. {
  74. instanceIfAvailable.PullRequestCompleted -= this.OnPullRequestCompleted;
  75. this._pullRequestHandlerRegistered = false;
  76. }
  77. else
  78. {
  79. UnityEngine.Debug.LogError("Pull request handler called, but not registered.");
  80. }
  81. }
  82. }
  83. protected bool _pullRequestHandlerRegistered;
  84. }