SoundWindow.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. using wf;
  6. public class SoundWindow : BaseMaidPhotoWindow
  7. {
  8. public override void Awake()
  9. {
  10. base.Awake();
  11. PhotoSoundData.Create();
  12. this.scroll_view_ = NGUITools.FindInParents<UIScrollView>(this.Grid.transform);
  13. for (int i = 0; i < PhotoSoundData.data.Count; i++)
  14. {
  15. PhotoSoundData photoSoundData = PhotoSoundData.data[i];
  16. GameObject gameObject = Utility.CreatePrefab(this.Grid.gameObject, "ScenePhotoMode/WindowListItem", true);
  17. gameObject.name = photoSoundData.id.ToString();
  18. UILabel componentInChildren = gameObject.GetComponentInChildren<UILabel>();
  19. componentInChildren.fontSize = 15;
  20. componentInChildren.text = photoSoundData.name;
  21. EventDelegate.Add(gameObject.GetComponent<UIWFTabButton>().onSelect, new EventDelegate.Callback(this.OnSelectBtn));
  22. }
  23. this.tab_panel_ = this.Grid.GetComponent<UIWFTabPanel>();
  24. NGUITools.FindInParents<UIScrollView>(this.Grid.transform).ResetPosition();
  25. this.Grid.Reposition();
  26. this.tab_panel_.UpdateChildren();
  27. this.scroll_view_.ResetPosition();
  28. this.UpdateChildren();
  29. }
  30. public override void Start()
  31. {
  32. base.Start();
  33. this.Init();
  34. }
  35. public void Init()
  36. {
  37. Dictionary<string, Dictionary<string, string>> woldStoreData = base.GetWoldStoreData();
  38. if (!woldStoreData.ContainsKey("再生サウンド"))
  39. {
  40. woldStoreData["再生サウンド"] = new Dictionary<string, string>();
  41. woldStoreData["再生サウンド"]["id"] = PhotoSoundData.Get(Path.ChangeExtension(this.initBgmFileName, ".ogg")).id.ToString();
  42. }
  43. long num = long.Parse(woldStoreData["再生サウンド"]["id"]);
  44. if (PhotoSoundData.Get(num) == null)
  45. {
  46. num = PhotoSoundData.Get("BGM021.ogg").id;
  47. }
  48. UIWFTabButton uiwftabButton = null;
  49. List<Transform> childList = this.Grid.GetChildList();
  50. int num2 = 0;
  51. while (num2 < childList.Count && uiwftabButton == null)
  52. {
  53. if (long.Parse(childList[num2].name) == num)
  54. {
  55. uiwftabButton = childList[num2].GetComponent<UIWFTabButton>();
  56. }
  57. num2++;
  58. }
  59. this.tab_panel_.Select(uiwftabButton);
  60. }
  61. public void OnSelectBtn()
  62. {
  63. if (!UIWFSelectButton.current.isSelected)
  64. {
  65. return;
  66. }
  67. long id = long.Parse(UIWFSelectButton.current.name);
  68. PhotoSoundData photoSoundData = PhotoSoundData.Get(id);
  69. photoSoundData.Play();
  70. Dictionary<string, Dictionary<string, string>> woldStoreData = base.GetWoldStoreData();
  71. if (!woldStoreData.ContainsKey("再生サウンド"))
  72. {
  73. woldStoreData["再生サウンド"] = new Dictionary<string, string>();
  74. }
  75. woldStoreData["再生サウンド"]["id"] = id.ToString();
  76. }
  77. public override void OnFinishMaidDeserializeLoad()
  78. {
  79. base.OnFinishMaidDeserializeLoad();
  80. this.scroll_view_.ResetPosition();
  81. GameMain.Instance.SoundMgr.StopBGM(0f);
  82. this.Init();
  83. }
  84. public override void OnDeserializeEvent()
  85. {
  86. List<string> maidStoreGuidList = this.mgr.GetMaidStoreGuidList();
  87. if (maidStoreGuidList.Count == 0)
  88. {
  89. this.scroll_view_.ResetPosition();
  90. GameMain.Instance.SoundMgr.StopBGM(0f);
  91. this.Init();
  92. }
  93. }
  94. public new PhotoWindowManager mgr
  95. {
  96. get
  97. {
  98. return base.mgr;
  99. }
  100. }
  101. public UIGrid Grid;
  102. public string initBgmFileName;
  103. private UIWFTabPanel tab_panel_;
  104. private UIScrollView scroll_view_;
  105. }