123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- /****************************************************************************
- * 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<SecondStepItem> m_SecondStepItems = new List<SecondStepItem>();
- public Color m_Color;
- [LabelText("常态")]
- public Sprite m_NormalSprite;
- [LabelText("选中")]
- public Sprite m_SeLectSprite;
- /// <summary>
- /// 展开列表
- /// </summary>
- 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;
- }
- }
- /// <summary>
- /// 设置展开状态
- /// </summary>
- /// <param name="state"></param>
- 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<OperationStepDataInfo> stepMsgInfos)
- {
- Num.text = index.ToString();
- //Message.text = msg;
- OperateStep operateStep = UIKit.GetPanel<PC_OperatePanel>().OperateStep;
- int tmpIndex = 1;
- foreach (var info in stepMsgInfos)
- {
- GameObject tmpObj = Instantiate<GameObject>(operateStep.SecondStepItem.gameObject, operateStep.Content);
- SecondStepItem tmpSecondStepItem = tmpObj.GetComponent<SecondStepItem>();
- 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
- }
- }
|