SecondStepItem.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /****************************************************************************
  2. * 2024.5 LXD
  3. ****************************************************************************/
  4. using UnityEngine;
  5. using ChivaXR;
  6. using Sirenix.OdinInspector;
  7. using I2.Loc;
  8. namespace QFramework
  9. {
  10. public partial class SecondStepItem : UIComponent
  11. {
  12. public OperationStepDataInfo m_StepMsgInfo;
  13. [LabelText("选中字体颜色")]
  14. public Color m_SelectClolor;
  15. [LabelText("选中字体")]
  16. public Font m_SelectFont;
  17. [LabelText("常态颜色")]
  18. public Color m_NormalClolor;
  19. [LabelText("常态字体")]
  20. public Font m_NormalFont;
  21. [LabelText("划入颜色")]
  22. public Color m_HoverClolor;
  23. [LabelText("划入字体")]
  24. public Font m_HoverFont;
  25. private string NO_BREAKING_SPACE = "\u00A0";
  26. private int m_ParentIndex;
  27. private int m_Index;
  28. private void Start()
  29. {
  30. if (OperateSetting.Instance.m_CurrentOperationMode == OperationMode.Learn)
  31. {
  32. ClickBtn.onClick.AddListener(OnClickBtnClick);
  33. }
  34. }
  35. public void InitData(int parentIndex, int index, OperationStepDataInfo stepMsgInfo)
  36. {
  37. m_ParentIndex = parentIndex;
  38. m_Index = index;
  39. m_StepMsgInfo = stepMsgInfo;
  40. //Message.text = index.ToString("00") + "." + stepMsgInfo.stepName;
  41. LocalizedString message = m_StepMsgInfo.id + "stepName";
  42. Message.text = m_Index.ToString("00") + "." + message;
  43. if (OperateSetting.Instance.m_CurrentOperationMode == OperationMode.Exam)
  44. {
  45. Message.text = "???";
  46. }
  47. }
  48. private void OnClickBtnClick()
  49. {
  50. ProcessManagement.Instance.JumpProcessState(int.Parse(m_StepMsgInfo.id));
  51. ProcessManagement.Instance.ActiveCurrentProcess();
  52. }
  53. public void OnSelect()
  54. {
  55. SetBtnState(BtnState.select);
  56. UIKit.GetPanel<PC_OperatePanel>().UpdateTitleText(m_ParentIndex.ToString() + "." + m_Index.ToString() + " " + m_StepMsgInfo.stepName);
  57. Debug.Log(UIKit.GetPanel<PC_OperatePanel>().TitleText.text);
  58. #region 多语言
  59. if (LocalizationConfig.localization)
  60. {
  61. LocalizedString message = m_StepMsgInfo.id + "stepName";
  62. UIKit.GetPanel<PC_OperatePanel>().UpdateTitleText(m_ParentIndex.ToString() + "." + m_Index.ToString() + " " + message);
  63. }
  64. #endregion
  65. Debug.Log(this.gameObject.name + "Select" + UIKit.GetPanel<PC_OperatePanel>().TitleText.text);
  66. if (OperateSetting.Instance.m_CurrentOperationMode == OperationMode.Exam)
  67. {
  68. Message.text = "???";
  69. }
  70. }
  71. public void OnUnSelect()
  72. {
  73. SetBtnState(BtnState.normal);
  74. if (OperateSetting.Instance.m_CurrentOperationMode == OperationMode.Exam)
  75. {
  76. RefrushLocalization();
  77. }
  78. }
  79. public void OnPointEnter()
  80. {
  81. if (!SelectIcon.isActiveAndEnabled)
  82. {
  83. SetBtnState(BtnState.highter);
  84. }
  85. }
  86. public void OnPointExit()
  87. {
  88. if (!SelectIcon.isActiveAndEnabled)
  89. {
  90. SetBtnState(BtnState.normal);
  91. }
  92. }
  93. public void SetBtnState(BtnState state)
  94. {
  95. switch (state)
  96. {
  97. case BtnState.normal:
  98. Message.color = m_NormalClolor;
  99. Message.font = m_NormalFont;
  100. SelectIcon.gameObject.SetActive(false);
  101. NormalIcon.gameObject.SetActive(true);
  102. break;
  103. case BtnState.highter:
  104. Message.color = m_HoverClolor;
  105. Message.font = m_HoverFont;
  106. SelectIcon.gameObject.SetActive(false);
  107. NormalIcon.gameObject.SetActive(true);
  108. break;
  109. case BtnState.select:
  110. Message.color = m_SelectClolor;
  111. Message.font = m_SelectFont;
  112. SelectIcon.gameObject.SetActive(true);
  113. NormalIcon.gameObject.SetActive(false);
  114. break;
  115. }
  116. }
  117. protected override void OnBeforeDestroy()
  118. {
  119. }
  120. #region 多语言
  121. public void RefrushLocalization()
  122. {
  123. LocalizedString message = m_StepMsgInfo.id + "stepName";
  124. Message.text = m_Index.ToString("00") + "." + message;
  125. if (SelectIcon.isActiveAndEnabled)
  126. {
  127. UIKit.GetPanel<PC_OperatePanel>().UpdateTitleText(m_ParentIndex.ToString() + "." + m_Index.ToString() + " " + message);
  128. Debug.Log(this.gameObject.name + UIKit.GetPanel<PC_OperatePanel>().TitleText.text);
  129. if (OperateSetting.Instance.m_CurrentOperationMode == OperationMode.Exam)
  130. {
  131. Message.text = "???";
  132. }
  133. }
  134. }
  135. void OnEnable()
  136. {
  137. RefrushLocalization();
  138. LocalizationManager.OnLocalizeEvent += LocalizationManager_OnLocalizeEvent;
  139. }
  140. void OnDisEnable()
  141. {
  142. LocalizationManager.OnLocalizeEvent -= LocalizationManager_OnLocalizeEvent;
  143. }
  144. private void LocalizationManager_OnLocalizeEvent()
  145. {
  146. if (LocalizationConfig.localization)
  147. {
  148. RefrushLocalization();
  149. }
  150. }
  151. #endregion
  152. }
  153. }