StudioPropertyView.cs 6.6 KB

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