mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 10:29:22 +00:00
Moved UI settings to MelonPreferences
(I missed two lunches because of this)
This commit is contained in:
parent
47298675e0
commit
d04cf447fd
13 changed files with 595 additions and 320 deletions
|
@ -71,9 +71,6 @@ namespace ml_fpt
|
|||
PlayerSetup.Instance._trackerManager.trackers[m_hipsTrackerIndex].ShowLine(false);
|
||||
CVR_InteractableManager.enableInteractions = true;
|
||||
|
||||
if(PlayerSetup.Instance._avatar.GetComponent<ABI.CCK.Components.CVRAvatar>().avatarUsesAdvancedSettings)
|
||||
PlayerSetup.Instance.LoadCurrentAvatarSettingsDefault();
|
||||
|
||||
Reset();
|
||||
|
||||
ShowHudNotification("Calibration completed");
|
||||
|
@ -92,7 +89,7 @@ namespace ml_fpt
|
|||
|
||||
ViewManager.Instance.gameMenuView.Listener.ReadyForBindings += () =>
|
||||
{
|
||||
ViewManager.Instance.gameMenuView.View.RegisterForEvent("MelonMod_Action_FPT_Calibrate", new System.Action(this.StartCalibration));
|
||||
ViewManager.Instance.gameMenuView.View.RegisterForEvent("MelonMod_FPT_Action_Calibrate", new System.Action(this.StartCalibration));
|
||||
};
|
||||
|
||||
ViewManager.Instance.gameMenuView.Listener.FinishLoad += (_) =>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle("FourPointTracking")]
|
||||
[assembly: AssemblyVersion("1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0")]
|
||||
[assembly: AssemblyVersion("1.0.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.1")]
|
||||
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_fpt.FourPointTracking), "FourPointTracking", "1.0.0", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_fpt.FourPointTracking), "FourPointTracking", "1.0.1", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
|
||||
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
|
@ -14,7 +14,7 @@ namespace ml_fpt
|
|||
|
||||
try
|
||||
{
|
||||
Stream l_libraryStream = l_assembly.GetManifestResourceStream(l_assemblyName + "." + p_name);
|
||||
Stream l_libraryStream = l_assembly.GetManifestResourceStream(l_assemblyName + ".resources." + p_name);
|
||||
StreamReader l_streadReader = new StreamReader(l_libraryStream);
|
||||
l_result = l_streadReader.ReadToEnd();
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
var l_block = document.createElement("fpt_block");
|
||||
l_block.innerHTML = `
|
||||
<h2>4-Point Tracking</h2>
|
||||
<div class="action-btn" onclick="engine.trigger('MelonMod_Action_FPT_Calibrate');"><img src=\"gfx/recalibrate.svg\">Calibrate</div>
|
||||
`;
|
||||
document.getElementById('settings-implementation').appendChild(l_block);
|
|
@ -84,7 +84,7 @@
|
|||
<Compile Include="Scripts.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="menu.js" />
|
||||
<EmbeddedResource Include="resources\menu.js" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
|
|
8
ml_fpt/resources/menu.js
Normal file
8
ml_fpt/resources/menu.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
var l_block = document.createElement('div');
|
||||
l_block.innerHTML = `
|
||||
<h2>4-Point Tracking</h2>
|
||||
<div class ="action-btn" onclick="engine.trigger('MelonMod_FPT_Action_Calibrate');"><img src="gfx/recalibrate.svg">Calibrate</div>
|
||||
`;
|
||||
document.getElementById('settings-implementation').appendChild(l_block);
|
||||
}
|
|
@ -28,7 +28,7 @@ namespace ml_lme
|
|||
|
||||
DependenciesHandler.ExtractDependencies();
|
||||
|
||||
Settings.Init(HarmonyInstance);
|
||||
Settings.Init();
|
||||
Settings.EnabledChange += this.OnSettingsEnableChange;
|
||||
Settings.DesktopOffsetChange += this.OnSettingsDesktopOffsetChange;
|
||||
Settings.FingersOnlyChange += this.OnSettingsFingersOptionChange;
|
||||
|
@ -60,7 +60,6 @@ namespace ml_lme
|
|||
new HarmonyLib.HarmonyMethod(typeof(LeapMotionExtension).GetMethod(nameof(OnAvatarClear_Postfix), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic))
|
||||
);
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitForMainMenuView());
|
||||
MelonLoader.MelonCoroutines.Start(CreateTrackingObjects());
|
||||
}
|
||||
|
||||
|
@ -98,29 +97,11 @@ namespace ml_lme
|
|||
m_leapControllerModel.transform.localRotation = Quaternion.identity;
|
||||
}
|
||||
|
||||
Settings.Reload();
|
||||
|
||||
OnSettingsEnableChange();
|
||||
OnSettingsFingersOptionChange();
|
||||
OnSettingsModelVisibilityChange();
|
||||
OnSettingsTrackingModeChange();
|
||||
OnSettingsHeadAttachChange(); // Includes offsets and parenting
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator WaitForMainMenuView()
|
||||
{
|
||||
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.FinishLoad += (_) =>
|
||||
{
|
||||
ViewManager.Instance.gameMenuView.View.ExecuteScript(Scripts.GetEmbeddedScript("menu.js"));
|
||||
ViewManager.Instance.RequestCurrentSettings();
|
||||
};
|
||||
OnSettingsEnableChange(Settings.Enabled);
|
||||
OnSettingsFingersOptionChange(Settings.FingersOnly);
|
||||
OnSettingsModelVisibilityChange(Settings.ModelVisibility);
|
||||
OnSettingsTrackingModeChange(Settings.TrackingMode);
|
||||
OnSettingsHeadAttachChange(Settings.HeadAttach); // Includes offsets and parenting
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
|
@ -157,9 +138,9 @@ namespace ml_lme
|
|||
}
|
||||
|
||||
// Settings changes
|
||||
void OnSettingsEnableChange()
|
||||
void OnSettingsEnableChange(bool p_state)
|
||||
{
|
||||
if(Settings.Enabled)
|
||||
if(p_state)
|
||||
{
|
||||
m_leapController.StartConnection();
|
||||
UpdateDeviceTrackingMode();
|
||||
|
@ -168,40 +149,40 @@ namespace ml_lme
|
|||
m_leapController.StopConnection();
|
||||
|
||||
if(m_leapTracked != null)
|
||||
m_leapTracked.SetEnabled(Settings.Enabled);
|
||||
m_leapTracked.SetEnabled(p_state);
|
||||
}
|
||||
|
||||
void OnSettingsDesktopOffsetChange()
|
||||
void OnSettingsDesktopOffsetChange(Vector3 p_offset)
|
||||
{
|
||||
if((m_leapTrackingRoot != null) && !Settings.HeadAttach)
|
||||
{
|
||||
if(!PlayerSetup.Instance._inVr)
|
||||
m_leapTrackingRoot.transform.localPosition = Settings.DesktopOffset * PlayerSetup.Instance.vrCameraRig.transform.localScale.x;
|
||||
m_leapTrackingRoot.transform.localPosition = p_offset * PlayerSetup.Instance.vrCameraRig.transform.localScale.x;
|
||||
else
|
||||
m_leapTrackingRoot.transform.localPosition = Settings.DesktopOffset;
|
||||
m_leapTrackingRoot.transform.localPosition = p_offset;
|
||||
}
|
||||
}
|
||||
|
||||
void OnSettingsFingersOptionChange()
|
||||
void OnSettingsFingersOptionChange(bool p_state)
|
||||
{
|
||||
if(m_leapTracked != null)
|
||||
m_leapTracked.SetFingersOnly(Settings.FingersOnly);
|
||||
m_leapTracked.SetFingersOnly(p_state);
|
||||
}
|
||||
|
||||
void OnSettingsModelVisibilityChange()
|
||||
void OnSettingsModelVisibilityChange(bool p_state)
|
||||
{
|
||||
if(m_leapControllerModel != null)
|
||||
m_leapControllerModel.SetActive(Settings.ModelVisibility);
|
||||
m_leapControllerModel.SetActive(p_state);
|
||||
}
|
||||
|
||||
void OnSettingsTrackingModeChange()
|
||||
void OnSettingsTrackingModeChange(Settings.LeapTrackingMode p_mode)
|
||||
{
|
||||
if(Settings.Enabled && (m_leapController != null))
|
||||
UpdateDeviceTrackingMode();
|
||||
|
||||
if(m_leapControllerModel != null)
|
||||
{
|
||||
switch(Settings.TrackingMode)
|
||||
switch(p_mode)
|
||||
{
|
||||
case Settings.LeapTrackingMode.Screentop:
|
||||
m_leapControllerModel.transform.localRotation = Quaternion.Euler(0f, 0f, 180f);
|
||||
|
@ -216,17 +197,17 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
|
||||
void OnSettingsRootAngleChange()
|
||||
void OnSettingsRootAngleChange(float p_angle)
|
||||
{
|
||||
if(m_leapTrackingRoot != null)
|
||||
m_leapTrackingRoot.transform.localRotation = Quaternion.Euler(Settings.RootAngle, 0f, 0f);
|
||||
m_leapTrackingRoot.transform.localRotation = Quaternion.Euler(p_angle, 0f, 0f);
|
||||
}
|
||||
|
||||
void OnSettingsHeadAttachChange()
|
||||
void OnSettingsHeadAttachChange(bool p_state)
|
||||
{
|
||||
if(m_leapTrackingRoot != null)
|
||||
{
|
||||
if(Settings.HeadAttach)
|
||||
if(p_state)
|
||||
{
|
||||
if(!PlayerSetup.Instance._inVr)
|
||||
{
|
||||
|
@ -261,14 +242,14 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
|
||||
void OnSettingsHeadOffsetChange()
|
||||
void OnSettingsHeadOffsetChange(Vector3 p_offset)
|
||||
{
|
||||
if((m_leapTrackingRoot != null) && Settings.HeadAttach)
|
||||
{
|
||||
if(!PlayerSetup.Instance._inVr)
|
||||
m_leapTrackingRoot.transform.localPosition = Settings.HeadOffset * PlayerSetup.Instance.vrCameraRig.transform.localScale.x;
|
||||
m_leapTrackingRoot.transform.localPosition = p_offset * PlayerSetup.Instance.vrCameraRig.transform.localScale.x;
|
||||
else
|
||||
m_leapTrackingRoot.transform.localPosition = Settings.HeadOffset;
|
||||
m_leapTrackingRoot.transform.localPosition = p_offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,7 +319,6 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void OnAvatarSetup_Postfix(ref PlayerSetup __instance)
|
||||
{
|
||||
if((__instance != null) && (__instance == PlayerSetup.Instance))
|
||||
|
@ -354,7 +334,7 @@ namespace ml_lme
|
|||
m_leapTracked.SetHands(m_leapHands[0].transform, m_leapHands[1].transform);
|
||||
m_leapTracked.SetFingersOnly(Settings.FingersOnly);
|
||||
|
||||
OnSettingsHeadAttachChange();
|
||||
OnSettingsHeadAttachChange(Settings.HeadAttach);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle("LeapMotionExtension")]
|
||||
[assembly: AssemblyVersion("1.1.1")]
|
||||
[assembly: AssemblyFileVersion("1.1.1")]
|
||||
[assembly: AssemblyVersion("1.1.2")]
|
||||
[assembly: AssemblyFileVersion("1.1.2")]
|
||||
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.1.1", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.1.2", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
|
||||
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace ml_lme
|
|||
|
||||
try
|
||||
{
|
||||
Stream l_libraryStream = l_assembly.GetManifestResourceStream(l_assemblyName + "." + p_name);
|
||||
Stream l_libraryStream = l_assembly.GetManifestResourceStream(l_assemblyName + ".resources." + p_name);
|
||||
StreamReader l_streadReader = new StreamReader(l_libraryStream);
|
||||
l_result = l_streadReader.ReadToEnd();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Core.InteractionSystem;
|
||||
using cohtml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ml_lme
|
||||
|
@ -15,18 +17,18 @@ namespace ml_lme
|
|||
|
||||
enum ModSetting
|
||||
{
|
||||
InteractionLeapMotionTracking,
|
||||
InteractionLeapMotionTrackingDesktopX,
|
||||
InteractionLeapMotionTrackingDesktopY,
|
||||
InteractionLeapMotionTrackingDesktopZ,
|
||||
InteractionLeapMotionTrackingFingersOnly,
|
||||
InteractionLeapMotionTrackingModel,
|
||||
InteractionLeapMotionTrackingMode,
|
||||
InteractionLeapMotionTrackingAngle,
|
||||
InteractionLeapMotionTrackingHead,
|
||||
InteractionLeapMotionTrackingHeadX,
|
||||
InteractionLeapMotionTrackingHeadY,
|
||||
InteractionLeapMotionTrackingHeadZ
|
||||
Enabled,
|
||||
DesktopX,
|
||||
DesktopY,
|
||||
DesktopZ,
|
||||
FingersOnly,
|
||||
Model,
|
||||
Mode,
|
||||
Angle,
|
||||
Head,
|
||||
HeadX,
|
||||
HeadY,
|
||||
HeadZ
|
||||
};
|
||||
|
||||
static bool ms_enabled = false;
|
||||
|
@ -38,155 +40,195 @@ namespace ml_lme
|
|||
static bool ms_headAttach = false;
|
||||
static Vector3 ms_headOffset = new Vector3(0f, -0.3f, 0.15f);
|
||||
|
||||
static bool ms_initialized = false;
|
||||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
||||
static public event Action EnabledChange;
|
||||
static public event Action DesktopOffsetChange;
|
||||
static public event Action FingersOnlyChange;
|
||||
static public event Action ModelVisibilityChange;
|
||||
static public event Action TrackingModeChange;
|
||||
static public event Action RootAngleChange;
|
||||
static public event Action HeadAttachChange;
|
||||
static public event Action HeadOffsetChange;
|
||||
static public event Action<bool> EnabledChange;
|
||||
static public event Action<Vector3> DesktopOffsetChange;
|
||||
static public event Action<bool> FingersOnlyChange;
|
||||
static public event Action<bool> ModelVisibilityChange;
|
||||
static public event Action<LeapTrackingMode> TrackingModeChange;
|
||||
static public event Action<float> RootAngleChange;
|
||||
static public event Action<bool> HeadAttachChange;
|
||||
static public event Action<Vector3> HeadOffsetChange;
|
||||
|
||||
public static void Init(HarmonyLib.Harmony p_instance)
|
||||
public static void Init()
|
||||
{
|
||||
p_instance.Patch(
|
||||
typeof(CVRSettings).GetMethod(nameof(CVRSettings.LoadSerializedSettings)),
|
||||
new HarmonyLib.HarmonyMethod(typeof(Settings).GetMethod(nameof(LoadSerializedSettings_Prefix), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)),
|
||||
null
|
||||
);
|
||||
ms_category = MelonLoader.MelonPreferences.CreateCategory("LME");
|
||||
|
||||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>();
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.Enabled.ToString(), ms_enabled));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.DesktopX.ToString(), 0));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.DesktopY.ToString(), -45));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.DesktopZ.ToString(), 30));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.FingersOnly.ToString(), ms_modelVisibility));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.Model.ToString(), ms_modelVisibility));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.Mode.ToString(), (int)ms_trackingMode));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.Angle.ToString(), 0));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.Head.ToString(), ms_headAttach));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.HeadX.ToString(), 0));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.HeadY.ToString(), -30));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.HeadZ.ToString(), 15));
|
||||
|
||||
Load();
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitMainMenuUi());
|
||||
}
|
||||
|
||||
static void LoadSerializedSettings_Prefix(ref CVRSettings __instance)
|
||||
static System.Collections.IEnumerator WaitMainMenuUi()
|
||||
{
|
||||
if(!ms_initialized && (__instance != null))
|
||||
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 += () =>
|
||||
{
|
||||
var l_settings = HarmonyLib.Traverse.Create(__instance)?.Field("_settings")?.GetValue<System.Collections.Generic.List<ABI_RC.Core.Savior.CVRSettingsValue>>();
|
||||
if(l_settings != null)
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("MelonMod_LME_Call_InpToggle", new Action<string, string>(OnToggleUpdate));
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("MelonMod_LME_Call_InpSlider", new Action<string, string>(OnSliderUpdate));
|
||||
ViewManager.Instance.gameMenuView.View.BindCall("MelonMod_LME_Call_InpDropdown", new Action<string, string>(OnDropdownUpdate));
|
||||
};
|
||||
ViewManager.Instance.gameMenuView.Listener.FinishLoad += (_) =>
|
||||
{
|
||||
ViewManager.Instance.gameMenuView.View.ExecuteScript(Scripts.GetEmbeddedScript("menu.js"));
|
||||
foreach(var l_entry in ms_entries)
|
||||
ViewManager.Instance.gameMenuView.View.TriggerEvent("updateModSetting", l_entry.DisplayName, l_entry.GetValueAsString());
|
||||
};
|
||||
}
|
||||
|
||||
static void Load()
|
||||
{
|
||||
ms_enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
|
||||
ms_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;
|
||||
ms_fingersOnly = (bool)ms_entries[(int)ModSetting.FingersOnly].BoxedValue;
|
||||
ms_modelVisibility = (bool)ms_entries[(int)ModSetting.Model].BoxedValue;
|
||||
ms_trackingMode = (LeapTrackingMode)(int)ms_entries[(int)ModSetting.Mode].BoxedValue;
|
||||
ms_rootAngle = (int)ms_entries[(int)ModSetting.Angle].BoxedValue;
|
||||
ms_headAttach = (bool)ms_entries[(int)ModSetting.Head].BoxedValue;
|
||||
ms_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;
|
||||
}
|
||||
|
||||
static void OnToggleUpdate(string p_name, string p_value)
|
||||
{
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting))
|
||||
{
|
||||
switch(l_setting)
|
||||
{
|
||||
l_settings.Add(new CVRSettingsBool(ModSetting.InteractionLeapMotionTracking.ToString(), false));
|
||||
l_settings.Add(new CVRSettingsInt(ModSetting.InteractionLeapMotionTrackingDesktopX.ToString(), 0));
|
||||
l_settings.Add(new CVRSettingsInt(ModSetting.InteractionLeapMotionTrackingDesktopY.ToString(), -45));
|
||||
l_settings.Add(new CVRSettingsInt(ModSetting.InteractionLeapMotionTrackingDesktopZ.ToString(), 30));
|
||||
l_settings.Add(new CVRSettingsBool(ModSetting.InteractionLeapMotionTrackingFingersOnly.ToString(), false));
|
||||
l_settings.Add(new CVRSettingsBool(ModSetting.InteractionLeapMotionTrackingModel.ToString(), false));
|
||||
l_settings.Add(new CVRSettingsInt(ModSetting.InteractionLeapMotionTrackingMode.ToString(), 1));
|
||||
l_settings.Add(new CVRSettingsInt(ModSetting.InteractionLeapMotionTrackingAngle.ToString(), 0));
|
||||
l_settings.Add(new CVRSettingsBool(ModSetting.InteractionLeapMotionTrackingHead.ToString(), false));
|
||||
l_settings.Add(new CVRSettingsInt(ModSetting.InteractionLeapMotionTrackingHeadX.ToString(), 0));
|
||||
l_settings.Add(new CVRSettingsInt(ModSetting.InteractionLeapMotionTrackingHeadY.ToString(), 0));
|
||||
l_settings.Add(new CVRSettingsInt(ModSetting.InteractionLeapMotionTrackingHeadZ.ToString(), 0));
|
||||
case ModSetting.Enabled:
|
||||
{
|
||||
ms_enabled = bool.Parse(p_value);
|
||||
EnabledChange?.Invoke(ms_enabled);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.FingersOnly:
|
||||
{
|
||||
ms_fingersOnly = bool.Parse(p_value);
|
||||
FingersOnlyChange?.Invoke(ms_fingersOnly);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Model:
|
||||
{
|
||||
ms_modelVisibility = bool.Parse(p_value);
|
||||
ModelVisibilityChange?.Invoke(ms_modelVisibility);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Head:
|
||||
{
|
||||
ms_headAttach = bool.Parse(p_value);
|
||||
HeadAttachChange?.Invoke(ms_headAttach);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
__instance.settingBoolChanged.AddListener((name, value) =>
|
||||
{
|
||||
if(Enum.TryParse(name, out ModSetting l_setting))
|
||||
{
|
||||
switch(l_setting)
|
||||
{
|
||||
case ModSetting.InteractionLeapMotionTracking:
|
||||
{
|
||||
ms_enabled = value;
|
||||
EnabledChange?.Invoke();
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.InteractionLeapMotionTrackingFingersOnly:
|
||||
{
|
||||
ms_fingersOnly = value;
|
||||
FingersOnlyChange?.Invoke();
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.InteractionLeapMotionTrackingModel:
|
||||
{
|
||||
ms_modelVisibility = value;
|
||||
ModelVisibilityChange?.Invoke();
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.InteractionLeapMotionTrackingHead:
|
||||
{
|
||||
ms_headAttach = value;
|
||||
HeadAttachChange?.Invoke();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
__instance.settingIntChanged.AddListener((name, value) =>
|
||||
{
|
||||
if(Enum.TryParse(name, out ModSetting l_setting))
|
||||
{
|
||||
switch(l_setting)
|
||||
{
|
||||
case ModSetting.InteractionLeapMotionTrackingDesktopX:
|
||||
case ModSetting.InteractionLeapMotionTrackingDesktopY:
|
||||
case ModSetting.InteractionLeapMotionTrackingDesktopZ:
|
||||
{
|
||||
ms_desktopOffset = new Vector3(
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingDesktopX.ToString()),
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingDesktopY.ToString()),
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingDesktopZ.ToString())
|
||||
) * 0.01f;
|
||||
DesktopOffsetChange?.Invoke();
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.InteractionLeapMotionTrackingMode:
|
||||
{
|
||||
ms_trackingMode = (LeapTrackingMode)value;
|
||||
TrackingModeChange?.Invoke();
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.InteractionLeapMotionTrackingAngle:
|
||||
{
|
||||
ms_rootAngle = value;
|
||||
RootAngleChange?.Invoke();
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.InteractionLeapMotionTrackingHeadX:
|
||||
case ModSetting.InteractionLeapMotionTrackingHeadY:
|
||||
case ModSetting.InteractionLeapMotionTrackingHeadZ:
|
||||
{
|
||||
ms_headOffset = new Vector3(
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingHeadX.ToString()),
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingHeadY.ToString()),
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingHeadZ.ToString())
|
||||
) * 0.01f;
|
||||
HeadOffsetChange?.Invoke();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ms_initialized = true;
|
||||
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);
|
||||
}
|
||||
}
|
||||
|
||||
static public void Reload()
|
||||
static void OnSliderUpdate(string p_name, string p_value)
|
||||
{
|
||||
ms_enabled = MetaPort.Instance.settings.GetSettingsBool(ModSetting.InteractionLeapMotionTracking.ToString());
|
||||
ms_desktopOffset = new Vector3(
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingDesktopX.ToString()),
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingDesktopY.ToString()),
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingDesktopZ.ToString())
|
||||
) * 0.01f;
|
||||
ms_fingersOnly = MetaPort.Instance.settings.GetSettingsBool(ModSetting.InteractionLeapMotionTrackingFingersOnly.ToString());
|
||||
ms_modelVisibility = MetaPort.Instance.settings.GetSettingsBool(ModSetting.InteractionLeapMotionTrackingModel.ToString());
|
||||
ms_trackingMode = (LeapTrackingMode)MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingMode.ToString());
|
||||
ms_rootAngle = MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingAngle.ToString());
|
||||
ms_headAttach = MetaPort.Instance.settings.GetSettingsBool(ModSetting.InteractionLeapMotionTrackingHead.ToString());
|
||||
ms_headOffset = new Vector3(
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingHeadX.ToString()),
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingHeadY.ToString()),
|
||||
MetaPort.Instance.settings.GetSettingInt(ModSetting.InteractionLeapMotionTrackingHeadZ.ToString())
|
||||
) * 0.01f;
|
||||
if(Enum.TryParse(p_name, out ModSetting l_setting))
|
||||
{
|
||||
switch(l_setting)
|
||||
{
|
||||
case ModSetting.DesktopX:
|
||||
{
|
||||
ms_desktopOffset.x = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffsetChange?.Invoke(ms_desktopOffset);
|
||||
}
|
||||
break;
|
||||
case ModSetting.DesktopY:
|
||||
{
|
||||
ms_desktopOffset.y = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffsetChange?.Invoke(ms_desktopOffset);
|
||||
}
|
||||
break;
|
||||
case ModSetting.DesktopZ:
|
||||
{
|
||||
ms_desktopOffset.z = int.Parse(p_value) * 0.01f;
|
||||
DesktopOffsetChange?.Invoke(ms_desktopOffset);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Angle:
|
||||
{
|
||||
ms_rootAngle = int.Parse(p_value);
|
||||
RootAngleChange?.Invoke(ms_rootAngle);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.HeadX:
|
||||
{
|
||||
ms_headOffset.x = int.Parse(p_value) * 0.01f;
|
||||
HeadOffsetChange?.Invoke(ms_headOffset);
|
||||
}
|
||||
break;
|
||||
case ModSetting.HeadY:
|
||||
{
|
||||
ms_headOffset.y = int.Parse(p_value) * 0.01f;
|
||||
HeadOffsetChange?.Invoke(ms_headOffset);
|
||||
}
|
||||
break;
|
||||
case ModSetting.HeadZ:
|
||||
{
|
||||
ms_headOffset.z = int.Parse(p_value) * 0.01f;
|
||||
HeadOffsetChange?.Invoke(ms_headOffset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = int.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.Mode:
|
||||
{
|
||||
ms_trackingMode = (LeapTrackingMode)int.Parse(p_value);
|
||||
TrackingModeChange?.Invoke(ms_trackingMode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Enabled
|
||||
|
|
106
ml_lme/menu.js
106
ml_lme/menu.js
|
@ -1,106 +0,0 @@
|
|||
var l_block = document.createElement("lme_block");
|
||||
l_block.innerHTML = `
|
||||
<h2>Leap Motion tracking</h2>
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Enable tracking: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTracking" class ="inp_toggle" data-current="false" data-saveOnChange="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Tracking mode: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTrackingMode" class ="inp_dropdown" data-options="0:Screentop,1:Desktop,2:HMD" data-current="1" data-saveOnChange="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Desktop offset X: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTrackingDesktopX" class ="inp_slider" data-min="-100" data-max="100" data-current="0" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Desktop offset Y: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTrackingDesktopY" class ="inp_slider" data-min="-100" data-max="100" data-current="-45" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Desktop offset Z: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTrackingDesktopZ" class ="inp_slider" data-min="-100" data-max="100" data-current="30" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Attach to head: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTrackingHead" class ="inp_toggle" data-current="false" data-saveOnChange="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Head offset X: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTrackingHeadX" class ="inp_slider" data-min="-100" data-max="100" data-current="0" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Head offset Y: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTrackingHeadY" class ="inp_slider" data-min="-100" data-max="100" data-current="-30" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Head offset Z: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTrackingHeadZ" class ="inp_slider" data-min="-100" data-max="100" data-current="15" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Offset angle: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTrackingAngle" class ="inp_slider" data-min="-180" data-max="180" data-current="0" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Fingers tracking only: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTrackingFingersOnly" class ="inp_toggle" data-current="false" data-saveOnChange="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Model visibility: </div>
|
||||
<div class ="option-input">
|
||||
<div id="InteractionLeapMotionTrackingModel" class ="inp_toggle" data-current="false" data-saveOnChange="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('settings-implementation').appendChild(l_block);
|
||||
|
||||
// Update toggles in new menu block
|
||||
var l_toggles = l_block.querySelectorAll('.inp_toggle');
|
||||
for (var i = 0; i < l_toggles.length; i++) {
|
||||
settings[settings.length] = new inp_toggle(l_toggles[i]);
|
||||
}
|
||||
|
||||
//Update dropdowns in new menu block
|
||||
var l_dropdowns = l_block.querySelectorAll('.inp_dropdown');
|
||||
for (var i = 0; i < l_dropdowns.length; i++) {
|
||||
settings[settings.length] = new inp_dropdown(l_dropdowns[i]);
|
||||
}
|
||||
|
||||
// Update sliders in new menu block
|
||||
var l_sliders = l_block.querySelectorAll('.inp_slider');
|
||||
for (var i = 0; i < l_sliders.length; i++) {
|
||||
settings[settings.length] = new inp_slider(l_sliders[i]);
|
||||
}
|
|
@ -133,7 +133,7 @@
|
|||
<EmbeddedResource Include="resources\leapmotion_controller.asset" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="menu.js" />
|
||||
<EmbeddedResource Include="resources\menu.js" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
|
|
360
ml_lme/resources/menu.js
Normal file
360
ml_lme/resources/menu.js
Normal file
|
@ -0,0 +1,360 @@
|
|||
// Add settings
|
||||
var g_modSettings = [];
|
||||
|
||||
engine.on('updateModSetting', function (_name, _value) {
|
||||
for (var i = 0; i < g_modSettings.length; i++) {
|
||||
if (g_modSettings[i].name == _name) {
|
||||
g_modSettings[i].updateValue(_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Modified from original `inp` types
|
||||
function inp_toggle_mod(_obj) {
|
||||
this.obj = _obj;
|
||||
this.value = _obj.getAttribute('data-current');
|
||||
this.name = _obj.id;
|
||||
this.type = _obj.getAttribute('data-type');
|
||||
|
||||
var self = this;
|
||||
|
||||
this.mouseDown = function (_e) {
|
||||
self.value = self.value == "True" ? "False" : "True";
|
||||
self.updateState();
|
||||
}
|
||||
|
||||
this.updateState = function () {
|
||||
self.obj.classList.remove("checked");
|
||||
if (self.value == "True") {
|
||||
self.obj.classList.add("checked");
|
||||
}
|
||||
|
||||
engine.call('MelonMod_LME_Call_InpToggle', self.name, self.value);
|
||||
}
|
||||
|
||||
_obj.addEventListener('mousedown', this.mouseDown);
|
||||
|
||||
this.getValue = function () {
|
||||
return self.value;
|
||||
}
|
||||
|
||||
this.updateValue = function (value) {
|
||||
self.value = value;
|
||||
|
||||
self.obj.classList.remove("checked");
|
||||
if (self.value == "True") {
|
||||
self.obj.classList.add("checked");
|
||||
}
|
||||
}
|
||||
|
||||
this.updateValue(this.value);
|
||||
|
||||
return {
|
||||
name: this.name,
|
||||
value: this.getValue,
|
||||
updateValue: this.updateValue
|
||||
}
|
||||
}
|
||||
|
||||
function inp_slider_mod(_obj) {
|
||||
this.obj = _obj;
|
||||
this.minValue = parseFloat(_obj.getAttribute('data-min'));
|
||||
this.maxValue = parseFloat(_obj.getAttribute('data-max'));
|
||||
this.percent = 0;
|
||||
this.value = parseFloat(_obj.getAttribute('data-current'));
|
||||
this.dragActive = false;
|
||||
this.name = _obj.id;
|
||||
this.type = _obj.getAttribute('data-type');
|
||||
this.caption = _obj.getAttribute('data-caption');
|
||||
this.continuousUpdate = _obj.getAttribute('data-continuousUpdate');
|
||||
|
||||
var self = this;
|
||||
|
||||
this.valueBar = document.createElement('div');
|
||||
this.valueBar.className = 'valueBar';
|
||||
this.valueBar.setAttribute('style', 'width: ' + (((this.value - this.minValue) / (this.maxValue - this.minValue)) * 100) + '%;');
|
||||
this.obj.appendChild(this.valueBar);
|
||||
|
||||
this.valueLabel = document.createElement('div');
|
||||
this.valueLabel.className = 'valueLabel';
|
||||
this.valueLabel.innerHTML = this.caption + Math.round(this.value);
|
||||
this.obj.appendChild(this.valueLabel);
|
||||
|
||||
this.mouseDown = function (_e) {
|
||||
self.dragActive = true;
|
||||
self.mouseMove(_e, false);
|
||||
}
|
||||
|
||||
this.mouseMove = function (_e, _write) {
|
||||
if (self.dragActive) {
|
||||
var rect = _obj.getBoundingClientRect();
|
||||
var start = rect.left;
|
||||
var end = rect.right;
|
||||
self.percent = Math.min(Math.max((_e.clientX - start) / rect.width, 0), 1);
|
||||
var value = self.percent;
|
||||
value *= (self.maxValue - self.minValue);
|
||||
value += self.minValue;
|
||||
self.value = Math.round(value);
|
||||
|
||||
self.valueBar.setAttribute('style', 'width: ' + (self.percent * 100) + '%;');
|
||||
self.valueLabel.innerHTML = self.caption + self.value;
|
||||
|
||||
if (_write === true || self.continuousUpdate == 'true') {
|
||||
engine.call('MelonMod_LME_Call_InpSlider', self.name, "" + self.value);
|
||||
self.displayImperial();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.mouseUp = function (_e) {
|
||||
self.mouseMove(_e, true);
|
||||
self.dragActive = false;
|
||||
}
|
||||
|
||||
_obj.addEventListener('mousedown', this.mouseDown);
|
||||
document.addEventListener('mousemove', this.mouseMove);
|
||||
document.addEventListener('mouseup', this.mouseUp);
|
||||
|
||||
this.getValue = function () {
|
||||
return self.value;
|
||||
}
|
||||
|
||||
this.updateValue = function (value) {
|
||||
self.value = Math.round(value);
|
||||
self.percent = (self.value - self.minValue) / (self.maxValue - self.minValue);
|
||||
self.valueBar.setAttribute('style', 'width: ' + (self.percent * 100) + '%;');
|
||||
self.valueLabel.innerHTML = self.caption + self.value;
|
||||
self.displayImperial();
|
||||
}
|
||||
|
||||
this.displayImperial = function () {
|
||||
var displays = document.querySelectorAll('.imperialDisplay');
|
||||
for (var i = 0; i < displays.length; i++) {
|
||||
var binding = displays[i].getAttribute('data-binding');
|
||||
if (binding == self.name) {
|
||||
var realFeet = ((self.value * 0.393700) / 12);
|
||||
var feet = Math.floor(realFeet);
|
||||
var inches = Math.floor((realFeet - feet) * 12);
|
||||
displays[i].innerHTML = feet + "'" + inches + '''';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
name: this.name,
|
||||
value: this.getValue,
|
||||
updateValue: this.updateValue
|
||||
}
|
||||
}
|
||||
|
||||
function inp_dropdown_mod(_obj) {
|
||||
this.obj = _obj;
|
||||
this.value = _obj.getAttribute('data-current');
|
||||
this.options = _obj.getAttribute('data-options').split(',');
|
||||
this.name = _obj.id;
|
||||
this.opened = false;
|
||||
this.keyValue = [];
|
||||
this.type = _obj.getAttribute('data-type');
|
||||
|
||||
this.optionElements = [];
|
||||
|
||||
var self = this;
|
||||
|
||||
this.SelectValue = function (_e) {
|
||||
self.value = _e.target.getAttribute('data-key');
|
||||
self.valueElement.innerHTML = _e.target.getAttribute('data-value');
|
||||
self.globalClose();
|
||||
|
||||
engine.call('MelonMod_LME_Call_InpDropdown', self.name, self.value);
|
||||
}
|
||||
|
||||
this.openClick = function (_e) {
|
||||
if (self.obj.classList.contains('open')) {
|
||||
self.obj.classList.remove('open');
|
||||
self.list.setAttribute('style', 'display: none;');
|
||||
} else {
|
||||
self.obj.classList.add('open');
|
||||
self.list.setAttribute('style', 'display: block;');
|
||||
self.opened = true;
|
||||
window.setTimeout(function () { self.opened = false; }, 10);
|
||||
}
|
||||
}
|
||||
|
||||
this.globalClose = function (_e) {
|
||||
if (self.opened) return;
|
||||
self.obj.classList.remove('open');
|
||||
self.list.setAttribute('style', 'display: none;');
|
||||
}
|
||||
|
||||
this.list = document.createElement('div');
|
||||
this.list.className = 'valueList';
|
||||
|
||||
this.updateOptions = function () {
|
||||
self.list.innerHTML = "";
|
||||
for (var i = 0; i < self.options.length; i++) {
|
||||
self.optionElements[i] = document.createElement('div');
|
||||
self.optionElements[i].className = 'listValue';
|
||||
var valuePair = Array.isArray(self.options[i]) ? self.options[i] : self.options[i].split(':');
|
||||
var key = "";
|
||||
var value = "";
|
||||
if (valuePair.length == 1) {
|
||||
key = valuePair[0];
|
||||
value = valuePair[0];
|
||||
} else {
|
||||
key = valuePair[0];
|
||||
value = valuePair[1];
|
||||
}
|
||||
self.keyValue[key] = value;
|
||||
self.optionElements[i].innerHTML = value;
|
||||
self.optionElements[i].setAttribute('data-value', value);
|
||||
self.optionElements[i].setAttribute('data-key', key);
|
||||
self.list.appendChild(self.optionElements[i]);
|
||||
self.optionElements[i].addEventListener('mousedown', self.SelectValue);
|
||||
}
|
||||
|
||||
self.valueElement.innerHTML = self.keyValue[self.value];
|
||||
}
|
||||
|
||||
this.valueElement = document.createElement('div');
|
||||
this.valueElement.className = 'dropdown-value';
|
||||
|
||||
this.updateOptions();
|
||||
|
||||
this.obj.appendChild(this.valueElement);
|
||||
this.obj.appendChild(this.list);
|
||||
this.valueElement.addEventListener('mousedown', this.openClick);
|
||||
document.addEventListener('mousedown', this.globalClose);
|
||||
|
||||
this.getValue = function () {
|
||||
return self.value;
|
||||
}
|
||||
|
||||
this.updateValue = function (value) {
|
||||
self.value = value;
|
||||
self.valueElement.innerHTML = self.keyValue[value];
|
||||
}
|
||||
|
||||
this.setOptions = function (options) {
|
||||
self.options = options;
|
||||
}
|
||||
|
||||
return {
|
||||
name: this.name,
|
||||
value: this.getValue,
|
||||
updateValue: this.updateValue,
|
||||
updateOptions: this.updateOptions,
|
||||
setOptions: this.setOptions
|
||||
}
|
||||
}
|
||||
|
||||
// Add own menu
|
||||
{
|
||||
var l_block = document.createElement('div');
|
||||
l_block.innerHTML = `
|
||||
<h2>Leap Motion tracking</h2>
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Enable tracking: </div>
|
||||
<div class ="option-input">
|
||||
<div id="Enabled" class ="inp_toggle" data-current="false" data-saveOnChange="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Tracking mode: </div>
|
||||
<div class ="option-input">
|
||||
<div id="Mode" class ="inp_dropdown" data-options="0:Screentop,1:Desktop,2:HMD" data-current="1" data-saveOnChange="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Desktop offset X: </div>
|
||||
<div class ="option-input">
|
||||
<div id="DesktopX" class ="inp_slider" data-min="-100" data-max="100" data-current="0" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Desktop offset Y: </div>
|
||||
<div class ="option-input">
|
||||
<div id="DesktopY" class ="inp_slider" data-min="-100" data-max="100" data-current="-45" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Desktop offset Z: </div>
|
||||
<div class ="option-input">
|
||||
<div id="DesktopZ" class ="inp_slider" data-min="-100" data-max="100" data-current="30" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Attach to head: </div>
|
||||
<div class ="option-input">
|
||||
<div id="Head" class ="inp_toggle" data-current="false" data-saveOnChange="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Head offset X: </div>
|
||||
<div class ="option-input">
|
||||
<div id="HeadX" class ="inp_slider" data-min="-100" data-max="100" data-current="0" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Head offset Y: </div>
|
||||
<div class ="option-input">
|
||||
<div id="HeadY" class ="inp_slider" data-min="-100" data-max="100" data-current="-30" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Head offset Z: </div>
|
||||
<div class ="option-input">
|
||||
<div id="HeadZ" class ="inp_slider" data-min="-100" data-max="100" data-current="15" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Offset angle: </div>
|
||||
<div class ="option-input">
|
||||
<div id="Angle" class ="inp_slider" data-min="-180" data-max="180" data-current="0" data-saveOnChange="true" data-continuousUpdate="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Fingers tracking only: </div>
|
||||
<div class ="option-input">
|
||||
<div id="FingersOnly" class ="inp_toggle" data-current="false" data-saveOnChange="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Model visibility: </div>
|
||||
<div class ="option-input">
|
||||
<div id="Model" class ="inp_toggle" data-current="false" data-saveOnChange="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('settings-implementation').appendChild(l_block);
|
||||
|
||||
// Update toggles in new menu block
|
||||
var l_toggles = l_block.querySelectorAll('.inp_toggle');
|
||||
for (var i = 0; i < l_toggles.length; i++) {
|
||||
g_modSettings[g_modSettings.length] = new inp_toggle_mod(l_toggles[i]);
|
||||
}
|
||||
|
||||
//Update dropdowns in new menu block
|
||||
var l_dropdowns = l_block.querySelectorAll('.inp_dropdown');
|
||||
for (var i = 0; i < l_dropdowns.length; i++) {
|
||||
g_modSettings[g_modSettings.length] = new inp_dropdown_mod(l_dropdowns[i]);
|
||||
}
|
||||
|
||||
// Update sliders in new menu block
|
||||
var l_sliders = l_block.querySelectorAll('.inp_slider');
|
||||
for (var i = 0; i < l_sliders.length; i++) {
|
||||
g_modSettings[g_modSettings.length] = new inp_slider_mod(l_sliders[i]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue