using System.Collections.Generic; using FairyGUI; using UI.Studio; using UnityEngine; namespace GFGGame { public class StudioPropertyView : StudioBaseView { // private GList _listProperty; private Controller _croProperty; private int _propertySelectIndex = 0; private int firstOpenProperty = -1;//第一个开放的副本(打开界面时,如未选择副本,则默认选中第一个开启的副本) //书画副本 public override void Dispose() { base.Dispose(); } protected override void OnInit() { base.OnInit(); _ui.m_btnBack.onClick.Add(OnClickBtnBack); // _ui.m_listProperty.itemRenderer = ListPropertyItemRender; // _ui.m_listProperty.onClickItem.Add(OnClickListProperty); } protected override void OnShown() { GComponent com = UIPackage.CreateObject(UI_StudioUI.PACKAGE_NAME, "ComProperty").asCom; this.AddChildCom(com); _croProperty = com.GetController("c1"); _croProperty.onChanged.Add(OnControllerChange); _propertySelectIndex = this.viewData == null ? 0 : (int)this.viewData; StudioDataManager.Instance.VIEW_NAME = typeof(StudioPropertyView).FullName; List studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name); firstOpenProperty = -1; for (int i = 0; i < studioCfgs.Count; i++) { GButton btn = com.GetChild("btn" + i).asButton; bool isOpen = TimeUtil.CheckDayOfWeek(studioCfgs[i].timeArr) ? true : false; btn.GetChild("icon").visible = isOpen; if (firstOpenProperty < 0 && isOpen) firstOpenProperty = i; } _propertySelectIndex = TimeUtil.CheckDayOfWeek(studioCfgs[_propertySelectIndex].timeArr) ? _propertySelectIndex : firstOpenProperty; _croProperty.selectedIndex = _propertySelectIndex; StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _propertySelectIndex; this._studioCfg = studioCfgs[_propertySelectIndex]; this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this._studioCfg.type, this._studioCfg.subType, this._studioCfg.id); list.numItems = this.storyLevelCfgs.Count; list.ScrollToView(curIndex); base.OnShown(); } protected override void OnHide() { base.OnHide(); } private void OnClickBtnBack() { ViewManager.GoBackFrom(typeof(StudioPropertyView).FullName); } // private void ListPropertyItemRender(int index, GObject obj) // { // List studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name); // GButton item = obj.asButton; // item.GetChild("icon0").asLoader.url = string.Format("ui://Studio/gzsltb_{0}", index + 1); // item.GetChild("icon1").asLoader.url = string.Format("ui://Studio/gzsatb_{0}", index + 1); // item.GetChild("icon2").asLoader.url = string.Format("ui://Studio/gzswtb_{0}", index + 1); // item.GetChild("icon2").asLoader.visible = TimeUtil.CheckDayOfWeek(studioCfgs[index].timeArr) ? false : true; // if (firstOpenProperty < 0 && TimeUtil.CheckDayOfWeek(studioCfgs[index].timeArr)) firstOpenProperty = index; // item.data = index; // } // private void OnClickListProperty(EventContext context) // { // GButton item = (context.data as GObject).asButton; // int index = (int)item.data; // List studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name); // StudioCfg studioCfg = studioCfgs[index]; // if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr)) // { // _listProperty.selectedIndex = _propertySelectIndex; // string str = ""; // for (int i = 0; i < studioCfg.timeArr.Length; i++) // { // str += NumberUtil.GetChiniseNumberWeekText(studioCfg.timeArr[i]); // if (i == studioCfg.timeArr.Length - 1) break; // str += "、"; // } // PromptController.Instance.ShowFloatTextPrompt(string.Format("周{0}开放", str)); // return; // } // _propertySelectIndex = index; // this.studioCfg = studioCfg; // this.studioData = StudioDataManager.Instance.GetStudioDataById(this.studioCfg.id); // this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this.studioCfg.type, this.studioCfg.subType, this.studioCfg.id); // list.numItems = this.storyLevelCfgs.Count; // list.ScrollToView(curIndex); // UpdateView(); // StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _listProperty.selectedIndex; // } private void OnControllerChange() { // int index = _croProperty.selectedIndex; List studioCfgs = StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioPropertyView).Name); StudioCfg studioCfg = studioCfgs[_croProperty.selectedIndex]; if (!TimeUtil.CheckDayOfWeek(studioCfg.timeArr)) { string str = ""; for (int i = 0; i < studioCfg.timeArr.Length; i++) { str += NumberUtil.GetChiniseNumberWeekText(studioCfg.timeArr[i]); if (i == studioCfg.timeArr.Length - 1) break; str += "、"; } PromptController.Instance.ShowFloatTextPrompt(string.Format("周{0}开放", str)); _croProperty.selectedIndex = _croProperty.previsousIndex; return; } // _propertySelectIndex = index; this._studioCfg = studioCfg; this.storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(this._studioCfg.type, this._studioCfg.subType, this._studioCfg.id); list.numItems = this.storyLevelCfgs.Count; list.ScrollToView(curIndex); UpdateView(); StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _croProperty.selectedIndex; } } }