/**************************************************************************** * 2023.10 DESKTOP-DL7CJI0 ****************************************************************************/ using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using QFramework; using ChivaXR; using DG.Tweening; using System.Collections; using UnityEngine.Tilemaps; using I2.Loc; namespace QFramework { public enum BtnState { normal, highter, select } public partial class OperateStep : UIElement { private List itemList = new List(); private List firstStepItems = new List(); private void Awake() { HelpBtn.Button.onClick.AddListener(OnHelpBtnClick); HelpBtn.isToggle = true; ToolLibraryBtn.Button.onClick.AddListener(OnToolLibraryBtnClick); AutoPlayBtn.Button.onClick.AddListener(OnAutoPlayBtnClick); AutoPlayBtn.isToggle = true; EndExam.Button.onClick.AddListener(OnEndExamBtnClick); OperateLogBtn.onClick.AddListener(OnOperateLogBtnClick); PlayBtn.onClick.AddListener(OnPlayBtnClick); PauseBtn.onClick.AddListener(OnPauseBtnClick); ExpandBtn.onClick.AddListener(OnExpandBtnClick); ScrollViewCtrl.gameObject.SetActive(false); } public void StartOperation() { ScrollViewCtrl.gameObject.SetActive(true); } /// /// 播放按钮点击 /// private void OnPlayBtnClick() { Time.timeScale = 0; AudioHelper.AudioPause(); GameObject tmpMiniModelView = GameObject.Find("MiniModelView/CreatModel"); tmpMiniModelView.GetComponentInChildren()?.Pause(); PauseBtn.gameObject.SetActive(true); PlayBtn.gameObject.SetActive(false); RoamCameraController.Instance.SetCameraMoveState(true); } /// /// 暂停按钮点击 /// private void OnPauseBtnClick() { Time.timeScale = 1; AudioHelper.AudioPlay(); PlayBtn.gameObject.SetActive(true); PauseBtn.gameObject.SetActive(false); GameObject tmpMiniModelView = GameObject.Find("MiniModelView/CreatModel"); tmpMiniModelView.GetComponentInChildren()?.Play(); RoamCameraController.Instance.SetCameraMoveState(false); } private void OnHelpBtnClick() { if (!OperateSetting.Instance.ToolPackUILogic.GetHint()) { HelpBtn.SetBtnState(BtnState.select); OperateSetting.Instance.ToolPackUILogic.SetHint(true); } else { HelpBtn.SetBtnState(BtnState.normal); OperateSetting.Instance.ToolPackUILogic.SetHint(false); } } public void OnAutoPlayBtnClick() { if (ProcessManagement.Instance.autoEnterNextProcess) { AutoPlayBtn.SetBtnState(BtnState.normal); ProcessManagement.Instance.autoEnterNextProcess = false; ProcessManagement.Instance.delayTime = 0; } else { AutoPlayBtn.SetBtnState(BtnState.select); ProcessManagement.Instance.autoEnterNextProcess = true; //如果当前步骤已完成,点击自动播放默认进入下一步 if (ProcessManagement.Instance.GetCurrentProcess().finished) { ProcessManagement.Instance.EnterNextProcess(); } ProcessManagement.Instance.delayTime = 1; } } public void OnEndExamBtnClick() { UIKit.GetPanel().SubmitResult.gameObject.SetActive(true); } private void OnToolLibraryBtnClick() { ToolLibraryForm tmpToolLibraryForm = UIKit.GetPanel(); if (tmpToolLibraryForm == null) { UIKit.OpenPanel(UILevel.PopUI); } else if (tmpToolLibraryForm != null && !tmpToolLibraryForm.isActiveAndEnabled) { UIKit.ShowPanel(); } } public void ShowToolLibraryHighter(bool state) { } private bool isLibraryEnter; public void SetTitle(string str) { Title_LowestLayer.text = Title_MiddleLayer.text = Title_TopLayer.text = str; } /// /// 将所有列表初始化出来 /// public void GenerateFirstStepItemList(Dictionary> dicStepMsgInfos) { int tmpNum = 1; foreach (var item in dicStepMsgInfos) { var tempItem = Instantiate(FistStepItem.gameObject, Content); FistStepItem tmpStepItem = tempItem.GetComponent(); tmpStepItem.GenerateSecondStepItemList(tmpNum, item.Key, item.Value); firstStepItems.Add(tmpStepItem); tempItem.SetActive(false); tmpNum++; } } /// /// 展开所有一级列表 /// public void ExpandAllFirstStepItem() { foreach (var item in firstStepItems) { item.gameObject.SetActive(true); item.SetState(true); } } public void InitList(Dictionary> dic) { if (dic.Count > 0) { foreach (var key in dic.Keys) { var tempItem = Instantiate(FistStepItem.gameObject, Content); tempItem.SetActive(false); //StepItem stepItem = tempItem.GetComponent(); //stepItem.SetItemInfo(key, dic[key][0].ToString()); itemList.Add(tempItem); } } else { Debug.LogError("树形步骤表为空!!!"); } } /// /// 练习模式 /// /// public void ShowSecondStepItemByStepId(int stepID) { bool tmpResul = false; foreach (var item in firstStepItems) { if (!tmpResul) { item.gameObject.SetActive(true); item.SetState(true); tmpResul = item.OpenSecondStepItem(stepID); if (tmpResul) item.Select.gameObject.SetActive(true); else item.Select.gameObject.SetActive(false); } else { item.SetState(false); item.gameObject.SetActive(false); } } Canvas.ForceUpdateCanvases(); ScrollView.verticalNormalizedPosition = 0; if (Content.transform.GetComponent().sizeDelta.y >= 929f) { BottomImage.gameObject.SetActive(false); } else { BottomImage.gameObject.SetActive(true); } } /// /// 学习模式 /// /// public void SetSecondStepItemSelectByStepId(int stepID) { foreach (var item in firstStepItems) { item.SetSecondStepItemSelectState(stepID); } } /// /// 刷新列表 /// /// public void RefreshList(int stepID) { Debug.LogError(stepID); if (itemList.Count > 0 && stepID < itemList.Count) { for (int i = 0; i < itemList.Count; i++) { itemList[i].SetActive(false); if (i <= stepID) { itemList[i].SetActive(true); } } } Canvas.ForceUpdateCanvases(); ScrollView.verticalNormalizedPosition = 0; } bool expande = false; /// /// 菜单展开 /// public void OnExpandBtnClick() { if (!expande) { ScrollViewCtrl.transform.DOMove(ScrollViewCtrlExpandTarget.transform.position, 1f).SetUpdate(true); ExpandBtn.transform.DOScaleX(-1, 1).SetUpdate(true); } else { //SetUpdate(ture)设置这个Tween不受Time.scale影响 ScrollViewCtrl.transform.DOMove(ScrollViewCtrlUnExpandTarget.transform.position, 1f).SetUpdate(true); ExpandBtn.transform.DOScaleX(1, 1).SetUpdate(true); } expande = !expande; } /// /// 操作记录按钮点击 /// private void OnOperateLogBtnClick() { LogSystemForm logSystemForm = UIKit.GetPanel(); if (logSystemForm == null) { logSystemForm = UIKit.OpenPanel(); } if (logSystemForm.ScrollView.gameObject.activeSelf) { logSystemForm.SetLogState(false); } else { logSystemForm.SetLogState(true); } } protected override void OnBeforeDestroy() { } } }