MessageWindowCtrl.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. UnityEngine.Object @object = Resources.Load("SystemUI/MessageWindow/Main/Prefabs/SelectButton");
  35. if (@object == null)
  36. {
  37. Debug.LogError(string.Format("ロードされるプレハブが見つかりませんでした。パス={0}", "SystemUI/MessageWindow/Main/Prefabs/SelectButton"));
  38. return;
  39. }
  40. this.m_selectButtonCtrl.CreateSelectButtons(listSelectBtn, onClickCallBack, @object);
  41. this.AdjustTargetPosInScrollView(this.m_selectBtnScrollView);
  42. if (listSelectBtn.Count > 4)
  43. {
  44. Debug.Log("スクロールバーのつまみの位置を初期化");
  45. this.m_selectBtnScrollBar.value = 0f;
  46. this.m_goDragMat.SetActive(true);
  47. }
  48. }
  49. public void CreateBacklog(List<BacklogCtrl.BacklogUnit> dicBacklog)
  50. {
  51. UnityEngine.Object @object = Resources.Load("SystemUI/MessageWindow/Backlog/Prefabs/BacklogUnit");
  52. if (@object == null)
  53. {
  54. Debug.LogError(string.Format("ロードされるプレハブが見つかりませんでした。パス={0}", "SystemUI/MessageWindow/Backlog/Prefabs/BacklogUnit"));
  55. return;
  56. }
  57. this.m_backlogCtrl.CreateBacklog(dicBacklog, @object);
  58. this.AdjustTargetPosInScrollView(this.m_backlogScrollView);
  59. int num = (dicBacklog == null) ? 0 : dicBacklog.Count;
  60. if (num > 5)
  61. {
  62. Debug.Log("スクロールバーのつまみの位置を初期化");
  63. this.m_backlogScrollBar.value = 1f;
  64. }
  65. }
  66. private void AdjustTargetPosInScrollView(UIScrollView target)
  67. {
  68. target.ResetPosition();
  69. }
  70. public bool IsSelectButtonPlayingEffect()
  71. {
  72. return this.m_selectButtonCtrl.IsPlayingEffect();
  73. }
  74. public void DisplayBacklog(bool display)
  75. {
  76. this.m_goBacklogViewer.SetActive(display);
  77. display = !display;
  78. this.m_goMessageViewer.SetActive(display);
  79. this.m_goSelectorViewer.SetActive(display);
  80. }
  81. public void ScrollDisplayBackLog(float delta)
  82. {
  83. if (delta != 0f)
  84. {
  85. this.m_goBacklogViewerScroll.Press(false);
  86. this.m_goBacklogViewerScroll.Scroll(delta);
  87. }
  88. }
  89. public bool IsDisplayBackLog()
  90. {
  91. return this.m_goBacklogViewer.activeSelf;
  92. }
  93. public GameObject GetBacklogViewerObject()
  94. {
  95. return this.m_goBacklogViewer;
  96. }
  97. public void ClearSelectBtn()
  98. {
  99. this.m_selectButtonCtrl.ClearExistSelectButton();
  100. this.m_selectBtnScrollView.ResetPosition();
  101. }
  102. public SelectButtonCtrl GetSelectButtonCtrl()
  103. {
  104. return this.m_selectButtonCtrl;
  105. }
  106. public void VRUIModeCheck()
  107. {
  108. if (GameMain.Instance.VRMode && this.m_bVRControllerNew != GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew)
  109. {
  110. if (GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew)
  111. {
  112. this.m_goSelectorViewer.transform.localPosition = new Vector3(572f, -610f, 0f);
  113. this.m_goSelectorViewer.transform.localScale = new Vector3(1.6f, 1.6f, 1f);
  114. }
  115. else
  116. {
  117. this.m_goSelectorViewer.transform.localPosition = this.m_vBackSelectorViewPos;
  118. this.m_goSelectorViewer.transform.localScale = this.m_vBackSelectorViewScale;
  119. }
  120. this.m_bVRControllerNew = GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew;
  121. }
  122. }
  123. [SerializeField]
  124. private const int maxSelectCnt = 4;
  125. [SerializeField]
  126. private const int maxBacklogUnitCnt = 5;
  127. private GameObject m_goMessageViewer;
  128. private GameObject m_goBacklogViewer;
  129. private UIScrollView m_goBacklogViewerScroll;
  130. private GameObject m_goSelectorViewer;
  131. private GameObject m_goSelectBtnParent;
  132. private GameObject m_goDragMat;
  133. private UIScrollView m_selectBtnScrollView;
  134. private UIScrollView m_backlogScrollView;
  135. private UIScrollBar m_selectBtnScrollBar;
  136. private UIScrollBar m_backlogScrollBar;
  137. private SelectButtonCtrl m_selectButtonCtrl;
  138. private BacklogCtrl m_backlogCtrl;
  139. private const string SELECT_BTN_PARENT_PATH = "SelectorViewer/Contents/SelectButtonParent";
  140. private const string SELECT_BUTTON_PREFAB_PATH = "SystemUI/MessageWindow/Main/Prefabs/SelectButton";
  141. private const string BACKLOG_UNIT_PARENT_PATH = "BacklogViewer/Contents/BacklogUnitParent";
  142. private const string BACKLOG_UNIT_PREFAB_PATH = "SystemUI/MessageWindow/Backlog/Prefabs/BacklogUnit";
  143. private const string BACKLOG_UNIT_PREFAB_SUBTITLE_PATH = "SystemUI/MessageWindow/Backlog/Prefabs/BacklogSubtitleUnit";
  144. private const int MIN_VALUE = 0;
  145. private const int MAX_VALUE = 1;
  146. private bool m_bVRControllerNew;
  147. private Vector3 m_vBackSelectorViewPos;
  148. private Vector3 m_vBackSelectorViewScale;
  149. }