using UI.Store; using UI.CommonGame; using FairyGUI; using System.Collections.Generic; using ET; using UnityEngine; // using System.Diagnostics; namespace GFGGame { public class StoreView : BaseWindow { private UI_StoreUI _ui; // private ValueBarController _valueBarController; private List> _arenaSubTab = new List>(); private int _curTabIndex = 0; private int _curSubTabIndex = 0; private string _curViewName = ""; public override void Dispose() { if (_ui != null) { _ui.Dispose(); } _arenaSubTab.Clear(); _ui = null; base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_StoreUI.PACKAGE_NAME; _ui = UI_StoreUI.Create(); this.viewCom = _ui.target; isfullScreen = true; this.bringToFontOnClick = false; StoreTabCfg charge = StoreTabCfgArray.Instance.GetCfgByfunctionId(ConstFunctionId.STORE_CHARGE); Debug.Log("charge[0]" + charge.subTabArr[0][0]); Debug.Log("charge[0]" + charge.subTabArr[0][1]); Debug.Log("charge[0]" + charge.subTabArr[0][2]); Debug.Log("charge[1]" + charge.subTabArr[1][0]); Debug.Log("charge[1]" + charge.subTabArr[1][1]); Debug.Log("charge[1]" + charge.subTabArr[1][2]); StoreTabCfg arenaTab = StoreTabCfgArray.Instance.GetCfgByfunctionId(ConstFunctionId.STORE_ARENA); _arenaSubTab.Add(new List() { arenaTab.subTabArr[0][0], arenaTab.subTabArr[0][1], arenaTab.subTabArr[0][2] }); for (int i = ArenaDataManager.Instance.SeasonId; i > 0; i--) { _arenaSubTab.Add(new List() { string.Format("第{0}赛季", i), i.ToString(), "StoreArenaView" }); } _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("sc_beijing"); _ui.m_btnBack.onClick.Add(OnClickBtnBack); _ui.m_comTab.m_c1.onChanged.Add(OnTabChange); _ui.m_listSubTab.itemRenderer = RenderListSubTabItem; _ui.m_listSubTab.onClickItem.Add(OnListSubTabClick); // _ui.m_listSubTab.selectionController.onChanged.Add(OnListSubTabClick); } protected override void AddEventListener() { base.AddEventListener(); } protected override void OnShown() { base.OnShown(); //this.viewData[functionId][subTabIndex] _curTabIndex = this.viewData == null ? ConstStoreTabId.STORE_CHARGE : (int)(this.viewData as object[])[0]; // StoreTabCfg tabCfg = StoreTabCfgArray.Instance.GetCfg(tabIndex); // _curTabIndex = tabCfg == null ? 1 : tabCfg.index; _ui.m_comTab.m_c1.selectedIndex = _curTabIndex; _ui.m_comTab.target.scrollPane.SetPercX((float)(_curTabIndex - 1) / (float)StoreTabCfgArray.Instance.dataArray.Length, false); _curSubTabIndex = this.viewData == null ? 0 : (int)(this.viewData as object[])[1]; if (_ui.m_listSubTab.numItems > _curSubTabIndex) { _ui.m_listSubTab.selectedIndex = _curSubTabIndex; _ui.m_listSubTab.ScrollToView(_curSubTabIndex); OnListSubTabChange(_curSubTabIndex); } } protected override void OnHide() { base.OnHide(); _ui.m_comTab.m_c1.selectedIndex = 0; _ui.m_listSubTab.selectedIndex = 0; } protected override void RemoveEventListener() { base.RemoveEventListener(); } private void OnClickBtnBack() { ViewManager.Hide(_curViewName); ViewManager.GoBackFrom(typeof(StoreView).FullName); } private void OnTabChange() { StoreTabCfg tabCfg = StoreTabCfgArray.Instance.GetCfg(_ui.m_comTab.m_c1.selectedIndex); if (tabCfg == null) return; if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(tabCfg.functionId)) { _ui.m_comTab.m_c1.selectedIndex = _ui.m_comTab.m_c1.previsousIndex; } _curTabIndex = _ui.m_comTab.m_c1.selectedIndex; if (tabCfg.functionId == ConstFunctionId.STORE_ARENA) { _ui.m_listSubTab.numItems = _arenaSubTab.Count; } else { _ui.m_listSubTab.numItems = tabCfg.subTabArr.Length; } _ui.m_listSubTab.selectedIndex = 0; _curSubTabIndex = 0; OnListSubTabChange(_curSubTabIndex); } private void RenderListSubTabItem(int index, GObject obj) { GButton item = obj.asButton; StoreTabCfg tabCfg = StoreTabCfgArray.Instance.GetCfg(_curTabIndex); int menu2 = 0; if (tabCfg.functionId == ConstFunctionId.STORE_ARENA) { item.title = _arenaSubTab[index][0]; menu2 = int.Parse(_arenaSubTab[index][1]); } else { item.title = tabCfg.subTabArr[index][0]; menu2 = int.Parse(tabCfg.subTabArr[index][1]); } item.data = index; if (menu2 == ConstStoreSubId.STORE_CHARGE_ADDUP) { RedDotController.Instance.SetComRedDot(_ui.m_comTab.m_btn0.target, RedDotDataManager.Instance.GetChargeAddUpReward()); } } private void OnListSubTabClick(EventContext context) { GObject obj = context.data as GObject; int index = (int)obj.data; if (index < 0) return; OnListSubTabChange(index); } private void OnListSubTabChange(int index) { StoreTabCfg tabCfg = StoreTabCfgArray.Instance.GetCfg(_curTabIndex); string viewName = ""; int menu2 = 0; if (tabCfg.functionId == ConstFunctionId.STORE_ARENA) { menu2 = int.Parse(_arenaSubTab[index][1]); viewName = _arenaSubTab[index][2]; } else { menu2 = int.Parse(tabCfg.subTabArr[index][1]); viewName = tabCfg.subTabArr[index][2]; } if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(viewName)) { _ui.m_listSubTab.selectedIndex = _curSubTabIndex; return; } ViewManager.Hide(_curViewName); if (!string.IsNullOrEmpty(viewName) && viewName != "“”") { ViewManager.Show("GFGGame." + viewName, menu2); } _curSubTabIndex = index; _curViewName = "GFGGame." + viewName; } private void UpdateRedDot() { RedDotController.Instance.SetComRedDot(_ui.m_comTab.m_btn0.target, RedDotDataManager.Instance.GetChargeAddUpReward()); } } }