using System.Collections; using System.Collections.Generic; using cfg.ActorCfg; using TMPro; using UnityEngine; using UnityEngine.UI; using UnityEngine.UIElements; using Button = UnityEngine.UI.Button; using Image = UnityEngine.UI.Image; using Toggle = UnityEngine.UI.Toggle; using ScrollView = PhxhSDK.PhxhScrollView; using Framework; using Gameplay; public class UI_MissionPannelController : UIWindow { //UI GameObj ///Auto Gen Start/// public Button Button_Back; public TMP_Text Text_Back; public Button Button_Home; public Image Image_MissionBG; public Image Image_TopBtnBG; public Toggle Toggle_Tab0; public TMP_Text Text_Day; public TMP_Text Text_Tab0; public Toggle Toggle_Tab1; public TMP_Text Text_Week; public TMP_Text Text_Tab1; public Toggle Toggle_Tab2; public TMP_Text Text_Achieve; public TMP_Text Text_Tab2; public Toggle Toggle_Tab3; public TMP_Text Text_Activity; public TMP_Text Text_Tab3; public Image Image_NotMission; public TMP_Text Text_NotMission; public Button Button_GetAll; public TMP_Text Text_GetAll; public Button Button_GetAllGray; public TMP_Text Text_GetAllGray; public Image Image_Left; ///Auto Gen End/// private int _curSelectTab; private TaskMap _curTaskMap; private List _tabList; private List _tabShowTxt; private ToggleGroup _toggleGroup; private ScrollView _scrollView; private enum Page { Daily, Weekend, Achievement, Activity } // Use this for initialization public override void OnAwake() { //bind UI GameObj UI_MissionPannelBinder.GetComponents(this); _tabList = new List(); _toggleGroup = Toggle_Tab0.GetComponent(); for (int i = 0; i < 4; i++) { var toggle = GetComponent("Image_MissionBG/Image_TopBtnBG/Toggle_Tab" + i); var txtShow = GetComponent("Image_MissionBG/Image_TopBtnBG/Toggle_Tab" + i + "/Text_Tab" + i); _tabList.Add(toggle); _tabShowTxt.Add(txtShow); toggle.onValueChanged.AddListener(_OnToggleStateChange); } } //invoke when open window protected override void OnOpenWindow(object data = null) { } //invoke when reload window protected override void OnReloadWindow(object data = null) { } //invoke when close window protected override void OnCloseWindow() { } private void _RefreshTaskMap() { var taskDic = TaskManager.Instance.TaskDic; switch (_curSelectTab) { case ((int)Page.Daily): { _curTaskMap = taskDic[TaskType.Daily]; break; } case ((int)Page.Weekend): { _curTaskMap = taskDic[TaskType.Weekly]; break; } case ((int)Page.Achievement): { _curTaskMap = taskDic[TaskType.Normal]; break; } case ((int)Page.Activity): { _curTaskMap = taskDic[TaskType.Activity]; break; } } } private void _RefreshList() { } private void _RefreshPage(int page) { _curSelectTab = page; _RefreshTaskMap(); } private void _CreateScrollView() { var content = FindObj("PhxhScrollView/Viewport/Content"); if (content) { CommonUtils.DestoryAllChildGameObject(content); } _SetScrollView(); } private void _SetScrollView() { _scrollView.SetUpdateFunc(_RefreshItem); _scrollView.SetItemCountFunc(GetCountFunc); _scrollView.UpdateData(false); _scrollView.SetButton(SetButtonBind); } private void _RefreshScrollView() { if (_curTaskMap.Count() > 0) { if (!_scrollView.gameObject.activeInHierarchy) { _scrollView.gameObject.SetActive(true); } _scrollView.UpdateData(true); return; } if (_scrollView.gameObject.activeInHierarchy) { _scrollView.gameObject.SetActive(false); } } private void _RefreshItem(int index, Transform item) { } private int GetCountFunc() { return 1; } private void SetButtonBind(GameObject obj) { } private void _OnToggleStateChange(bool state) { _OnToggleIsOnChange(); } private void _OnToggleIsOnChange() { for (int i = 0; i < _tabList.Count; i++) { var toggle = _tabList[i]; if (toggle.isOn) { _RefreshPage(i); } } } }