2024-12-14 18:27:59 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
using QFramework;
|
|
|
|
|
|
using XMLTool;
|
|
|
|
|
|
using UnityEditor.Rendering;
|
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using static OperationController;
|
|
|
|
|
|
using System;
|
2025-02-07 14:25:12 +08:00
|
|
|
|
using UnityEditor.Hardware;
|
2024-12-14 18:27:59 +08:00
|
|
|
|
namespace QFramework.Example
|
|
|
|
|
|
{
|
|
|
|
|
|
public class UIOperationListData : UIPanelData
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
public partial class UIOperationList : UIPanel
|
|
|
|
|
|
{
|
|
|
|
|
|
Operation op;
|
|
|
|
|
|
List<Button> btns = new List<Button>();
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnInit(IUIData uiData = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
mData = uiData as UIOperationListData ?? new UIOperationListData();
|
2025-02-08 17:27:06 +08:00
|
|
|
|
TypeEventSystem.Global.Register<OnOperationChanged>((arg) => Refresh()).UnRegisterWhenGameObjectDestroyed(gameObject);
|
2025-02-07 13:35:33 +08:00
|
|
|
|
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
|
2024-12-14 18:27:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnStepChanged(StepStatusOnChange change)
|
|
|
|
|
|
{
|
|
|
|
|
|
ResetBtnStatus(change.curIndex, change.status);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ResetBtnStatus(int index, OperationController.StepStatus status)
|
|
|
|
|
|
{
|
|
|
|
|
|
Button btn = btns[index];
|
|
|
|
|
|
bool isParent = btn.transform.Find("StepLabel") == null;
|
|
|
|
|
|
Color highColor = new Color(25f / 255f, 224f / 255f, 224f / 255f);
|
|
|
|
|
|
if (isParent)
|
|
|
|
|
|
{
|
|
|
|
|
|
var name = btn.transform.Find("Name").GetComponent<TextMeshProUGUI>();
|
|
|
|
|
|
var arrow = btn.transform.Find("Arrow").transform;
|
|
|
|
|
|
Image highIcon = btn.transform.Find("HighIcon").GetComponent<Image>();
|
|
|
|
|
|
switch (status)
|
|
|
|
|
|
{
|
|
|
|
|
|
case StepStatus.NoStart:
|
|
|
|
|
|
name.color = Color.white;
|
|
|
|
|
|
highIcon.color = Color.white;
|
|
|
|
|
|
arrow.eulerAngles = new Vector3(0, 0, 90);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case StepStatus.Start:
|
|
|
|
|
|
case StepStatus.Finished:
|
|
|
|
|
|
name.color = highColor;
|
|
|
|
|
|
highIcon.color = highColor;
|
|
|
|
|
|
arrow.eulerAngles = Vector3.zero;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var stepLabel = btn.transform.Find("StepLabel").GetComponent<TextMeshProUGUI>();
|
|
|
|
|
|
switch (status)
|
|
|
|
|
|
{
|
|
|
|
|
|
case StepStatus.NoStart:
|
|
|
|
|
|
stepLabel.color = Color.white;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case StepStatus.Start:
|
|
|
|
|
|
stepLabel.color = highColor;
|
|
|
|
|
|
btn.transform.parent.gameObject.SetActive(true);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case StepStatus.Finished:
|
2024-12-31 16:41:03 +08:00
|
|
|
|
// TODO<44><4F>ʵ<EFBFBD>ַ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ż<EFBFBD>
|
2025-01-09 09:43:15 +08:00
|
|
|
|
if (Global.Instance.curModule.type == "Exam")
|
2024-12-31 16:41:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
stepLabel.color = highColor;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
stepLabel.color = Color.white;
|
|
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnOpen(IUIData uiData = null)
|
|
|
|
|
|
{
|
2025-01-09 10:08:22 +08:00
|
|
|
|
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(this);
|
2025-02-08 17:27:06 +08:00
|
|
|
|
Refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Refresh()
|
|
|
|
|
|
{
|
2025-01-09 10:08:22 +08:00
|
|
|
|
btns.Clear();
|
2024-12-14 18:27:59 +08:00
|
|
|
|
op = OperationController.Instance.operation;
|
|
|
|
|
|
StepContent.RemoveAllChildren();
|
|
|
|
|
|
foreach (var item in op.Steps)
|
|
|
|
|
|
{
|
2025-02-07 14:25:12 +08:00
|
|
|
|
|
|
|
|
|
|
if (item.SubSteps != null && item.SubSteps.Count > 0)
|
2024-12-14 18:27:59 +08:00
|
|
|
|
{
|
2025-02-07 14:25:12 +08:00
|
|
|
|
GameObject obj = GameObject.Instantiate(Step.gameObject, StepContent);
|
|
|
|
|
|
Transform title = obj.transform.Find("Title");
|
|
|
|
|
|
var name = title.Find("Name").GetComponent<TextMeshProUGUI>();
|
|
|
|
|
|
name.text = item.Name;
|
|
|
|
|
|
Image highIcon = title.Find("HighIcon").GetComponent<Image>();
|
|
|
|
|
|
Color highColor = new Color(25f / 255f, 224f / 255f, 224f / 255f);
|
|
|
|
|
|
GameObject subContent = obj.transform.Find("SubContent").gameObject;
|
|
|
|
|
|
Button btn = title.GetComponent<Button>();
|
|
|
|
|
|
subContent.gameObject.SetActive(false);
|
|
|
|
|
|
btn.name = btns.Count.ToString();
|
|
|
|
|
|
btns.Add(btn);
|
|
|
|
|
|
btn.onClick.AddListener(() =>
|
2025-02-07 13:35:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
subContent.SetActive(!subContent.activeSelf);
|
2025-02-07 14:25:12 +08:00
|
|
|
|
if (op.freeStep)
|
2024-12-20 10:31:29 +08:00
|
|
|
|
{
|
2025-02-07 14:25:12 +08:00
|
|
|
|
if (highIcon.color != highColor)
|
|
|
|
|
|
{
|
|
|
|
|
|
TypeEventSystem.Global.Send<StepExecute>(new StepExecute() { index = int.Parse(btn.name) });
|
|
|
|
|
|
}
|
2024-12-20 10:31:29 +08:00
|
|
|
|
}
|
2025-02-07 14:25:12 +08:00
|
|
|
|
});
|
2024-12-14 18:27:59 +08:00
|
|
|
|
foreach (var sub in item.SubSteps)
|
|
|
|
|
|
{
|
2025-02-07 14:25:12 +08:00
|
|
|
|
StepItemFactory(subContent.transform, sub.Name);
|
2024-12-14 18:27:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-07 14:25:12 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
StepItemFactory(StepContent, item.Name);
|
|
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-08 17:27:06 +08:00
|
|
|
|
|
2025-02-07 14:25:12 +08:00
|
|
|
|
public void StepItemFactory(Transform content, string txt)
|
|
|
|
|
|
{
|
|
|
|
|
|
GameObject subObj = GameObject.Instantiate(SubStep.gameObject, content.transform);
|
|
|
|
|
|
var stepLabel = subObj.transform.Find("StepLabel").GetComponent<TextMeshProUGUI>();
|
|
|
|
|
|
stepLabel.text = txt;
|
|
|
|
|
|
Button subBtn = subObj.GetComponent<Button>();
|
|
|
|
|
|
subBtn.name = btns.Count.ToString();
|
|
|
|
|
|
btns.Add(subBtn);
|
|
|
|
|
|
subBtn.onClick.AddListener(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (op.freeStep)
|
|
|
|
|
|
{
|
|
|
|
|
|
subBtn.transform.parent.gameObject.SetActive(true);
|
|
|
|
|
|
TypeEventSystem.Global.Send<StepExecute>(new StepExecute() { index = int.Parse(subBtn.name) });
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
|
|
|
|
|
|
protected override void OnShow()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
protected override void OnClose()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|