Code structure cleanup. (2)
This commit is contained in:
45
Assets/Cryville/Crtr/Config/UI/InputConfigPanelEntry.cs
Normal file
45
Assets/Cryville/Crtr/Config/UI/InputConfigPanelEntry.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Crtr.Ruleset;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr.Config.UI {
|
||||
public class InputConfigPanelEntry : MonoBehaviour {
|
||||
[SerializeField]
|
||||
Text m_key;
|
||||
|
||||
[SerializeField]
|
||||
Text m_value;
|
||||
|
||||
[SerializeField]
|
||||
Button m_button;
|
||||
|
||||
public void SetKey(InputConfigPanel master, Identifier name) {
|
||||
m_key.text = (string)name.Name;
|
||||
m_value.text = "None";
|
||||
m_button.onClick.AddListener(() => {
|
||||
master.OpenDialog(name);
|
||||
EventSystem.current.SetSelectedGameObject(null);
|
||||
});
|
||||
}
|
||||
|
||||
public void OnProxyChanged(ProxyChangedEventArgs e) {
|
||||
if (e.Used) {
|
||||
m_button.interactable = false;
|
||||
m_value.text = "(Not Required)";
|
||||
}
|
||||
else {
|
||||
m_button.interactable = true;
|
||||
if (e.Proxy == null) {
|
||||
m_value.text = "(Unassigned)";
|
||||
if (e.Required) m_value.text += " (Required)";
|
||||
}
|
||||
else {
|
||||
m_value.text = e.Proxy.Value.Handler.GetTypeName(e.Proxy.Value.Type);
|
||||
}
|
||||
}
|
||||
m_value.color = e.Required ? Color.yellow : Color.black;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user