101 lines
3.0 KiB
C#
101 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using WI;
|
|
|
|
namespace CHN
|
|
{
|
|
public class UI_InputOrFind : UIBase
|
|
{
|
|
TextMeshProUGUI machineInfoPath;
|
|
Button Button_Find;
|
|
Image Image_Connected;
|
|
Image Image_UnConnected;
|
|
TextMeshProUGUI ErrorMessage;
|
|
|
|
public Action onClickFind;
|
|
private Dictionary<string, string> initOption = new();
|
|
private Dictionary<string, string> mappingOption = new();
|
|
|
|
public void InitInfoFile(MonoBehaviour mo)
|
|
{
|
|
var optionManager = FindSingle<OptionManager>();
|
|
var option = optionManager.GetOption(mo);
|
|
|
|
initOption.Add(machineInfoPath.name, option[machineInfoPath.name]);
|
|
}
|
|
public enum State
|
|
{
|
|
None,
|
|
Good,
|
|
Error,
|
|
Warning,
|
|
}
|
|
|
|
public void SetState(State s)
|
|
{
|
|
switch (s)
|
|
{
|
|
case State.None:
|
|
Image_Connected.gameObject.SetActive(false);
|
|
Image_UnConnected.gameObject.SetActive(true);
|
|
ErrorMessage.color = new Color(245, 0, 0);
|
|
break;
|
|
case State.Good:
|
|
Image_Connected.gameObject.SetActive(true);
|
|
Image_UnConnected.gameObject.SetActive(false);
|
|
ErrorMessage.color = new Color(0, 245, 0);
|
|
break;
|
|
case State.Error:
|
|
Image_Connected.gameObject.SetActive(false);
|
|
Image_UnConnected.gameObject.SetActive(true);
|
|
ErrorMessage.color = new Color(245, 0, 0);
|
|
break;
|
|
case State.Warning:
|
|
Image_Connected.gameObject.SetActive(false);
|
|
Image_UnConnected.gameObject.SetActive(true);
|
|
ErrorMessage.color = new Color(245, 0, 0);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void SetPathText(string str)
|
|
{
|
|
machineInfoPath.SetText(str);
|
|
}
|
|
public void SetErrorMessageText(string error)
|
|
{
|
|
ErrorMessage.SetText(error);
|
|
}
|
|
|
|
public override void AfterAwake()
|
|
{
|
|
Button_Find.onClick.AddListener(OnClickFindButton);
|
|
}
|
|
|
|
private void OnClickFindButton()
|
|
{
|
|
onClickFind?.Invoke();
|
|
}
|
|
public void ResetInputOrFind(MonoBehaviour mo)
|
|
{
|
|
var optionManager = FindSingle<OptionManager>();
|
|
|
|
foreach (var key in initOption.Keys)
|
|
{
|
|
machineInfoPath.text = initOption[key];
|
|
}
|
|
optionManager.SetOptionValue(mo, initOption);
|
|
}
|
|
public void AcceptInputOrFind(MonoBehaviour mo)
|
|
{
|
|
var optionManager = FindSingle<OptionManager>();
|
|
mappingOption.Clear();
|
|
|
|
mappingOption.Add(machineInfoPath.name, machineInfoPath.text);
|
|
optionManager.SetOptionValue(mo, mappingOption);
|
|
}
|
|
}
|
|
} |