mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-05 03:19:23 +00:00
Custom event classes for patched methods
Update to LeapCSharp 6.15.0
This commit is contained in:
parent
4b879d53d5
commit
85925a7072
76 changed files with 3443 additions and 2187 deletions
|
@ -7,6 +7,14 @@ namespace ml_lme
|
|||
{
|
||||
static class Settings
|
||||
{
|
||||
internal class SettingEvent<T>
|
||||
{
|
||||
event Action<T> m_action;
|
||||
public void AddHandler(Action<T> p_listener) => m_action += p_listener;
|
||||
public void RemoveHandler(Action<T> p_listener) => m_action -= p_listener;
|
||||
public void Invoke(T p_value) => m_action?.Invoke(p_value);
|
||||
}
|
||||
|
||||
public enum LeapTrackingMode
|
||||
{
|
||||
Screentop = 0,
|
||||
|
@ -58,21 +66,21 @@ namespace ml_lme
|
|||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
||||
public static event Action<bool> EnabledChange;
|
||||
public static event Action<Vector3> DesktopOffsetChange;
|
||||
public static event Action<bool> FingersOnlyChange;
|
||||
public static event Action<bool> ModelVisibilityChange;
|
||||
public static event Action<LeapTrackingMode> TrackingModeChange;
|
||||
public static event Action<Vector3> RootAngleChange;
|
||||
public static event Action<bool> HeadAttachChange;
|
||||
public static event Action<Vector3> HeadOffsetChange;
|
||||
public static event Action<bool> TrackElbowsChange;
|
||||
public static event Action<bool> InteractionChange;
|
||||
public static event Action<bool> GesturesChange;
|
||||
public static event Action<float> InteractThreadholdChange;
|
||||
public static event Action<float> GripThreadholdChange;
|
||||
public static event Action<bool> VisualHandsChange;
|
||||
public static event Action<bool> MechanimFilterChange;
|
||||
public static readonly SettingEvent<bool> OnEnabledChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<Vector3> OnDesktopOffsetChanged = new SettingEvent<Vector3>();
|
||||
public static readonly SettingEvent<bool> OnFingersOnlyChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<bool> OnModelVisibilityChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<LeapTrackingMode> OnTrackingModeChanged = new SettingEvent<LeapTrackingMode>();
|
||||
public static readonly SettingEvent<Vector3> OnRootAngleChanged = new SettingEvent<Vector3>();
|
||||
public static readonly SettingEvent<bool> OnHeadAttachChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<Vector3> OnHeadOffsetChanged = new SettingEvent<Vector3>();
|
||||
public static readonly SettingEvent<bool> OnTrackElbowsChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<bool> OnInteractionChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<bool> OnGesturesChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<float> OnInteractThreadholdChanged = new SettingEvent<float>();
|
||||
public static readonly SettingEvent<float> OnGripThreadholdChanged = new SettingEvent<float>();
|
||||
public static readonly SettingEvent<bool> OnVisualHandsChanged = new SettingEvent<bool>();
|
||||
public static readonly SettingEvent<bool> OnMechanimFilterChanged = new SettingEvent<bool>();
|
||||
|
||||
internal static void Init()
|
||||
{
|
||||
|
@ -103,7 +111,33 @@ namespace ml_lme
|
|||
ms_category.CreateEntry(ModSetting.MechanimFilter.ToString(), MechanimFilter)
|
||||
};
|
||||
|
||||
Load();
|
||||
Enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
|
||||
DesktopOffset = new Vector3(
|
||||
(int)ms_entries[(int)ModSetting.DesktopX].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.DesktopY].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.DesktopZ].BoxedValue
|
||||
) * 0.01f;
|
||||
FingersOnly = (bool)ms_entries[(int)ModSetting.FingersOnly].BoxedValue;
|
||||
ModelVisibility = (bool)ms_entries[(int)ModSetting.Model].BoxedValue;
|
||||
TrackingMode = (LeapTrackingMode)(int)ms_entries[(int)ModSetting.Mode].BoxedValue;
|
||||
RootAngle = new Vector3(
|
||||
(int)ms_entries[(int)ModSetting.AngleX].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.AngleY].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.AngleZ].BoxedValue
|
||||
);
|
||||
HeadAttach = (bool)ms_entries[(int)ModSetting.Head].BoxedValue;
|
||||
HeadOffset = new Vector3(
|
||||
(int)ms_entries[(int)ModSetting.HeadX].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.HeadY].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.HeadZ].BoxedValue
|
||||
) * 0.01f;
|
||||
TrackElbows = (bool)ms_entries[(int)ModSetting.TrackElbows].BoxedValue;
|
||||
Interaction = (bool)ms_entries[(int)ModSetting.Interaction].BoxedValue;
|
||||
Gestures = (bool)ms_entries[(int)ModSetting.Gestures].BoxedValue;
|
||||
InteractThreadhold = (int)ms_entries[(int)ModSetting.InteractThreadhold].BoxedValue * 0.01f;
|
||||
GripThreadhold = (int)ms_entries[(int)ModSetting.GripThreadhold].BoxedValue * 0.01f;
|
||||
VisualHands = (bool)ms_entries[(int)ModSetting.VisualHands].BoxedValue;
|
||||
MechanimFilter = (bool)ms_entries[(int)ModSetting.MechanimFilter].BoxedValue;
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitMainMenuUi());
|
||||
}
|
||||
|
@ -132,226 +166,216 @@ namespace ml_lme
|
|||
};
|
||||
}
|
||||
|
||||
static void Load()
|
||||
{
|
||||
Enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
|
||||
DesktopOffset = new Vector3(
|
||||
(int)ms_entries[(int)ModSetting.DesktopX].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.DesktopY].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.DesktopZ].BoxedValue
|
||||
) * 0.01f;
|
||||
FingersOnly = (bool)ms_entries[(int)ModSetting.FingersOnly].BoxedValue;
|
||||
ModelVisibility = (bool)ms_entries[(int)ModSetting.Model].BoxedValue;
|
||||
TrackingMode = (LeapTrackingMode)(int)ms_entries[(int)ModSetting.Mode].BoxedValue;
|
||||
RootAngle = new Vector3(
|
||||
(int)ms_entries[(int)ModSetting.AngleX].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.AngleY].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.AngleZ].BoxedValue
|
||||
);
|
||||
HeadAttach = (bool)ms_entries[(int)ModSetting.Head].BoxedValue;
|
||||
HeadOffset = new Vector3(
|
||||
(int)ms_entries[(int)ModSetting.HeadX].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.HeadY].BoxedValue,
|
||||
(int)ms_entries[(int)ModSetting.HeadZ].BoxedValue
|
||||
) * 0.01f;
|
||||
TrackElbows = (bool)ms_entries[(int)ModSetting.TrackElbows].BoxedValue;
|
||||
Interaction = (bool)ms_entries[(int)ModSetting.Interaction].BoxedValue;
|
||||
Gestures = (bool)ms_entries[(int)ModSetting.Gestures].BoxedValue;
|
||||
InteractThreadhold = (int)ms_entries[(int)ModSetting.InteractThreadhold].BoxedValue * 0.01f;
|
||||
GripThreadhold = (int)ms_entries[(int)ModSetting.GripThreadhold].BoxedValue * 0.01f;
|
||||
VisualHands = (bool)ms_entries[(int)ModSetting.VisualHands].BoxedValue;
|
||||
MechanimFilter = (bool)ms_entries[(int)ModSetting.MechanimFilter].BoxedValue;
|
||||
}
|
||||
|
||||
static void OnToggleUpdate(string p_name, string p_value)
|
||||
{
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting))
|
||||
try
|
||||
{
|
||||
switch(l_setting)
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting))
|
||||
{
|
||||
case ModSetting.Enabled:
|
||||
switch(l_setting)
|
||||
{
|
||||
Enabled = bool.Parse(p_value);
|
||||
EnabledChange?.Invoke(Enabled);
|
||||
}
|
||||
break;
|
||||
case ModSetting.Enabled:
|
||||
{
|
||||
Enabled = bool.Parse(p_value);
|
||||
OnEnabledChanged.Invoke(Enabled);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.FingersOnly:
|
||||
{
|
||||
FingersOnly = bool.Parse(p_value);
|
||||
FingersOnlyChange?.Invoke(FingersOnly);
|
||||
}
|
||||
break;
|
||||
case ModSetting.FingersOnly:
|
||||
{
|
||||
FingersOnly = bool.Parse(p_value);
|
||||
OnFingersOnlyChanged.Invoke(FingersOnly);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Model:
|
||||
{
|
||||
ModelVisibility = bool.Parse(p_value);
|
||||
ModelVisibilityChange?.Invoke(ModelVisibility);
|
||||
}
|
||||
break;
|
||||
case ModSetting.Model:
|
||||
{
|
||||
ModelVisibility = bool.Parse(p_value);
|
||||
OnModelVisibilityChanged.Invoke(ModelVisibility);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Head:
|
||||
{
|
||||
HeadAttach = bool.Parse(p_value);
|
||||
HeadAttachChange?.Invoke(HeadAttach);
|
||||
}
|
||||
break;
|
||||
case ModSetting.Head:
|
||||
{
|
||||
HeadAttach = bool.Parse(p_value);
|
||||
OnHeadAttachChanged.Invoke(HeadAttach);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.TrackElbows:
|
||||
{
|
||||
TrackElbows = bool.Parse(p_value);
|
||||
TrackElbowsChange?.Invoke(TrackElbows);
|
||||
}
|
||||
break;
|
||||
case ModSetting.TrackElbows:
|
||||
{
|
||||
TrackElbows = bool.Parse(p_value);
|
||||
OnTrackElbowsChanged.Invoke(TrackElbows);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Interaction:
|
||||
{
|
||||
Interaction = bool.Parse(p_value);
|
||||
InteractionChange?.Invoke(Interaction);
|
||||
}
|
||||
break;
|
||||
case ModSetting.Interaction:
|
||||
{
|
||||
Interaction = bool.Parse(p_value);
|
||||
OnInteractionChanged.Invoke(Interaction);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Gestures:
|
||||
{
|
||||
Gestures = bool.Parse(p_value);
|
||||
GesturesChange?.Invoke(Gestures);
|
||||
}
|
||||
break;
|
||||
case ModSetting.Gestures:
|
||||
{
|
||||
Gestures = bool.Parse(p_value);
|
||||
OnGesturesChanged.Invoke(Gestures);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.VisualHands:
|
||||
{
|
||||
VisualHands = bool.Parse(p_value);
|
||||
VisualHandsChange?.Invoke(VisualHands);
|
||||
case ModSetting.VisualHands:
|
||||
{
|
||||
VisualHands = bool.Parse(p_value);
|
||||
OnVisualHandsChanged.Invoke(VisualHands);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.MechanimFilter:
|
||||
{
|
||||
MechanimFilter = bool.Parse(p_value);
|
||||
OnMechanimFilterChanged.Invoke(MechanimFilter);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.MechanimFilter:
|
||||
{
|
||||
MechanimFilter = bool.Parse(p_value);
|
||||
MechanimFilterChange?.Invoke(MechanimFilter);
|
||||
}
|
||||
break;
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnSliderUpdate(string p_name, string p_value)
|
||||
{
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting))
|
||||
try
|
||||
{
|
||||
switch(l_setting)
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting))
|
||||
{
|
||||
case ModSetting.DesktopX:
|
||||
switch(l_setting)
|
||||
{
|
||||
Vector3 l_current = DesktopOffset;
|
||||
l_current.x = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffset = l_current;
|
||||
DesktopOffsetChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.DesktopY:
|
||||
{
|
||||
Vector3 l_current = DesktopOffset;
|
||||
l_current.y = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffset = l_current;
|
||||
DesktopOffsetChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.DesktopZ:
|
||||
{
|
||||
Vector3 l_current = DesktopOffset;
|
||||
l_current.z = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffset = l_current;
|
||||
DesktopOffsetChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.DesktopX:
|
||||
{
|
||||
Vector3 l_current = DesktopOffset;
|
||||
l_current.x = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffset = l_current;
|
||||
OnDesktopOffsetChanged.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.DesktopY:
|
||||
{
|
||||
Vector3 l_current = DesktopOffset;
|
||||
l_current.y = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffset = l_current;
|
||||
OnDesktopOffsetChanged.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.DesktopZ:
|
||||
{
|
||||
Vector3 l_current = DesktopOffset;
|
||||
l_current.z = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffset = l_current;
|
||||
OnDesktopOffsetChanged.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.AngleX:
|
||||
{
|
||||
Vector3 l_current = RootAngle;
|
||||
l_current.x = int.Parse(p_value);
|
||||
RootAngle = l_current;
|
||||
RootAngleChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.AngleX:
|
||||
{
|
||||
Vector3 l_current = RootAngle;
|
||||
l_current.x = int.Parse(p_value);
|
||||
RootAngle = l_current;
|
||||
OnRootAngleChanged.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.AngleY:
|
||||
{
|
||||
Vector3 l_current = RootAngle;
|
||||
l_current.y = int.Parse(p_value);
|
||||
RootAngle = l_current;
|
||||
RootAngleChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.AngleY:
|
||||
{
|
||||
Vector3 l_current = RootAngle;
|
||||
l_current.y = int.Parse(p_value);
|
||||
RootAngle = l_current;
|
||||
OnRootAngleChanged.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.AngleZ:
|
||||
{
|
||||
Vector3 l_current = RootAngle;
|
||||
l_current.z = int.Parse(p_value);
|
||||
RootAngle = l_current;
|
||||
RootAngleChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.AngleZ:
|
||||
{
|
||||
Vector3 l_current = RootAngle;
|
||||
l_current.z = int.Parse(p_value);
|
||||
RootAngle = l_current;
|
||||
OnRootAngleChanged.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.HeadX:
|
||||
{
|
||||
Vector3 l_current = HeadOffset;
|
||||
l_current.x = int.Parse(p_value) * 0.01f;
|
||||
HeadOffset = l_current;
|
||||
HeadOffsetChange?.Invoke(l_current);
|
||||
case ModSetting.HeadX:
|
||||
{
|
||||
Vector3 l_current = HeadOffset;
|
||||
l_current.x = int.Parse(p_value) * 0.01f;
|
||||
HeadOffset = l_current;
|
||||
OnHeadOffsetChanged.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.HeadY:
|
||||
{
|
||||
Vector3 l_current = HeadOffset;
|
||||
l_current.y = int.Parse(p_value) * 0.01f;
|
||||
HeadOffset = l_current;
|
||||
OnHeadOffsetChanged.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.HeadZ:
|
||||
{
|
||||
Vector3 l_current = HeadOffset;
|
||||
l_current.z = int.Parse(p_value) * 0.01f;
|
||||
HeadOffset = l_current;
|
||||
OnHeadOffsetChanged.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.InteractThreadhold:
|
||||
{
|
||||
InteractThreadhold = int.Parse(p_value) * 0.01f;
|
||||
OnInteractThreadholdChanged.Invoke(InteractThreadhold);
|
||||
}
|
||||
break;
|
||||
case ModSetting.GripThreadhold:
|
||||
{
|
||||
GripThreadhold = int.Parse(p_value) * 0.01f;
|
||||
OnGripThreadholdChanged.Invoke(GripThreadhold);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ModSetting.HeadY:
|
||||
{
|
||||
Vector3 l_current = HeadOffset;
|
||||
l_current.y = int.Parse(p_value) * 0.01f;
|
||||
HeadOffset = l_current;
|
||||
HeadOffsetChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.HeadZ:
|
||||
{
|
||||
Vector3 l_current = HeadOffset;
|
||||
l_current.z = int.Parse(p_value) * 0.01f;
|
||||
HeadOffset = l_current;
|
||||
HeadOffsetChange?.Invoke(l_current);
|
||||
}
|
||||
break;
|
||||
case ModSetting.InteractThreadhold:
|
||||
{
|
||||
InteractThreadhold = int.Parse(p_value) * 0.01f;
|
||||
InteractThreadholdChange?.Invoke(InteractThreadhold);
|
||||
}
|
||||
break;
|
||||
case ModSetting.GripThreadhold:
|
||||
{
|
||||
GripThreadhold = int.Parse(p_value) * 0.01f;
|
||||
GripThreadholdChange?.Invoke(GripThreadhold);
|
||||
}
|
||||
break;
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value);
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnDropdownUpdate(string p_name, string p_value)
|
||||
{
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting))
|
||||
try
|
||||
{
|
||||
switch(l_setting)
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting))
|
||||
{
|
||||
case ModSetting.Mode:
|
||||
switch(l_setting)
|
||||
{
|
||||
TrackingMode = (LeapTrackingMode)int.Parse(p_value);
|
||||
TrackingModeChange?.Invoke(TrackingMode);
|
||||
case ModSetting.Mode:
|
||||
{
|
||||
TrackingMode = (LeapTrackingMode)int.Parse(p_value);
|
||||
OnTrackingModeChanged.Invoke(TrackingMode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value);
|
||||
ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue