StudioPropertyView.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using System.Collections.Generic;
  2. using FairyGUI;
  3. using UI.Studio;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class StudioPropertyView : StudioBaseView
  8. {
  9. // private GList _listProperty;
  10. private Controller _croProperty;
  11. private int _propertySelectIndex = 0;
  12. private int firstOpenProperty = -1;//第一个开放的副本(打开界面时,如未选择副本,则默认选中第一个开启的副本)
  13. //书画副本
  14. public override void Dispose()
  15. {
  16. base.Dispose();
  17. }
  18. protected override void OnInit()
  19. {
  20. base.OnInit();
  21. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  22. // _ui.m_listProperty.itemRenderer = ListPropertyItemRender;
  23. // _ui.m_listProperty.onClickItem.Add(OnClickListProperty);
  24. }
  25. protected override void OnShown()
  26. {
  27. GComponent com = UIPackage.CreateObject(UI_StudioUI.PACKAGE_NAME, "ComProperty").asCom;
  28. this.AddChildCom(com);
  29. _croProperty = com.GetController("c1");
  30. _croProperty.onChanged.Add(OnControllerChange);
  31. _propertySelectIndex = this.viewData == null ? 0 : (int)this.viewData;
  32. StudioDataManager.Instance.VIEW_NAME = typeof(StudioPropertyView).FullName;
  33. List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
  34. firstOpenProperty = -1;
  35. for (int i = 0; i < studioCfgs.Count; i++)
  36. {
  37. GButton btn = com.GetChild("btn" + i).asButton;
  38. bool isOpen = TimeUtil.CheckDayOfWeek(studioCfgs[i].timeArr) ? true : false;
  39. btn.GetChild("icon").visible = isOpen;
  40. if (firstOpenProperty < 0 && isOpen) firstOpenProperty = i;
  41. }
  42. _propertySelectIndex = TimeUtil.CheckDayOfWeek(studioCfgs[_propertySelectIndex].timeArr) ? _propertySelectIndex : firstOpenProperty;
  43. _croProperty.selectedIndex = _propertySelectIndex;
  44. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _propertySelectIndex;
  45. this.studioCfg = studioCfgs[_propertySelectIndex];
  46. this.studioData = StudioDataManager.Instance.GetStudioDataById(this.studioCfg.id);
  47. this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this.studioCfg.type, this.studioCfg.subType, this.studioCfg.id);
  48. list.numItems = this.storyLevelCfgs.Count;
  49. list.ScrollToView(curIndex);
  50. base.OnShown();
  51. }
  52. protected override void OnHide()
  53. {
  54. base.OnHide();
  55. }
  56. private void OnClickBtnBack()
  57. {
  58. ViewManager.GoBackFrom(typeof(StudioPropertyView).FullName);
  59. }
  60. // private void ListPropertyItemRender(int index, GObject obj)
  61. // {
  62. // List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
  63. // GButton item = obj.asButton;
  64. // item.GetChild("icon0").asLoader.url = string.Format("ui://Studio/gzsltb_{0}", index + 1);
  65. // item.GetChild("icon1").asLoader.url = string.Format("ui://Studio/gzsatb_{0}", index + 1);
  66. // item.GetChild("icon2").asLoader.url = string.Format("ui://Studio/gzswtb_{0}", index + 1);
  67. // item.GetChild("icon2").asLoader.visible = TimeUtil.CheckDayOfWeek(studioCfgs[index].timeArr) ? false : true;
  68. // if (firstOpenProperty < 0 && TimeUtil.CheckDayOfWeek(studioCfgs[index].timeArr)) firstOpenProperty = index;
  69. // item.data = index;
  70. // }
  71. // private void OnClickListProperty(EventContext context)
  72. // {
  73. // GButton item = (context.data as GObject).asButton;
  74. // int index = (int)item.data;
  75. // List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
  76. // StudioCfg studioCfg = studioCfgs[index];
  77. // if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))
  78. // {
  79. // _listProperty.selectedIndex = _propertySelectIndex;
  80. // string str = "";
  81. // for (int i = 0; i < studioCfg.timeArr.Length; i++)
  82. // {
  83. // str += NumberUtil.GetChiniseNumberWeekText(studioCfg.timeArr[i]);
  84. // if (i == studioCfg.timeArr.Length - 1) break;
  85. // str += "、";
  86. // }
  87. // PromptController.Instance.ShowFloatTextPrompt(string.Format("周{0}开放", str));
  88. // return;
  89. // }
  90. // _propertySelectIndex = index;
  91. // this.studioCfg = studioCfg;
  92. // this.studioData = StudioDataManager.Instance.GetStudioDataById(this.studioCfg.id);
  93. // this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this.studioCfg.type, this.studioCfg.subType, this.studioCfg.id);
  94. // list.numItems = this.storyLevelCfgs.Count;
  95. // list.ScrollToView(curIndex);
  96. // UpdateView();
  97. // StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _listProperty.selectedIndex;
  98. // }
  99. private void OnControllerChange()
  100. {
  101. // int index = _croProperty.selectedIndex;
  102. List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
  103. StudioCfg studioCfg = studioCfgs[_croProperty.selectedIndex];
  104. if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))
  105. {
  106. string str = "";
  107. for (int i = 0; i < studioCfg.timeArr.Length; i++)
  108. {
  109. str += NumberUtil.GetChiniseNumberWeekText(studioCfg.timeArr[i]);
  110. if (i == studioCfg.timeArr.Length - 1) break;
  111. str += "、";
  112. }
  113. PromptController.Instance.ShowFloatTextPrompt(string.Format("周{0}开放", str));
  114. _croProperty.selectedIndex = _croProperty.previsousIndex;
  115. return;
  116. }
  117. // _propertySelectIndex = index;
  118. this.studioCfg = studioCfg;
  119. this.studioData = StudioDataManager.Instance.GetStudioDataById(this.studioCfg.id);
  120. this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this.studioCfg.type, this.studioCfg.subType, this.studioCfg.id);
  121. list.numItems = this.storyLevelCfgs.Count;
  122. list.ScrollToView(curIndex);
  123. UpdateView();
  124. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _croProperty.selectedIndex;
  125. }
  126. }
  127. }