CreativeRoomUISaveLoad.cs 5.3 KB

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