New mod: AvatarMotionTweaker

This commit is contained in:
SDraw 2022-08-13 17:00:04 +03:00
parent a6539f46be
commit c4a92bf451
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
23 changed files with 609 additions and 23 deletions

View file

@ -1,9 +1,10 @@
Merged set of MelonLoader mods for ChilloutVR.
**State table for game build 2022r166:**
**State table for game build 2022r166p1:**
| Full name | Short name | Latest version | Available in [CVRMA](https://github.com/knah/CVRMelonAssistant) | Current Status | Notes |
|-----------|------------|----------------|-----------------------------------------------------------------|----------------|-------|
| Avatar Change Info | ml_aci | 1.0.1 | Pending approval | Working |
| Avatar Motion Tweaker | ml_amt | 1.0.0 | Pending approval | Working |
| Desktop Reticle Switch | ml_drs | 1.0.0 | Yes | Working |
| Four Point Tracking | ml_fpt | 1.0.1 | Pending approval | Working |
| Leap Motion Extension | ml_lme | 1.1.2 | Pending approval | Working |
| Leap Motion Extension | ml_lme | 1.1.3 | Pending approval | Working |

BIN
ml_amt/.github/img_02.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
ml_amt/.github/img_03.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
ml_amt/.github/img_04.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

BIN
ml_amt/.github/img_05.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
ml_amt/.github/img_06.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

BIN
ml_amt/.github/img_07.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

BIN
ml_amt/.github/img_08.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

61
ml_amt/Main.cs Normal file
View file

@ -0,0 +1,61 @@
using ABI_RC.Core.Player;
namespace ml_amt
{
public class AvatarMotionTweaker : MelonLoader.MelonMod
{
static AvatarMotionTweaker ms_instance = null;
MotionTweaker m_localTweaker = null;
public override void OnApplicationStart()
{
ms_instance = this;
Settings.Init();
Settings.CrouchLimitChange += this.OnCrouchLimitChange;
HarmonyInstance.Patch(
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)),
null,
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnAvatarClear_Postfix), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static))
);
HarmonyInstance.Patch(
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar)),
null,
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnLocalAvatarSetup_Postfix), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static))
);
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
}
System.Collections.IEnumerator WaitForLocalPlayer()
{
while(PlayerSetup.Instance == null)
yield return null;
m_localTweaker = PlayerSetup.Instance.gameObject.AddComponent<MotionTweaker>();
}
void OnCrouchLimitChange(float p_value)
{
if(m_localTweaker != null)
m_localTweaker.SetCrouchLimit(p_value);
}
static void OnLocalAvatarSetup_Postfix() => ms_instance?.OnLocalAvatarSetup();
void OnLocalAvatarSetup()
{
if((m_localTweaker != null) && !PlayerSetup.Instance._inVr)
m_localTweaker.OnAvatarSetup();
}
static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear();
void OnAvatarClear()
{
if(m_localTweaker != null)
m_localTweaker.OnAvatarClear();
}
}
}

139
ml_amt/MotionTweaker.cs Normal file
View file

@ -0,0 +1,139 @@
using ABI_RC.Core.Player;
using System.Collections.Generic;
using UnityEngine;
namespace ml_amt
{
class MotionTweaker : MonoBehaviour
{
enum ParameterType
{
Upright
}
enum ParameterSyncType
{
Local,
Synced
}
struct AdditionalParameterInfo
{
public ParameterType m_type;
public ParameterSyncType m_sync;
public string m_name;
public int m_hash; // For local only
}
static readonly Vector4 ms_pointVector = new Vector4(0f, 0f, 0f, 1f);
RootMotion.FinalIK.VRIK m_vrIk = null;
bool m_standing = true;
float m_currentUpright = 1f;
float m_locomotionWeight = 1f;
float m_crouchLimit = 0.65f;
bool m_customCrouchLimit = false;
readonly List<AdditionalParameterInfo> m_parameters = null;
public MotionTweaker()
{
m_parameters = new List<AdditionalParameterInfo>();
}
void Start()
{
if(PlayerSetup.Instance._inVr)
PlayerSetup.Instance.avatarSetupCompleted.AddListener(this.OnAvatarSetup);
}
void Update()
{
// Update upright
Matrix4x4 l_hmdMatrix = PlayerSetup.Instance.transform.GetMatrix().inverse * (PlayerSetup.Instance._inVr ? PlayerSetup.Instance.vrHeadTracker.transform.GetMatrix() : PlayerSetup.Instance.desktopCameraRig.transform.GetMatrix());
float l_currentHeight = Mathf.Clamp((l_hmdMatrix * ms_pointVector).y, 0f, float.MaxValue);
float l_avatarViewHeight = Mathf.Clamp(PlayerSetup.Instance.GetViewPointHeight() * PlayerSetup.Instance._avatar.transform.localScale.y, 0f, float.MaxValue);
m_currentUpright = Mathf.Clamp((((l_currentHeight > 0f) && (l_avatarViewHeight > 0f)) ? (l_currentHeight / l_avatarViewHeight) : 0f), 0f, 1f);
m_standing = (m_currentUpright > m_crouchLimit);
if((m_vrIk != null) && m_vrIk.enabled && !PlayerSetup.Instance._movementSystem.sitting && (PlayerSetup.Instance._movementSystem.movementVector.magnitude <= Mathf.Epsilon) && !PlayerSetup.Instance.fullBodyActive)
{
m_locomotionWeight = Mathf.Lerp(m_locomotionWeight, m_standing ? 1f : 0f, 0.5f);
m_vrIk.solver.locomotion.weight = m_locomotionWeight;
}
if(m_parameters.Count > 0)
{
foreach(AdditionalParameterInfo l_param in m_parameters)
{
switch(l_param.m_type)
{
case ParameterType.Upright:
{
switch(l_param.m_sync)
{
case ParameterSyncType.Local:
PlayerSetup.Instance._animator.SetFloat(l_param.m_hash, m_currentUpright);
break;
case ParameterSyncType.Synced:
PlayerSetup.Instance.changeAnimatorParam(l_param.m_name, m_currentUpright);
break;
}
}
break;
}
}
}
}
public void OnAvatarClear()
{
m_vrIk = null;
m_standing = true;
m_parameters.Clear();
m_locomotionWeight = 1f;
m_crouchLimit = 0.65f;
m_customCrouchLimit = false;
}
public void OnAvatarSetup()
{
m_vrIk = PlayerSetup.Instance._avatar.GetComponent<RootMotion.FinalIK.VRIK>();
// Parse animator parameters
AnimatorControllerParameter[] l_params = PlayerSetup.Instance._animator.parameters;
ParameterType[] l_enumParams = (ParameterType[])System.Enum.GetValues(typeof(ParameterType));
foreach(var l_param in l_params)
{
foreach(var l_enumParam in l_enumParams)
{
if(l_param.name.Contains(l_enumParam.ToString()) && (m_parameters.FindIndex(p => p.m_type == l_enumParam) == -1))
{
bool l_local = (l_param.name[0] == '#');
m_parameters.Add(new AdditionalParameterInfo
{
m_type = l_enumParam,
m_sync = (l_local ? ParameterSyncType.Local : ParameterSyncType.Synced),
m_name = l_param.name,
m_hash = (l_local ? l_param.nameHash : 0)
});
break;
}
}
}
Transform l_customLimit = PlayerSetup.Instance._avatar.transform.Find("CrouchLimit");
m_customCrouchLimit = (l_customLimit != null);
m_crouchLimit = m_customCrouchLimit ? Mathf.Clamp(l_customLimit.localPosition.y, 0f, 1f) : Settings.CrouchLimit;
}
public void SetCrouchLimit(float p_value)
{
if(!m_customCrouchLimit)
m_crouchLimit = Mathf.Clamp(p_value, 0f, 1f);
}
}
}

View file

@ -0,0 +1,10 @@
using System.Reflection;
[assembly: AssemblyTitle("AvatarMotionTweaker")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.0.0", "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)]

