UIWFSelectButton.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using System.Collections.Generic;
  3. public class UIWFSelectButton : UIButton
  4. {
  5. protected override void OnClick()
  6. {
  7. if (UIWFSelectButton.current == null && this.isEnabled)
  8. {
  9. UIWFSelectButton uiwfselectButton = UIWFSelectButton.current;
  10. UIWFSelectButton.current = this;
  11. base.OnClick();
  12. UIWFSelectButton.current = uiwfselectButton;
  13. }
  14. }
  15. public bool isSelected
  16. {
  17. get
  18. {
  19. return this.selected_;
  20. }
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. this.widget_ = base.gameObject.GetComponent<UIWidget>();
  26. if (this.widget_ == null && this.tweenTarget != null)
  27. {
  28. this.widget_ = this.tweenTarget.GetComponent<UIWidget>();
  29. }
  30. if (this.SelectSprite != null)
  31. {
  32. if (!this.SelectSprite.enabled)
  33. {
  34. this.SelectSprite.enabled = true;
  35. }
  36. this.SelectSprite.alpha = 0f;
  37. }
  38. }
  39. public virtual void SetSelect(bool is_select)
  40. {
  41. if (!this.mInitDone)
  42. {
  43. this.OnInit();
  44. }
  45. if (!this.isEnabled)
  46. {
  47. return;
  48. }
  49. this.selected_ = is_select;
  50. if (is_select)
  51. {
  52. if (this.SelectSprite != null)
  53. {
  54. this.SelectSprite.GetComponent<UIWidget>().depth = this.widget_.depth + 1;
  55. this.SelectSprite.alpha = 1f;
  56. }
  57. }
  58. else if (this.SelectSprite != null)
  59. {
  60. this.SelectSprite.alpha = 0f;
  61. }
  62. UIButton uibutton = UIButton.current;
  63. UIWFSelectButton uiwfselectButton = UIWFSelectButton.current;
  64. UIWFSelectButton.current = this;
  65. UIButton.current = this;
  66. UIWFSelectButton.selected = is_select;
  67. EventDelegate.Execute(this.onSelect);
  68. UIWFSelectButton.selected = false;
  69. UIWFSelectButton.current = uiwfselectButton;
  70. UIButton.current = uibutton;
  71. }
  72. public List<EventDelegate> onSelect = new List<EventDelegate>();
  73. public UISprite SelectSprite;
  74. public static bool selected;
  75. public new static UIWFSelectButton current;
  76. protected UIWidget widget_;
  77. protected bool selected_;
  78. }