CreativeRoomUISaveLoad.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. using wf;
  5. namespace MyRoomCustom
  6. {
  7. public class CreativeRoomUISaveLoad : MonoBehaviour
  8. {
  9. private void Start()
  10. {
  11. }
  12. public void OpenSavePanel()
  13. {
  14. if (this.m_IsOpenSave)
  15. {
  16. base.gameObject.SetActive(false);
  17. this.m_IsOpenSave = false;
  18. return;
  19. }
  20. this.m_IsOpenSave = true;
  21. this.m_IsOpenLoad = false;
  22. this.m_UITextTitle.text = "セーブ";
  23. Utility.SetLocalizeTerm(this.m_UITextTitle, "ScenePhotoMode/メニュー/セーブ", false);
  24. NDebug.Assert(this.m_Manager, "部屋作成シーンのマネージャが見つかりませんでした");
  25. base.gameObject.SetActive(true);
  26. GameObject uiparentButtonArea = this.m_UIParentButtonArea;
  27. Transform transform = uiparentButtonArea.transform;
  28. int childCount = transform.childCount;
  29. for (int i = 0; i < childCount; i++)
  30. {
  31. int number = i;
  32. Transform child = transform.GetChild(number);
  33. Button componentInChildren = child.GetComponentInChildren<Button>();
  34. Text textDate = child.GetComponentInChildren<Text>();
  35. uGUIInputField componentInChildren2 = child.GetComponentInChildren<uGUIInputField>();
  36. CreativeRoomManager.CreativeRoomHeader saveDataHeader = this.m_Manager.GetSaveDataHeader(number);
  37. if (saveDataHeader != null)
  38. {
  39. componentInChildren.interactable = true;
  40. componentInChildren2.interactable = true;
  41. textDate.text = this.m_Manager.DateTimeParse(saveDataHeader.lastWriteTime);
  42. componentInChildren2.text = saveDataHeader.comment;
  43. }
  44. else
  45. {
  46. componentInChildren.interactable = true;
  47. componentInChildren2.interactable = false;
  48. textDate.text = string.Empty;
  49. componentInChildren2.text = string.Empty;
  50. }
  51. componentInChildren.onClick.RemoveAllListeners();
  52. componentInChildren.onClick.AddListener(delegate()
  53. {
  54. if (!GameMain.Instance.SysDlg.IsDecided)
  55. {
  56. return;
  57. }
  58. GameMain.Instance.SysDlg.ShowFromLanguageTerm("Dialog/セーブロード/データを保存しますか?", null, SystemDialog.TYPE.OK_CANCEL, delegate
  59. {
  60. CreativeRoomManager.CreativeRoomHeader creativeRoomHeader = this.m_Manager.Save(number);
  61. textDate.text = this.m_Manager.DateTimeParse(creativeRoomHeader.lastWriteTime);
  62. GameMain.Instance.SysDlg.Close();
  63. }, delegate
  64. {
  65. GameMain.Instance.SysDlg.Close();
  66. });
  67. });
  68. componentInChildren2.onEndEdit.RemoveAllListeners();
  69. componentInChildren2.onEndEdit.AddListener(delegate(string value)
  70. {
  71. this.m_Manager.SaveComment(number, value);
  72. });
  73. }
  74. }
  75. public void OpenLoadPanel()
  76. {
  77. if (this.m_IsOpenLoad)
  78. {
  79. base.gameObject.SetActive(false);
  80. this.m_IsOpenLoad = false;
  81. return;
  82. }
  83. this.m_IsOpenSave = false;
  84. this.m_IsOpenLoad = true;
  85. this.m_UITextTitle.text = "ロード";
  86. Utility.SetLocalizeTerm(this.m_UITextTitle, "ScenePhotoMode/メニュー/ロード", false);
  87. NDebug.Assert(this.m_Manager, "[CreativeRoom] 部屋作成シーンのマネージャクラスが見つかりませんでした");
  88. base.gameObject.SetActive(true);
  89. GameObject uiparentButtonArea = this.m_UIParentButtonArea;
  90. Transform transform = uiparentButtonArea.transform;
  91. int childCount = transform.childCount;
  92. for (int i = 0; i < childCount; i++)
  93. {
  94. int number = i;
  95. Transform child = transform.GetChild(number);
  96. Button componentInChildren = child.GetComponentInChildren<Button>();
  97. Text componentInChildren2 = child.GetComponentInChildren<Text>();
  98. uGUIInputField componentInChildren3 = child.GetComponentInChildren<uGUIInputField>();
  99. CreativeRoomManager.CreativeRoomHeader head = this.m_Manager.GetSaveDataHeader(number);
  100. if (head != null)
  101. {
  102. componentInChildren.interactable = true;
  103. componentInChildren3.interactable = true;
  104. componentInChildren2.text = this.m_Manager.DateTimeParse(head.lastWriteTime);
  105. componentInChildren3.text = head.comment;
  106. }
  107. else
  108. {
  109. componentInChildren.interactable = false;
  110. componentInChildren3.interactable = false;
  111. componentInChildren2.text = string.Empty;
  112. componentInChildren3.text = string.Empty;
  113. }
  114. componentInChildren.onClick.RemoveAllListeners();
  115. componentInChildren.onClick.AddListener(delegate()
  116. {
  117. if (head == null)
  118. {
  119. return;
  120. }
  121. if (!GameMain.Instance.SysDlg.IsDecided)
  122. {
  123. return;
  124. }
  125. GameMain.Instance.SysDlg.ShowFromLanguageTerm("Dialog/セーブロード/データをロードしますか?", null, SystemDialog.TYPE.OK_CANCEL, delegate
  126. {
  127. this.m_Manager.Load(number);
  128. GameMain.Instance.SysDlg.Close();
  129. this.gameObject.SetActive(false);
  130. }, delegate
  131. {
  132. GameMain.Instance.SysDlg.Close();
  133. });
  134. });
  135. componentInChildren3.onEndEdit.RemoveAllListeners();
  136. componentInChildren3.onEndEdit.AddListener(delegate(string value)
  137. {
  138. this.m_Manager.SaveComment(number, value);
  139. });
  140. }
  141. }
  142. private void OnDisable()
  143. {
  144. if (this.m_IsQuittingApplication)
  145. {
  146. return;
  147. }
  148. this.m_IsOpenSave = false;
  149. this.m_IsOpenLoad = false;
  150. }
  151. private void OnApplicationQuit()
  152. {
  153. this.m_IsQuittingApplication = (true && Application.isEditor);
  154. }
  155. [SerializeField]
  156. [Tooltip("セーブ、ロードを行うウィンドウのタイトルテキスト")]
  157. private Text m_UITextTitle;
  158. [SerializeField]
  159. [Tooltip("セーブ用のボタンを並べる親オブジェクト")]
  160. private GameObject m_UIParentButtonArea;
  161. [SerializeField]
  162. [Tooltip("部屋作成シーンのマネージャクラス")]
  163. private CreativeRoomManager m_Manager;
  164. private bool m_IsOpenSave;
  165. private bool m_IsOpenLoad;
  166. private bool m_IsQuittingApplication;
  167. }
  168. }