MessageWindowCtrl.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class MessageWindowCtrl : MonoBehaviour
  5. {
  6. public void Init(GameObject goMessageWindowPanel)
  7. {
  8. this.m_goMessageViewer = UTY.GetChildObject(goMessageWindowPanel, "MessageViewer", false);
  9. this.m_goSelectorViewer = UTY.GetChildObject(goMessageWindowPanel, "SelectorViewer", false);
  10. this.m_goBacklogViewer = UTY.GetChildObject(goMessageWindowPanel, "BacklogViewer", false);
  11. this.m_goBacklogViewerScroll = UTY.GetChildObject(this.m_goBacklogViewer, "Contents", false).GetComponent<UIScrollView>();
  12. this.m_goSelectBtnParent = UTY.GetChildObject(goMessageWindowPanel, "SelectorViewer/Contents/SelectButtonParent", false);
  13. this.m_selectBtnScrollView = UTY.GetChildObject(this.m_goSelectorViewer, "Contents", false).GetComponent<UIScrollView>();
  14. this.m_selectBtnScrollBar = UTY.GetChildObject(this.m_goSelectorViewer, "Scroll Bar", false).GetComponent<UIScrollBar>();
  15. GameObject childObject = UTY.GetChildObject(goMessageWindowPanel, "BacklogViewer/Contents/BacklogUnitParent", false);
  16. this.m_backlogScrollView = UTY.GetChildObject(this.m_goBacklogViewer, "Contents", false).GetComponent<UIScrollView>();
  17. this.m_backlogScrollBar = UTY.GetChildObject(this.m_goBacklogViewer, "Scroll Bar", false).GetComponent<UIScrollBar>();
  18. this.m_selectButtonCtrl = this.m_goSelectBtnParent.GetComponent<SelectButtonCtrl>();
  19. this.m_backlogCtrl = childObject.GetComponent<BacklogCtrl>();
  20. this.m_goDragMat = UTY.GetChildObject(this.m_goSelectorViewer, "DragMat", false);
  21. this.m_goDragMat.SetActive(false);
  22. UTY.GetChildObject(this.m_goSelectorViewer, "Scroll Bar/Down", false).GetComponent<UISprite>().enabled = false;
  23. UTY.GetChildObject(this.m_goSelectorViewer, "Scroll Bar/Up", false).GetComponent<UISprite>().enabled = false;
  24. if (GameMain.Instance.VRMode)
  25. {
  26. this.m_vBackSelectorViewPos = this.m_goSelectorViewer.transform.localPosition;
  27. this.m_vBackSelectorViewScale = this.m_goSelectorViewer.transform.localScale;
  28. }
  29. }
  30. public void CreateSelectButtons(List<KeyValuePair<string, KeyValuePair<string, bool>>> listSelectBtn, Action<string, string> onClickCallBack)
  31. {
  32. UTY.GetChildObject(this.m_goSelectorViewer, "Scroll Bar/Down", false).GetComponent<UISprite>().enabled = true;
  33. UTY.GetChildObject(this.m_goSelectorViewer, "Scroll Bar/Up", false).GetComponent<UISprite>().enabled = true;
  34. string text = (!Product.supportMultiLanguage) ? "SystemUI/MessageWindow/Main/Prefabs/SelectButton" : "SystemUI/MessageWindow/Main/Prefabs/SelectButtonDouble";
  35. UnityEngine.Object @object = Resources.Load(text);
  36. if (@object == null)
  37. {
  38. Debug.LogError(string.Format("ロードされるプレハブが見つかりませんでした。パス={0}", text));
  39. return;
  40. }
  41. this.m_selectButtonCtrl.CreateSelectButtons(listSelectBtn, onClickCallBack, @object);
  42. this.AdjustTargetPosInScrollView(this.m_selectBtnScrollView);
  43. if (listSelectBtn.Count > 4)
  44. {
  45. Debug.Log("スクロールバーのつまみの位置を初期化");
  46. this.m_selectBtnScrollBar.value = 0f;
  47. this.m_goDragMat.SetActive(true);
  48. }
  49. }
  50. public void CreateBacklog(List<BacklogCtrl.BacklogUnit> dicBacklog)
  51. {
  52. string path;
  53. if (!Product.supportMultiLanguage)
  54. {
  55. path = "SystemUI/MessageWindow/Backlog/Prefabs/BacklogUnit";
  56. }
  57. else
  58. {
  59. path = "SystemUI/MessageWindow/Backlog/Prefabs/BacklogSubtitleUnit";
  60. }
  61. UnityEngine.Object @object = Resources.Load(path);
  62. if (@object == null)
  63. {
  64. Debug.LogError(string.Format("ロードされるプレハブが見つかりませんでした。パス={0}", "SystemUI/MessageWindow/Backlog/Prefabs/BacklogUnit"));
  65. return;
  66. }
  67. this.m_backlogCtrl.CreateBacklog(dicBacklog, @object);
  68. this.AdjustTargetPosInScrollView(this.m_backlogScrollView);
  69. int num = (dicBacklog == null) ? 0 : dicBacklog.Count;
  70. if (num > 5)
  71. {
  72. Debug.Log("スクロールバーのつまみの位置を初期化");
  73. this.m_backlogScrollBar.value = 1f;
  74. }
  75. }
  76. private void AdjustTargetPosInScrollView(UIScrollView target)
  77. {
  78. target.ResetPosition();
  79. }
  80. public bool IsSelectButtonPlayingEffect()
  81. {
  82. return this.m_selectButtonCtrl.IsPlayingEffect();
  83. }
  84. public void DisplayBacklog(bool display)
  85. {
  86. this.m_goBacklogViewer.SetActive(display);
  87. display = !display;
  88. this.m_goMessageViewer.SetActive(display);
  89. this.m_goSelectorViewer.SetActive(display);
  90. }
  91. public void ScrollDisplayBackLog(float delta)
  92. {
  93. if (delta != 0f)
  94. {
  95. this.m_goBacklogViewerScroll.Press(false);
  96. this.m_goBacklogViewerScroll.Scroll(delta);
  97. }
  98. }
  99. public bool IsDisplayBackLog()
  100. {
  101. return this.m_goBacklogViewer.activeSelf;
  102. }
  103. public GameObject GetBacklogViewerObject()
  104. {
  105. return this.m_goBacklogViewer;
  106. }
  107. public void ClearSelectBtn()
  108. {
  109. this.m_selectButtonCtrl.ClearExistSelectButton();
  110. this.m_selectBtnScrollView.ResetPosition();
  111. }
  112. public SelectButtonCtrl GetSelectButtonCtrl()
  113. {
  114. return this.m_selectButtonCtrl;
  115. }
  116. public void VRUIModeCheck()
  117. {
  118. if (GameMain.Instance.VRMode && this.m_bVRControllerNew != GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew)
  119. {
  120. if (GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew)
  121. {
  122. this.m_goSelectorViewer.transform.localPosition = new Vector3(572f, -610f, 0f);
  123. this.m_goSelectorViewer.transform.localScale = new Vector3(1.6f, 1.6f, 1f);
  124. }
  125. else
  126. {
  127. this.m_goSelectorViewer.transform.localPosition = this.m_vBackSelectorViewPos;
  128. this.m_goSelectorViewer.transform.localScale = this.m_vBackSelectorViewScale;
  129. }
  130. this.m_bVRControllerNew = GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew;
  131. }
  132. }
  133. [SerializeField]
  134. private const int maxSelectCnt = 4;
  135. [SerializeField]
  136. private const int maxBacklogUnitCnt = 5;
  137. private GameObject m_goMessageViewer;
  138. private GameObject m_goBacklogViewer;
  139. private UIScrollView m_goBacklogViewerScroll;
  140. private GameObject m_goSelectorViewer;
  141. private GameObject m_goSelectBtnParent;
  142. private GameObject m_goDragMat;
  143. private UIScrollView m_selectBtnScrollView;
  144. private UIScrollView m_backlogScrollView;
  145. private UIScrollBar m_selectBtnScrollBar;
  146. private UIScrollBar m_backlogScrollBar;
  147. private SelectButtonCtrl m_selectButtonCtrl;
  148. private BacklogCtrl m_backlogCtrl;
  149. private const string SELECT_BTN_PARENT_PATH = "SelectorViewer/Contents/SelectButtonParent";
  150. private const string SELECT_BUTTON_PREFAB_PATH_EN = "SystemUI/MessageWindow/Main/Prefabs/SelectButtonDouble";
  151. private const string SELECT_BUTTON_PREFAB_PATH = "SystemUI/MessageWindow/Main/Prefabs/SelectButton";
  152. private const string BACKLOG_UNIT_PARENT_PATH = "BacklogViewer/Contents/BacklogUnitParent";
  153. private const string BACKLOG_UNIT_PREFAB_PATH = "SystemUI/MessageWindow/Backlog/Prefabs/BacklogUnit";
  154. private const string BACKLOG_UNIT_PREFAB_SUBTITLE_PATH = "SystemUI/MessageWindow/Backlog/Prefabs/BacklogSubtitleUnit";
  155. private const int MIN_VALUE = 0;
  156. private const int MAX_VALUE = 1;
  157. private bool m_bVRControllerNew;
  158. private Vector3 m_vBackSelectorViewPos;
  159. private Vector3 m_vBackSelectorViewScale;
  160. }