/**************************************************************************** * 2024.5 LXD ****************************************************************************/ using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using QFramework; using Google.Protobuf.WellKnownTypes; using Sirenix.OdinInspector; using I2.Loc; using ChivaXR; namespace QFramework { public partial class FistStepItem : UIComponent { List m_SecondStepItems = new List(); public Color m_Color; [LabelText("常态")] public Sprite m_NormalSprite; [LabelText("选中")] public Sprite m_SeLectSprite; /// /// 展开列表 /// private bool m_Expand = false; private string NO_BREAKING_SPACE = "\u00A0"; private void Start() { //if (OperateSetting.Instance.m_CurrentOperationMode == OperationMode.Learn) //{ // ExpandBtn.onClick.AddListener(OnExpandBtnClick); //} ExpandBtn.onClick.AddListener(OnExpandBtnClick); } private void OnExpandBtnClick() { SetState(!m_Expand); } public bool OpenSecondStepItem(int id) { bool tmpResult = false; foreach (var item in m_SecondStepItems) { item.gameObject.SetActive(!tmpResult); if (int.Parse(item.m_StepMsgInfo.id) == id) { tmpResult = true; item.OnSelect(); } else { item.OnUnSelect(); } } return tmpResult; } public void SetSecondStepItemSelectState(int id) { bool result = false; foreach (var item in m_SecondStepItems) { if (int.Parse(item.m_StepMsgInfo.id) == id) { item.OnSelect(); result = true; } else { item.OnUnSelect(); } } if (result) { Select.sprite = m_SeLectSprite; } else { Select.sprite = m_NormalSprite; } } /// /// 设置展开状态 /// /// public void SetState(bool state) { m_Expand = state; UnExpand.gameObject.SetActive(!state); Expand.gameObject.SetActive(state); if (OperateSetting.Instance.m_CurrentOperationMode != OperationMode.Learn && m_Expand == true) { //练考模式只展开到当前步骤 ShowCurrentSecondStepItem(ProcessManagement.Instance.currentStepID); } else { ShowAllSecondStepItems(m_Expand); } } public void GenerateSecondStepItemList(int index, string msg, List stepMsgInfos) { Num.text = index.ToString(); //Message.text = msg; OperateStep operateStep = UIKit.GetPanel().OperateStep; int tmpIndex = 1; foreach (var info in stepMsgInfos) { GameObject tmpObj = Instantiate(operateStep.SecondStepItem.gameObject, operateStep.Content); SecondStepItem tmpSecondStepItem = tmpObj.GetComponent(); tmpSecondStepItem.InitData(index, tmpIndex, info); m_SecondStepItems.Add(tmpSecondStepItem); tmpObj.SetActive(false); tmpIndex++; } LocalizedString realText = m_SecondStepItems[0].m_StepMsgInfo.id + "parentStepName"; Message.text = realText; } public void ShowAllSecondStepItems(bool state) { foreach (var item in m_SecondStepItems) { item.gameObject.SetActive(state); } } public void ShowCurrentSecondStepItem(int step) { foreach (var item in m_SecondStepItems) { if (int.Parse(item.m_StepMsgInfo.id) <= step) { item.gameObject.SetActive(true); } else { item.gameObject.SetActive(false); } } } protected override void OnBeforeDestroy() { } #region 多语言 public void RefrushLocalization() { LocalizedString realText = m_SecondStepItems[0].m_StepMsgInfo.id + "parentStepName"; Message.text = realText; } void OnEnable() { LocalizationManager.OnLocalizeEvent += LocalizationManager_OnLocalizeEvent; LocalizationManager_OnLocalizeEvent(); } void OnDisEnable() { LocalizationManager.OnLocalizeEvent -= LocalizationManager_OnLocalizeEvent; } private void LocalizationManager_OnLocalizeEvent() { if (LocalizationConfig.localization) { RefrushLocalization(); } } #endregion } }