123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- 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<StudioCfg> 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<StudioCfg> 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<StudioCfg> 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<StudioCfg> 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;
- }
- }
- }
|