You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

81 lines
1.5 KiB

  1. using System;
  2. using CIG.Translation;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. namespace CIG
  6. {
  7. public class TabButtonView : MonoBehaviour
  8. {
  9. public bool IsActive
  10. {
  11. get
  12. {
  13. return this._isActive;
  14. }
  15. set
  16. {
  17. this._isActive = value;
  18. if (this._isActive)
  19. {
  20. this._tabBackground.sprite = this._activeTabBackgroundSprite;
  21. }
  22. else
  23. {
  24. this._tabBackground.sprite = this._inactiveTabBackgroundSprite;
  25. }
  26. }
  27. }
  28. public void UpdateBadge(bool isActive)
  29. {
  30. if (this._badgeObject != null)
  31. {
  32. this._badgeObject.SetActive(isActive);
  33. }
  34. }
  35. public void UpdateBadge(int amount)
  36. {
  37. if (this._badgeObject != null)
  38. {
  39. bool flag = amount > 0;
  40. this._badgeObject.SetActive(flag);
  41. if (flag)
  42. {
  43. this._badgeLabel.LocalizedString = Localization.Integer(amount);
  44. }
  45. }
  46. }
  47. public ILocalizedString LocalizedTitle
  48. {
  49. get
  50. {
  51. return string.IsNullOrEmpty(this._titleLocalizationKey) ? Localization.EmptyLocalizedString : Localization.Key(this._titleLocalizationKey);
  52. }
  53. }
  54. [SerializeField]
  55. [Header("Background")]
  56. private Sprite _inactiveTabBackgroundSprite;
  57. [SerializeField]
  58. private Sprite _activeTabBackgroundSprite;
  59. [SerializeField]
  60. private Image _tabBackground;
  61. [SerializeField]
  62. private GameObject _badgeObject;
  63. [SerializeField]
  64. private LocalizedText _badgeLabel;
  65. [SerializeField]
  66. private string _titleLocalizationKey;
  67. private bool _isActive;
  68. }
  69. }