191 lines
8.2 KiB
C#
191 lines
8.2 KiB
C#
using CG.Framework;
|
||
using CG.UTility;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
/*******************************************************************************
|
||
*Create By CG
|
||
*Function
|
||
*******************************************************************************/
|
||
namespace ZXK.LouDiXvMuNiu
|
||
{
|
||
public class ScoreDataPanel : UIBase
|
||
{
|
||
private InputField _studentNameInF = null;
|
||
private InputField _studentNumberInF = null;
|
||
private Text _studentTotalTxt = null;
|
||
private Text _studentActualTxt = null;
|
||
private Text _errorTipTxt = null;
|
||
private Transform _scoreItemContent = null;
|
||
private GameObject _scoreItemPrefab = null;
|
||
private Button _closeBtn = null;
|
||
|
||
private string _nameTemp = null;
|
||
|
||
protected override void Awake()
|
||
{
|
||
base.Awake();
|
||
_studentNameInF = GetWedage("NameTxt_N").GetComponent<InputField>();
|
||
_studentNumberInF = GetWedage("NumberTxt_N").GetComponent<InputField>();
|
||
_studentTotalTxt = GetWedage("TotalScoreText_N").GetComponent<Text>();
|
||
_studentActualTxt = GetWedage("ActualScoreTxt_N").GetComponent<Text>();
|
||
_errorTipTxt = GetWedage("ErroTipTxt_N").GetComponent<Text>();
|
||
_scoreItemContent = GetWedage("ScoreItemContent_N").transform;
|
||
_scoreItemPrefab = GetWedage("ScoreItemPrefab_N");
|
||
_closeBtn = GetWedage("CloseBtn_N").GetComponent<Button>();
|
||
|
||
_closeBtn.onClick.AddListener(() =>
|
||
{
|
||
UI_Manage.Instance.ClosePanel("ScoreDataPanel");
|
||
CG.UTility.PopUpMng._TriAble = true;
|
||
});
|
||
_studentNameInF.onValueChanged.AddListener((vul) =>
|
||
{
|
||
if (UtilitiesMng.GetTransCharNum(vul) > 24)
|
||
{
|
||
_studentNameInF.text = _nameTemp;
|
||
}
|
||
else
|
||
{
|
||
_studentNameInF.text = _nameTemp = vul;
|
||
}
|
||
GameManager.Instance._StudentName = _studentNameInF.text;
|
||
});
|
||
_studentNumberInF.onValueChanged.AddListener((vul) =>
|
||
{
|
||
GameManager.Instance._StudentNumber = _studentNumberInF.text;
|
||
_errorTipTxt.gameObject.SetActive(false);
|
||
});
|
||
AddEventListener("PDFLoadBtn_N", UIEventType.OnButtonClick, () =>
|
||
{
|
||
if (!CheckInfo()) return;
|
||
Queue<string[]> scoreQueue = GameManager.Instance._DataNiuHandler.GetExamScore();
|
||
#if UNITY_EDITOR || UNITY_STANDALONE
|
||
|
||
string savePath = CG.UTility.FolderBrowserHelper.GetPathFromWindowsExplorer();
|
||
if (!string.IsNullOrEmpty(savePath))
|
||
{
|
||
string systemTypeName = GameManager.Instance._CurModelType;
|
||
string fileName = "ʵѵ<CAB5>ɼ<EFBFBD><C9BC><EFBFBD>_ţ<5F><C5A3><EFBFBD><EFBFBD>̥<EFBFBD><CCA5>ֲ.pdf";
|
||
string filePath = System.IO.Path.Combine(savePath, fileName);
|
||
PDFGreadeManager.Instance.GreatePDFPC(filePath
|
||
, systemTypeName
|
||
, scoreQueue
|
||
, GameManager.Instance._StudentName
|
||
, GameManager.Instance._StudentNumber
|
||
, () =>
|
||
{
|
||
PopUpMng.PopConBox("<22><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>", $"<22>ļ<EFBFBD><C4BC>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\"{filePath}\"<22><><EFBFBD>Ƿ<EFBFBD>ֱ<EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>", "<22><><EFBFBD><EFBFBD>", "ȡ<><C8A1>",
|
||
() => { FolderBrowserHelper.OpenFolder(filePath); });
|
||
});
|
||
}
|
||
#elif UNITY_WEBGL
|
||
string systemTypeName = GameManager.Instance._CurModelType;
|
||
string fileName = "ʵѵ<CAB5>ɼ<EFBFBD><C9BC><EFBFBD>_ţ<5F><C5A3><EFBFBD><EFBFBD>̥<EFBFBD><CCA5>ֲ.pdf";
|
||
PDFGreadeManager.Instance.GreatePDFWeb(fileName
|
||
, systemTypeName
|
||
, scoreQueue
|
||
, GameManager.Instance._StudentName
|
||
, GameManager.Instance._StudentNumber);
|
||
#endif
|
||
});
|
||
ShowScore(GameManager.Instance._DataNiuHandler.GetExamScore());
|
||
CG.UTility.PopUpMng._TriAble = false;
|
||
}
|
||
/// <summary>
|
||
/// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>
|
||
/// </summary>
|
||
/// <param name="scoreQueue"></param>
|
||
private void ShowScore(Queue<string[]> scoreQueue)
|
||
{
|
||
float totalScore = 0.0f;//<2F>ܵ÷<DCB5>
|
||
float actualScore = 0.0f;//ʵ<>ʵ÷<CAB5>
|
||
List<string> stepNames = new List<string>();
|
||
List<int> maxScore = new List<int>();
|
||
List<int> scores = new List<int>();
|
||
foreach (string[] item in scoreQueue)
|
||
{
|
||
//WDebug.Log(item[0] + "@@@" + item[1] + "$$$" + item[2] + "%%%" + item[3]);
|
||
Transform scoreItem = _scoreItemContent.Find((item[0] + "_" + item[1]).Replace("/", ""));
|
||
if (scoreItem == null)
|
||
{
|
||
scoreItem = Instantiate(_scoreItemPrefab, _scoreItemContent).transform;
|
||
scoreItem.name = (item[0] + "_" + item[1]).Replace("/", "");
|
||
}
|
||
scoreItem.gameObject.SetActive(true);
|
||
scoreItem.Find("StepTxt").GetComponent<Text>().text = item[0];
|
||
scoreItem.Find("CaoZuoTxt").GetComponent<Text>().text = item[1];
|
||
scoreItem.Find("TotalScoreTxt").GetComponent<Text>().text = item[2];
|
||
scoreItem.Find("ActualScoreTxt").GetComponent<Text>().text = item[3];
|
||
float _totalScore = float.Parse(item[2]);
|
||
float _actualScore = float.Parse(item[3]);
|
||
actualScore += _actualScore;
|
||
totalScore += _totalScore;
|
||
stepNames.Add(item[0] + item[1]);
|
||
maxScore.Add((int)float.Parse(item[2]));
|
||
scores.Add((int)float.Parse(item[3]));
|
||
|
||
}
|
||
|
||
_studentNameInF.placeholder.GetComponent<Text>().text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...";
|
||
_studentNameInF.placeholder.GetComponent<Text>().color = new Color(1, 1, 1, 0.5f);
|
||
_studentNameInF.placeholder.GetComponent<Text>().text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>...";
|
||
_studentNameInF.placeholder.GetComponent<Text>().color = new Color(1, 1, 1, 0.5f);
|
||
|
||
_studentNameInF.text = GameManager.Instance._StudentName;
|
||
_studentNumberInF.text = GameManager.Instance._StudentNumber;
|
||
_studentTotalTxt.text = totalScore.ToString();
|
||
_studentActualTxt.text = actualScore.ToString();
|
||
|
||
#if !UNITY_EDITOR && UNITY_WEBGL
|
||
LYTWebGLHelper.Instance.UpLoadData((int)totalScore, stepNames, maxScore, scores);
|
||
#endif
|
||
}
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>Ϣ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private bool CheckInfo()
|
||
{
|
||
#if UNITY_EDITOR
|
||
GameManager.Instance._StudentName = "<22><><EFBFBD><EFBFBD>";
|
||
GameManager.Instance._StudentNumber = "1234567890";
|
||
_studentNameInF.text = "<22><><EFBFBD><EFBFBD>";
|
||
_studentNameInF.text = "1234567890";
|
||
return true;
|
||
#else
|
||
bool isPass = true;
|
||
string studentName = _studentNameInF.text;
|
||
string studentNumber = _studentNumberInF.text;
|
||
if (string.IsNullOrEmpty(studentName))
|
||
{
|
||
_studentNameInF.placeholder.GetComponent<Text>().text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||
_studentNameInF.placeholder.GetComponent<Text>().color = Color.red;
|
||
isPass = false;
|
||
}
|
||
else
|
||
{
|
||
if (string.IsNullOrEmpty(studentNumber))
|
||
{
|
||
_studentNumberInF.placeholder.GetComponent<Text>().text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>";
|
||
_studentNumberInF.placeholder.GetComponent<Text>().color = Color.red;
|
||
isPass = false;
|
||
}
|
||
else if (studentNumber.Length < 9)
|
||
{
|
||
_errorTipTxt.gameObject.SetActive(true);
|
||
//_studentNumberInF.placeholder.GetComponent<Text>().text = "ѧ<><D1A7>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||
//_studentNumberInF.placeholder.GetComponent<Text>().color = Color.red;
|
||
isPass = false;
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
}
|
||
return isPass;
|
||
#endif
|
||
}
|
||
}
|
||
} |