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

106 行
2.6 KiB

  1. using System;
  2. using CIG.Translation;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class GenericPopupView : PopupBaseView
  6. {
  7. public bool Dismissable { get; private set; }
  8. public override void OnBlackOverlayClicked()
  9. {
  10. if (this.Dismissable && (this.State as GenericPopupState).overlayDismisses)
  11. {
  12. base.OnBlackOverlayClicked();
  13. }
  14. }
  15. public void OnGreenButtonClicked()
  16. {
  17. if (!base.PopupState.Closed)
  18. {
  19. ((GenericPopupState)this.State).GreenButton();
  20. }
  21. }
  22. public void OnRedButtonClicked()
  23. {
  24. if (!base.PopupState.Closed)
  25. {
  26. ((GenericPopupState)this.State).RedButton();
  27. }
  28. }
  29. public override void OnCloseClicked()
  30. {
  31. ((GenericPopupState)this.State).CloseButton();
  32. base.OnCloseClicked();
  33. }
  34. public void UpdateInfo(Sprite icon, ILocalizedString title, ILocalizedString bodyText, ILocalizedString greenText, ILocalizedString redText, bool dismissable)
  35. {
  36. this.Dismissable = dismissable;
  37. this._iconBottomSprite.gameObject.SetActive(false);
  38. this._titleLabel.gameObject.SetActive(title != null && title != Localization.EmptyLocalizedString);
  39. this._titleLabel.LocalizedString = title;
  40. this._bodyLabel.LocalizedString = bodyText;
  41. this._iconBackground.SetActive(icon != null);
  42. this._iconSprite.gameObject.SetActive(icon != null);
  43. this._iconSprite.sprite = icon;
  44. bool flag = greenText != null && greenText != Localization.EmptyLocalizedString;
  45. bool flag2 = redText != null && redText != Localization.EmptyLocalizedString;
  46. this._greenButton.gameObject.SetActive(flag);
  47. if (flag)
  48. {
  49. this._greenButtonLabel.LocalizedString = greenText;
  50. }
  51. this._redButton.gameObject.SetActive(flag2);
  52. if (flag2)
  53. {
  54. this._redButtonLabel.LocalizedString = redText;
  55. }
  56. this._closeButton.gameObject.SetActive(this.Dismissable);
  57. }
  58. public void SetBottomSprite(SpriteRenderer bottomRenderer)
  59. {
  60. Sprite sprite = (!(bottomRenderer.sprite == null)) ? bottomRenderer.sprite : null;
  61. if (sprite == null)
  62. {
  63. return;
  64. }
  65. this._iconBottomSprite.sprite = sprite;
  66. this._iconBottomSprite.gameObject.SetActive(true);
  67. }
  68. [SerializeField]
  69. private Button _closeButton;
  70. [SerializeField]
  71. private LocalizedText _titleLabel;
  72. [SerializeField]
  73. private LocalizedText _bodyLabel;
  74. [SerializeField]
  75. private GameObject _iconBackground;
  76. [SerializeField]
  77. private Image _iconSprite;
  78. [SerializeField]
  79. private Image _iconBottomSprite;
  80. [SerializeField]
  81. private Button _greenButton;
  82. [SerializeField]
  83. private LocalizedText _greenButtonLabel;
  84. [SerializeField]
  85. private Button _redButton;
  86. [SerializeField]
  87. private LocalizedText _redButtonLabel;
  88. }