unityzgy/Assets/Scripts/UIScripts/Teacher/RecordDetailPanel.cs
ayuan9957 bf12e02276 feat: 多语言本地化系统 - 支持中/英/法/俄实时切换
- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg)
- LoginPanel: InputField placeholder本地化、字体颜色保持
- HistoryPanel: 用时数据本地化、placeholder本地化
- RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建)
- AppraiseWindowBase: 评价等级本地化、操作消息重建
- EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized
- StudentOperateRecorder: 新增InjectOperateMsgLocalized方法
- LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选
- 字体切换时保留颜色和verticalOverflow
2026-07-16 10:05:59 +08:00

124 lines
4.5 KiB
C#

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);/*GetComponent<Button>().onClick.AddListener(PlayVideo)*/; //赞不实现播放视频功能
LocalizationManager.LanguageChanged += OnLanguageChanged;
}
private void OnLanguageChanged()
{
if (currentRecord == null) return;
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;
}
}