FFNameDialog.cs 4.2 KB

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