2024-12-23 18:14:25 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2025-04-24 14:54:32 +08:00
|
|
|
|
using System;
|
2025-04-09 13:59:32 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-12-14 18:27:59 +08:00
|
|
|
|
using TMPro;
|
2024-12-23 18:14:25 +08:00
|
|
|
|
using UnityEngine;
|
2025-04-24 14:54:32 +08:00
|
|
|
|
using static LYTWebGLHelper;
|
2024-12-14 18:27:59 +08:00
|
|
|
|
|
|
|
|
|
|
namespace QFramework.Example
|
|
|
|
|
|
{
|
|
|
|
|
|
public class UIScoreData : UIPanelData
|
|
|
|
|
|
{
|
2025-03-26 09:48:17 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// ֻ<><D6BB>ʾ<EFBFBD><CABE>ǰģ<C7B0><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool onlyCurModule = false;
|
2024-12-14 18:27:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
public partial class UIScore : UIPanel
|
|
|
|
|
|
{
|
|
|
|
|
|
protected override void OnInit(IUIData uiData = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
mData = uiData as UIScoreData ?? new UIScoreData();
|
2025-01-09 09:43:15 +08:00
|
|
|
|
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
|
2024-12-14 18:27:59 +08:00
|
|
|
|
DownLoad.onClick.AddListener(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(InputName.text) || string.IsNullOrEmpty(InputId.text))
|
|
|
|
|
|
{
|
2025-03-01 12:52:39 +08:00
|
|
|
|
UITipWindowData data = new UITipWindowData();
|
|
|
|
|
|
data.txt = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>Ϊ<EFBFBD><CEAA>";
|
|
|
|
|
|
data.btns.Add(new UITipWindowData.ItemData() { txt = "ȷ<><C8B7>" });
|
|
|
|
|
|
UIKit.OpenPanelAsync<UITipWindow>(canvasLevel: UILevel.PopUI, uiData: data).ToAction().Start(this);
|
2024-12-14 18:27:59 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-12-23 18:14:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-02-27 19:15:03 +08:00
|
|
|
|
|
|
|
|
|
|
#if UNITY_WEBGL
|
2024-12-23 18:14:25 +08:00
|
|
|
|
ResLoader loader = ResLoader.Allocate();
|
|
|
|
|
|
loader.Add2Load(Global.reportDemoPath.ToLocalBytesResName(), (success, res) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (success)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] bytes = res.As<LocalBytesRes>().bytes;
|
2025-02-27 19:15:03 +08:00
|
|
|
|
WebGLDownLoadFile.Instance.DownloadDocx(bytes, GetScoreDataJson());
|
|
|
|
|
|
|
2024-12-23 18:14:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
loader.LoadAsync();
|
2025-02-27 19:15:03 +08:00
|
|
|
|
#elif UNITY_STANDALONE_WIN
|
2025-02-28 19:22:44 +08:00
|
|
|
|
DownLoad.interactable = false;
|
2025-03-06 13:28:21 +08:00
|
|
|
|
AsposeHelper.Writer(GetScoreDataJson(), () =>
|
2025-02-28 19:22:44 +08:00
|
|
|
|
{
|
|
|
|
|
|
DownLoad.interactable = true;
|
|
|
|
|
|
});
|
2025-02-27 19:15:03 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2024-12-23 18:14:25 +08:00
|
|
|
|
|
2024-12-14 18:27:59 +08:00
|
|
|
|
});
|
|
|
|
|
|
Confirm.onClick.AddListener(Hide);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-27 19:15:03 +08:00
|
|
|
|
public string GetScoreDataJson()
|
|
|
|
|
|
{
|
2025-04-21 09:59:18 +08:00
|
|
|
|
return ScoreController.Instance.GetModuleDictJson(InputName.text);
|
2025-02-27 19:15:03 +08:00
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnOpen(IUIData uiData = null)
|
|
|
|
|
|
{
|
2025-03-26 09:48:17 +08:00
|
|
|
|
mData = uiData as UIScoreData ?? new UIScoreData();
|
2024-12-14 18:27:59 +08:00
|
|
|
|
|
|
|
|
|
|
Content.RemoveAllChildren();
|
2025-01-19 11:20:01 +08:00
|
|
|
|
|
2024-12-14 18:27:59 +08:00
|
|
|
|
float sum = 0;
|
|
|
|
|
|
float score = 0;
|
2025-03-26 09:48:17 +08:00
|
|
|
|
|
|
|
|
|
|
bool onlyCur = false;
|
|
|
|
|
|
if (uiData == null)
|
2024-12-14 18:27:59 +08:00
|
|
|
|
{
|
2025-03-26 09:48:17 +08:00
|
|
|
|
if (bool.TryParse(Global.Instance.curModule.OnlyCurScore, out onlyCur) == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
onlyCur = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
onlyCur = mData.onlyCurModule;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-24 14:54:32 +08:00
|
|
|
|
|
|
|
|
|
|
List<Expstepvtwolist> datas = new List<Expstepvtwolist>();
|
|
|
|
|
|
int seq = 0;
|
2025-03-26 09:48:17 +08:00
|
|
|
|
if (onlyCur)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in ScoreController.Instance.GetCurScoreData())
|
2025-01-19 11:20:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
GameObject obj = GameObject.Instantiate(ItemPrefab.gameObject, Content);
|
|
|
|
|
|
obj.transform.Find("Step").GetComponent<TextMeshProUGUI>().text = item.Value.step;
|
|
|
|
|
|
obj.transform.Find("Name").GetComponent<TextMeshProUGUI>().text = item.Value.name;
|
|
|
|
|
|
obj.transform.Find("Sum").GetComponent<TextMeshProUGUI>().text = item.Value.sum;
|
|
|
|
|
|
obj.transform.Find("Score").GetComponent<TextMeshProUGUI>().text = item.Value.value.ToString();
|
|
|
|
|
|
sum += float.Parse(item.Value.sum);
|
|
|
|
|
|
score += item.Value.value;
|
2025-04-24 14:54:32 +08:00
|
|
|
|
datas.Add(new Expstepvtwolist()
|
|
|
|
|
|
{
|
|
|
|
|
|
ExpStepName = item.Value.step + item.Value.name,
|
|
|
|
|
|
maxScore = int.Parse(item.Value.sum),
|
|
|
|
|
|
score = (int)item.Value.value,
|
|
|
|
|
|
startTime = item.Value.time,
|
|
|
|
|
|
endTime = item.Value.time,
|
|
|
|
|
|
seq = seq,
|
|
|
|
|
|
});
|
|
|
|
|
|
seq++;
|
2025-01-19 11:20:01 +08:00
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
}
|
2025-03-26 09:48:17 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var moduleDict in ScoreController.Instance.moduleDict)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in moduleDict.Value.scoreDict)
|
|
|
|
|
|
{
|
|
|
|
|
|
GameObject obj = GameObject.Instantiate(ItemPrefab.gameObject, Content);
|
|
|
|
|
|
obj.transform.Find("Step").GetComponent<TextMeshProUGUI>().text = item.Value.step;
|
|
|
|
|
|
obj.transform.Find("Name").GetComponent<TextMeshProUGUI>().text = item.Value.name;
|
|
|
|
|
|
obj.transform.Find("Sum").GetComponent<TextMeshProUGUI>().text = item.Value.sum;
|
|
|
|
|
|
obj.transform.Find("Score").GetComponent<TextMeshProUGUI>().text = item.Value.value.ToString();
|
|
|
|
|
|
sum += float.Parse(item.Value.sum);
|
|
|
|
|
|
score += item.Value.value;
|
2025-04-24 14:54:32 +08:00
|
|
|
|
datas.Add(new Expstepvtwolist()
|
|
|
|
|
|
{
|
|
|
|
|
|
ExpStepName = item.Value.step + item.Value.name,
|
|
|
|
|
|
maxScore = int.Parse(item.Value.sum),
|
|
|
|
|
|
score = (int)item.Value.value,
|
|
|
|
|
|
startTime = item.Value.time,
|
|
|
|
|
|
endTime = item.Value.time,
|
|
|
|
|
|
seq = seq
|
|
|
|
|
|
});
|
|
|
|
|
|
seq++;
|
2025-03-26 09:48:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-19 11:20:01 +08:00
|
|
|
|
|
2025-01-11 13:52:16 +08:00
|
|
|
|
this.Score.text = score.ToString();
|
|
|
|
|
|
this.Sum.text = sum.ToString();
|
2025-01-19 11:20:01 +08:00
|
|
|
|
|
2025-04-24 14:54:32 +08:00
|
|
|
|
#if UNITY_WEBGL
|
|
|
|
|
|
|
|
|
|
|
|
LYTWebGLHelper.Instance.UpLoadData((int)score, datas.ToArray());
|
|
|
|
|
|
#endif
|
2024-12-14 18:27:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnShow()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnHide()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnClose()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|