208 lines
11 KiB
C#
208 lines
11 KiB
C#
using CG.Framework;
|
||
using CG.UTility;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
/*******************************************************************************
|
||
*Create By CG
|
||
*Function ²Ù×÷½çÃæ¶¥²¿UI
|
||
*******************************************************************************/
|
||
namespace ZXK.GYJQR
|
||
{
|
||
public class OperationTopPanel : UIBase
|
||
{
|
||
private Text _subjectNameTxt = null;
|
||
//private Button _pdfLoadBtn = null;
|
||
private Text _studentNameTxt = null;
|
||
private Text _studentNumTxt = null;
|
||
private Text _studentTotalTxt = null;
|
||
private Text _studentActualTxt = null;
|
||
|
||
private Transform _scoreItemContent = null;
|
||
private GameObject _scoreItemPrefab = null;
|
||
|
||
private Image _oprationImg = null;
|
||
|
||
protected override void Awake()
|
||
{
|
||
base.Awake();
|
||
|
||
//Ê״νøÈëѵÁ·Ò³Ìáʾ
|
||
if (!GameManager.Instance._EnteredTrainSceneArray.Contains(GameManager.Instance._CurSystemType))
|
||
{
|
||
GameManager.Instance._EnteredTrainSceneArray.Add(GameManager.Instance._CurSystemType);
|
||
UI_Manage.Instance.ShowPanel("FirstEnterTrainPanel", System.Type.GetType("ZXK.GYJQR.FirstEnterTrainPanel"), UIGroup.Tip);
|
||
}
|
||
}
|
||
private void Start()
|
||
{
|
||
_subjectNameTxt = GetWedage("SubjectNameText_N").GetComponent<Text>();
|
||
_studentNameTxt = GetWedage("NameTxt_N").GetComponent<Text>();
|
||
_studentNumTxt = GetWedage("NumberTxt_N").GetComponent<Text>();
|
||
_studentTotalTxt = GetWedage("TotalScoreTxt_N").GetComponent<Text>();
|
||
_studentActualTxt = GetWedage("ActualScoreTxt_N").GetComponent<Text>();
|
||
_oprationImg = GetWedage("OprationImg_N").GetComponent<Image>();
|
||
_scoreItemContent = GetWedage("ScoreItemContent_N").transform;
|
||
_scoreItemPrefab = GetWedage("ScoreItemPrefab_N");
|
||
GameObject AZBSExplain = GetWedage("ExplainContain_N").transform.Find("BG/AZBSTrainExplainTxt").gameObject;
|
||
GameObject BJCJExplain = GetWedage("ExplainContain_N").transform.Find("BG/BJCJTrainExplainTxt").gameObject;
|
||
if (GameManager.Instance._CurSystemType == EnumCtrl.SystemType.AZBS)
|
||
{
|
||
_oprationImg.sprite = Resources.Load<Sprite>(ConstCtrl.OPRATION1_IMG_PATH);
|
||
AZBSExplain.SetActive(true);
|
||
BJCJExplain.SetActive(false);
|
||
}
|
||
else if (GameManager.Instance._CurSystemType == EnumCtrl.SystemType.BJCZ)
|
||
{
|
||
_oprationImg.sprite = Resources.Load<Sprite>(ConstCtrl.OPRATION2_IMG_PATH);
|
||
AZBSExplain.SetActive(false);
|
||
BJCJExplain.SetActive(true);
|
||
}
|
||
|
||
_subjectNameTxt.text = EnumCtrl.GetEnumDescription(GameManager.Instance._CurSystemType);
|
||
_studentNameTxt.text = GameManager.Instance._StudentName;
|
||
_studentNumTxt.text = GameManager.Instance._StudentNumber;
|
||
GetWedage("ScoreContain_N").transform.Find("BG/CloseBtn").GetComponent<Button>().onClick.AddListener(() =>
|
||
{
|
||
if (Camera.main.GetComponent<CameraAroundCtrl>())
|
||
Camera.main.GetComponent<CameraAroundCtrl>()._AllForbid = false;
|
||
if (Camera.main.GetComponent<CameraControl>())
|
||
Camera.main.GetComponent<CameraControl>()._AllForbid = false;
|
||
CG.UTility.PopUpMng._TriAble = true;
|
||
});
|
||
GetWedage("ExplainContain_N").transform.Find("BG/CloseBtn").GetComponent<Button>().onClick.AddListener(() =>
|
||
{
|
||
if (Camera.main.GetComponent<CameraAroundCtrl>())
|
||
Camera.main.GetComponent<CameraAroundCtrl>()._AllForbid = false;
|
||
if (Camera.main.GetComponent<CameraControl>())
|
||
Camera.main.GetComponent<CameraControl>()._AllForbid = false;
|
||
UI_Manage.Instance.GetPanel("OperationTopPanel").transform.SetAsLastSibling();
|
||
CG.UTility.PopUpMng._TriAble = true;
|
||
});
|
||
AddEventListener("ScoreTog_N", UIEventType.OnToggleValueChanged, (bool isOn) =>
|
||
{//µã»÷³É¼¨°´Å¥Õ¹Ê¾³É¼¨
|
||
if (!isOn) return;
|
||
UI_Manage.Instance.GetPanel("OperationTopPanel").transform.SetAsLastSibling();
|
||
Queue<string[]> scoreQueue=new Queue<string[]>();
|
||
switch (GameManager.Instance._CurSystemType)
|
||
{
|
||
case EnumCtrl.SystemType.None:
|
||
break;
|
||
case EnumCtrl.SystemType.AZBS:
|
||
scoreQueue = GameManager.Instance._DataAZBSHandler.GetExamScore();
|
||
break;
|
||
case EnumCtrl.SystemType.BJCZ:
|
||
scoreQueue = GameManager.Instance._DataBJCJHandler.GetExamScore();
|
||
break;
|
||
case EnumCtrl.SystemType.BY:
|
||
break;
|
||
case EnumCtrl.SystemType.SJFJ:
|
||
break;
|
||
case EnumCtrl.SystemType.HJ:
|
||
break;
|
||
case EnumCtrl.SystemType.PT:
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
float totalBJCZScore = 0.0f;//×ܵ÷Ö
|
||
float actualBJCZScore = 0.0f;//ʵ¼ÊµÃ·Ö
|
||
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;
|
||
actualBJCZScore += _actualScore;
|
||
totalBJCZScore += _totalScore;
|
||
}
|
||
|
||
//if (GameManager.Instance._CurSystemType == EnumCtrl.SystemType.AZBS)
|
||
//{
|
||
// GetWedage("ScoreContain_N").transform.Find("BG/PersonalInfo").transform.Find("TotalScoreTxt_N").GetComponent<Text>().text = DataAZBSHandler.TotalAZBSScore.ToString();
|
||
// GetWedage("ScoreContain_N").transform.Find("BG/PersonalInfo").transform.Find("ActualScoreTxt_N").GetComponent<Text>().text = actualScore.ToString();
|
||
// actualScore = 0.0f;
|
||
// DataAZBSHandler.TotalAZBSScore = 0.0f;
|
||
//}
|
||
//else if(GameManager.Instance._CurSystemType == EnumCtrl.SystemType.BJCZ)
|
||
//{
|
||
GetWedage("ScoreContain_N").transform.Find("BG/PersonalInfo").transform.Find("TotalScoreTxt_N").GetComponent<Text>().text = totalBJCZScore.ToString();
|
||
GetWedage("ScoreContain_N").transform.Find("BG/PersonalInfo").transform.Find("ActualScoreTxt_N").GetComponent<Text>().text = actualBJCZScore.ToString();
|
||
//}
|
||
CG.UTility.PopUpMng._TriAble = false;
|
||
});
|
||
GameObject tog1Geo = GetWedage("ExplainContain_N").transform.Find("BG/TrainExplainTitle").gameObject;
|
||
tog1Geo.GetComponent<Toggle>().onValueChanged.AddListener((isOn) =>
|
||
{
|
||
if (isOn)
|
||
tog1Geo.transform.Find("Label").GetComponent<Text>().color = new Color(0 / 255.0f, 107 / 255.0f, 255 / 255.0f);
|
||
else
|
||
tog1Geo.transform.Find("Label").GetComponent<Text>().color = new Color(0 / 255.0f, 0 / 255.0f, 0 / 255.0f);
|
||
});
|
||
GameObject tog2Geo = GetWedage("ExplainContain_N").transform.Find("BG/HandlerExplainTitle").gameObject;
|
||
tog2Geo.GetComponent<Toggle>().onValueChanged.AddListener((isOn) =>
|
||
{
|
||
if (isOn)
|
||
tog2Geo.transform.Find("Label").GetComponent<Text>().color = new Color(0 / 255.0f, 107 / 255.0f, 255 / 255.0f);
|
||
else
|
||
tog2Geo.transform.Find("Label").GetComponent<Text>().color = new Color(0 / 255.0f, 0 / 255.0f, 0 / 255.0f);
|
||
});
|
||
AddEventListener("ExplainTog_N", UIEventType.OnToggleValueChanged, (bool isOn) =>
|
||
{
|
||
if (!isOn) return;
|
||
if(Camera.main.GetComponent<CameraAroundCtrl>())
|
||
Camera.main.GetComponent<CameraAroundCtrl>()._AllForbid = true;
|
||
if (Camera.main.GetComponent<CameraControl>())
|
||
Camera.main.GetComponent<CameraControl>()._AllForbid = true;
|
||
CG.UTility.PopUpMng._TriAble = false;
|
||
});
|
||
AddEventListener("PDFLoadBtn_N", UIEventType.OnButtonClick, () =>
|
||
{
|
||
Queue<string[]> scoreQueue = GameManager.Instance._DataBJCJHandler.GetExamScore();
|
||
#if UNITY_WEBGL
|
||
string systemTypeName = EnumCtrl.GetEnumDescription(GameManager.Instance._CurSystemType);
|
||
string fileName = "¹¤Òµ»úÆ÷ÈËÐé·Âʵѵ³É¼¨µ¥_" + systemTypeName + ".pdf";
|
||
PDFGreadeManager.Instance.GreatePDFWeb(fileName
|
||
, systemTypeName
|
||
, scoreQueue, GameManager.Instance._StudentName
|
||
, GameManager.Instance._StudentNumber);
|
||
#else
|
||
string savePath = FolderBrowserHelper.GetPathFromWindowsExplorer();
|
||
if (!string.IsNullOrEmpty(savePath))
|
||
{
|
||
string systemTypeName = EnumCtrl.GetEnumDescription(GameManager.Instance._CurSystemType);
|
||
string fileName = "¹¤Òµ»úÆ÷ÈËÐé·Âʵѵ³É¼¨µ¥_" + systemTypeName + ".pdf";
|
||
string filePath= System.IO.Path.Combine(savePath, fileName);
|
||
PDFGreadeManager.Instance.GreatePDFPC(filePath
|
||
, systemTypeName
|
||
, scoreQueue, GameManager.Instance._StudentName
|
||
, GameManager.Instance._StudentNumber
|
||
, () =>
|
||
{
|
||
PopUpMng.PopConBox("´ò¿ªÎļþ", $"ÎļþÒѾ±£´æÔÚ\"{filePath}\"£¬ÊÇ·ñÖ±½Ó´ò¿ª", "´ò¿ª","È¡Ïû",
|
||
() => { FolderBrowserHelper.OpenFolder(filePath); });
|
||
});
|
||
}
|
||
#endif
|
||
});
|
||
}
|
||
public void OnDisable()
|
||
{
|
||
DataAZBSHandler.TotalAZBSScore = 0.0f;
|
||
//actualScore = 0.0f;
|
||
}
|
||
}
|
||
} |