FFNameDialog.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using System;
  2. using I2.Loc;
  3. using UnityEngine;
  4. using wf;
  5. public class FFNameDialog : MonoBehaviour
  6. {
  7. public bool IsDecided
  8. {
  9. get
  10. {
  11. return this.m_bDecided;
  12. }
  13. }
  14. public void Init()
  15. {
  16. this.m_uiPanel = base.gameObject.GetComponent<UIPanel>();
  17. this.m_goMsg = UTY.GetChildObject(base.gameObject, "Base/Message", false);
  18. this.m_uiMsg = this.m_goMsg.GetComponent<UILabel>();
  19. this.m_uiMsg.gameObject.AddComponent<Localize>();
  20. this.m_goSelectA = UTY.GetChildObject(base.gameObject, "Base/SelectA", false);
  21. this.m_uiBtnSelectA = this.m_goSelectA.GetComponent<UIButton>();
  22. this.m_uiLabelA = UTY.GetChildObject(this.m_goSelectA, "label", false).GetComponent<UILabel>();
  23. this.m_uiLabelA.gameObject.AddComponent<Localize>();
  24. this.m_goSelectB = UTY.GetChildObject(base.gameObject, "Base/SelectB", false);
  25. this.m_uiBtnSelectB = this.m_goSelectB.GetComponent<UIButton>();
  26. this.m_uiLabelB = UTY.GetChildObject(this.m_goSelectB, "label", false).GetComponent<UILabel>();
  27. this.m_uiLabelB.gameObject.AddComponent<Localize>();
  28. this.m_goSelectC = UTY.GetChildObject(base.gameObject, "Base/SelectC", true);
  29. if (this.m_goSelectC != null)
  30. {
  31. this.m_uiBtnSelectC = this.m_goSelectC.GetComponent<UIButton>();
  32. this.m_uiLabelC = UTY.GetChildObject(this.m_goSelectC, "label", false).GetComponent<UILabel>();
  33. this.m_uiLabelC.gameObject.AddComponent<Localize>();
  34. this.m_goSelectC.SetActive(false);
  35. }
  36. EventDelegate.Set(this.m_uiBtnSelectA.onClick, new EventDelegate.Callback(this.OnClickA));
  37. EventDelegate.Set(this.m_uiBtnSelectB.onClick, new EventDelegate.Callback(this.OnClickB));
  38. if (this.m_uiBtnSelectC != null)
  39. {
  40. EventDelegate.Set(this.m_uiBtnSelectC.onClick, new EventDelegate.Callback(this.OnClickC));
  41. }
  42. base.gameObject.SetActive(false);
  43. }
  44. public void SetOnClickCallBack(string f_strA, FFNameDialog.OnClick f_dgA, string f_strB, FFNameDialog.OnClick f_dgB, string f_strC, FFNameDialog.OnClick f_dgC)
  45. {
  46. this.m_dgOnClickA = f_dgA;
  47. this.m_dgOnClickB = f_dgB;
  48. this.m_dgOnClickC = f_dgC;
  49. if (this.m_dgOnClickA == null)
  50. {
  51. this.m_dgOnClickA = new FFNameDialog.OnClick(this.OnCloseDefaultEvent);
  52. }
  53. if (this.m_dgOnClickB == null)
  54. {
  55. this.m_dgOnClickB = new FFNameDialog.OnClick(this.OnCloseDefaultEvent);
  56. }
  57. if (this.m_dgOnClickC == null)
  58. {
  59. this.m_dgOnClickC = new FFNameDialog.OnClick(this.OnCloseDefaultEvent);
  60. }
  61. if (!string.IsNullOrEmpty(f_strA))
  62. {
  63. this.m_uiLabelA.text = f_strA;
  64. }
  65. if (!string.IsNullOrEmpty(f_strB))
  66. {
  67. this.m_uiLabelB.text = f_strB;
  68. }
  69. if (this.m_uiLabelC != null && !string.IsNullOrEmpty(f_strC))
  70. {
  71. this.m_uiLabelC.text = f_strC;
  72. }
  73. }
  74. public void Show(string f_strMsg, string f_strA, FFNameDialog.OnClick f_dgA, string f_strB, FFNameDialog.OnClick f_dgB, string f_strC, FFNameDialog.OnClick f_dgC)
  75. {
  76. if (this.selectABPostion != null)
  77. {
  78. this.selectABPostion.Apply();
  79. }
  80. NDebug.Assert(this.m_bDecided, "ダイアログの二重呼出しはできません。");
  81. if (!string.IsNullOrEmpty(f_strMsg))
  82. {
  83. this.m_uiMsg.text = f_strMsg;
  84. Utility.SetLocalizeTerm(this.m_uiMsg, f_strMsg, false);
  85. }
  86. this.SetOnClickCallBack(f_strA, f_dgA, f_strB, f_dgB, f_strC, f_dgC);
  87. base.gameObject.SetActive(true);
  88. iTween.StopByName(base.gameObject, "ffdlg");
  89. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  90. {
  91. "name",
  92. "ffdlg",
  93. "from",
  94. this.m_uiPanel.alpha,
  95. "to",
  96. 1.0,
  97. "time",
  98. 0.3,
  99. "onUpdate",
  100. "UpdateAlpha"
  101. }));
  102. this.m_bDecided = false;
  103. }
  104. public void ShowFromLanguageTerm(string messageTerm, string resultATerm, FFNameDialog.OnClick f_dgA, string resultBTerm, FFNameDialog.OnClick f_dgB = null)
  105. {
  106. Utility.SetLocalizeTerm(this.m_uiMsg, messageTerm, true);
  107. Utility.SetLocalizeTerm(this.m_uiLabelA, resultATerm, true);
  108. Utility.SetLocalizeTerm(this.m_uiLabelB, resultBTerm, true);
  109. this.Show(null, null, f_dgA, null, f_dgB, null, null);
  110. }
  111. public void ShowFromLanguageTerm(string messageTerm, string resultATerm, FFNameDialog.OnClick f_dgA, string resultBTerm, FFNameDialog.OnClick f_dgB, string resultCTerm, FFNameDialog.OnClick f_dgC)
  112. {
  113. Utility.SetLocalizeTerm(this.m_uiMsg, messageTerm, true);
  114. Utility.SetLocalizeTerm(this.m_uiLabelA, resultATerm, true);
  115. Utility.SetLocalizeTerm(this.m_uiLabelB, resultBTerm, true);
  116. Utility.SetLocalizeTerm(this.m_uiLabelC, resultCTerm, true);
  117. this.Show(null, null, f_dgA, null, f_dgB, null, f_dgC);
  118. if (this.selectCPostion != null)
  119. {
  120. this.selectCPostion.Apply();
  121. }
  122. }
  123. public void UpdateAlpha(float f_fNewValue)
  124. {
  125. this.m_uiPanel.alpha = f_fNewValue;
  126. }
  127. public void CompleteHide()
  128. {
  129. this.Hide();
  130. }
  131. public void Hide()
  132. {
  133. base.gameObject.SetActive(false);
  134. this.m_dgOnClickA = null;
  135. this.m_dgOnClickB = null;
  136. this.m_dgOnClickC = null;
  137. }
  138. public void Close()
  139. {
  140. if (base.gameObject.activeSelf)
  141. {
  142. iTween.StopByName(base.gameObject, "ffdlg");
  143. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  144. {
  145. "name",
  146. "ffdlg",
  147. "from",
  148. this.m_uiPanel.alpha,
  149. "to",
  150. 0.0,
  151. "time",
  152. 0.3,
  153. "onUpdate",
  154. "UpdateAlpha",
  155. "onComplete",
  156. "CompleteHide"
  157. }));
  158. }
  159. }
  160. private void OnClickA()
  161. {
  162. this.m_bDecided = true;
  163. if (this.m_dgOnClickA != null)
  164. {
  165. FFNameDialog.OnClick dgOnClickA = this.m_dgOnClickA;
  166. this.m_dgOnClickA = null;
  167. dgOnClickA();
  168. }
  169. }
  170. private void OnClickB()
  171. {
  172. this.m_bDecided = true;
  173. if (this.m_dgOnClickB != null)
  174. {
  175. FFNameDialog.OnClick dgOnClickB = this.m_dgOnClickB;
  176. this.m_dgOnClickB = null;
  177. dgOnClickB();
  178. }
  179. }
  180. private void OnClickC()
  181. {
  182. this.m_bDecided = true;
  183. if (this.m_dgOnClickC != null)
  184. {
  185. FFNameDialog.OnClick dgOnClickC = this.m_dgOnClickC;
  186. this.m_dgOnClickC = null;
  187. dgOnClickC();
  188. }
  189. }
  190. private void OnCloseDefaultEvent()
  191. {
  192. GameMain.Instance.SysDlg.Close();
  193. }
  194. [SerializeField]
  195. private UIWFPositionStore selectABPostion;
  196. [SerializeField]
  197. private UIWFPositionStore selectCPostion;
  198. private GameObject m_goSelectA;
  199. private UIButton m_uiBtnSelectA;
  200. private UILabel m_uiLabelA;
  201. private GameObject m_goSelectB;
  202. private UIButton m_uiBtnSelectB;
  203. private UILabel m_uiLabelB;
  204. private GameObject m_goSelectC;
  205. private UIButton m_uiBtnSelectC;
  206. private UILabel m_uiLabelC;
  207. private GameObject m_goMsg;
  208. private UILabel m_uiMsg;
  209. private UIPanel m_uiPanel;
  210. private FFNameDialog.OnClick m_dgOnClickA;
  211. private FFNameDialog.OnClick m_dgOnClickB;
  212. private FFNameDialog.OnClick m_dgOnClickC;
  213. private bool m_bDecided = true;
  214. public delegate void OnClick();
  215. }