38
ml_amt/README.md Normal file
View file

@ -0,0 +1,38 @@
# Avatar Motion Tweaker
This mod adds `Upright` parameter for usage in AAS animator and allows disabling legs autostep upon reaching specific `Upright` value.
![](.github/img_01.png)
# Installation
* Install [latest MelonLoader](https://github.com/LavaGang/MelonLoader)
* Get [latest release DLL](../../../releases/latest):
* Put `ml_amt.dll` in `Mods` folder of game
# Usage
Available mod's settings in `Settings - Implementation - Avatar Motion Tweaker`:
* **Legs locomotion upright limit:** defines upright limit of legs autostep. If HMD tracking goes below set limit, legs autostep is disabled. Default value - 65.
* Limit can be overrided by avatar. For this avatar has to have child gameobject with name `CrouchLimit` and its Y-axis location will be used as limit, should be in range [0.0, 1.0].
Available additional parameters for AAS animator:
* **`Upright`:** defines linear coefficient between current viewpoint height and avatar's viewpoint height. Range - [0.0,1.0] (0.0 - floor, 1.0 - full standing).
* Note: can be set as local-only (not synced) if starts with `#` character.
## Example of usage in AAS animator for mixed desktop and VR
* To differentiate between desktop and VR players use `CVR Parameter Stream` component on avatar's root gameobject. As example, `InVR` and `InFBT` are boolean typed animator parameters:
![](.github/img_02.png)
* Add additional transitions between standing, crouching and proning blend trees:
![](.github/img_03.png)
* Add conditions for new VR transitions:
* Standing -> Crouching:
![](.github/img_04.png)
* Crouching -> Standing:
![](.github/img_05.png)
* Crouching -> Proning:
![](.github/img_06.png)
* Proning -> Crouching:
![](.github/img_07.png)
* Add condition check for all desktop transitions:
![](.github/img_08.png)
# Notes
* Sometimes after restoring legs autostep avatar's torso shakes, currently investigating solution.

26
ml_amt/Scripts.cs Normal file
View file

@ -0,0 +1,26 @@
using System;
using System.IO;
using System.Reflection;
namespace ml_amt
{
static class Scripts
{
public static string GetEmbeddedScript(string p_name)
{
string l_result = "";
Assembly l_assembly = Assembly.GetExecutingAssembly();
string l_assemblyName = l_assembly.GetName().Name;
try
{
Stream l_libraryStream = l_assembly.GetManifestResourceStream(l_assemblyName + ".resources." + p_name);
StreamReader l_streadReader = new StreamReader(l_libraryStream);
l_result = l_streadReader.ReadToEnd();
}
catch(Exception) { }
return l_result;
}
}
}

83
ml_amt/Settings.cs Normal file
View file

@ -0,0 +1,83 @@
using ABI_RC.Core.InteractionSystem;
using cohtml;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace ml_amt
{
static class Settings
{
enum ModSetting
{
CrouchLimit = 0
};
static float ms_crouchLimit = 0.65f;
static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
static public event Action<float> CrouchLimitChange;
public static void Init()
{
ms_category = MelonLoader.MelonPreferences.CreateCategory("AMT");
ms_entries = new List<MelonLoader.MelonPreferences_Entry>();
ms_entries.Add(ms_category.CreateEntry(ModSetting.CrouchLimit.ToString(), 65));
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_AMT_Call_InpSlider", new Action<string, string>(OnSliderUpdate));
};
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("updateModSettingAMT", l_entry.DisplayName, l_entry.GetValueAsString());
};
}
static void Load()
{
ms_crouchLimit = ((int)ms_entries[(int)ModSetting.CrouchLimit].BoxedValue) * 0.01f;
}
static void OnSliderUpdate(string p_name, string p_value)
{
if(Enum.TryParse(p_name, out ModSetting l_setting))
{
switch(l_setting)
{
case ModSetting.CrouchLimit:
{
ms_crouchLimit = ((int)ms_entries[(int)ModSetting.CrouchLimit].BoxedValue) * 0.01f;
CrouchLimitChange?.Invoke(ms_crouchLimit);
} break;
}
ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value);
}
}
public static float CrouchLimit
{
get => ms_crouchLimit;
}
}
}

13
ml_amt/Utils.cs Normal file
View file

@ -0,0 +1,13 @@
using UnityEngine;
namespace ml_amt
{
static class Utils
{
// Extensions
public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false)
{
return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one);
}
}
}

87
ml_amt/ml_amt.csproj Normal file
View file

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{74E13D02-A506-41A2-A2CF-C8B3D5B1E452}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ml_amt</RootNamespace>
<AssemblyName>ml_amt</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Games\Steam\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="cohtml.Net">
<Private>False</Private>
</Reference>
<Reference Include="Cohtml.Runtime">
<Private>False</Private>
</Reference>
<Reference Include="MelonLoader, Version=0.5.4.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine.AnimationModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MotionTweaker.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scripts.cs" />
<Compile Include="Settings.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="resources\menu.js" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /y "$(TargetPath)" "C:\Games\Steam\common\ChilloutVR\Mods\"</PostBuildEvent>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ReferencePath>C:\Games\Steam\common\ChilloutVR\MelonLoader\;C:\Games\Steam\common\ChilloutVR\ChilloutVR_Data\Managed\</ReferencePath>
</PropertyGroup>
</Project>

122
ml_amt/resources/menu.js Normal file
View file

@ -0,0 +1,122 @@
// Add settings
var g_modSettingsAMT = [];
engine.on('updateModSettingAMT', function (_name, _value) {
for (var i = 0; i < g_modSettingsAMT.length; i++) {
if (g_modSettingsAMT[i].name == _name) {
g_modSettingsAMT[i].updateValue(_value);
break;
}
}
});
// Modified from original `inp` types, because I have no js knowledge to hook stuff
function inp_slider_mod_amt(_obj, _callbackName) {
this.obj = _obj;
this.callbackName = _callbackName;
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');
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;
engine.call(self.callbackName, 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 + "&apos;" + inches + '&apos;&apos;';
}
}
}
return {
name: this.name,
value: this.getValue,
updateValue: this.updateValue
}
}
// Add own menu
{
var l_block = document.createElement('div');
l_block.innerHTML = `
<h2>Avatar Motion Tweaker</h2>
<div class ="row-wrapper">
<div class ="option-caption">Legs locomotion upright limit: </div>
<div class ="option-input">
<div id="CrouchLimit" class ="inp_slider" data-min="0" data-max="100" data-current="65"></div>
</div>
</div>
`;
document.getElementById('settings-implementation').appendChild(l_block);
// Update sliders in new menu block
var l_sliders = l_block.querySelectorAll('.inp_slider');
for (var i = 0; i < l_sliders.length; i++) {
g_modSettingsAMT[g_modSettingsAMT.length] = new inp_slider_mod_amt(l_sliders[i], 'MelonMod_AMT_Call_InpSlider');
}
}

View file

@ -1,10 +1,10 @@
using System.Reflection;
[assembly: AssemblyTitle("LeapMotionExtension")]
[assembly: AssemblyVersion("1.1.2")]
[assembly: AssemblyFileVersion("1.1.2")]
[assembly: AssemblyVersion("1.1.3")]
[assembly: AssemblyFileVersion("1.1.3")]
[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.1.2", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.1.3", "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)]

View file

@ -94,7 +94,7 @@ namespace ml_lme
{
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());
ViewManager.Instance.gameMenuView.View.TriggerEvent("updateModSettingLME", l_entry.DisplayName, l_entry.GetValueAsString());
};
}

View file

@ -137,6 +137,6 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /y "$(TargetPath)" "C:\Games\Steam\common\ChilloutVR\Mods\</PostBuildEvent>
<PostBuildEvent>copy /y "$(TargetPath)" "C:\Games\Steam\common\ChilloutVR\Mods\"</PostBuildEvent>
</PropertyGroup>
</Project>

View file

@ -1,17 +1,17 @@
// Add settings
var g_modSettings = [];
var g_modSettingsLME = [];
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);
engine.on('updateModSettingLME', function (_name, _value) {
for (var i = 0; i < g_modSettingsLME.length; i++) {
if (g_modSettingsLME[i].name == _name) {
g_modSettingsLME[i].updateValue(_value);
break;
}
}
});
// Modified from original `inp` types, because I have no js knowledge to hook stuff
function inp_toggle_mod(_obj, _callbackName) {
function inp_toggle_mod_lme(_obj, _callbackName) {
this.obj = _obj;
this.callbackName = _callbackName;
this.value = _obj.getAttribute('data-current');
@ -58,7 +58,7 @@ function inp_toggle_mod(_obj, _callbackName) {
}
}
function inp_slider_mod(_obj, _callbackName) {
function inp_slider_mod_lme(_obj, _callbackName) {
this.obj = _obj;
this.callbackName = _callbackName;
this.minValue = parseFloat(_obj.getAttribute('data-min'));
@ -147,7 +147,7 @@ function inp_slider_mod(_obj, _callbackName) {
}
}
function inp_dropdown_mod(_obj, _callbackName) {
function inp_dropdown_mod_lme(_obj, _callbackName) {
this.obj = _obj;
this.callbackName = _callbackName;
this.value = _obj.getAttribute('data-current');
@ -342,19 +342,19 @@ function inp_dropdown_mod(_obj, _callbackName) {
// 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], 'MelonMod_LME_Call_InpToggle');
g_modSettingsLME[g_modSettingsLME.length] = new inp_toggle_mod_lme(l_toggles[i], 'MelonMod_LME_Call_InpToggle');
}
// 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], 'MelonMod_LME_Call_InpSlider');
g_modSettingsLME[g_modSettingsLME.length] = new inp_slider_mod_lme(l_sliders[i], 'MelonMod_LME_Call_InpSlider');
}
//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], 'MelonMod_LME_Call_InpDropdown');
g_modSettingsLME[g_modSettingsLME.length] = new inp_dropdown_mod_lme(l_dropdowns[i], 'MelonMod_LME_Call_InpDropdown');
}
}

View file

@ -11,7 +11,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_aci", "ml_aci\ml_aci.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_drs", "ml_drs\ml_drs.csproj", "{06CD5155-4459-48C3-8A53-E0B91136351B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_aap", "ml_aap\ml_aap.csproj", "{96D1D71A-23A4-4A0F-9736-25E711BA48F9}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ml_amt", "ml_amt\ml_amt.csproj", "{74E13D02-A506-41A2-A2CF-C8B3D5B1E452}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -35,10 +35,10 @@ Global
{06CD5155-4459-48C3-8A53-E0B91136351B}.Debug|x64.Build.0 = Debug|x64
{06CD5155-4459-48C3-8A53-E0B91136351B}.Release|x64.ActiveCfg = Release|x64
{06CD5155-4459-48C3-8A53-E0B91136351B}.Release|x64.Build.0 = Release|x64
{96D1D71A-23A4-4A0F-9736-25E711BA48F9}.Debug|x64.ActiveCfg = Debug|x64
{96D1D71A-23A4-4A0F-9736-25E711BA48F9}.Debug|x64.Build.0 = Debug|x64
{96D1D71A-23A4-4A0F-9736-25E711BA48F9}.Release|x64.ActiveCfg = Release|x64
{96D1D71A-23A4-4A0F-9736-25E711BA48F9}.Release|x64.Build.0 = Release|x64
{74E13D02-A506-41A2-A2CF-C8B3D5B1E452}.Debug|x64.ActiveCfg = Debug|x64
{74E13D02-A506-41A2-A2CF-C8B3D5B1E452}.Debug|x64.Build.0 = Debug|x64
{74E13D02-A506-41A2-A2CF-C8B3D5B1E452}.Release|x64.ActiveCfg = Release|x64
{74E13D02-A506-41A2-A2CF-C8B3D5B1E452}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE