unityzgy/Assets/Scripts/UIScripts/Teacher/RecordDetailPanel.cs
ayuan9957 a57981ea2e fix: 山地改名林地 + 想定深拷贝 + 翻译修复
- 山地→林地: 场景/AB/数据库/SAMap/本地化/旧想定XML全部改名
- 想定编辑: 深拷贝selectRecord防止引用污染, 设置地形下拉框匹配原文件
- 想定下发: 深拷贝后发送独立副本
- XmlHelper: FileStream改using, 新增字符串反序列化重载
- RecordDetailPanel: OnStart重新订阅LanguageChanged, 完整翻译标题/用时/视频/操作记录
- AppraiseWindowBase: OnLanguageChanged重新翻译标题+操作记录
- LocalizeOperateMsg: 旧消息回退Get()翻译
- 分组提示: ShowSetGroupError用Get()翻译, 新增4条分组错误翻译
- 学员端地形名: SetFormatted+DisplayName实时翻译
- 丘陵: 重新生成地图含道路材质, 重建AB
2026-07-31 17:58:41 +08:00

183 lines
6.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using XFramework;
/// <summary>
/// 历史界面弹出显示记录详情信息
/// </summary>
public class RecordDetailPanel : BasePanel
{
const string panelName = "Panel_RecordDeatail";
Text text_msg;//展示操作记录文字
Text text_Title;//记录标题
Text text_useTime;//录屏文件路径
Text text_videoPath;//录屏文件路径
Button button_playVideo;//播放录屏文件
OperaterRecording currentRecord;
public RecordDetailPanel() : base(new UIType(panelName))
{
}
//初始化界面引用和事件
protected override void InitEvent()
{
ActivePanel.FindChildTrans("Button_Close").GetComponent<Button>().onClick.AddListener(() => Pop());
text_msg = ActivePanel.FindChildTrans("Content_Text").GetComponent<Text>();
text_Title = ActivePanel.FindChildTrans("Text_title").GetComponent<Text>();
text_videoPath = ActivePanel.FindChildTrans("Text_videoPath").GetComponent<Text>();
text_useTime = ActivePanel.FindChildTrans("Text_useTime").GetComponent<Text>();
ActivePanel.FindChildTrans("Button_playVideo").gameObject.SetActive(false);
LocalizationManager.LanguageChanged += OnLanguageChanged;
}
//每次Push时重新订阅InitEvent只执行一次Pop后订阅会丢失
public override void OnStart()
{
base.OnStart();
LocalizationManager.LanguageChanged -= OnLanguageChanged;
LocalizationManager.LanguageChanged += OnLanguageChanged;
}
public override void OnDisable()
{
base.OnDisable();
LocalizationManager.LanguageChanged -= OnLanguageChanged;
}
private void OnLanguageChanged()
{
if (currentRecord == null) return;
// 重新翻译标题
LocalizationManager.SetFormatted(text_Title, "{0} {1}完成{2}科目:{3}", currentRecord.user, currentRecord.date, LocalizationManager.DisplayName(currentRecord.learnType), LocalizationManager.DisplayName(currentRecord.subName));
// 重新翻译用时
int totalSeconds;
if (int.TryParse(currentRecord.useTime, out totalSeconds))
{
int h = totalSeconds / 3600;
int m = (totalSeconds % 3600) / 60;
int s = totalSeconds % 60;
if (h > 0)
LocalizationManager.SetFormatted(text_useTime, "用时:{0}小时{1}分{2}秒", h, m, s);
else
LocalizationManager.SetFormatted(text_useTime, "用时:{0}分:{1}秒", m, s);
}
else
{
totalSeconds = LocalizationManager.ParseChineseDuration(currentRecord.useTime);
if (totalSeconds >= 0)
{
int h = totalSeconds / 3600;
int m = (totalSeconds % 3600) / 60;
int s = totalSeconds % 60;
if (h > 0)
LocalizationManager.SetFormatted(text_useTime, "用时:{0}小时{1}分{2}秒", h, m, s);
else
LocalizationManager.SetFormatted(text_useTime, "用时:{0}分:{1}秒", m, s);
}
else
{
LocalizationManager.SetFormatted(text_useTime, "用时:{0}", currentRecord.useTime);
}
}
// 重新翻译视频路径
if (!string.IsNullOrEmpty(currentRecord.videoPath))
{
if (File.Exists(currentRecord.videoPath))
LocalizationManager.SetFormatted(text_videoPath, "录屏视频:{0}", currentRecord.videoPath);
else
LocalizationManager.SetFormatted(text_videoPath, "录屏视频:{0}\r\n(视频文件已丢失,无法播放!)", currentRecord.videoPath);
}
else
{
text_videoPath.text = LocalizationManager.Get("录屏视频:无");
}
// 重新翻译操作记录
RebuildOperateMsg();
}
private void RebuildOperateMsg()
{
text_msg.text = "";
for (int i = 0; i < currentRecord.operaterMsg.Count; i++)
{
text_msg.text += $"{LocalizationManager.LocalizeOperateMsg(currentRecord.operaterMsg[i])}\r\n";
}
}
//根据数据初始化界面
public override void Change(object newData)
{
currentRecord = (OperaterRecording)newData;
OperaterRecording operaterRecording = currentRecord;
LocalizationManager.SetFormatted(text_Title, "{0} {1}完成{2}科目:{3}", operaterRecording.user, operaterRecording.date, LocalizationManager.DisplayName(operaterRecording.learnType), LocalizationManager.DisplayName(operaterRecording.subName));
int totalSeconds;
if (int.TryParse(operaterRecording.useTime, out totalSeconds))
{
int h = totalSeconds / 3600;
int m = (totalSeconds % 3600) / 60;
int s = totalSeconds % 60;
if (h > 0)
LocalizationManager.SetFormatted(text_useTime, "用时:{0}小时{1}分{2}秒", h, m, s);
else
LocalizationManager.SetFormatted(text_useTime, "用时:{0}分:{1}秒", m, s);
}
else
{
totalSeconds = LocalizationManager.ParseChineseDuration(operaterRecording.useTime);
if (totalSeconds >= 0)
{
int h = totalSeconds / 3600;
int m = (totalSeconds % 3600) / 60;
int s = totalSeconds % 60;
if (h > 0)
LocalizationManager.SetFormatted(text_useTime, "用时:{0}小时{1}分{2}秒", h, m, s);
else
LocalizationManager.SetFormatted(text_useTime, "用时:{0}分:{1}秒", m, s);
}
else
{
LocalizationManager.SetFormatted(text_useTime, "用时:{0}", operaterRecording.useTime);
}
}
RebuildOperateMsg();
if (!string.IsNullOrEmpty(operaterRecording.videoPath))//存在视频路径
{
if (File.Exists(operaterRecording.videoPath))//判断文件存在
{
LocalizationManager.SetFormatted(text_videoPath, "录屏视频:{0}", operaterRecording.videoPath);
//button_playVideo.interactable = true;
}
else //视频文件不存在
{
LocalizationManager.SetFormatted(text_videoPath, "录屏视频:{0}\r\n(视频文件已丢失,无法播放!)", operaterRecording.videoPath);
//button_playVideo.interactable = false;
}
}
else {
text_videoPath.text = LocalizationManager.Get("录屏视频:无");
//button_playVideo.interactable = false;
}
}
void PlayVideo()
{
}
public override void OnDestroy(bool isDestroy = false)
{
base.OnDestroy(isDestroy);
LocalizationManager.LanguageChanged -= OnLanguageChanged;
}
}