StudioPropertyView.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this._studioCfg.type, this._studioCfg.subType, this._studioCfg.id);
  47. list.numItems = this.storyLevelCfgs.Count;
  48. list.ScrollToView(curIndex);
  49. base.OnShown();
  50. }
  51. protected override void OnHide()
  52. {
  53. base.OnHide();
  54. }
  55. private void OnClickBtnBack()
  56. {
  57. ViewManager.GoBackFrom(typeof(StudioPropertyView).FullName);
  58. }
  59. // private void ListPropertyItemRender(int index, GObject obj)
  60. // {
  61. // List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
  62. // GButton item = obj.asButton;
  63. // item.GetChild("icon0").asLoader.url = string.Format("ui://Studio/gzsltb_{0}", index + 1);
  64. // item.GetChild("icon1").asLoader.url = string.Format("ui://Studio/gzsatb_{0}", index + 1);
  65. // item.GetChild("icon2").asLoader.url = string.Format("ui://Studio/gzswtb_{0}", index + 1);
  66. // item.GetChild("icon2").asLoader.visible = TimeUtil.CheckDayOfWeek(studioCfgs[index].timeArr) ? false : true;
  67. // if (firstOpenProperty < 0 && TimeUtil.CheckDayOfWeek(studioCfgs[index].timeArr)) firstOpenProperty = index;
  68. // item.data = index;
  69. // }
  70. // private void OnClickListProperty(EventContext context)
  71. // {
  72. // GButton item = (context.data as GObject).asButton;
  73. // int index = (int)item.data;
  74. // List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
  75. // StudioCfg studioCfg = studioCfgs[index];
  76. // if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))
  77. // {
  78. // _listProperty.selectedIndex = _propertySelectIndex;
  79. // string str = "";
  80. // for (int i = 0; i < studioCfg.timeArr.Length; i++)
  81. // {
  82. // str += NumberUtil.GetChiniseNumberWeekText(studioCfg.timeArr[i]);
  83. // if (i == studioCfg.timeArr.Length - 1) break;
  84. // str += "、";
  85. // }
  86. // PromptController.Instance.ShowFloatTextPrompt(string.Format("周{0}开放", str));
  87. // return;
  88. // }
  89. // _propertySelectIndex = index;
  90. // this.studioCfg = studioCfg;
  91. // this.studioData = StudioDataManager.Instance.GetStudioDataById(this.studioCfg.id);
  92. // this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this.studioCfg.type, this.studioCfg.subType, this.studioCfg.id);
  93. // list.numItems = this.storyLevelCfgs.Count;
  94. // list.ScrollToView(curIndex);
  95. // UpdateView();
  96. // StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _listProperty.selectedIndex;
  97. // }
  98. private void OnControllerChange()
  99. {
  100. // int index = _croProperty.selectedIndex;
  101. List<StudioCfg> studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name);
  102. StudioCfg studioCfg = studioCfgs[_croProperty.selectedIndex];
  103. if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr))
  104. {
  105. string str = "";
  106. for (int i = 0; i < studioCfg.timeArr.Length; i++)
  107. {
  108. str += NumberUtil.GetChiniseNumberWeekText(studioCfg.timeArr[i]);
  109. if (i == studioCfg.timeArr.Length - 1) break;
  110. str += "、";
  111. }
  112. PromptController.Instance.ShowFloatTextPrompt(string.Format("周{0}开放", str));
  113. _croProperty.selectedIndex = _croProperty.previsousIndex;
  114. return;
  115. }
  116. // _propertySelectIndex = index;
  117. this._studioCfg = studioCfg;
  118. this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this._studioCfg.type, this._studioCfg.subType, this._studioCfg.id);
  119. list.numItems = this.storyLevelCfgs.Count;
  120. list.ScrollToView(curIndex);
  121. UpdateView();
  122. StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _croProperty.selectedIndex;
  123. }
  124. }
  125. }