mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-02-04 17:02:17 +08:00
UXAssist 1.2.4
This commit is contained in:
@@ -13,8 +13,13 @@ public class MyCheckBox : MonoBehaviour
|
||||
public RectTransform rectTrans;
|
||||
public Text labelText;
|
||||
public event Action OnChecked;
|
||||
protected event Action OnFree;
|
||||
private bool _checked;
|
||||
private ConfigEntry<bool> _configAssigned;
|
||||
|
||||
protected void OnDestroy()
|
||||
{
|
||||
OnFree?.Invoke();
|
||||
}
|
||||
|
||||
public bool Checked
|
||||
{
|
||||
@@ -29,9 +34,10 @@ public class MyCheckBox : MonoBehaviour
|
||||
public static MyCheckBox CreateCheckBox(float x, float y, RectTransform parent, ConfigEntry<bool> config, string label = "", int fontSize = 15)
|
||||
{
|
||||
var cb = CreateCheckBox(x, y, parent, config.Value, label, fontSize);
|
||||
cb._configAssigned = config;
|
||||
cb.OnChecked += () => config.Value = !config.Value;
|
||||
config.SettingChanged += (_, _) => cb.Checked = config.Value;
|
||||
EventHandler func = (_, _) => cb.Checked = config.Value;
|
||||
config.SettingChanged += func;
|
||||
cb.OnFree += () => config.SettingChanged -= func;
|
||||
return cb;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ public class MyConfigWindow : MyWindowWithTabs
|
||||
|
||||
public override void _OnCreate()
|
||||
{
|
||||
base._OnCreate();
|
||||
_windowTrans = GetComponent<RectTransform>();
|
||||
OnUICreated?.Invoke(this, _windowTrans);
|
||||
AutoFitWindowSize();
|
||||
@@ -32,26 +33,16 @@ public class MyConfigWindow : MyWindowWithTabs
|
||||
public override void _OnDestroy()
|
||||
{
|
||||
_windowTrans = null;
|
||||
base._OnDestroy();
|
||||
}
|
||||
|
||||
public override bool _OnInit()
|
||||
{
|
||||
if (!base._OnInit()) return false;
|
||||
_windowTrans.anchoredPosition = new Vector2(0, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void _OnFree()
|
||||
{
|
||||
}
|
||||
|
||||
public override void _OnOpen()
|
||||
{
|
||||
}
|
||||
|
||||
public override void _OnClose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void _OnUpdate()
|
||||
{
|
||||
base._OnUpdate();
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace UXAssist.UI;
|
||||
public class MyKeyBinder : MonoBehaviour
|
||||
{
|
||||
private ConfigEntry<KeyboardShortcut> _config;
|
||||
protected event Action OnFree;
|
||||
|
||||
[SerializeField]
|
||||
public Text functionText;
|
||||
@@ -42,6 +43,11 @@ public class MyKeyBinder : MonoBehaviour
|
||||
public UIButton setNoneKeyUIButton;
|
||||
|
||||
private bool _nextNotOn;
|
||||
|
||||
protected void OnDestroy()
|
||||
{
|
||||
OnFree?.Invoke();
|
||||
}
|
||||
|
||||
public static RectTransform CreateKeyBinder(float x, float y, RectTransform parent, ConfigEntry<KeyboardShortcut> config, string label = "", int fontSize = 17)
|
||||
{
|
||||
@@ -82,10 +88,10 @@ public class MyKeyBinder : MonoBehaviour
|
||||
Destroy(uikeyEntry);
|
||||
kb.setNoneKeyUIButton.gameObject.SetActive(false);
|
||||
|
||||
EventHandler func = (_, _) => kb.SettingChanged();
|
||||
kb.SettingChanged();
|
||||
config.SettingChanged += (_, _) => {
|
||||
kb.SettingChanged();
|
||||
};
|
||||
config.SettingChanged += func;
|
||||
kb.OnFree += () => config.SettingChanged -= func;
|
||||
kb.inputUIButton.onClick += kb.OnInputUIButtonClick;
|
||||
kb.setDefaultUIButton.onClick += kb.OnSetDefaultKeyClick;
|
||||
//kb.setNoneKeyUIButton.onClick += kb.OnSetNoneKeyClick;
|
||||
|
||||
@@ -22,6 +22,12 @@ public class MyWindow : ManualBehaviour
|
||||
protected const float TabHeight = 27f;
|
||||
protected const float Margin = 30f;
|
||||
protected const float Spacing = 10f;
|
||||
protected event Action OnFree;
|
||||
|
||||
public override void _OnFree()
|
||||
{
|
||||
OnFree?.Invoke();
|
||||
}
|
||||
|
||||
public virtual void TryClose()
|
||||
{
|
||||
@@ -222,12 +228,14 @@ public class MyWindow : ManualBehaviour
|
||||
{
|
||||
var slider = MySlider.CreateSlider(x, y, parent, OnConfigValueChanged(config), valueMapper.Min, valueMapper.Max, format, width);
|
||||
slider.SetLabelText(valueMapper.FormatValue(format, config.Value));
|
||||
config.SettingChanged += (sender, args) =>
|
||||
EventHandler func = (_, _) =>
|
||||
{
|
||||
var index = OnConfigValueChanged(config);
|
||||
slider.Value = index;
|
||||
slider.SetLabelText(valueMapper.FormatValue(format, config.Value));
|
||||
};
|
||||
config.SettingChanged += func;
|
||||
OnFree += () => config.SettingChanged -= func;
|
||||
slider.OnValueChanged += () =>
|
||||
{
|
||||
var index = Mathf.RoundToInt(slider.Value);
|
||||
|
||||
Reference in New Issue
Block a user