mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-05 03:19:23 +00:00
Impovement of UI extension
This commit is contained in:
parent
2828de3818
commit
c0e9ee15b3
16 changed files with 439 additions and 426 deletions
|
@ -6,17 +6,29 @@ namespace ml_vei
|
|||
{
|
||||
static class Settings
|
||||
{
|
||||
public enum ModSetting
|
||||
enum ModSetting
|
||||
{
|
||||
Gestures = 0
|
||||
Gestures = 0,
|
||||
GripTrigger,
|
||||
AxisPriority
|
||||
}
|
||||
|
||||
public enum PriorityAxis
|
||||
{
|
||||
Grip = 0,
|
||||
Trigger
|
||||
}
|
||||
|
||||
public static bool Gestures { get; private set; } = true;
|
||||
public static bool GripTrigger { get; private set; } = true;
|
||||
public static PriorityAxis AxisPriority { get; private set; } = PriorityAxis.Grip;
|
||||
|
||||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
||||
static public event Action<bool> GesturesChange;
|
||||
static public event Action<bool> GripTriggerChange;
|
||||
static public event Action<PriorityAxis> AxisPriorityChange;
|
||||
|
||||
internal static void Init()
|
||||
{
|
||||
|
@ -25,9 +37,13 @@ namespace ml_vei
|
|||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
|
||||
{
|
||||
ms_category.CreateEntry(ModSetting.Gestures.ToString(), Gestures),
|
||||
ms_category.CreateEntry(ModSetting.GripTrigger.ToString(), GripTrigger),
|
||||
ms_category.CreateEntry(ModSetting.AxisPriority.ToString(), (int)AxisPriority),
|
||||
};
|
||||
|
||||
Load();
|
||||
Gestures = (bool)ms_entries[(int)ModSetting.Gestures].BoxedValue;
|
||||
GripTrigger = (bool)ms_entries[(int)ModSetting.GripTrigger].BoxedValue;
|
||||
AxisPriority = (PriorityAxis)(int)ms_entries[(int)ModSetting.AxisPriority].BoxedValue;
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitMainMenuUi());
|
||||
}
|
||||
|
@ -43,22 +59,18 @@ namespace ml_vei
|
|||
|
||||
ViewManager.Instance.gameMenuView.Listener.ReadyForBindings += () =>
|
||||
{
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("MelonMod_VEI_Call_InpToggle", new Action<string, string>(OnToggleUpdate));
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("OnToggleUpdate_" + ms_category.Identifier, new Action<string, string>(OnToggleUpdate));
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("OnDropdownUpdate_" + ms_category.Identifier, new Action<string, string>(OnDropdownUpdate));
|
||||
};
|
||||
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"));
|
||||
ViewManager.Instance.gameMenuView.View.ExecuteScript(Scripts.GetEmbeddedScript("mods_extension.js"));
|
||||
ViewManager.Instance.gameMenuView.View.ExecuteScript(Scripts.GetEmbeddedScript("mod_menu.js"));
|
||||
foreach(var l_entry in ms_entries)
|
||||
ViewManager.Instance.gameMenuView.View.TriggerEvent("updateModSettingVEI", l_entry.DisplayName, l_entry.GetValueAsString());
|
||||
ViewManager.Instance.gameMenuView.View.TriggerEvent("updateModSetting", ms_category.Identifier, 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))
|
||||
|
@ -71,10 +83,34 @@ namespace ml_vei
|
|||
GesturesChange?.Invoke(Gestures);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.GripTrigger:
|
||||
{
|
||||
GripTrigger = bool.Parse(p_value);
|
||||
GripTriggerChange?.Invoke(GripTrigger);
|
||||
} break;
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnDropdownUpdate(string p_name, string p_value)
|
||||
{
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting))
|
||||
{
|
||||
switch(l_setting)
|
||||
{
|
||||
case ModSetting.AxisPriority:
|
||||
{
|
||||
AxisPriority = (PriorityAxis)int.Parse(p_value);
|
||||
AxisPriorityChange?.Invoke(AxisPriority);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue