mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-07 03:59:16 +00:00
HMD mode
Head attachment Head offsets Model visibility VR compatibility
This commit is contained in:
parent
eb3f09fffd
commit
4c85c92203
8 changed files with 436 additions and 147 deletions
|
@ -1,4 +1,8 @@
|
|||
namespace ml_lme_cvr
|
||||
using ABI_RC.Core.Savior;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ml_lme_cvr
|
||||
{
|
||||
static class Settings
|
||||
{
|
||||
|
@ -8,87 +12,186 @@
|
|||
"InteractionLeapMotionTrackingDesktopX",
|
||||
"InteractionLeapMotionTrackingDesktopY",
|
||||
"InteractionLeapMotionTrackingDesktopZ",
|
||||
"InteractionLeapMotionTrackingFingersOnly"
|
||||
"InteractionLeapMotionTrackingFingersOnly",
|
||||
"InteractionLeapMotionTrackingModel",
|
||||
"InteractionLeapMotionTrackingHmd",
|
||||
"InteractionLeapMotionTrackingAngle",
|
||||
"InteractionLeapMotionTrackingHead",
|
||||
"InteractionLeapMotionTrackingHeadX",
|
||||
"InteractionLeapMotionTrackingHeadY",
|
||||
"InteractionLeapMotionTrackingHeadZ"
|
||||
};
|
||||
|
||||
static bool ms_enabled = false;
|
||||
static float ms_desktopOffsetX = 0f;
|
||||
static float ms_desktopOffsetY = -0.45f;
|
||||
static float ms_desktopOffsetZ = 0.3f;
|
||||
static Vector3 ms_desktopOffset = new Vector3(0f, -0.45f, 0.3f);
|
||||
static bool ms_fingersOnly = false;
|
||||
static bool ms_modelVisibility = false;
|
||||
static bool ms_hmdMode = false;
|
||||
static float ms_rootAngle = 0f;
|
||||
static bool ms_headAttach = false;
|
||||
static Vector3 ms_headOffset = new Vector3(0f, 0f, 0f);
|
||||
|
||||
static bool ms_initialized = false;
|
||||
|
||||
static public event System.Action EnabledChange;
|
||||
static public event System.Action DesktopOffsetChange;
|
||||
static public event System.Action FingersOnlyChange;
|
||||
static public event Action EnabledChange;
|
||||
static public event Action DesktopOffsetChange;
|
||||
static public event Action FingersOnlyChange;
|
||||
static public event Action ModelVisibilityChange;
|
||||
static public event Action HmdModeChange;
|
||||
static public event Action RootAngleChange;
|
||||
static public event Action HeadAttachChange;
|
||||
static public event Action HeadOffsetChange;
|
||||
|
||||
public static void Init(HarmonyLib.Harmony p_instance)
|
||||
{
|
||||
p_instance.Patch(
|
||||
typeof(ABI_RC.Core.Savior.CVRSettings).GetMethod(nameof(ABI_RC.Core.Savior.CVRSettings.LoadSerializedSettings)),
|
||||
typeof(CVRSettings).GetMethod(nameof(CVRSettings.LoadSerializedSettings)),
|
||||
new HarmonyLib.HarmonyMethod(typeof(Settings).GetMethod(nameof(BeforeSettingsLoad), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
static void BeforeSettingsLoad(ref ABI_RC.Core.Savior.CVRSettings __instance)
|
||||
static void BeforeSettingsLoad(ref CVRSettings __instance)
|
||||
{
|
||||
if(!ms_initialized && __instance != null)
|
||||
{
|
||||
var l_settings = HarmonyLib.Traverse.Create(__instance)?.Field("_settings")?.GetValue<System.Collections.Generic.List<ABI_RC.Core.Savior.CVRSettingsValue>>();
|
||||
if(l_settings != null)
|
||||
{
|
||||
l_settings.Add(new ABI_RC.Core.Savior.CVRSettingsBool(ms_defaultSettings[0], false));
|
||||
l_settings.Add(new ABI_RC.Core.Savior.CVRSettingsInt(ms_defaultSettings[1], 0));
|
||||
l_settings.Add(new ABI_RC.Core.Savior.CVRSettingsInt(ms_defaultSettings[2], -45));
|
||||
l_settings.Add(new ABI_RC.Core.Savior.CVRSettingsInt(ms_defaultSettings[3], 30));
|
||||
l_settings.Add(new ABI_RC.Core.Savior.CVRSettingsBool(ms_defaultSettings[4], false));
|
||||
l_settings.Add(new CVRSettingsBool(ms_defaultSettings[0], false));
|
||||
l_settings.Add(new CVRSettingsInt(ms_defaultSettings[1], 0));
|
||||
l_settings.Add(new CVRSettingsInt(ms_defaultSettings[2], -45));
|
||||
l_settings.Add(new CVRSettingsInt(ms_defaultSettings[3], 30));
|
||||
l_settings.Add(new CVRSettingsBool(ms_defaultSettings[4], false));
|
||||
l_settings.Add(new CVRSettingsBool(ms_defaultSettings[5], false));
|
||||
l_settings.Add(new CVRSettingsBool(ms_defaultSettings[6], false));
|
||||
l_settings.Add(new CVRSettingsInt(ms_defaultSettings[7], 0));
|
||||
l_settings.Add(new CVRSettingsBool(ms_defaultSettings[8], false));
|
||||
l_settings.Add(new CVRSettingsInt(ms_defaultSettings[9], 0));
|
||||
l_settings.Add(new CVRSettingsInt(ms_defaultSettings[10], 0));
|
||||
l_settings.Add(new CVRSettingsInt(ms_defaultSettings[11], 0));
|
||||
}
|
||||
|
||||
// Changes events
|
||||
|
||||
// Enable tracking
|
||||
__instance.settingBoolChanged.AddListener((name, value) =>
|
||||
{
|
||||
if(name == ms_defaultSettings[0])
|
||||
{
|
||||
Settings.Reload();
|
||||
ms_enabled = value;
|
||||
EnabledChange?.Invoke();
|
||||
}
|
||||
});
|
||||
|
||||
// Desktop offsets
|
||||
__instance.settingIntChanged.AddListener((name, value) =>
|
||||
{
|
||||
for(int i=1; i <= 3; i++)
|
||||
for(int i = 1; i <= 3; i++)
|
||||
{
|
||||
if(name == ms_defaultSettings[i])
|
||||
{
|
||||
Settings.Reload();
|
||||
ms_desktopOffset = new Vector3(
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[1]),
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[2]),
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[3])
|
||||
) * 0.01f;
|
||||
DesktopOffsetChange?.Invoke();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Fingers tracking only
|
||||
__instance.settingBoolChanged.AddListener((name, value) =>
|
||||
{
|
||||
if(name == ms_defaultSettings[4])
|
||||
{
|
||||
Settings.Reload();
|
||||
ms_fingersOnly = value;
|
||||
FingersOnlyChange?.Invoke();
|
||||
}
|
||||
});
|
||||
|
||||
// Model visibility
|
||||
__instance.settingBoolChanged.AddListener((name, value) =>
|
||||
{
|
||||
if(name == ms_defaultSettings[5])
|
||||
{
|
||||
ms_modelVisibility = value;
|
||||
ModelVisibilityChange?.Invoke();
|
||||
}
|
||||
});
|
||||
|
||||
// HMD mode
|
||||
__instance.settingBoolChanged.AddListener((name, value) =>
|
||||
{
|
||||
if(name == ms_defaultSettings[6])
|
||||
{
|
||||
ms_hmdMode = value;
|
||||
HmdModeChange?.Invoke();
|
||||
}
|
||||
});
|
||||
|
||||
// Root angle
|
||||
__instance.settingIntChanged.AddListener((name, value) =>
|
||||
{
|
||||
if(name == ms_defaultSettings[7])
|
||||
{
|
||||
ms_rootAngle = value;
|
||||
RootAngleChange?.Invoke();
|
||||
}
|
||||
});
|
||||
|
||||
// Head attach
|
||||
__instance.settingBoolChanged.AddListener((name, value) =>
|
||||
{
|
||||
if(name == ms_defaultSettings[8])
|
||||
{
|
||||
ms_headAttach = value;
|
||||
HeadAttachChange?.Invoke();
|
||||
}
|
||||
});
|
||||
|
||||
// Head offset
|
||||
__instance.settingIntChanged.AddListener((name, value) =>
|
||||
{
|
||||
for(int i = 9; i <= 11; i++)
|
||||
{
|
||||
if(name == ms_defaultSettings[i])
|
||||
{
|
||||
ms_headOffset = new Vector3(
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[9]),
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[10]),
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[11])
|
||||
) * 0.01f;
|
||||
HeadOffsetChange?.Invoke();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ms_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
static public void Reload()
|
||||
{
|
||||
ms_enabled = ABI_RC.Core.Savior.MetaPort.Instance.settings.GetSettingsBool(ms_defaultSettings[0]);
|
||||
ms_desktopOffsetX = ABI_RC.Core.Savior.MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[1]) * 0.01f;
|
||||
ms_desktopOffsetY = ABI_RC.Core.Savior.MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[2]) * 0.01f;
|
||||
ms_desktopOffsetZ = ABI_RC.Core.Savior.MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[3]) * 0.01f;
|
||||
ms_fingersOnly = ABI_RC.Core.Savior.MetaPort.Instance.settings.GetSettingsBool(ms_defaultSettings[4]);
|
||||
ms_enabled = MetaPort.Instance.settings.GetSettingsBool(ms_defaultSettings[0]);
|
||||
ms_desktopOffset = new Vector3(
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[1]),
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[2]),
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[3])
|
||||
) * 0.01f;
|
||||
ms_fingersOnly = MetaPort.Instance.settings.GetSettingsBool(ms_defaultSettings[4]);
|
||||
ms_modelVisibility = MetaPort.Instance.settings.GetSettingsBool(ms_defaultSettings[5]);
|
||||
ms_hmdMode = MetaPort.Instance.settings.GetSettingsBool(ms_defaultSettings[6]);
|
||||
ms_rootAngle = MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[7]);
|
||||
ms_headAttach = MetaPort.Instance.settings.GetSettingsBool(ms_defaultSettings[8]);
|
||||
ms_headOffset = new Vector3(
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[9]),
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[10]),
|
||||
MetaPort.Instance.settings.GetSettingInt(ms_defaultSettings[11])
|
||||
) * 0.01f;
|
||||
}
|
||||
|
||||
public static bool Enabled
|
||||
|
@ -96,22 +199,39 @@
|
|||
get => ms_enabled;
|
||||
}
|
||||
|
||||
public static float DesktopOffsetX
|
||||
public static Vector3 DesktopOffset
|
||||
{
|
||||
get => ms_desktopOffsetX;
|
||||
}
|
||||
public static float DesktopOffsetY
|
||||
{
|
||||
get => ms_desktopOffsetY;
|
||||
}
|
||||
public static float DesktopOffsetZ
|
||||
{
|
||||
get => ms_desktopOffsetZ;
|
||||
get => ms_desktopOffset;
|
||||
}
|
||||
|
||||
public static bool FingersOnly
|
||||
{
|
||||
get => ms_fingersOnly;
|
||||
}
|
||||
|
||||
public static bool ModelVisibility
|
||||
{
|
||||
get => ms_modelVisibility;
|
||||
}
|
||||
|
||||
public static bool HmdMode
|
||||
{
|
||||
get => ms_hmdMode;
|
||||
}
|
||||
|
||||
public static float RootAngle
|
||||
{
|
||||
get => ms_rootAngle;
|
||||
}
|
||||
|
||||
public static bool HeadAttach
|
||||
{
|
||||
get => ms_headAttach;
|
||||
}
|
||||
|
||||
public static Vector3 HeadOffset
|
||||
{
|
||||
get => ms_headOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue