157 lines
4.8 KiB
C#
157 lines
4.8 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using WI;
|
|
|
|
namespace CHN
|
|
{
|
|
public class UI_DashboardCheckListItem : UIBase
|
|
{
|
|
private Toggle toggle;
|
|
private TextMeshProUGUI toggleText;
|
|
public GameObject dashboardItem;
|
|
public bool isClick => toggle.isOn;
|
|
|
|
private string keyName;
|
|
private string type;
|
|
public void SetItem(string name, GameObject item)
|
|
{
|
|
toggle = GetComponentInChildren<Toggle>();
|
|
toggleText = GetComponentInChildren<TextMeshProUGUI>();
|
|
keyName = name;
|
|
RefreshText();
|
|
dashboardItem = item;
|
|
type = Type();
|
|
|
|
var isBool = PlayerPrefs.GetInt(type) == 0 ? false : true;
|
|
toggle.isOn = isBool;
|
|
|
|
if (type != "isLibrary" && type != "isSimpleMachineDashbard")
|
|
{
|
|
dashboardItem.gameObject.SetActive(isBool);
|
|
}
|
|
|
|
toggle.onValueChanged.AddListener(OnValueChange);
|
|
//LocaleService.Instance.OnChanged += OnChangeText;
|
|
}
|
|
|
|
//private void OnChangeText(object sender, Locale e)
|
|
//{
|
|
// if (e.name.Contains("ko"))
|
|
// {
|
|
// toggleText.fontSize = 14f;
|
|
// }
|
|
// else
|
|
// {
|
|
// toggleText.fontSize = 9f;
|
|
// }
|
|
// RefreshText();
|
|
//}
|
|
|
|
private void RefreshText()
|
|
{
|
|
toggleText.SetText(keyName);
|
|
}
|
|
|
|
public void ToggleOnItem()
|
|
{
|
|
toggle.isOn = true;
|
|
}
|
|
public void ToggleOffItem()
|
|
{
|
|
toggle.isOn = false;
|
|
}
|
|
|
|
private void OnValueChange(bool isOn)
|
|
{
|
|
PlayerPrefs.SetInt(type, isOn ? 1 : 0);
|
|
PlayerPrefs.Save();
|
|
|
|
if (type == "isCompleteAlramHistory")
|
|
{
|
|
dashboardItem.gameObject.SetActive(isOn);
|
|
}
|
|
else
|
|
{
|
|
if (isOn)
|
|
{
|
|
OpenDashBoardItem(type);
|
|
}
|
|
else
|
|
{
|
|
CloseDashBoardItem(type);
|
|
}
|
|
}
|
|
}
|
|
private void OpenDashBoardItem(string type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case "isLibrary":
|
|
var library = dashboardItem.GetComponent<Panel_Library>();
|
|
library.Open();
|
|
break;
|
|
case "isWorkConditionAnalysis":
|
|
var workConditionAnalysis = dashboardItem.GetComponent<Panel_WorkConditionAnalysis>();
|
|
workConditionAnalysis.Open();
|
|
break;
|
|
case "isWorkTimeAnalysis":
|
|
var workTimeAnalysis = dashboardItem.GetComponent<Panel_WorkTimeAnalysis>();
|
|
workTimeAnalysis.Open();
|
|
break;
|
|
case "isSimpleMachineDashbard":
|
|
var canvas_popup = dashboardItem.GetComponent<Canvas_Popup>();
|
|
canvas_popup.ActiveSimpleDashBoard();
|
|
break;
|
|
}
|
|
}
|
|
private void CloseDashBoardItem(string type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case "isLibrary":
|
|
var library = dashboardItem.GetComponent<Panel_Library>();
|
|
library.Close();
|
|
break;
|
|
case "isWorkConditionAnalysis":
|
|
var workConditionAnalysis = dashboardItem.GetComponent<Panel_WorkConditionAnalysis>();
|
|
workConditionAnalysis.Close();
|
|
break;
|
|
case "isWorkTimeAnalysis":
|
|
var workTimeAnalysis = dashboardItem.GetComponent<Panel_WorkTimeAnalysis>();
|
|
workTimeAnalysis.Close();
|
|
break;
|
|
case "isSimpleMachineDashbard":
|
|
var canvas_popup = dashboardItem.GetComponent<Canvas_Popup>();
|
|
canvas_popup.DeactiveSimpleDashBoard();
|
|
break;
|
|
}
|
|
}
|
|
|
|
private string Type()
|
|
{
|
|
var type = "";
|
|
switch (keyName)
|
|
{
|
|
case ("완료 시간 알람"):
|
|
type = "isCompleteAlramHistory";
|
|
break;
|
|
case ("라이브러리"):
|
|
type = "isLibrary";
|
|
break;
|
|
case ("작업 조건 분석"):
|
|
type = "isWorkConditionAnalysis";
|
|
break;
|
|
case ("작업 시간 분석"):
|
|
type = "isWorkTimeAnalysis";
|
|
break;
|
|
case ("설비 요약 대시 보드"):
|
|
type = "isSimpleMachineDashbard";
|
|
break;
|
|
}
|
|
return type;
|
|
}
|
|
}
|
|
|
|
}
|