SystemShortcut.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. using System;
  2. using System.Collections.Generic;
  3. using I2.Loc;
  4. using UnityEngine;
  5. using UnityEngine.SceneManagement;
  6. public class SystemShortcut : MonoBehaviour
  7. {
  8. private void Awake()
  9. {
  10. this.m_uiCam = base.gameObject.transform.parent.Find("Camera").GetComponent<Camera>();
  11. this.m_uiPanel = base.gameObject.GetComponent<UIPanel>();
  12. this.m_goBase = UTY.GetChildObject(base.gameObject, "Base", false);
  13. this.m_uiBase = this.m_goBase.GetComponent<UISprite>();
  14. this.m_hitArea = this.m_goBase.GetComponent<BoxCollider>();
  15. this.m_goBaseVR = UTY.GetChildObject(base.gameObject, "BaseVR", false);
  16. this.m_uiBaseVR = this.m_goBaseVR.GetComponent<UISprite>();
  17. this.m_goBaseVR.SetActive(false);
  18. this.m_goGear = UTY.GetChildObject(base.gameObject, "Gear", false);
  19. this.m_uiGear = this.m_goGear.GetComponent<UIButton>();
  20. EventDelegate.Add(this.m_uiGear.onClick, new EventDelegate.Callback(this.OnClick_Gear));
  21. this.m_aryDgOnClick[0] = new EventDelegate(new EventDelegate.Callback(this.OnClick_Config));
  22. this.m_aryDgOnClick[1] = new EventDelegate(new EventDelegate.Callback(this.OnClick_Exit));
  23. this.m_aryDgOnClick[2] = new EventDelegate(new EventDelegate.Callback(this.OnClick_Info));
  24. this.m_aryDgOnClick[3] = new EventDelegate(new EventDelegate.Callback(this.OnClick_Ss));
  25. this.m_aryDgOnClick[4] = new EventDelegate(new EventDelegate.Callback(this.OnClick_SsUi));
  26. this.m_aryDgOnClick[5] = new EventDelegate(new EventDelegate.Callback(this.OnClick_ToTitle));
  27. this.m_aryDgOnClick[6] = new EventDelegate(new EventDelegate.Callback(this.OnClick_Shop));
  28. this.m_aryDgOnClick[7] = new EventDelegate(new EventDelegate.Callback(this.OnClick_VRCommHome));
  29. this.m_aryDgOnClick[8] = new EventDelegate(new EventDelegate.Callback(this.OnClick_VRHelp));
  30. this.m_aryDgOnClick[9] = new EventDelegate(new EventDelegate.Callback(this.OnClick_Help));
  31. this.m_aryDgOnClick[10] = new EventDelegate(new EventDelegate.Callback(this.OnClick_VRAvatar));
  32. Dictionary<int, string> dictionary = new Dictionary<int, string>();
  33. dictionary.Add(0, "System/ショートカット/コンフィグ");
  34. dictionary.Add(3, "System/ショートカット/UI無し スクリーンショット");
  35. dictionary.Add(4, "System/ショートカット/UI有り スクリーンショット");
  36. dictionary.Add(6, "System/ショートカット/ショップ");
  37. dictionary.Add(5, "System/ショートカット/タイトルへ");
  38. dictionary.Add(2, "System/ショートカット/ゲーム情報");
  39. dictionary.Add(1, "System/ショートカット/終了");
  40. dictionary.Add(7, "System/ショートカット/エンパイアクラブに帰る");
  41. dictionary.Add(8, "System/ショートカット/VRヘルプ");
  42. dictionary.Add(9, "System/ショートカット/シーンのヘルプ");
  43. dictionary.Add(10, "System/ショートカット/バーチャル アバター スタジオ");
  44. for (int i = 0; i < this.m_aryObjPath.Length; i++)
  45. {
  46. this.m_goBtn[i] = UTY.GetChildObject(base.gameObject, this.m_aryObjPath[i], false);
  47. this.m_uiBtn[i] = this.m_goBtn[i].GetComponent<UIButton>();
  48. EventDelegate.Add(this.m_uiBtn[i].onClick, this.m_aryDgOnClick[i]);
  49. if (dictionary.ContainsKey(i))
  50. {
  51. UIEventTrigger component = this.m_goBtn[i].GetComponent<UIEventTrigger>();
  52. string text = dictionary[i];
  53. EventDelegate.Add(component.onHoverOver, delegate()
  54. {
  55. this.VisibleExplanation(text, true);
  56. });
  57. EventDelegate.Add(component.onHoverOut, delegate()
  58. {
  59. this.VisibleExplanation(text, false);
  60. });
  61. EventDelegate.Add(component.onDragStart, delegate()
  62. {
  63. this.VisibleExplanation(text, false);
  64. });
  65. }
  66. }
  67. UIWidget uiBaseVR = this.m_uiBaseVR;
  68. Color color = new Color(1f, 1f, 1f, 0f);
  69. this.m_uiBase.color = color;
  70. uiBaseVR.color = color;
  71. this.m_uiGear.defaultColor = new Color(1f, 1f, 1f, 0.3f);
  72. this.m_spriteExplanation = UTY.GetChildObject(base.gameObject, "Explanation", false).GetComponent<UISprite>();
  73. this.m_labelExplanation = UTY.GetChildObject(this.m_spriteExplanation.gameObject, "Value", false).GetComponent<UILabel>();
  74. this.m_spriteExplanation.gameObject.SetActive(false);
  75. this.dicBGSizeType.Add(SystemShortcut.BGSizeType.Long, 380);
  76. this.dicBGSizeType.Add(SystemShortcut.BGSizeType.Short, 340);
  77. int width = this.dicBGSizeType[SystemShortcut.BGSizeType.Short];
  78. GameObject childObject = UTY.GetChildObject(base.gameObject, this.m_aryObjPath[6], false);
  79. childObject.SetActive(false);
  80. this.m_uiBase.width = width;
  81. Vector2 vector = new Vector2(700f, 110f);
  82. this.m_hitArea.size = new Vector3((float)this.m_uiBase.width + vector.x, (float)this.m_uiBase.height + vector.y, 0f);
  83. Vector3 center = this.m_uiBase.GetComponent<BoxCollider>().center;
  84. center.x += vector.x / 2f;
  85. center.y -= 50f;
  86. this.m_hitArea.center = center;
  87. UTY.GetChildObject(this.m_goBase, "Grid", false).GetComponent<UIGrid>().repositionNow = true;
  88. SceneManager.activeSceneChanged += this.OnActiveSceneChanged;
  89. SceneManager.sceneUnloaded += this.OnSceneUnloaded;
  90. }
  91. private void OnClick_Gear()
  92. {
  93. if (this.m_bEnableBase)
  94. {
  95. this.BaseClose();
  96. }
  97. else if (!this.m_bEnableBase)
  98. {
  99. this.BaseOpen();
  100. }
  101. }
  102. private void BaseClose()
  103. {
  104. if (this.m_bEnableBase)
  105. {
  106. this.m_bEnableBase = false;
  107. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  108. {
  109. "from",
  110. this.m_uiBase.color.a,
  111. "to",
  112. 0f,
  113. "time",
  114. 0.25f,
  115. "onUpdate",
  116. "UpdateBase"
  117. }));
  118. this.m_uiGear.defaultColor = new Color(1f, 1f, 1f, 0.3f);
  119. }
  120. }
  121. private void BaseOpen()
  122. {
  123. if (!this.m_bEnableBase)
  124. {
  125. this.m_bEnableBase = true;
  126. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  127. {
  128. "from",
  129. this.m_uiBase.color.a,
  130. "to",
  131. 1f,
  132. "time",
  133. 0.25f,
  134. "onUpdate",
  135. "UpdateBase"
  136. }));
  137. this.m_uiGear.defaultColor = new Color(1f, 1f, 1f, 1f);
  138. }
  139. }
  140. private void UpdateBase(float f_fValue)
  141. {
  142. UIWidget uiBaseVR = this.m_uiBaseVR;
  143. Color color = new Color(1f, 1f, 1f, f_fValue);
  144. this.m_uiBase.color = color;
  145. uiBaseVR.color = color;
  146. }
  147. private void PanelClose()
  148. {
  149. if (this.m_bEnablePanel)
  150. {
  151. this.m_bEnablePanel = false;
  152. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  153. {
  154. "from",
  155. this.m_uiPanel.alpha,
  156. "to",
  157. 0f,
  158. "time",
  159. 0.25f,
  160. "onUpdate",
  161. "UpdatePanel"
  162. }));
  163. }
  164. }
  165. private void PanelOpen()
  166. {
  167. if (!this.m_bEnablePanel)
  168. {
  169. this.m_bEnablePanel = true;
  170. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  171. {
  172. "from",
  173. this.m_uiPanel.alpha,
  174. "to",
  175. 1f,
  176. "time",
  177. 0.25f,
  178. "onUpdate",
  179. "UpdatePanel"
  180. }));
  181. }
  182. }
  183. private void UpdatePanel(float f_fValue)
  184. {
  185. this.m_uiPanel.alpha = f_fValue;
  186. }
  187. private void OnClick_Config()
  188. {
  189. if (!this.m_bEnablePanel || BaseMgr<ConfigMgr>.Instance.IsOpenConfigPanel())
  190. {
  191. return;
  192. }
  193. BaseMgr<ConfigMgr>.Instance.OpenConfigPanel();
  194. if (ConfigVRCtrl.IsOpen())
  195. {
  196. ConfigVRCtrl.Close(true);
  197. }
  198. this.BaseClose();
  199. }
  200. private void OnClick_Exit()
  201. {
  202. if (!this.m_bEnablePanel)
  203. {
  204. return;
  205. }
  206. GameMain.Instance.SysDlg.ShowFromLanguageTerm("Dialog/終了しますか?", SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.OnToEnd), new SystemDialog.OnClick(this.OnCancel));
  207. this.BaseClose();
  208. }
  209. private void OnClick_Info()
  210. {
  211. if (!this.m_bEnablePanel)
  212. {
  213. return;
  214. }
  215. string text = "カスタムメイド3D 2";
  216. string translation = LocalizationManager.GetTranslation("System/カスタムオーダーメイド3D 2", true, 0, true, false, null, null);
  217. string text2 = string.Concat(new string[]
  218. {
  219. translation,
  220. "\nVersion ",
  221. GameUty.GetGameVersionText(),
  222. " (BuildVersion : ",
  223. GameUty.GetBuildVersionText(),
  224. ")"
  225. });
  226. if (!string.IsNullOrEmpty(GameMain.Instance.CMSystem.CM3D2Path))
  227. {
  228. string text3 = text2;
  229. text2 = string.Concat(new string[]
  230. {
  231. text3,
  232. "\n",
  233. text,
  234. "\nVersion ",
  235. GameUty.GetLegacyGameVersionText()
  236. });
  237. }
  238. GameMain.Instance.SysDlg.Show(text2, SystemDialog.TYPE.OK, new SystemDialog.OnClick(this.OnCancel), null);
  239. this.BaseClose();
  240. }
  241. private void OnClick_Ss()
  242. {
  243. GameMain.Instance.MainCamera.ScreenShot(true);
  244. }
  245. private void OnClick_SsUi()
  246. {
  247. this.VisibleExplanation(string.Empty, false);
  248. GameMain.Instance.MainCamera.ScreenShot(false);
  249. }
  250. private void OnClick_ToTitle()
  251. {
  252. if (!this.m_bEnablePanel)
  253. {
  254. return;
  255. }
  256. if (Application.loadedLevelName != "SceneTitle")
  257. {
  258. GameMain.Instance.SysDlg.ShowFromLanguageTerm("Dialog/タイトルに戻りますか?", SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.OnToTitle), new SystemDialog.OnClick(this.OnCancel));
  259. }
  260. else
  261. {
  262. GameMain.Instance.SysDlg.ShowFromLanguageTerm("Dialog/現在タイトルに戻れません。", SystemDialog.TYPE.OK, new SystemDialog.OnClick(this.OnCancel), null);
  263. }
  264. this.BaseClose();
  265. }
  266. private void OnClick_Shop()
  267. {
  268. Application.OpenURL(GameMain.Instance.CMSystem.ShopURL);
  269. }
  270. private void OnClick_VRCommHome()
  271. {
  272. GameMain.Instance.SysDlg.Show("エンパイアクラブに帰りますか?", SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.OnToHome), new SystemDialog.OnClick(this.OnCancel));
  273. this.BaseClose();
  274. }
  275. private void OnToHome()
  276. {
  277. }
  278. private void OnClick_VRHelp()
  279. {
  280. }
  281. private void OnClick_Help()
  282. {
  283. if (!this.m_bEnablePanel)
  284. {
  285. return;
  286. }
  287. if (uGUITutorialPanel.IsOpened())
  288. {
  289. return;
  290. }
  291. string text = this.strSceneHelpName;
  292. if (string.IsNullOrEmpty(text))
  293. {
  294. text = GameMain.Instance.GetNowSceneName();
  295. if (string.IsNullOrEmpty(text))
  296. {
  297. text = SceneManager.GetActiveScene().name;
  298. }
  299. }
  300. if (uGUITutorialPanel.IsExistTutorial(text))
  301. {
  302. uGUITutorialPanel.OpenTutorial(text, null, true);
  303. }
  304. else
  305. {
  306. NDebug.Warning(string.Format("シーン名「{0}」のチュートリアルは存在しません", text));
  307. }
  308. this.BaseClose();
  309. }
  310. private void OnClick_VRAvatar()
  311. {
  312. }
  313. private void OnClick_VRConfig()
  314. {
  315. if (!this.m_bEnablePanel)
  316. {
  317. return;
  318. }
  319. if (ConfigVRCtrl.IsOpen())
  320. {
  321. return;
  322. }
  323. ConfigVRCtrl.Open(null);
  324. if (BaseMgr<ConfigMgr>.Instance.IsOpenConfigPanel())
  325. {
  326. BaseMgr<ConfigMgr>.Instance.CloseConfigPanel();
  327. }
  328. this.BaseClose();
  329. }
  330. private void OnToEnd()
  331. {
  332. GameMain.Instance.ToApplicationQuit(true);
  333. }
  334. private void OnToTitle()
  335. {
  336. GameMain.Instance.SysDlg.Close();
  337. GameMain.Instance.LoadScene("SceneToTitle");
  338. GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
  339. }
  340. private void OnCancel()
  341. {
  342. GameMain.Instance.SysDlg.Close();
  343. }
  344. private void Start()
  345. {
  346. this.m_sys = GameMain.Instance.CMSystem;
  347. this.m_bEnablePanel = (this.m_bAlways = this.m_sys.SysButtonShowAlways);
  348. if (this.m_bAlways)
  349. {
  350. this.m_uiPanel.alpha = 1f;
  351. }
  352. else
  353. {
  354. this.m_uiPanel.alpha = 0f;
  355. }
  356. this.SetVRAvatarButtonInteractable();
  357. }
  358. private void Update()
  359. {
  360. if (this.m_sys.SysButtonShowAlways != this.m_bAlways)
  361. {
  362. if (this.m_sys.SysButtonShowAlways)
  363. {
  364. this.m_uiPanel.alpha = 1f;
  365. this.PanelOpen();
  366. }
  367. else
  368. {
  369. this.PanelClose();
  370. }
  371. this.m_bAlways = this.m_sys.SysButtonShowAlways;
  372. }
  373. if (!this.m_bAlways)
  374. {
  375. if (!GameMain.Instance.VRMode)
  376. {
  377. Ray ray = this.m_uiCam.ScreenPointToRay(Input.mousePosition);
  378. RaycastHit raycastHit = default(RaycastHit);
  379. if (this.m_hitArea.Raycast(ray, out raycastHit, 3.40282347E+38f))
  380. {
  381. if (!this.m_bEnablePanel)
  382. {
  383. this.PanelOpen();
  384. }
  385. }
  386. else if (this.m_bEnablePanel)
  387. {
  388. this.PanelClose();
  389. }
  390. }
  391. else
  392. {
  393. Vector3 ovrVirtualMousePos = GameMain.Instance.OvrMgr.SystemUICamera.GetOvrVirtualMousePos(true);
  394. Vector3 ovrVirtualMousePos2 = GameMain.Instance.OvrMgr.SystemUICamera.GetOvrVirtualMousePos(false);
  395. Ray ray2 = this.m_uiCam.ScreenPointToRay(ovrVirtualMousePos);
  396. Ray ray3 = this.m_uiCam.ScreenPointToRay(ovrVirtualMousePos2);
  397. RaycastHit raycastHit2 = default(RaycastHit);
  398. if (this.m_hitArea.Raycast(ray2, out raycastHit2, 3.40282347E+38f) || this.m_hitArea.Raycast(ray3, out raycastHit2, 3.40282347E+38f))
  399. {
  400. if (!this.m_bEnablePanel)
  401. {
  402. this.PanelOpen();
  403. }
  404. }
  405. else if (this.m_bEnablePanel)
  406. {
  407. this.PanelClose();
  408. }
  409. }
  410. }
  411. }
  412. public void VisibleExplanation(string text, bool visible)
  413. {
  414. if (visible)
  415. {
  416. this.m_labelExplanation.text = LocalizationManager.GetTranslation(text, true, 0, true, false, null, null);
  417. this.m_labelExplanation.width = 0;
  418. this.m_labelExplanation.MakePixelPerfect();
  419. UISprite component = this.m_spriteExplanation.GetComponent<UISprite>();
  420. component.width = this.m_labelExplanation.width + 15;
  421. }
  422. this.m_spriteExplanation.gameObject.SetActive(visible);
  423. }
  424. private void OnActiveSceneChanged(Scene beforeScene, Scene activeScene)
  425. {
  426. this.SetHelpButtonInteractable();
  427. uGUITutorialPanel.CloseTutorial(true, false);
  428. this.SetVRAvatarButtonInteractable();
  429. }
  430. private void OnSceneUnloaded(Scene unloadedScene)
  431. {
  432. this.strSceneHelpName = string.Empty;
  433. }
  434. public string strSceneHelpName
  435. {
  436. get
  437. {
  438. return this.m_strSceneHelpName;
  439. }
  440. set
  441. {
  442. if (string.IsNullOrEmpty(value))
  443. {
  444. this.m_strSceneHelpName = string.Empty;
  445. this.SetHelpButtonInteractable();
  446. return;
  447. }
  448. if (!uGUITutorialPanel.IsExistTutorial(value))
  449. {
  450. this.m_strSceneHelpName = string.Empty;
  451. this.SetHelpButtonInteractable();
  452. NDebug.Warning(string.Format("チュートリアル「{0}」は存在しないので、\nシーン名を利用します。", value));
  453. return;
  454. }
  455. this.m_strSceneHelpName = value;
  456. this.SetHelpButtonInteractable();
  457. }
  458. }
  459. private void SetHelpButtonInteractable()
  460. {
  461. GameObject childObject = UTY.GetChildObject(base.gameObject, this.m_aryObjPath[9], false);
  462. NDebug.Assert(childObject != null, "ヘルプ用ボタンの取得に失敗しました。");
  463. UIButton component = childObject.GetComponent<UIButton>();
  464. string text = this.strSceneHelpName;
  465. if (string.IsNullOrEmpty(text))
  466. {
  467. text = GameMain.Instance.GetNowSceneName();
  468. if (string.IsNullOrEmpty(text))
  469. {
  470. text = SceneManager.GetActiveScene().name;
  471. }
  472. }
  473. if (uGUITutorialPanel.IsExistTutorial(text))
  474. {
  475. component.isEnabled = true;
  476. }
  477. else
  478. {
  479. component.isEnabled = false;
  480. }
  481. }
  482. public bool helpButtonInteractable
  483. {
  484. get
  485. {
  486. GameObject childObject = UTY.GetChildObject(base.gameObject, this.m_aryObjPath[9], false);
  487. NDebug.Assert(childObject != null, "ヘルプ用ボタンの取得に失敗しました。");
  488. UIButton component = childObject.GetComponent<UIButton>();
  489. return component.isEnabled;
  490. }
  491. set
  492. {
  493. GameObject childObject = UTY.GetChildObject(base.gameObject, this.m_aryObjPath[9], false);
  494. NDebug.Assert(childObject != null, "ヘルプ用ボタンの取得に失敗しました。");
  495. UIButton component = childObject.GetComponent<UIButton>();
  496. component.isEnabled = value;
  497. }
  498. }
  499. private void SetVRAvatarButtonInteractable()
  500. {
  501. GameObject childObject = UTY.GetChildObject(base.gameObject, this.m_aryObjPath[10], false);
  502. NDebug.Assert(childObject != null, "VRアバターボタンの取得に失敗しました。");
  503. if (GameMain.Instance == null)
  504. {
  505. return;
  506. }
  507. childObject.SetActive(false);
  508. }
  509. private string[] m_aryObjPath = new string[]
  510. {
  511. "Base/Grid/Config",
  512. "Base/Grid/Exit",
  513. "Base/Grid/Info",
  514. "Base/Grid/Ss",
  515. "Base/Grid/SsUi",
  516. "Base/Grid/ToTitle",
  517. "Base/Grid/Shop",
  518. "BaseVR/Grid/VRCommHome",
  519. "BaseVR/Grid/VRHelp",
  520. "Base/Grid/Help",
  521. "Base/VR Avatar"
  522. };
  523. private UIPanel m_uiPanel;
  524. private BoxCollider m_hitArea;
  525. private GameObject m_goBase;
  526. private UISprite m_uiBase;
  527. private GameObject m_goBaseVR;
  528. private UISprite m_uiBaseVR;
  529. private GameObject m_goGear;
  530. private UIButton m_uiGear;
  531. private GameObject[] m_goBtn = new GameObject[11];
  532. private UIButton[] m_uiBtn = new UIButton[11];
  533. private Camera m_uiCam;
  534. private UISprite m_spriteExplanation;
  535. private UILabel m_labelExplanation;
  536. private bool m_bEnablePanel;
  537. private bool m_bEnableBase;
  538. private Dictionary<SystemShortcut.BGSizeType, int> dicBGSizeType = new Dictionary<SystemShortcut.BGSizeType, int>();
  539. private EventDelegate[] m_aryDgOnClick = new EventDelegate[11];
  540. private bool m_bAlways = true;
  541. private CMSystem m_sys;
  542. private string m_strSceneHelpName = string.Empty;
  543. private enum Btn
  544. {
  545. Config,
  546. Exit,
  547. Info,
  548. Ss,
  549. SsUi,
  550. ToTitle,
  551. Shop,
  552. VRCommHome,
  553. VRHelp,
  554. Help,
  555. VRAvatar,
  556. Max
  557. }
  558. private enum BGSizeType
  559. {
  560. Long,
  561. Short
  562. }
  563. }