FFNameDialog.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. using System;
  2. using UnityEngine;
  3. public class FFNameDialog : MonoBehaviour
  4. {
  5. public bool IsDecided
  6. {
  7. get
  8. {
  9. return this.m_bDecided;
  10. }
  11. }
  12. public void Init()
  13. {
  14. this.m_uiPanel = base.gameObject.GetComponent<UIPanel>();
  15. this.m_goMsg = UTY.GetChildObject(base.gameObject, "Base/Message", false);
  16. this.m_uiMsg = this.m_goMsg.GetComponent<UILabel>();
  17. this.m_goSelectA = UTY.GetChildObject(base.gameObject, "Base/SelectA", false);
  18. this.m_uiBtnSelectA = this.m_goSelectA.GetComponent<UIButton>();
  19. this.m_uiLabelA = UTY.GetChildObject(this.m_goSelectA, "label", false).GetComponent<UILabel>();
  20. this.m_goSelectB = UTY.GetChildObject(base.gameObject, "Base/SelectB", false);
  21. this.m_uiBtnSelectB = this.m_goSelectB.GetComponent<UIButton>();
  22. this.m_uiLabelB = UTY.GetChildObject(this.m_goSelectB, "label", false).GetComponent<UILabel>();
  23. EventDelegate.Set(this.m_uiBtnSelectA.onClick, new EventDelegate.Callback(this.OnClickA));
  24. EventDelegate.Set(this.m_uiBtnSelectB.onClick, new EventDelegate.Callback(this.OnClickB));
  25. base.gameObject.SetActive(false);
  26. }
  27. public void SetOnClickCallBack(string f_strA, FFNameDialog.OnClick f_dgA, string f_strB, FFNameDialog.OnClick f_dgB = null)
  28. {
  29. this.m_dgOnClickA = f_dgA;
  30. this.m_dgOnClickB = f_dgB;
  31. if (this.m_dgOnClickA == null)
  32. {
  33. this.m_dgOnClickA = new FFNameDialog.OnClick(this.OnCloseDefaultEvent);
  34. }
  35. if (this.m_dgOnClickB == null)
  36. {
  37. this.m_dgOnClickB = new FFNameDialog.OnClick(this.OnCloseDefaultEvent);
  38. }
  39. this.m_uiLabelA.text = f_strA;
  40. this.m_uiLabelB.text = f_strB;
  41. }
  42. public void Show(string f_strMsg, string f_strA, FFNameDialog.OnClick f_dgA, string f_strB, FFNameDialog.OnClick f_dgB = null)
  43. {
  44. NDebug.Assert(this.m_bDecided, "ダイアログの二重呼出しはできません。");
  45. this.m_uiMsg.text = f_strMsg;
  46. this.SetOnClickCallBack(f_strA, f_dgA, f_strB, f_dgB);
  47. base.gameObject.SetActive(true);
  48. iTween.StopByName(base.gameObject, "ffdlg");
  49. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  50. {
  51. "name",
  52. "ffdlg",
  53. "from",
  54. this.m_uiPanel.alpha,
  55. "to",
  56. 1.0,
  57. "time",
  58. 0.3,
  59. "onUpdate",
  60. "UpdateAlpha"
  61. }));
  62. this.m_bDecided = false;
  63. }
  64. public void UpdateAlpha(float f_fNewValue)
  65. {
  66. this.m_uiPanel.alpha = f_fNewValue;
  67. }
  68. public void CompleteHide()
  69. {
  70. this.Hide();
  71. }
  72. public void Hide()
  73. {
  74. base.gameObject.SetActive(false);
  75. this.m_dgOnClickA = null;
  76. this.m_dgOnClickB = null;
  77. }
  78. public void Close()
  79. {
  80. if (base.gameObject.activeSelf)
  81. {
  82. iTween.StopByName(base.gameObject, "ffdlg");
  83. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  84. {
  85. "name",
  86. "ffdlg",
  87. "from",
  88. this.m_uiPanel.alpha,
  89. "to",
  90. 0.0,
  91. "time",
  92. 0.3,
  93. "onUpdate",
  94. "UpdateAlpha",
  95. "onComplete",
  96. "CompleteHide"
  97. }));
  98. }
  99. }
  100. private void OnClickA()
  101. {
  102. this.m_bDecided = true;
  103. if (this.m_dgOnClickA != null)
  104. {
  105. FFNameDialog.OnClick dgOnClickA = this.m_dgOnClickA;
  106. this.m_dgOnClickA = null;
  107. dgOnClickA();
  108. }
  109. }
  110. private void OnClickB()
  111. {
  112. this.m_bDecided = true;
  113. if (this.m_dgOnClickB != null)
  114. {
  115. FFNameDialog.OnClick dgOnClickB = this.m_dgOnClickB;
  116. this.m_dgOnClickB = null;
  117. dgOnClickB();
  118. }
  119. }
  120. private void OnCloseDefaultEvent()
  121. {
  122. GameMain.Instance.SysDlg.Close();
  123. }
  124. private GameObject m_goSelectA;
  125. private UIButton m_uiBtnSelectA;
  126. private UILabel m_uiLabelA;
  127. private GameObject m_goSelectB;
  128. private UIButton m_uiBtnSelectB;
  129. private UILabel m_uiLabelB;
  130. private GameObject m_goMsg;
  131. private UILabel m_uiMsg;
  132. private UIPanel m_uiPanel;
  133. private FFNameDialog.OnClick m_dgOnClickA;
  134. private FFNameDialog.OnClick m_dgOnClickB;
  135. private bool m_bDecided = true;
  136. public delegate void OnClick();
  137. }