mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 10:29:22 +00:00
80 lines
2.7 KiB
C#
80 lines
2.7 KiB
C#
using ABI_RC.Core.InteractionSystem;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ml_vei
|
|
{
|
|
static class Settings
|
|
{
|
|
public enum ModSetting
|
|
{
|
|
Gestures = 0
|
|
}
|
|
|
|
public static bool Gestures { get; private set; } = true;
|
|
|
|
static MelonLoader.MelonPreferences_Category ms_category = null;
|
|
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
|
|
|
static public event Action<bool> GesturesChange;
|
|
|
|
internal static void Init()
|
|
{
|
|
ms_category = MelonLoader.MelonPreferences.CreateCategory("VEI", null, true);
|
|
|
|
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
|
|
{
|
|
ms_category.CreateEntry(ModSetting.Gestures.ToString(), Gestures),
|
|
};
|
|
|
|
Load();
|
|
|
|
MelonLoader.MelonCoroutines.Start(WaitMainMenuUi());
|
|
}
|
|
|
|
static System.Collections.IEnumerator WaitMainMenuUi()
|
|
{
|
|
while(ViewManager.Instance == null)
|
|
yield return null;
|
|
while(ViewManager.Instance.gameMenuView == null)
|
|
yield return null;
|
|
while(ViewManager.Instance.gameMenuView.Listener == null)
|
|
yield return null;
|
|
|
|
ViewManager.Instance.gameMenuView.Listener.ReadyForBindings += () =>
|
|
{
|
|
ViewManager.Instance.gameMenuView.View.BindCall("MelonMod_VEI_Call_InpToggle", new Action<string, string>(OnToggleUpdate));
|
|
};
|
|
ViewManager.Instance.gameMenuView.Listener.FinishLoad += (_) =>
|
|
{
|
|
ViewManager.Instance.gameMenuView.View.ExecuteScript(Scripts.GetEmbeddedScript("ui_elements.js"));
|
|
ViewManager.Instance.gameMenuView.View.ExecuteScript(Scripts.GetEmbeddedScript("ui_menu.js"));
|
|
foreach(var l_entry in ms_entries)
|
|
ViewManager.Instance.gameMenuView.View.TriggerEvent("updateModSettingVEI", l_entry.DisplayName, l_entry.GetValueAsString());
|
|
};
|
|
}
|
|
|
|
static void Load()
|
|
{
|
|
Gestures = (bool)ms_entries[(int)ModSetting.Gestures].BoxedValue;
|
|
}
|
|
|
|
static void OnToggleUpdate(string p_name, string p_value)
|
|
{
|
|
if(Enum.TryParse(p_name, out ModSetting l_setting))
|
|
{
|
|
switch(l_setting)
|
|
{
|
|
case ModSetting.Gestures:
|
|
{
|
|
Gestures = bool.Parse(p_value);
|
|
GesturesChange?.Invoke(Gestures);
|
|
}
|
|
break;
|
|
}
|
|
|
|
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);
|
|
}
|
|
}
|
|
}
|
|
}
|