From e994a280465928a39759d44179e9fa0b5cd9d17f Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Sat, 10 Sep 2022 05:24:56 -0500
Subject: [PATCH 01/41] Initial commit
---
.gitattributes | 2 +
.gitignore | 398 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 400 insertions(+)
create mode 100644 .gitattributes
create mode 100644 .gitignore
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..dfe0770
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# Auto detect text files and perform LF normalization
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..426d76d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,398 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
From 7332bc73b5fc1ffe609de259fa1f83dc9bbf513b Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Sat, 10 Sep 2022 05:29:42 -0500
Subject: [PATCH 02/41] initial upload
---
LICENSE | 21 ++++++++++
MenuScalePatch/Main.cs | 48 +++++++++++++++++++++++
MenuScalePatch/MenuScalePatch.csproj | 43 ++++++++++++++++++++
MenuScalePatch/MenuScalePatch.sln | 25 ++++++++++++
MenuScalePatch/Properties/AssemblyInfo.cs | 30 ++++++++++++++
MenuScalePatch/format.json | 23 +++++++++++
README.md | 30 ++++++++++++++
7 files changed, 220 insertions(+)
create mode 100644 LICENSE
create mode 100644 MenuScalePatch/Main.cs
create mode 100644 MenuScalePatch/MenuScalePatch.csproj
create mode 100644 MenuScalePatch/MenuScalePatch.sln
create mode 100644 MenuScalePatch/Properties/AssemblyInfo.cs
create mode 100644 MenuScalePatch/format.json
create mode 100644 README.md
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..262b1ec
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2022 NotAKidoS
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
new file mode 100644
index 0000000..2a50bfe
--- /dev/null
+++ b/MenuScalePatch/Main.cs
@@ -0,0 +1,48 @@
+using ABI_RC.Core.InteractionSystem;
+using ABI_RC.Core.Player;
+using ABI_RC.Core.Savior;
+using cohtml;
+using HarmonyLib;
+using MelonLoader;
+using UnityEngine;
+
+
+namespace MenuScalePatch;
+
+public class MenuScalePatch : MelonMod
+{
+ [HarmonyPatch]
+ private class HarmonyPatches
+ {
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
+ private static void SetQMScale(ref CohtmlView ___quickMenu, ref float ____scaleFactor)
+ {
+ //correct quickmenu - pretty much needsQuickmenuPositionUpdate()
+ Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
+ ___quickMenu.transform.eulerAngles = new Vector3(rotationPivot.eulerAngles.x, rotationPivot.eulerAngles.y, rotationPivot.eulerAngles.z);
+ ___quickMenu.transform.position = rotationPivot.position + rotationPivot.forward * 1f * ____scaleFactor;
+ }
+
+ //ViewManager.SetScale runs once a second when it should only run when aspect ratio changes...? bug
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(ViewManager), "SetScale")]
+ private static void SetMMScale(ref ViewManager __instance, ref bool ___needsMenuPositionUpdate, ref float ___scaleFactor, ref float ___cachedScreenAspectRatio, ref float ___cachedAvatarHeight)
+ {
+ //correct main menu - pretty much UpdateMenuPosition()
+ Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
+ float num = Mathf.Abs(rotationPivot.localRotation.eulerAngles.z);
+ float settingsFloat = MetaPort.Instance.settings.GetSettingsFloat("GeneralMinimumMenuTilt");
+ if (MetaPort.Instance.isUsingVr && (num <= settingsFloat || num >= 360f - settingsFloat))
+ {
+ __instance.gameObject.transform.rotation = Quaternion.LookRotation(rotationPivot.forward, Vector3.up);
+ }
+ else
+ {
+ __instance.gameObject.transform.eulerAngles = new Vector3(rotationPivot.eulerAngles.x, rotationPivot.eulerAngles.y, rotationPivot.eulerAngles.z);
+ }
+ __instance.gameObject.transform.position = rotationPivot.position + rotationPivot.forward * 1f * ___scaleFactor;
+ ___needsMenuPositionUpdate = false;
+ }
+ }
+}
diff --git a/MenuScalePatch/MenuScalePatch.csproj b/MenuScalePatch/MenuScalePatch.csproj
new file mode 100644
index 0000000..7c80c7d
--- /dev/null
+++ b/MenuScalePatch/MenuScalePatch.csproj
@@ -0,0 +1,43 @@
+
+
+
+
+ net472
+ enable
+ latest
+ false
+
+
+
+
+ C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\0Harmony.dll
+
+
+ C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll
+
+
+ C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll
+
+
+ C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\SteamVR.dll
+
+
+ C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll
+
+
+ C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.InputLegacyModule.dll
+
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.PhysicsModule.dll
+
+
+
+
+
+
+
+
+
diff --git a/MenuScalePatch/MenuScalePatch.sln b/MenuScalePatch/MenuScalePatch.sln
new file mode 100644
index 0000000..fe3a351
--- /dev/null
+++ b/MenuScalePatch/MenuScalePatch.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.2.32630.192
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvatarScaleUpdater", "AvatarScaleUpdater.csproj", "{1B069D34-0AD6-43A4-A116-C325F37D33A6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1B069D34-0AD6-43A4-A116-C325F37D33A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1B069D34-0AD6-43A4-A116-C325F37D33A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1B069D34-0AD6-43A4-A116-C325F37D33A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1B069D34-0AD6-43A4-A116-C325F37D33A6}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {67335521-EBA9-453E-A0E2-3DE0E3A86EBF}
+ EndGlobalSection
+EndGlobal
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..2150156
--- /dev/null
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -0,0 +1,30 @@
+using MelonLoader;
+using MenuScalePatch.Properties;
+using System.Reflection;
+
+
+[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
+[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
+[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
+[assembly: AssemblyTitle(nameof(MenuScalePatch))]
+[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
+[assembly: AssemblyProduct(nameof(MenuScalePatch))]
+
+[assembly: MelonInfo(
+ typeof(MenuScalePatch.MenuScalePatch),
+ nameof(MenuScalePatch),
+ AssemblyInfoParams.Version,
+ AssemblyInfoParams.Author,
+ downloadLink: "https://github.com/NotAKidOnSteam/MenuScalePatch"
+)]
+
+[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
+[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
+[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
+
+namespace MenuScalePatch.Properties;
+internal static class AssemblyInfoParams
+{
+ public const string Version = "1.0.0";
+ public const string Author = "NotAKidoS";
+}
\ No newline at end of file
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
new file mode 100644
index 0000000..cca9289
--- /dev/null
+++ b/MenuScalePatch/format.json
@@ -0,0 +1,23 @@
+{
+ "_id": -1,
+ "name": "MenuScalePatch",
+ "modversion": "1.0.0",
+ "gameversion": "2022r168",
+ "loaderversion": "0.5.4",
+ "modtype": "Mod",
+ "author": "NotAKidoS",
+ "description": "Corrects MM and QM position when avatar is scaled.",
+ "searchtags": [
+ "menu",
+ "scale",
+ "avatarscale",
+ "slider"
+ ],
+ "requirements": [
+ "None"
+ ],
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r1/MenuScalePatch.dll",
+ "sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
+ "changelog": "Initial Release.",
+ "embedcolor": "804221"
+}
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..8d86a35
--- /dev/null
+++ b/README.md
@@ -0,0 +1,30 @@
+# MenuScalePatch
+
+just updates the menu position when the game detects a change in avatar scale
+
+im sure itll be patched officially before cvrmg verifies it lol
+
+---
+
+Here is the block of text where I tell you this mod is not affiliated or endorsed by ABI.
+https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games
+
+> I am not affiliated with ABI in any official capacity, these mods are not endorsed or outright permitted by ABI and are subject to scrutiny.
+
+> Neither I nor these mods are in any way affiliated with Alpha Blend Interactive and/or ChilloutVR. Using these modifications might cause issues with the performance, security or stability of the game. Use at your own risk.
+
+> Any modifications that are not approved can get your ABI account terminated and such this modification is following the "modding guidelines" at the best it could be.
+> They reserve the right to punish users using my mod.
+> If you are scared of using modifications in your game do not install mods.
+
+> I do not affiliate ABI and the mod is not supported by ABI.
+
+> Me and this modification are in no affiliation with ABI and not supported by ABI.
+
+> This mod is not affiliated with Alpha Blend Interactive. The mod comes with no warranty. Use at your own risk, as I am not responsible for any misuse.
+
+> I'm not affiliated with Alpha Blend Interactive and this mod is not officially supported by the game.
+
+> When releasing mods to the public, it is required to state, that the mod authors and modification are in no affiliation with ABI and not supported by ABI. :trollface:
+
+> i ran out of places to steal disclaimers from
From 9c8f5d1915fa6c53eaf24bb9c2b574acf433fe7c Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Sat, 10 Sep 2022 05:33:22 -0500
Subject: [PATCH 03/41] Update README.md
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 8d86a35..bda1baf 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,8 @@ just updates the menu position when the game detects a change in avatar scale
im sure itll be patched officially before cvrmg verifies it lol
+https://user-images.githubusercontent.com/37721153/189479474-41e93dff-a695-42f2-9d20-6a895a723039.mp4
+
---
Here is the block of text where I tell you this mod is not affiliated or endorsed by ABI.
From f9e15701ae8a533c6b44b1bc632e749fe9039e43 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Sat, 10 Sep 2022 21:25:29 -0500
Subject: [PATCH 04/41] lots of tweaks
main menu fix for cvr bug + vr
quickmenu no longer scales in vr
main menu no longer uses player rotation
settings page, with refresh on click
added collision scaling
added optional removal of skin width from character controller- it is what makes avatars in this game hover
mix in Allow Smaller Playercollider toggle to fully touch the ground (**can cause console errors**)
---
MenuScalePatch/Main.cs | 120 ++++++++++++++++++++++-----
MenuScalePatch/MenuScalePatch.csproj | 3 +
2 files changed, 104 insertions(+), 19 deletions(-)
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
index 2a50bfe..9c9ea08 100644
--- a/MenuScalePatch/Main.cs
+++ b/MenuScalePatch/Main.cs
@@ -1,6 +1,7 @@
using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
+using ABI_RC.Systems.MovementSystem;
using cohtml;
using HarmonyLib;
using MelonLoader;
@@ -11,37 +12,118 @@ namespace MenuScalePatch;
public class MenuScalePatch : MelonMod
{
+
+ private static MelonPreferences_Category m_categoryMenuScalePatch;
+ private static MelonPreferences_Entry m_entryScaleCollision;
+ private static MelonPreferences_Entry m_entrySkinWidthLimit;
+
+ public override void OnApplicationStart()
+ {
+ m_categoryMenuScalePatch = MelonPreferences.CreateCategory(nameof(MenuScalePatch));
+ m_entryScaleCollision = m_categoryMenuScalePatch.CreateEntry("Scale Collision", false, description: "Should we scale player collision alongside avatar?");
+ //m_entrySmallHeightLimit = m_categoryMenuScalePatch.CreateEntry("Small Height Limit", true, description: "Prevents avatar collision height from going below 0.3f. Disabling this can lead to errors if avatar is too small.");
+ m_entrySkinWidthLimit = m_categoryMenuScalePatch.CreateEntry("No Skin Width", false, description: "Enabling this allows your feet to touch the ground properly, but may also make it easier for you to get stuck on collision.");
+
+ m_categoryMenuScalePatch.SaveToFile(false);
+ m_entryScaleCollision.OnValueChangedUntyped += UpdateSettings;
+ m_entrySkinWidthLimit.OnValueChangedUntyped += UpdateSettings;
+
+ UpdateSettings();
+ }
+
+ private static void UpdateSettings()
+ {
+ HarmonyPatches._controllerScaleCollision = m_entryScaleCollision.Value;
+
+ if (!MovementSystem.Instance) return;
+
+ CharacterController controller = Traverse.Create(MovementSystem.Instance).Field("controller").GetValue() as CharacterController;
+
+ if (!m_entryScaleCollision.Value)
+ {
+ controller.skinWidth = 0.08f;
+ MovementSystem.Instance.UpdateAvatarHeightFactor(1f);
+ }
+ else
+ {
+ controller.skinWidth = (m_entrySkinWidthLimit.Value ? 0.001f : 0.08f);
+ float _avatarHeight = Traverse.Create(PlayerSetup.Instance).Field("_avatarHeight").GetValue();
+ MovementSystem.Instance.UpdateAvatarHeightFactor(_avatarHeight);
+ }
+ }
+
[HarmonyPatch]
private class HarmonyPatches
{
+
+ static public bool _controllerScaleCollision = false;
+
[HarmonyPostfix]
- [HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
- private static void SetQMScale(ref CohtmlView ___quickMenu, ref float ____scaleFactor)
+ [HarmonyPatch(typeof(MovementSystem), "UpdateCollider")]
+ private static void SetScale(ref float ____minimumColliderRadius, ref float ____avatarHeightFactor, ref CharacterController ___controller, ref float ___groundDistance, ref CapsuleCollider ___proxyCollider, ref GameObject ___forceObject, ref Transform ___groundCheck, ref Vector3 ____colliderCenter)
{
- //correct quickmenu - pretty much needsQuickmenuPositionUpdate()
- Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
- ___quickMenu.transform.eulerAngles = new Vector3(rotationPivot.eulerAngles.x, rotationPivot.eulerAngles.y, rotationPivot.eulerAngles.z);
- ___quickMenu.transform.position = rotationPivot.position + rotationPivot.forward * 1f * ____scaleFactor;
+ if (!_controllerScaleCollision) return;
+ //avatar height = viewpoint height
+ //heightfactor = viewpoint height * scale difference
+ //___controller.stepOffset = 0.0001f; (this is 0.3 or 0 based on groundedraw..)
+ //unity docs say to not put skinwidth too low, or you chance getting stuck often
+ //because i cant overwrite stepOffset, ill limit height to min of 0.3 to prevent console spam
+
+ ___controller.height = Mathf.Max(____avatarHeightFactor, ____minimumColliderRadius);
+ ___controller.radius = Mathf.Max(____avatarHeightFactor / 6f, ____minimumColliderRadius); ;
+ ___controller.center = Vector3.up * (___controller.height * 0.5f);
+ ___groundDistance = ___controller.radius;
+
+ ___proxyCollider.height = ___controller.height;
+ ___proxyCollider.radius = ___controller.radius;
+ ___proxyCollider.center = ___controller.center;
+
+ ___forceObject.transform.localScale = new Vector3(___controller.radius + 0.1f, ___controller.height, ___controller.radius + 0.1f);
+ ___groundCheck.localPosition = ____colliderCenter;
+ }
+
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
+ private static void SetQMScale(ref CohtmlView ___quickMenu, ref float ____scaleFactor, float avatarHeight)
+ {
+ if (!MetaPort.Instance.isUsingVr)
+ {
+ //correct quickmenu - pretty much needsQuickmenuPositionUpdate()
+ Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
+ ___quickMenu.transform.eulerAngles = new Vector3(rotationPivot.eulerAngles.x, rotationPivot.eulerAngles.y, rotationPivot.eulerAngles.z);
+ ___quickMenu.transform.position = rotationPivot.position + rotationPivot.forward * 1f * ____scaleFactor;
+ }
+
+ //update avatar height while we are here
+ if (!_controllerScaleCollision) return;
+ MovementSystem.Instance.UpdateAvatarHeightFactor(avatarHeight);
+ }
+
+ //ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug
+ //assuming its caused by cast from int to float getting the screen size, something floating point bleh
+ //attempting to ignore that call if there wasnt actually a change
+
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(ViewManager), "SetScale")]
+ private static void CheckLegit(float avatarHeight, ref ViewManager __instance, ref float ___cachedScreenAspectRatio, ref float ___cachedAvatarHeight, out bool __state)
+ {
+ if (___cachedAvatarHeight == avatarHeight)
+ {
+ __state = false;
+ return;
+ }
+ __state = true;
}
- //ViewManager.SetScale runs once a second when it should only run when aspect ratio changes...? bug
[HarmonyPostfix]
[HarmonyPatch(typeof(ViewManager), "SetScale")]
- private static void SetMMScale(ref ViewManager __instance, ref bool ___needsMenuPositionUpdate, ref float ___scaleFactor, ref float ___cachedScreenAspectRatio, ref float ___cachedAvatarHeight)
+ private static void SetMMScale(ref ViewManager __instance, ref bool ___needsMenuPositionUpdate, ref float ___scaleFactor, bool __state)
{
+ if (!__state) return;
+
//correct main menu - pretty much UpdateMenuPosition()
Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
- float num = Mathf.Abs(rotationPivot.localRotation.eulerAngles.z);
- float settingsFloat = MetaPort.Instance.settings.GetSettingsFloat("GeneralMinimumMenuTilt");
- if (MetaPort.Instance.isUsingVr && (num <= settingsFloat || num >= 360f - settingsFloat))
- {
- __instance.gameObject.transform.rotation = Quaternion.LookRotation(rotationPivot.forward, Vector3.up);
- }
- else
- {
- __instance.gameObject.transform.eulerAngles = new Vector3(rotationPivot.eulerAngles.x, rotationPivot.eulerAngles.y, rotationPivot.eulerAngles.z);
- }
- __instance.gameObject.transform.position = rotationPivot.position + rotationPivot.forward * 1f * ___scaleFactor;
+ __instance.gameObject.transform.position = rotationPivot.position + __instance.gameObject.transform.forward * 1f * ___scaleFactor;
___needsMenuPositionUpdate = false;
}
}
diff --git a/MenuScalePatch/MenuScalePatch.csproj b/MenuScalePatch/MenuScalePatch.csproj
index 7c80c7d..bb32f6d 100644
--- a/MenuScalePatch/MenuScalePatch.csproj
+++ b/MenuScalePatch/MenuScalePatch.csproj
@@ -18,6 +18,9 @@
..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll
+
+ ..\..\Giamoz\Giamoz\bin\Debug\net472\Giamoz.dll
+
C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll
From a12b27749021587cf3d1a3a8db3350df7433810f Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Sat, 10 Sep 2022 21:31:57 -0500
Subject: [PATCH 05/41] Update README.md
---
README.md | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index bda1baf..9b27b01 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,13 @@
just updates the menu position when the game detects a change in avatar scale
-im sure itll be patched officially before cvrmg verifies it lol
+additional options to scale player collision & remove collider margin (skinWidth is pushing avatars off the floor by 0.08f)
+
+To fully reach the floor, enable Scale Collision, No Skin Width, & Allow Small Player Collider in Experimental settings.
+
+**Be aware**, as Allow Small Player Collider will allow the collider to reach below 0.3f, which will cause *harmless..?* console errors.
+
+
https://user-images.githubusercontent.com/37721153/189479474-41e93dff-a695-42f2-9d20-6a895a723039.mp4
From 32c3ebc6ef288c2667a9d83016ab67c5b18ec9ac Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Sat, 1 Oct 2022 18:17:25 -0500
Subject: [PATCH 06/41] fixed centered collision, updated skinwidth to match
latest patch
---
MenuScalePatch/Main.cs | 29 +++++++++++++++--------
MenuScalePatch/MenuScalePatch.sln | 12 +++++-----
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
MenuScalePatch/format.json | 10 ++++----
4 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
index 9c9ea08..5706914 100644
--- a/MenuScalePatch/Main.cs
+++ b/MenuScalePatch/Main.cs
@@ -17,6 +17,8 @@ public class MenuScalePatch : MelonMod
private static MelonPreferences_Entry m_entryScaleCollision;
private static MelonPreferences_Entry m_entrySkinWidthLimit;
+ private static float defaultSkinWidth = 0f;
+
public override void OnApplicationStart()
{
m_categoryMenuScalePatch = MelonPreferences.CreateCategory(nameof(MenuScalePatch));
@@ -41,12 +43,11 @@ public class MenuScalePatch : MelonMod
if (!m_entryScaleCollision.Value)
{
- controller.skinWidth = 0.08f;
+ controller.skinWidth = defaultSkinWidth;
MovementSystem.Instance.UpdateAvatarHeightFactor(1f);
}
else
{
- controller.skinWidth = (m_entrySkinWidthLimit.Value ? 0.001f : 0.08f);
float _avatarHeight = Traverse.Create(PlayerSetup.Instance).Field("_avatarHeight").GetValue();
MovementSystem.Instance.UpdateAvatarHeightFactor(_avatarHeight);
}
@@ -65,21 +66,29 @@ public class MenuScalePatch : MelonMod
if (!_controllerScaleCollision) return;
//avatar height = viewpoint height
//heightfactor = viewpoint height * scale difference
- //___controller.stepOffset = 0.0001f; (this is 0.3 or 0 based on groundedraw..)
+
//unity docs say to not put skinwidth too low, or you chance getting stuck often
- //because i cant overwrite stepOffset, ill limit height to min of 0.3 to prevent console spam
+ //but removing skinWidth allows your character to completely touch the floor
+ //grab the original skinWidth if it wasn't already logged
+ if (defaultSkinWidth == 0f) defaultSkinWidth = ___controller.skinWidth;
+
+ float skinWidth = (m_entrySkinWidthLimit.Value ? 0.001f : defaultSkinWidth);
+ //to prevent falling anims when smol- take skinWidth into maths
+ ___controller.skinWidth = skinWidth;
+ ___groundDistance = ___controller.radius + skinWidth;
+ ___groundCheck.localPosition = ____colliderCenter + Vector3.up * skinWidth;
+
+ //scale charactercontroller collision (take allow small player collider setting into account)
___controller.height = Mathf.Max(____avatarHeightFactor, ____minimumColliderRadius);
- ___controller.radius = Mathf.Max(____avatarHeightFactor / 6f, ____minimumColliderRadius); ;
- ___controller.center = Vector3.up * (___controller.height * 0.5f);
- ___groundDistance = ___controller.radius;
+ ___controller.radius = Mathf.Max(____avatarHeightFactor / 6f, ____minimumColliderRadius);
+ ___controller.center = ____colliderCenter + Vector3.up * (___controller.height * 0.5f);
+ //match the proxy and force colliders to the scaled charactercontroller
___proxyCollider.height = ___controller.height;
___proxyCollider.radius = ___controller.radius;
___proxyCollider.center = ___controller.center;
-
___forceObject.transform.localScale = new Vector3(___controller.radius + 0.1f, ___controller.height, ___controller.radius + 0.1f);
- ___groundCheck.localPosition = ____colliderCenter;
}
[HarmonyPostfix]
@@ -105,7 +114,7 @@ public class MenuScalePatch : MelonMod
[HarmonyPrefix]
[HarmonyPatch(typeof(ViewManager), "SetScale")]
- private static void CheckLegit(float avatarHeight, ref ViewManager __instance, ref float ___cachedScreenAspectRatio, ref float ___cachedAvatarHeight, out bool __state)
+ private static void CheckLegit(float avatarHeight, ref float ___cachedAvatarHeight, out bool __state)
{
if (___cachedAvatarHeight == avatarHeight)
{
diff --git a/MenuScalePatch/MenuScalePatch.sln b/MenuScalePatch/MenuScalePatch.sln
index fe3a351..57b61f9 100644
--- a/MenuScalePatch/MenuScalePatch.sln
+++ b/MenuScalePatch/MenuScalePatch.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32630.192
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvatarScaleUpdater", "AvatarScaleUpdater.csproj", "{1B069D34-0AD6-43A4-A116-C325F37D33A6}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MenuScalePatch", "MenuScalePatch.csproj", "{19D9CD91-0387-4E35-AFCD-BAB15AEC9765}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,15 +11,15 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {1B069D34-0AD6-43A4-A116-C325F37D33A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1B069D34-0AD6-43A4-A116-C325F37D33A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1B069D34-0AD6-43A4-A116-C325F37D33A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1B069D34-0AD6-43A4-A116-C325F37D33A6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {19D9CD91-0387-4E35-AFCD-BAB15AEC9765}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {19D9CD91-0387-4E35-AFCD-BAB15AEC9765}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {19D9CD91-0387-4E35-AFCD-BAB15AEC9765}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {19D9CD91-0387-4E35-AFCD-BAB15AEC9765}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {67335521-EBA9-453E-A0E2-3DE0E3A86EBF}
+ SolutionGuid = {4E0D4C6B-166C-4456-BAD7-6A358308116E}
EndGlobalSection
EndGlobal
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index 2150156..0e3ac90 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "1.0.0";
+ public const string Version = "1.1.0";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index cca9289..1d4c231 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -1,12 +1,12 @@
{
- "_id": -1,
+ "_id": 95,
"name": "MenuScalePatch",
- "modversion": "1.0.0",
+ "modversion": "1.1.0",
"gameversion": "2022r168",
"loaderversion": "0.5.4",
"modtype": "Mod",
"author": "NotAKidoS",
- "description": "Corrects MM and QM position when avatar is scaled.",
+ "description": "Corrects MM and QM position when avatar is scaled.\nAdditional option to scale player collision.",
"searchtags": [
"menu",
"scale",
@@ -16,8 +16,8 @@
"requirements": [
"None"
],
- "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r1/MenuScalePatch.dll",
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r2/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
- "changelog": "Initial Release.",
+ "changelog": "Added option to scale player collision. Fixed some VR specific issues.",
"embedcolor": "804221"
}
\ No newline at end of file
From 33d0714429bdf8bf29a462bed8aa8eca9a6817c0 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Sat, 1 Oct 2022 19:16:04 -0500
Subject: [PATCH 07/41] cvrmg info
---
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
MenuScalePatch/format.json | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index 0e3ac90..20d8b73 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "1.1.0";
+ public const string Version = "1.1.1";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index 1d4c231..b3e377b 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -1,7 +1,7 @@
{
"_id": 95,
"name": "MenuScalePatch",
- "modversion": "1.1.0",
+ "modversion": "1.1.1",
"gameversion": "2022r168",
"loaderversion": "0.5.4",
"modtype": "Mod",
@@ -16,8 +16,8 @@
"requirements": [
"None"
],
- "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r2/MenuScalePatch.dll",
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r3/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
- "changelog": "Added option to scale player collision. Fixed some VR specific issues.",
+ "changelog": "Fixed collision center. Collision no longer disconnects from avatar when moving roomscale.",
"embedcolor": "804221"
}
\ No newline at end of file
From 2ada1263cc49a689a97ca116bd8b57acd02fb309 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 22 Nov 2022 17:26:17 -0600
Subject: [PATCH 08/41] Remove collision scaling.
---
MenuScalePatch/Main.cs | 84 +----------------------
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
MenuScalePatch/format.json | 4 +-
3 files changed, 4 insertions(+), 86 deletions(-)
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
index 5706914..3d10049 100644
--- a/MenuScalePatch/Main.cs
+++ b/MenuScalePatch/Main.cs
@@ -1,96 +1,18 @@
using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
-using ABI_RC.Systems.MovementSystem;
using cohtml;
using HarmonyLib;
using MelonLoader;
using UnityEngine;
-
namespace MenuScalePatch;
public class MenuScalePatch : MelonMod
{
-
- private static MelonPreferences_Category m_categoryMenuScalePatch;
- private static MelonPreferences_Entry m_entryScaleCollision;
- private static MelonPreferences_Entry m_entrySkinWidthLimit;
-
- private static float defaultSkinWidth = 0f;
-
- public override void OnApplicationStart()
- {
- m_categoryMenuScalePatch = MelonPreferences.CreateCategory(nameof(MenuScalePatch));
- m_entryScaleCollision = m_categoryMenuScalePatch.CreateEntry("Scale Collision", false, description: "Should we scale player collision alongside avatar?");
- //m_entrySmallHeightLimit = m_categoryMenuScalePatch.CreateEntry("Small Height Limit", true, description: "Prevents avatar collision height from going below 0.3f. Disabling this can lead to errors if avatar is too small.");
- m_entrySkinWidthLimit = m_categoryMenuScalePatch.CreateEntry("No Skin Width", false, description: "Enabling this allows your feet to touch the ground properly, but may also make it easier for you to get stuck on collision.");
-
- m_categoryMenuScalePatch.SaveToFile(false);
- m_entryScaleCollision.OnValueChangedUntyped += UpdateSettings;
- m_entrySkinWidthLimit.OnValueChangedUntyped += UpdateSettings;
-
- UpdateSettings();
- }
-
- private static void UpdateSettings()
- {
- HarmonyPatches._controllerScaleCollision = m_entryScaleCollision.Value;
-
- if (!MovementSystem.Instance) return;
-
- CharacterController controller = Traverse.Create(MovementSystem.Instance).Field("controller").GetValue() as CharacterController;
-
- if (!m_entryScaleCollision.Value)
- {
- controller.skinWidth = defaultSkinWidth;
- MovementSystem.Instance.UpdateAvatarHeightFactor(1f);
- }
- else
- {
- float _avatarHeight = Traverse.Create(PlayerSetup.Instance).Field("_avatarHeight").GetValue();
- MovementSystem.Instance.UpdateAvatarHeightFactor(_avatarHeight);
- }
- }
-
[HarmonyPatch]
private class HarmonyPatches
{
-
- static public bool _controllerScaleCollision = false;
-
- [HarmonyPostfix]
- [HarmonyPatch(typeof(MovementSystem), "UpdateCollider")]
- private static void SetScale(ref float ____minimumColliderRadius, ref float ____avatarHeightFactor, ref CharacterController ___controller, ref float ___groundDistance, ref CapsuleCollider ___proxyCollider, ref GameObject ___forceObject, ref Transform ___groundCheck, ref Vector3 ____colliderCenter)
- {
- if (!_controllerScaleCollision) return;
- //avatar height = viewpoint height
- //heightfactor = viewpoint height * scale difference
-
- //unity docs say to not put skinwidth too low, or you chance getting stuck often
- //but removing skinWidth allows your character to completely touch the floor
-
- //grab the original skinWidth if it wasn't already logged
- if (defaultSkinWidth == 0f) defaultSkinWidth = ___controller.skinWidth;
-
- float skinWidth = (m_entrySkinWidthLimit.Value ? 0.001f : defaultSkinWidth);
- //to prevent falling anims when smol- take skinWidth into maths
- ___controller.skinWidth = skinWidth;
- ___groundDistance = ___controller.radius + skinWidth;
- ___groundCheck.localPosition = ____colliderCenter + Vector3.up * skinWidth;
-
- //scale charactercontroller collision (take allow small player collider setting into account)
- ___controller.height = Mathf.Max(____avatarHeightFactor, ____minimumColliderRadius);
- ___controller.radius = Mathf.Max(____avatarHeightFactor / 6f, ____minimumColliderRadius);
- ___controller.center = ____colliderCenter + Vector3.up * (___controller.height * 0.5f);
-
- //match the proxy and force colliders to the scaled charactercontroller
- ___proxyCollider.height = ___controller.height;
- ___proxyCollider.radius = ___controller.radius;
- ___proxyCollider.center = ___controller.center;
- ___forceObject.transform.localScale = new Vector3(___controller.radius + 0.1f, ___controller.height, ___controller.radius + 0.1f);
- }
-
[HarmonyPostfix]
[HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
private static void SetQMScale(ref CohtmlView ___quickMenu, ref float ____scaleFactor, float avatarHeight)
@@ -102,10 +24,6 @@ public class MenuScalePatch : MelonMod
___quickMenu.transform.eulerAngles = new Vector3(rotationPivot.eulerAngles.x, rotationPivot.eulerAngles.y, rotationPivot.eulerAngles.z);
___quickMenu.transform.position = rotationPivot.position + rotationPivot.forward * 1f * ____scaleFactor;
}
-
- //update avatar height while we are here
- if (!_controllerScaleCollision) return;
- MovementSystem.Instance.UpdateAvatarHeightFactor(avatarHeight);
}
//ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug
@@ -136,4 +54,4 @@ public class MenuScalePatch : MelonMod
___needsMenuPositionUpdate = false;
}
}
-}
+}
\ No newline at end of file
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index 20d8b73..e5e3453 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "1.1.1";
+ public const string Version = "2.0.0";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index b3e377b..c49ee8b 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -1,4 +1,4 @@
-{
+wa {
"_id": 95,
"name": "MenuScalePatch",
"modversion": "1.1.1",
@@ -16,7 +16,7 @@
"requirements": [
"None"
],
- "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r3/MenuScalePatch.dll",
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r4/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
"changelog": "Fixed collision center. Collision no longer disconnects from avatar when moving roomscale.",
"embedcolor": "804221"
From 218839abf1c75ee70cf9c779d554bb97a54a54ae Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 22 Nov 2022 17:27:04 -0600
Subject: [PATCH 09/41] Update Main.cs
---
MenuScalePatch/Main.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
index 3d10049..7a090e2 100644
--- a/MenuScalePatch/Main.cs
+++ b/MenuScalePatch/Main.cs
@@ -15,7 +15,7 @@ public class MenuScalePatch : MelonMod
{
[HarmonyPostfix]
[HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
- private static void SetQMScale(ref CohtmlView ___quickMenu, ref float ____scaleFactor, float avatarHeight)
+ private static void SetQMScale(ref CohtmlView ___quickMenu, ref float ____scaleFactor)
{
if (!MetaPort.Instance.isUsingVr)
{
From 83268619da4bd2505b4230567af8cfac6e80054c Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 22 Nov 2022 18:20:01 -0600
Subject: [PATCH 10/41] Update format.json
---
MenuScalePatch/format.json | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index c49ee8b..e845b2b 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -1,12 +1,12 @@
-wa {
+{
"_id": 95,
"name": "MenuScalePatch",
- "modversion": "1.1.1",
- "gameversion": "2022r168",
- "loaderversion": "0.5.4",
+ "modversion": "2.0.0",
+ "gameversion": "2022r169",
+ "loaderversion": "0.5.7",
"modtype": "Mod",
"author": "NotAKidoS",
- "description": "Corrects MM and QM position when avatar is scaled.\nAdditional option to scale player collision.",
+ "description": "Corrects MM and QM position when avatar is scaled.",
"searchtags": [
"menu",
"scale",
@@ -18,6 +18,6 @@ wa {
],
"downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r4/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
- "changelog": "Fixed collision center. Collision no longer disconnects from avatar when moving roomscale.",
+ "changelog": "Removed collision scaling feature as it is now native.",
"embedcolor": "804221"
}
\ No newline at end of file
From e54a20ee42f38ae240271491c4767baf6c091d17 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Mon, 26 Dec 2022 22:21:43 -0600
Subject: [PATCH 11/41] fixed shit
---
MenuScalePatch/Main.cs | 73 ++++++++++++++++++-----
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
MenuScalePatch/format.json | 6 +-
3 files changed, 63 insertions(+), 18 deletions(-)
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
index 7a090e2..b8b38df 100644
--- a/MenuScalePatch/Main.cs
+++ b/MenuScalePatch/Main.cs
@@ -13,26 +13,42 @@ public class MenuScalePatch : MelonMod
[HarmonyPatch]
private class HarmonyPatches
{
- [HarmonyPostfix]
- [HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
- private static void SetQMScale(ref CohtmlView ___quickMenu, ref float ____scaleFactor)
+ internal static bool adjustedMenuPosition = false;
+ internal static void SetMenuPosition(Transform menuTransform, float scale)
{
+ Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
if (!MetaPort.Instance.isUsingVr)
{
- //correct quickmenu - pretty much needsQuickmenuPositionUpdate()
- Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
- ___quickMenu.transform.eulerAngles = new Vector3(rotationPivot.eulerAngles.x, rotationPivot.eulerAngles.y, rotationPivot.eulerAngles.z);
- ___quickMenu.transform.position = rotationPivot.position + rotationPivot.forward * 1f * ____scaleFactor;
+ menuTransform.eulerAngles = rotationPivot.eulerAngles;
}
+ menuTransform.position = rotationPivot.position + rotationPivot.forward * 1f * scale;
+ adjustedMenuPosition = true;
}
- //ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug
- //assuming its caused by cast from int to float getting the screen size, something floating point bleh
- //attempting to ignore that call if there wasnt actually a change
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
+ private static void SetQMScale(ref CohtmlView ___quickMenu, ref bool ___needsQuickmenuPositionUpdate, ref float ____scaleFactor, ref GameObject ____leftVrAnchor)
+ {
+ if (MetaPort.Instance.isUsingVr)
+ {
+ ___quickMenu.transform.position = ____leftVrAnchor.transform.position;
+ ___quickMenu.transform.rotation = ____leftVrAnchor.transform.rotation;
+ ___needsQuickmenuPositionUpdate = false;
+ return;
+ }
+ SetMenuPosition(___quickMenu.transform, ____scaleFactor);
+ ___needsQuickmenuPositionUpdate = false;
+ }
+
+ /**
+ ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug
+ assuming its caused by cast from int to float getting the screen size, something floating point bleh
+ attempting to ignore that call if there wasnt actually a change
+ **/
[HarmonyPrefix]
[HarmonyPatch(typeof(ViewManager), "SetScale")]
- private static void CheckLegit(float avatarHeight, ref float ___cachedAvatarHeight, out bool __state)
+ private static void CheckMMScale(float avatarHeight, ref float ___cachedAvatarHeight, out bool __state)
{
if (___cachedAvatarHeight == avatarHeight)
{
@@ -48,10 +64,39 @@ public class MenuScalePatch : MelonMod
{
if (!__state) return;
- //correct main menu - pretty much UpdateMenuPosition()
- Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
- __instance.gameObject.transform.position = rotationPivot.position + __instance.gameObject.transform.forward * 1f * ___scaleFactor;
+ SetMenuPosition(__instance.transform, ___scaleFactor);
___needsMenuPositionUpdate = false;
}
+
+ /**
+ Following code resets the menu position on LateUpdate so you can use the menu while moving/falling.
+ It is Desktop only. QM inputs still don't work because they do their input checks in LateUpdate???
+ **/
+
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(CVR_MenuManager), "LateUpdate")]
+ private static void DesktopQMFix(ref CohtmlView ___quickMenu, ref bool ___needsQuickmenuPositionUpdate, ref float ____scaleFactor, ref bool ____quickMenuOpen)
+ {
+ if (MetaPort.Instance.isUsingVr) return;
+ if (____quickMenuOpen && !adjustedMenuPosition)
+ {
+ SetMenuPosition(___quickMenu.transform, ____scaleFactor);
+ ___needsQuickmenuPositionUpdate = false;
+ }
+ adjustedMenuPosition = false;
+ }
+
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(ViewManager), "LateUpdate")]
+ private static void DesktopMMFix(ref ViewManager __instance, ref bool ___needsMenuPositionUpdate, ref float ___scaleFactor, bool __state, ref bool ____gameMenuOpen)
+ {
+ if (MetaPort.Instance.isUsingVr) return;
+ if (____gameMenuOpen && !adjustedMenuPosition)
+ {
+ SetMenuPosition(__instance.transform, ___scaleFactor);
+ ___needsMenuPositionUpdate = false;
+ }
+ adjustedMenuPosition = false;
+ }
}
}
\ No newline at end of file
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index e5e3453..a007473 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "2.0.0";
+ public const string Version = "3.0.0";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index e845b2b..0efb4ff 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -1,8 +1,8 @@
{
"_id": 95,
"name": "MenuScalePatch",
- "modversion": "2.0.0",
- "gameversion": "2022r169",
+ "modversion": "3.0.0",
+ "gameversion": "2022r170",
"loaderversion": "0.5.7",
"modtype": "Mod",
"author": "NotAKidoS",
@@ -18,6 +18,6 @@
],
"downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r4/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
- "changelog": "Removed collision scaling feature as it is now native.",
+ "changelog": "Removed collision scaling feature as it is now native.\nImplemented adjusted QM scaling for VR.\nAdded menu correction for Desktop so you can use menus while moving.",
"embedcolor": "804221"
}
\ No newline at end of file
From 84cf4c0875e74bc93a9575372aa8e86b80ff00cb Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Mon, 26 Dec 2022 22:58:59 -0600
Subject: [PATCH 12/41] viewpoint correction
---
MenuScalePatch/Main.cs | 2 ++
MenuScalePatch/format.json | 6 +++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
index b8b38df..e8da0bd 100644
--- a/MenuScalePatch/Main.cs
+++ b/MenuScalePatch/Main.cs
@@ -36,6 +36,7 @@ public class MenuScalePatch : MelonMod
___needsQuickmenuPositionUpdate = false;
return;
}
+ PlayerSetup.Instance.HandleDesktopCameraPosition(true);
SetMenuPosition(___quickMenu.transform, ____scaleFactor);
___needsQuickmenuPositionUpdate = false;
}
@@ -64,6 +65,7 @@ public class MenuScalePatch : MelonMod
{
if (!__state) return;
+ PlayerSetup.Instance.HandleDesktopCameraPosition(true);
SetMenuPosition(__instance.transform, ___scaleFactor);
___needsMenuPositionUpdate = false;
}
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index 0efb4ff..02f7943 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -6,7 +6,7 @@
"loaderversion": "0.5.7",
"modtype": "Mod",
"author": "NotAKidoS",
- "description": "Corrects MM and QM position when avatar is scaled.",
+ "description": "Corrects MM and QM position when avatar is being scaled.\n\nDesktop menus will now always follow camera while open.",
"searchtags": [
"menu",
"scale",
@@ -16,8 +16,8 @@
"requirements": [
"None"
],
- "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/r4/MenuScalePatch.dll",
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v3.0.0/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
- "changelog": "Removed collision scaling feature as it is now native.\nImplemented adjusted QM scaling for VR.\nAdded menu correction for Desktop so you can use menus while moving.",
+ "changelog": "Removed collision scaling feature as it is now native.\nAdjusted QM scaling for VR.\nAdded menu correction for Desktop so you can use menus while moving.\nImmediate viewpoint correction for Desktop during scaling.",
"embedcolor": "804221"
}
\ No newline at end of file
From ed38a64ce54bbef45faddeeb25de82649242364c Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Mon, 26 Dec 2022 23:00:21 -0600
Subject: [PATCH 13/41] Update README.md
---
README.md | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 9b27b01..b28519e 100644
--- a/README.md
+++ b/README.md
@@ -2,11 +2,7 @@
just updates the menu position when the game detects a change in avatar scale
-additional options to scale player collision & remove collider margin (skinWidth is pushing avatars off the floor by 0.08f)
-
-To fully reach the floor, enable Scale Collision, No Skin Width, & Allow Small Player Collider in Experimental settings.
-
-**Be aware**, as Allow Small Player Collider will allow the collider to reach below 0.3f, which will cause *harmless..?* console errors.
+also forces menu positions to be constantly updated while open on desktop
From 72c9f123768d1dd067ca7a042ef857391c16c5dd Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 3 Jan 2023 01:20:05 -0600
Subject: [PATCH 14/41] overcomplicated shit
---
MenuScalePatch/HarmonyPatches.cs | 108 +++++++++++++++
MenuScalePatch/MSP_Menus.cs | 25 ++++
MenuScalePatch/Main.cs | 104 +++-----------
MenuScalePatch/MainMenuHelper.cs | 159 ++++++++++++++++++++++
MenuScalePatch/Properties/AssemblyInfo.cs | 4 +-
MenuScalePatch/QuickMenuHelper.cs | 148 ++++++++++++++++++++
6 files changed, 458 insertions(+), 90 deletions(-)
create mode 100644 MenuScalePatch/HarmonyPatches.cs
create mode 100644 MenuScalePatch/MSP_Menus.cs
create mode 100644 MenuScalePatch/MainMenuHelper.cs
create mode 100644 MenuScalePatch/QuickMenuHelper.cs
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
new file mode 100644
index 0000000..3d24450
--- /dev/null
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -0,0 +1,108 @@
+using ABI_RC.Core.InteractionSystem;
+using ABI_RC.Core.Player;
+using ABI_RC.Core.Savior;
+using ABI_RC.Core;
+using cohtml;
+using HarmonyLib;
+using NAK.Melons.MenuScalePatch.Helpers;
+using UnityEngine;
+
+namespace NAK.Melons.MenuScalePatch.HarmonyPatches;
+
+[HarmonyPatch]
+internal class HarmonyPatches
+{
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
+ private static void SetQMScale(float avatarHeight, ref float ____scaleFactor, out bool __runOriginal)
+ {
+ ____scaleFactor = avatarHeight / 1.8f;
+ if (MetaPort.Instance.isUsingVr)
+ {
+ ____scaleFactor *= 0.5f;
+ }
+ MSP_MenuInfo.ScaleFactor = ____scaleFactor;
+ __runOriginal = false;
+ }
+
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(ViewManager), "SetScale")]
+ private static void CheckMMScale(out bool __runOriginal)
+ {
+ /**
+ ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug
+ assuming its caused by cast from int to float getting the screen size, something floating point bleh
+ i dont need it so i will nuke it >:)
+ **/
+ __runOriginal = false;
+ }
+
+ //nuke UpdateMenuPosition methods
+ //there are 2 Jobs calling this each second, which is fucking my shit
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(CVR_MenuManager), "UpdateMenuPosition")]
+ private static void Prefix_CVR_MenuManager_UpdateMenuPosition(out bool __runOriginal)
+ {
+ __runOriginal = false;
+ }
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(ViewManager), "UpdateMenuPosition")]
+ private static void Prefix_ViewManager_UpdateMenuPosition(out bool __runOriginal)
+ {
+ __runOriginal = false;
+ }
+
+ //Set QM stuff
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(CVR_MenuManager), "Start")]
+ private static void SetupQMHelper(ref CVR_MenuManager __instance, ref GameObject ____leftVrAnchor)
+ {
+ QuickMenuHelper helper = __instance.quickMenu.gameObject.AddComponent();
+ helper.handAnchor = ____leftVrAnchor.transform;
+ }
+
+ //Set MM stuff
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(ViewManager), "Start")]
+ private static void SetupMMHelper(ref ViewManager __instance)
+ {
+ __instance.gameObject.AddComponent();
+ }
+
+ //hook quickmenu open/close
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
+ private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show)
+ {
+ if (QuickMenuHelper.Instance == null) return;
+ QuickMenuHelper.Instance.UpdateWorldAnchors();
+ QuickMenuHelper.Instance.ToggleDesktopInputMethod(show);
+ QuickMenuHelper.Instance.enabled = show;
+ }
+
+ //add independent head movement to important input
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(InputModuleMouseKeyboard), "UpdateImportantInput")]
+ private static void Postfix_InputModuleMouseKeyboard_UpdateImportantInput(ref CVRInputManager ____inputManager)
+ {
+ ____inputManager.independentHeadTurn |= Input.GetKey(KeyCode.LeftAlt);
+ }
+
+ //hook menu open/close
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
+ private static void Postfix_ViewManager_UiStateToggle(bool show)
+ {
+ if (MainMenuHelper.Instance == null) return;
+ MainMenuHelper.Instance.UpdateWorldAnchors();
+ MainMenuHelper.Instance.enabled = show;
+ }
+
+ //Support for changing VRMode during runtime.
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(PlayerSetup), "CalibrateAvatar")]
+ private static void CheckVRModeOnSwitch()
+ {
+ MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
+ }
+}
\ No newline at end of file
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
new file mode 100644
index 0000000..341c3c3
--- /dev/null
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using UnityEngine;
+using ABI_RC.Core.Savior;
+
+namespace NAK.Melons.MenuScalePatch.Helpers;
+
+public class MSP_MenuInfo
+{
+ //Shared Info
+ public static float ScaleFactor = 1f;
+ public static Transform CameraTransform;
+
+ //Settings...?
+ public static bool WorldAnchorQM;
+
+ //if other mods need to disable?
+ public static bool DisableQMHelper;
+ public static bool DisableQMHelper_VR;
+ public static bool DisableMMHelper;
+ public static bool DisableMMHelper_VR;
+}
\ No newline at end of file
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
index e8da0bd..812989b 100644
--- a/MenuScalePatch/Main.cs
+++ b/MenuScalePatch/Main.cs
@@ -5,100 +5,28 @@ using cohtml;
using HarmonyLib;
using MelonLoader;
using UnityEngine;
+using NAK.Melons.MenuScalePatch.Helpers;
-namespace MenuScalePatch;
+namespace NAK.Melons.MenuScalePatch;
public class MenuScalePatch : MelonMod
{
- [HarmonyPatch]
- private class HarmonyPatches
+ private static MelonPreferences_Category m_categoryMenuScalePatch;
+ private static MelonPreferences_Entry m_entryWorldAnchorVRQM;
+ public override void OnInitializeMelon()
{
- internal static bool adjustedMenuPosition = false;
- internal static void SetMenuPosition(Transform menuTransform, float scale)
+ m_categoryMenuScalePatch = MelonPreferences.CreateCategory(nameof(MenuScalePatch));
+ m_entryWorldAnchorVRQM = m_categoryMenuScalePatch.CreateEntry("World Anchor VR QM", false, description: "Should place QM in World Space while VR.");
+
+ foreach (var setting in m_categoryMenuScalePatch.Entries)
{
- Transform rotationPivot = PlayerSetup.Instance._movementSystem.rotationPivot;
- if (!MetaPort.Instance.isUsingVr)
- {
- menuTransform.eulerAngles = rotationPivot.eulerAngles;
- }
- menuTransform.position = rotationPivot.position + rotationPivot.forward * 1f * scale;
- adjustedMenuPosition = true;
- }
-
- [HarmonyPostfix]
- [HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
- private static void SetQMScale(ref CohtmlView ___quickMenu, ref bool ___needsQuickmenuPositionUpdate, ref float ____scaleFactor, ref GameObject ____leftVrAnchor)
- {
- if (MetaPort.Instance.isUsingVr)
- {
- ___quickMenu.transform.position = ____leftVrAnchor.transform.position;
- ___quickMenu.transform.rotation = ____leftVrAnchor.transform.rotation;
- ___needsQuickmenuPositionUpdate = false;
- return;
- }
- PlayerSetup.Instance.HandleDesktopCameraPosition(true);
- SetMenuPosition(___quickMenu.transform, ____scaleFactor);
- ___needsQuickmenuPositionUpdate = false;
- }
-
- /**
- ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug
- assuming its caused by cast from int to float getting the screen size, something floating point bleh
- attempting to ignore that call if there wasnt actually a change
- **/
-
- [HarmonyPrefix]
- [HarmonyPatch(typeof(ViewManager), "SetScale")]
- private static void CheckMMScale(float avatarHeight, ref float ___cachedAvatarHeight, out bool __state)
- {
- if (___cachedAvatarHeight == avatarHeight)
- {
- __state = false;
- return;
- }
- __state = true;
- }
-
- [HarmonyPostfix]
- [HarmonyPatch(typeof(ViewManager), "SetScale")]
- private static void SetMMScale(ref ViewManager __instance, ref bool ___needsMenuPositionUpdate, ref float ___scaleFactor, bool __state)
- {
- if (!__state) return;
-
- PlayerSetup.Instance.HandleDesktopCameraPosition(true);
- SetMenuPosition(__instance.transform, ___scaleFactor);
- ___needsMenuPositionUpdate = false;
- }
-
- /**
- Following code resets the menu position on LateUpdate so you can use the menu while moving/falling.
- It is Desktop only. QM inputs still don't work because they do their input checks in LateUpdate???
- **/
-
- [HarmonyPrefix]
- [HarmonyPatch(typeof(CVR_MenuManager), "LateUpdate")]
- private static void DesktopQMFix(ref CohtmlView ___quickMenu, ref bool ___needsQuickmenuPositionUpdate, ref float ____scaleFactor, ref bool ____quickMenuOpen)
- {
- if (MetaPort.Instance.isUsingVr) return;
- if (____quickMenuOpen && !adjustedMenuPosition)
- {
- SetMenuPosition(___quickMenu.transform, ____scaleFactor);
- ___needsQuickmenuPositionUpdate = false;
- }
- adjustedMenuPosition = false;
- }
-
- [HarmonyPrefix]
- [HarmonyPatch(typeof(ViewManager), "LateUpdate")]
- private static void DesktopMMFix(ref ViewManager __instance, ref bool ___needsMenuPositionUpdate, ref float ___scaleFactor, bool __state, ref bool ____gameMenuOpen)
- {
- if (MetaPort.Instance.isUsingVr) return;
- if (____gameMenuOpen && !adjustedMenuPosition)
- {
- SetMenuPosition(__instance.transform, ___scaleFactor);
- ___needsMenuPositionUpdate = false;
- }
- adjustedMenuPosition = false;
+ setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);
}
}
+
+ private void UpdateAllSettings()
+ {
+ MSP_MenuInfo.WorldAnchorQM = m_entryWorldAnchorVRQM.Value;
+ }
+ private void OnUpdateSettings(object arg1, object arg2) => UpdateAllSettings();
}
\ No newline at end of file
diff --git a/MenuScalePatch/MainMenuHelper.cs b/MenuScalePatch/MainMenuHelper.cs
new file mode 100644
index 0000000..ba3f83d
--- /dev/null
+++ b/MenuScalePatch/MainMenuHelper.cs
@@ -0,0 +1,159 @@
+using ABI_RC.Core.InteractionSystem;
+using ABI_RC.Core.Player;
+using ABI_RC.Core.Savior;
+using ABI_RC.Core;
+using ABI_RC.Systems.MovementSystem;
+using cohtml;
+using HarmonyLib;
+using MelonLoader;
+using UnityEngine;
+using System.Reflection;
+
+namespace NAK.Melons.MenuScalePatch.Helpers;
+
+//TODO: Implement desktop ratio scaling back to MM
+
+/**
+
+ This helper is assigned to the MainMenu object.
+ The DefaultExecutionOrder attribute saves me from needing
+ to use OnPreRender() callback... yay.
+
+**/
+
+[DefaultExecutionOrder(999999)]
+public class MainMenuHelper : MonoBehaviour
+{
+ public static MainMenuHelper Instance;
+ public Transform worldAnchor;
+
+ static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
+ private bool independentHeadTurn = false;
+ private bool returnIndependentHeadTurn = false;
+ private bool prevIndependentHeadTurn = false;
+
+ void Start()
+ {
+ Instance = this;
+ CreateWorldAnchors();
+ }
+
+ void LateUpdate()
+ {
+ UpdateMenuPosition();
+ }
+
+ void OnDisable()
+ {
+ independentHeadTurn = false;
+ returnIndependentHeadTurn = false;
+ prevIndependentHeadTurn = false;
+ }
+
+ public void ToggleDesktopInputMethod(bool flag)
+ {
+ PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
+ CVRInputManager.Instance.inputEnabled = !flag;
+ RootLogic.Instance.ToggleMouse(flag);
+ CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
+ Traverse.Create(CVR_MenuManager.Instance).Field("_desktopMouseMode").SetValue(flag);
+ }
+
+ public void CreateWorldAnchors()
+ {
+ //VR specific anchor
+ GameObject vrAnchor = new GameObject("MSP_MMVR_Anchor");
+ vrAnchor.transform.parent = PlayerSetup.Instance.vrCameraRig.transform;
+ vrAnchor.transform.localPosition = Vector3.zero;
+ this.worldAnchor = vrAnchor.transform;
+ }
+
+ public void UpdateWorldAnchors()
+ {
+ if (this.worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
+
+ if (MetaPort.Instance.isUsingVr)
+ {
+ float zRotation = Mathf.Abs(MSP_MenuInfo.CameraTransform.localRotation.eulerAngles.z);
+ float minTilt = MetaPort.Instance.settings.GetSettingsFloat("GeneralMinimumMenuTilt", 0f);
+ if (zRotation <= minTilt || zRotation >= 360f - minTilt)
+ {
+ this.worldAnchor.rotation = Quaternion.LookRotation(MSP_MenuInfo.CameraTransform.forward, Vector3.up);
+ }
+ else
+ {
+ this.worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
+ }
+ this.worldAnchor.position = MSP_MenuInfo.CameraTransform.position + MSP_MenuInfo.CameraTransform.forward * 2f * MSP_MenuInfo.ScaleFactor;
+ }
+ else
+ {
+ this.worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
+ this.worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
+ }
+ }
+
+ public void UpdateMenuPosition()
+ {
+ if (MetaPort.Instance.isUsingVr)
+ {
+ HandleVRPosition();
+ return;
+ }
+
+ bool independentHeadTurnChanged = CVRInputManager.Instance.independentHeadTurn != prevIndependentHeadTurn;
+ if (independentHeadTurnChanged)
+ {
+ prevIndependentHeadTurn = CVRInputManager.Instance.independentHeadTurn;
+ //if pressing but not already enabled
+ if (prevIndependentHeadTurn)
+ {
+ if (!independentHeadTurn)
+ {
+ UpdateWorldAnchors();
+ ToggleDesktopInputMethod(!prevIndependentHeadTurn);
+ independentHeadTurn = true;
+ }
+ returnIndependentHeadTurn = false;
+ }
+ else
+ {
+ returnIndependentHeadTurn = true;
+ }
+ }
+
+ if (returnIndependentHeadTurn)
+ {
+ float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
+ if (angle == 0f)
+ {
+ independentHeadTurn = false;
+ returnIndependentHeadTurn = false;
+ ToggleDesktopInputMethod(!prevIndependentHeadTurn);
+ }
+ }
+
+ HandleDesktopPosition();
+ }
+
+ //Desktop Main Menu
+ public void HandleDesktopPosition()
+ {
+ if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableMMHelper) return;
+
+ Transform activeAnchor = independentHeadTurn ? this.worldAnchor : MSP_MenuInfo.CameraTransform;
+ this.transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f);
+ this.transform.eulerAngles = activeAnchor.eulerAngles;
+ this.transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor;
+ }
+
+ //VR Main Menu
+ public void HandleVRPosition()
+ {
+ if (this.worldAnchor == null || MSP_MenuInfo.DisableMMHelper_VR) return;
+ this.transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor * 1.8f, 0.9f * MSP_MenuInfo.ScaleFactor * 1.8f, 1f);
+ this.transform.position = this.worldAnchor.position;
+ this.transform.eulerAngles = this.worldAnchor.eulerAngles;
+ }
+}
+
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index a007473..34cef9b 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -11,7 +11,7 @@ using System.Reflection;
[assembly: AssemblyProduct(nameof(MenuScalePatch))]
[assembly: MelonInfo(
- typeof(MenuScalePatch.MenuScalePatch),
+ typeof(NAK.Melons.MenuScalePatch.MenuScalePatch),
nameof(MenuScalePatch),
AssemblyInfoParams.Version,
AssemblyInfoParams.Author,
@@ -25,6 +25,6 @@ using System.Reflection;
namespace MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "3.0.0";
+ public const string Version = "4.0.0";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
diff --git a/MenuScalePatch/QuickMenuHelper.cs b/MenuScalePatch/QuickMenuHelper.cs
new file mode 100644
index 0000000..82e5791
--- /dev/null
+++ b/MenuScalePatch/QuickMenuHelper.cs
@@ -0,0 +1,148 @@
+using ABI_RC.Core.InteractionSystem;
+using ABI_RC.Core.Player;
+using ABI_RC.Core.Savior;
+using ABI_RC.Core;
+using ABI_RC.Systems.MovementSystem;
+using cohtml;
+using HarmonyLib;
+using MelonLoader;
+using UnityEngine;
+using System.Reflection;
+
+namespace NAK.Melons.MenuScalePatch.Helpers;
+
+/**
+
+ This helper is assigned to the QuickMenu object.
+ The DefaultExecutionOrder attribute saves me from needing
+ to use OnPreRender() callback... yay.
+
+**/
+
+[DefaultExecutionOrder(999999)]
+public class QuickMenuHelper : MonoBehaviour
+{
+ public static QuickMenuHelper Instance;
+ public Transform worldAnchor;
+ public Transform handAnchor;
+
+ static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
+ private bool independentHeadTurn = false;
+ private bool returnIndependentHeadTurn = false;
+ private bool prevIndependentHeadTurn = false;
+
+ void Start()
+ {
+ Instance = this;
+ CreateWorldAnchors();
+ }
+
+ void LateUpdate()
+ {
+ UpdateMenuPosition();
+ }
+
+ void OnDisable()
+ {
+ independentHeadTurn = false;
+ returnIndependentHeadTurn = false;
+ prevIndependentHeadTurn = false;
+ }
+
+ public void ToggleDesktopInputMethod(bool flag)
+ {
+ PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
+ CVRInputManager.Instance.inputEnabled = !flag;
+ RootLogic.Instance.ToggleMouse(flag);
+ CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
+ Traverse.Create(CVR_MenuManager.Instance).Field("_desktopMouseMode").SetValue(flag);
+ }
+
+ public void CreateWorldAnchors()
+ {
+ //VR specific anchor
+ GameObject vrAnchor = new GameObject("MSP_QMVR_Anchor");
+ vrAnchor.transform.parent = PlayerSetup.Instance.vrCameraRig.transform;
+ vrAnchor.transform.localPosition = Vector3.zero;
+ this.worldAnchor = vrAnchor.transform;
+ }
+
+ public void UpdateWorldAnchors()
+ {
+ if (this.worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
+
+ this.worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
+ this.worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
+ }
+
+ public void UpdateMenuPosition()
+ {
+ if (MetaPort.Instance.isUsingVr)
+ {
+ HandleVRPosition();
+ return;
+ }
+
+ bool independentHeadTurnChanged = CVRInputManager.Instance.independentHeadTurn != prevIndependentHeadTurn;
+ if (independentHeadTurnChanged)
+ {
+ prevIndependentHeadTurn = CVRInputManager.Instance.independentHeadTurn;
+ //if pressing but not already enabled
+ if (prevIndependentHeadTurn)
+ {
+ if (!independentHeadTurn)
+ {
+ UpdateWorldAnchors();
+ ToggleDesktopInputMethod(!prevIndependentHeadTurn);
+ independentHeadTurn = true;
+ }
+ returnIndependentHeadTurn = false;
+ }
+ else
+ {
+ returnIndependentHeadTurn = true;
+ }
+ }
+
+ if (returnIndependentHeadTurn)
+ {
+ float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
+ if (angle == 0f)
+ {
+ independentHeadTurn = false;
+ returnIndependentHeadTurn = false;
+ ToggleDesktopInputMethod(!prevIndependentHeadTurn);
+ }
+ }
+
+ HandleDesktopPosition();
+ }
+
+ //Desktop Quick Menu
+ public void HandleDesktopPosition()
+ {
+ if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableQMHelper) return;
+
+ Transform activeAnchor = independentHeadTurn ? this.worldAnchor : MSP_MenuInfo.CameraTransform;
+ this.transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
+ this.transform.eulerAngles = activeAnchor.eulerAngles;
+ this.transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
+ }
+
+ //VR Quick Menu
+ public void HandleVRPosition()
+ {
+ if (this.handAnchor == null || MSP_MenuInfo.DisableQMHelper_VR) return;
+
+ if (MSP_MenuInfo.WorldAnchorQM)
+ {
+ this.transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
+ this.transform.eulerAngles = this.worldAnchor.eulerAngles;
+ this.transform.position = this.worldAnchor.position + this.worldAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
+ return;
+ }
+ this.transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
+ this.transform.position = this.handAnchor.position;
+ this.transform.rotation = this.handAnchor.rotation;
+ }
+}
\ No newline at end of file
From 61823892d17fc66191813411bc08a7d167ee806e Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 3 Jan 2023 10:33:27 -0600
Subject: [PATCH 15/41] Update README.md
---
README.md | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 9b27b01..4a8dc6c 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,20 @@
# MenuScalePatch
-just updates the menu position when the game detects a change in avatar scale
+Originally forced menu position to update while scaling. Now changes ChilloutVR menu behavior to feel less clunky.
-additional options to scale player collision & remove collider margin (skinWidth is pushing avatars off the floor by 0.08f)
+## Features:
+* Menu position properly updates at end of update cycle.
+ * This makes sure menu is always correctly positioned while moving and scaling.
+ * This also allows for menus to be used while moving. (this is iffy though)
-To fully reach the floor, enable Scale Collision, No Skin Width, & Allow Small Player Collider in Experimental settings.
-
-**Be aware**, as Allow Small Player Collider will allow the collider to reach below 0.3f, which will cause *harmless..?* console errors.
+* Adds independent head moving support while on Desktop. (makes selecting users easier)
+ * Hold ALT while on Desktop. Native feature that now works while in a menu.
+* Implemented world anchors for menus. They can now be placed in the world, but still attached to you.
+ * This is used for independent head movement internally, as well as a toggle for VR QM.
+* Main Menu in VR is now attached to player rig.
+ * Menu will now follow you while moving in world space, but not while moving in play space.
https://user-images.githubusercontent.com/37721153/189479474-41e93dff-a695-42f2-9d20-6a895a723039.mp4
From 77c1e0fea97c63f65d8dfd9416bded5875faedc4 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 3 Jan 2023 11:59:13 -0600
Subject: [PATCH 16/41] dont change mouse input while in VR
bruh
---
MenuScalePatch/HarmonyPatches.cs | 1 +
.../{ => Helpers}/MainMenuHelper.cs | 37 ++++++++++---------
.../{ => Helpers}/QuickMenuHelper.cs | 34 +++++++++--------
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
4 files changed, 39 insertions(+), 35 deletions(-)
rename MenuScalePatch/{ => Helpers}/MainMenuHelper.cs (73%)
rename MenuScalePatch/{ => Helpers}/QuickMenuHelper.cs (72%)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index 3d24450..d0c1abc 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -6,6 +6,7 @@ using cohtml;
using HarmonyLib;
using NAK.Melons.MenuScalePatch.Helpers;
using UnityEngine;
+using MenuScalePatch.Helpers;
namespace NAK.Melons.MenuScalePatch.HarmonyPatches;
diff --git a/MenuScalePatch/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
similarity index 73%
rename from MenuScalePatch/MainMenuHelper.cs
rename to MenuScalePatch/Helpers/MainMenuHelper.cs
index ba3f83d..fd93a19 100644
--- a/MenuScalePatch/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -8,8 +8,9 @@ using HarmonyLib;
using MelonLoader;
using UnityEngine;
using System.Reflection;
+using NAK.Melons.MenuScalePatch.Helpers;
-namespace NAK.Melons.MenuScalePatch.Helpers;
+namespace MenuScalePatch.Helpers;
//TODO: Implement desktop ratio scaling back to MM
@@ -52,6 +53,7 @@ public class MainMenuHelper : MonoBehaviour
public void ToggleDesktopInputMethod(bool flag)
{
+ if (MetaPort.Instance.isUsingVr) return;
PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
CVRInputManager.Instance.inputEnabled = !flag;
RootLogic.Instance.ToggleMouse(flag);
@@ -65,12 +67,12 @@ public class MainMenuHelper : MonoBehaviour
GameObject vrAnchor = new GameObject("MSP_MMVR_Anchor");
vrAnchor.transform.parent = PlayerSetup.Instance.vrCameraRig.transform;
vrAnchor.transform.localPosition = Vector3.zero;
- this.worldAnchor = vrAnchor.transform;
+ worldAnchor = vrAnchor.transform;
}
public void UpdateWorldAnchors()
{
- if (this.worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
+ if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
if (MetaPort.Instance.isUsingVr)
{
@@ -78,18 +80,18 @@ public class MainMenuHelper : MonoBehaviour
float minTilt = MetaPort.Instance.settings.GetSettingsFloat("GeneralMinimumMenuTilt", 0f);
if (zRotation <= minTilt || zRotation >= 360f - minTilt)
{
- this.worldAnchor.rotation = Quaternion.LookRotation(MSP_MenuInfo.CameraTransform.forward, Vector3.up);
+ worldAnchor.rotation = Quaternion.LookRotation(MSP_MenuInfo.CameraTransform.forward, Vector3.up);
}
else
{
- this.worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
+ worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
}
- this.worldAnchor.position = MSP_MenuInfo.CameraTransform.position + MSP_MenuInfo.CameraTransform.forward * 2f * MSP_MenuInfo.ScaleFactor;
+ worldAnchor.position = MSP_MenuInfo.CameraTransform.position + MSP_MenuInfo.CameraTransform.forward * 2f * MSP_MenuInfo.ScaleFactor;
}
else
{
- this.worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
- this.worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
+ worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
+ worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
}
}
@@ -141,19 +143,18 @@ public class MainMenuHelper : MonoBehaviour
{
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableMMHelper) return;
- Transform activeAnchor = independentHeadTurn ? this.worldAnchor : MSP_MenuInfo.CameraTransform;
- this.transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f);
- this.transform.eulerAngles = activeAnchor.eulerAngles;
- this.transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor;
+ Transform activeAnchor = independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
+ transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f);
+ transform.eulerAngles = activeAnchor.eulerAngles;
+ transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor;
}
//VR Main Menu
public void HandleVRPosition()
{
- if (this.worldAnchor == null || MSP_MenuInfo.DisableMMHelper_VR) return;
- this.transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor * 1.8f, 0.9f * MSP_MenuInfo.ScaleFactor * 1.8f, 1f);
- this.transform.position = this.worldAnchor.position;
- this.transform.eulerAngles = this.worldAnchor.eulerAngles;
+ if (worldAnchor == null || MSP_MenuInfo.DisableMMHelper_VR) return;
+ transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor * 1.8f, 0.9f * MSP_MenuInfo.ScaleFactor * 1.8f, 1f);
+ transform.position = worldAnchor.position;
+ transform.eulerAngles = worldAnchor.eulerAngles;
}
-}
-
+}
\ No newline at end of file
diff --git a/MenuScalePatch/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
similarity index 72%
rename from MenuScalePatch/QuickMenuHelper.cs
rename to MenuScalePatch/Helpers/QuickMenuHelper.cs
index 82e5791..b99c5a5 100644
--- a/MenuScalePatch/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -8,8 +8,9 @@ using HarmonyLib;
using MelonLoader;
using UnityEngine;
using System.Reflection;
+using NAK.Melons.MenuScalePatch.Helpers;
-namespace NAK.Melons.MenuScalePatch.Helpers;
+namespace MenuScalePatch.Helpers;
/**
@@ -51,6 +52,7 @@ public class QuickMenuHelper : MonoBehaviour
public void ToggleDesktopInputMethod(bool flag)
{
+ if (MetaPort.Instance.isUsingVr) return;
PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
CVRInputManager.Instance.inputEnabled = !flag;
RootLogic.Instance.ToggleMouse(flag);
@@ -64,15 +66,15 @@ public class QuickMenuHelper : MonoBehaviour
GameObject vrAnchor = new GameObject("MSP_QMVR_Anchor");
vrAnchor.transform.parent = PlayerSetup.Instance.vrCameraRig.transform;
vrAnchor.transform.localPosition = Vector3.zero;
- this.worldAnchor = vrAnchor.transform;
+ worldAnchor = vrAnchor.transform;
}
public void UpdateWorldAnchors()
{
- if (this.worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
+ if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
- this.worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
- this.worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
+ worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
+ worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
}
public void UpdateMenuPosition()
@@ -123,26 +125,26 @@ public class QuickMenuHelper : MonoBehaviour
{
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableQMHelper) return;
- Transform activeAnchor = independentHeadTurn ? this.worldAnchor : MSP_MenuInfo.CameraTransform;
- this.transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
- this.transform.eulerAngles = activeAnchor.eulerAngles;
- this.transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
+ Transform activeAnchor = independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
+ transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
+ transform.eulerAngles = activeAnchor.eulerAngles;
+ transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
}
//VR Quick Menu
public void HandleVRPosition()
{
- if (this.handAnchor == null || MSP_MenuInfo.DisableQMHelper_VR) return;
+ if (handAnchor == null || MSP_MenuInfo.DisableQMHelper_VR) return;
if (MSP_MenuInfo.WorldAnchorQM)
{
- this.transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
- this.transform.eulerAngles = this.worldAnchor.eulerAngles;
- this.transform.position = this.worldAnchor.position + this.worldAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
+ transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
+ transform.eulerAngles = worldAnchor.eulerAngles;
+ transform.position = worldAnchor.position + worldAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
return;
}
- this.transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
- this.transform.position = this.handAnchor.position;
- this.transform.rotation = this.handAnchor.rotation;
+ transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
+ transform.position = handAnchor.position;
+ transform.rotation = handAnchor.rotation;
}
}
\ No newline at end of file
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index 34cef9b..ab7045d 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "4.0.0";
+ public const string Version = "4.0.1";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
From 8ef891434ae66772719c5e076a2e13cac89f374e Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 3 Jan 2023 12:27:08 -0600
Subject: [PATCH 17/41] add aspect ratio calculation
---
MenuScalePatch/HarmonyPatches.cs | 27 +++++++++++++++---------
MenuScalePatch/Helpers/MainMenuHelper.cs | 2 +-
MenuScalePatch/MSP_Menus.cs | 1 +
3 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index d0c1abc..3cfee9d 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -10,6 +10,16 @@ using MenuScalePatch.Helpers;
namespace NAK.Melons.MenuScalePatch.HarmonyPatches;
+/**
+ ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug
+ assuming its caused by cast from int to float getting the screen size, something floating point bleh
+
+ ViewManager.UpdatePosition & CVR_MenuManager.UpdatePosition are called every second in a scheduled job.
+ (its why ViewManager.SetScale is called, because MM uses aspect ratio in scale calculation)
+
+ I nuke those methods. Fuck them. I cannot disable the jobs though...
+**/
+
[HarmonyPatch]
internal class HarmonyPatches
{
@@ -18,10 +28,7 @@ internal class HarmonyPatches
private static void SetQMScale(float avatarHeight, ref float ____scaleFactor, out bool __runOriginal)
{
____scaleFactor = avatarHeight / 1.8f;
- if (MetaPort.Instance.isUsingVr)
- {
- ____scaleFactor *= 0.5f;
- }
+ if (MetaPort.Instance.isUsingVr) ____scaleFactor *= 0.5f;
MSP_MenuInfo.ScaleFactor = ____scaleFactor;
__runOriginal = false;
}
@@ -30,11 +37,7 @@ internal class HarmonyPatches
[HarmonyPatch(typeof(ViewManager), "SetScale")]
private static void CheckMMScale(out bool __runOriginal)
{
- /**
- ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug
- assuming its caused by cast from int to float getting the screen size, something floating point bleh
- i dont need it so i will nuke it >:)
- **/
+ //bitch
__runOriginal = false;
}
@@ -48,8 +51,11 @@ internal class HarmonyPatches
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ViewManager), "UpdateMenuPosition")]
- private static void Prefix_ViewManager_UpdateMenuPosition(out bool __runOriginal)
+ private static void Prefix_ViewManager_UpdateMenuPosition(ref float ___cachedScreenAspectRatio, out bool __runOriginal)
{
+ //this is called once a second, so ill fix their dumb aspect ratio shit
+ float ratio = (float)Screen.width / (float)Screen.height;
+ MSP_MenuInfo.AspectRatio = 1.7777779f / ratio;
__runOriginal = false;
}
@@ -96,6 +102,7 @@ internal class HarmonyPatches
{
if (MainMenuHelper.Instance == null) return;
MainMenuHelper.Instance.UpdateWorldAnchors();
+ MainMenuHelper.Instance.ToggleDesktopInputMethod(show);
MainMenuHelper.Instance.enabled = show;
}
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index fd93a19..c5411d1 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -146,7 +146,7 @@ public class MainMenuHelper : MonoBehaviour
Transform activeAnchor = independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f);
transform.eulerAngles = activeAnchor.eulerAngles;
- transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor;
+ transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.AspectRatio;
}
//VR Main Menu
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
index 341c3c3..d690295 100644
--- a/MenuScalePatch/MSP_Menus.cs
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -12,6 +12,7 @@ public class MSP_MenuInfo
{
//Shared Info
public static float ScaleFactor = 1f;
+ public static float AspectRatio = 1f;
public static Transform CameraTransform;
//Settings...?
From 81affe9377284d337a25891f6e84e7e977c5b21b Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 3 Jan 2023 12:44:56 -0600
Subject: [PATCH 18/41] add clamp to aspect ratio
---
MenuScalePatch/HarmonyPatches.cs | 3 ++-
MenuScalePatch/MenuScalePatch.csproj | 9 ---------
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index 3cfee9d..189e34a 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -55,7 +55,8 @@ internal class HarmonyPatches
{
//this is called once a second, so ill fix their dumb aspect ratio shit
float ratio = (float)Screen.width / (float)Screen.height;
- MSP_MenuInfo.AspectRatio = 1.7777779f / ratio;
+ float clamp = Mathf.Clamp(ratio, 0f, 1.8f);
+ MSP_MenuInfo.AspectRatio = 1.7777779f / clamp;
__runOriginal = false;
}
diff --git a/MenuScalePatch/MenuScalePatch.csproj b/MenuScalePatch/MenuScalePatch.csproj
index bb32f6d..655b3bd 100644
--- a/MenuScalePatch/MenuScalePatch.csproj
+++ b/MenuScalePatch/MenuScalePatch.csproj
@@ -18,24 +18,15 @@
..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll
-
- ..\..\Giamoz\Giamoz\bin\Debug\net472\Giamoz.dll
-
C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll
-
- C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\SteamVR.dll
-
C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll
C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.InputLegacyModule.dll
-
- ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.PhysicsModule.dll
-
From 845baee8498153243d63938b9d8a6e6d724933ef Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 3 Jan 2023 16:45:32 -0600
Subject: [PATCH 19/41] well
---
MenuScalePatch/HarmonyPatches.cs | 13 +++++++++++--
MenuScalePatch/Helpers/MainMenuHelper.cs | 21 +++++++++------------
MenuScalePatch/Helpers/QuickMenuHelper.cs | 21 +++++++++------------
MenuScalePatch/MSP_Menus.cs | 16 ++++++++++++++++
4 files changed, 45 insertions(+), 26 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index 189e34a..d6e1a3d 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -84,7 +84,7 @@ internal class HarmonyPatches
{
if (QuickMenuHelper.Instance == null) return;
QuickMenuHelper.Instance.UpdateWorldAnchors();
- QuickMenuHelper.Instance.ToggleDesktopInputMethod(show);
+ MSP_MenuInfo.ToggleDesktopInputMethod(show);
QuickMenuHelper.Instance.enabled = show;
}
@@ -103,7 +103,7 @@ internal class HarmonyPatches
{
if (MainMenuHelper.Instance == null) return;
MainMenuHelper.Instance.UpdateWorldAnchors();
- MainMenuHelper.Instance.ToggleDesktopInputMethod(show);
+ MSP_MenuInfo.ToggleDesktopInputMethod(show);
MainMenuHelper.Instance.enabled = show;
}
@@ -114,4 +114,13 @@ internal class HarmonyPatches
{
MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
}
+
+ //only fixes Desktop QM interaction while using independent head input...
+ //[HarmonyPrefix]
+ //[HarmonyPatch(typeof(ControllerRay), "LateUpdate")]
+ //private static void UpdateMenuPositionForInput()
+ //{
+ // MainMenuHelper.Instance.UpdateMenuPosition();
+ // QuickMenuHelper.Instance.UpdateMenuPosition();
+ //}
}
\ No newline at end of file
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index c5411d1..1c90ee9 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -44,21 +44,18 @@ public class MainMenuHelper : MonoBehaviour
UpdateMenuPosition();
}
- void OnDisable()
+ void OnEnable()
{
independentHeadTurn = false;
returnIndependentHeadTurn = false;
prevIndependentHeadTurn = false;
}
- public void ToggleDesktopInputMethod(bool flag)
+ void OnDisable()
{
- if (MetaPort.Instance.isUsingVr) return;
- PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
- CVRInputManager.Instance.inputEnabled = !flag;
- RootLogic.Instance.ToggleMouse(flag);
- CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
- Traverse.Create(CVR_MenuManager.Instance).Field("_desktopMouseMode").SetValue(flag);
+ independentHeadTurn = false;
+ returnIndependentHeadTurn = false;
+ prevIndependentHeadTurn = false;
}
public void CreateWorldAnchors()
@@ -103,6 +100,7 @@ public class MainMenuHelper : MonoBehaviour
return;
}
+ float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
bool independentHeadTurnChanged = CVRInputManager.Instance.independentHeadTurn != prevIndependentHeadTurn;
if (independentHeadTurnChanged)
{
@@ -110,10 +108,10 @@ public class MainMenuHelper : MonoBehaviour
//if pressing but not already enabled
if (prevIndependentHeadTurn)
{
- if (!independentHeadTurn)
+ if (!independentHeadTurn && angle == 0f)
{
UpdateWorldAnchors();
- ToggleDesktopInputMethod(!prevIndependentHeadTurn);
+ MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
independentHeadTurn = true;
}
returnIndependentHeadTurn = false;
@@ -126,12 +124,11 @@ public class MainMenuHelper : MonoBehaviour
if (returnIndependentHeadTurn)
{
- float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
if (angle == 0f)
{
independentHeadTurn = false;
returnIndependentHeadTurn = false;
- ToggleDesktopInputMethod(!prevIndependentHeadTurn);
+ MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
}
}
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index b99c5a5..a0f467a 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -43,21 +43,18 @@ public class QuickMenuHelper : MonoBehaviour
UpdateMenuPosition();
}
- void OnDisable()
+ void OnEnable()
{
independentHeadTurn = false;
returnIndependentHeadTurn = false;
prevIndependentHeadTurn = false;
}
- public void ToggleDesktopInputMethod(bool flag)
+ void OnDisable()
{
- if (MetaPort.Instance.isUsingVr) return;
- PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
- CVRInputManager.Instance.inputEnabled = !flag;
- RootLogic.Instance.ToggleMouse(flag);
- CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
- Traverse.Create(CVR_MenuManager.Instance).Field("_desktopMouseMode").SetValue(flag);
+ independentHeadTurn = false;
+ returnIndependentHeadTurn = false;
+ prevIndependentHeadTurn = false;
}
public void CreateWorldAnchors()
@@ -85,6 +82,7 @@ public class QuickMenuHelper : MonoBehaviour
return;
}
+ float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
bool independentHeadTurnChanged = CVRInputManager.Instance.independentHeadTurn != prevIndependentHeadTurn;
if (independentHeadTurnChanged)
{
@@ -92,10 +90,10 @@ public class QuickMenuHelper : MonoBehaviour
//if pressing but not already enabled
if (prevIndependentHeadTurn)
{
- if (!independentHeadTurn)
+ if (!independentHeadTurn && angle == 0f)
{
UpdateWorldAnchors();
- ToggleDesktopInputMethod(!prevIndependentHeadTurn);
+ MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
independentHeadTurn = true;
}
returnIndependentHeadTurn = false;
@@ -108,12 +106,11 @@ public class QuickMenuHelper : MonoBehaviour
if (returnIndependentHeadTurn)
{
- float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
if (angle == 0f)
{
independentHeadTurn = false;
returnIndependentHeadTurn = false;
- ToggleDesktopInputMethod(!prevIndependentHeadTurn);
+ MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
}
}
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
index d690295..3961816 100644
--- a/MenuScalePatch/MSP_Menus.cs
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -4,7 +4,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
+using ABI_RC.Core.InteractionSystem;
+using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
+using ABI_RC.Core;
+using ABI_RC.Systems.MovementSystem;
+using HarmonyLib;
namespace NAK.Melons.MenuScalePatch.Helpers;
@@ -23,4 +28,15 @@ public class MSP_MenuInfo
public static bool DisableQMHelper_VR;
public static bool DisableMMHelper;
public static bool DisableMMHelper_VR;
+
+ public static void ToggleDesktopInputMethod(bool flag)
+ {
+ if (MetaPort.Instance.isUsingVr) return;
+ MelonLoader.MelonLogger.Msg("Toggled Desktop Input");
+ PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
+ CVRInputManager.Instance.inputEnabled = !flag;
+ RootLogic.Instance.ToggleMouse(flag);
+ CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
+ Traverse.Create(CVR_MenuManager.Instance).Field("_desktopMouseMode").SetValue(flag);
+ }
}
\ No newline at end of file
From 4a5527d7de0e7c59defcd910c3827487b19e3668 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 3 Jan 2023 21:11:16 -0600
Subject: [PATCH 20/41] i hate all
holy shit this fucking bug took me two hours to fix
why was the solution so simple... fuck
---
MenuScalePatch/HarmonyPatches.cs | 31 ++++++-------
MenuScalePatch/Helpers/MainMenuHelper.cs | 56 +----------------------
MenuScalePatch/Helpers/QuickMenuHelper.cs | 56 +----------------------
MenuScalePatch/MSP_Menus.cs | 21 ++++++++-
4 files changed, 38 insertions(+), 126 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index d6e1a3d..97e38aa 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -78,13 +78,16 @@ internal class HarmonyPatches
}
//hook quickmenu open/close
- [HarmonyPostfix]
+ [HarmonyPrefix]
[HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
- private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show)
+ private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show, ref bool ____quickMenuOpen)
{
if (QuickMenuHelper.Instance == null) return;
- QuickMenuHelper.Instance.UpdateWorldAnchors();
- MSP_MenuInfo.ToggleDesktopInputMethod(show);
+ if (show != ____quickMenuOpen)
+ {
+ QuickMenuHelper.Instance.UpdateWorldAnchors();
+ MSP_MenuInfo.ToggleDesktopInputMethod(show);
+ }
QuickMenuHelper.Instance.enabled = show;
}
@@ -97,13 +100,16 @@ internal class HarmonyPatches
}
//hook menu open/close
- [HarmonyPostfix]
+ [HarmonyPrefix]
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
- private static void Postfix_ViewManager_UiStateToggle(bool show)
+ private static void Postfix_ViewManager_UiStateToggle(bool show, ref bool ____gameMenuOpen)
{
if (MainMenuHelper.Instance == null) return;
- MainMenuHelper.Instance.UpdateWorldAnchors();
- MSP_MenuInfo.ToggleDesktopInputMethod(show);
+ if (show != ____gameMenuOpen)
+ {
+ MainMenuHelper.Instance.UpdateWorldAnchors();
+ MSP_MenuInfo.ToggleDesktopInputMethod(show);
+ }
MainMenuHelper.Instance.enabled = show;
}
@@ -114,13 +120,4 @@ internal class HarmonyPatches
{
MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
}
-
- //only fixes Desktop QM interaction while using independent head input...
- //[HarmonyPrefix]
- //[HarmonyPatch(typeof(ControllerRay), "LateUpdate")]
- //private static void UpdateMenuPositionForInput()
- //{
- // MainMenuHelper.Instance.UpdateMenuPosition();
- // QuickMenuHelper.Instance.UpdateMenuPosition();
- //}
}
\ No newline at end of file
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index 1c90ee9..5959276 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -28,11 +28,6 @@ public class MainMenuHelper : MonoBehaviour
public static MainMenuHelper Instance;
public Transform worldAnchor;
- static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
- private bool independentHeadTurn = false;
- private bool returnIndependentHeadTurn = false;
- private bool prevIndependentHeadTurn = false;
-
void Start()
{
Instance = this;
@@ -41,23 +36,10 @@ public class MainMenuHelper : MonoBehaviour
void LateUpdate()
{
+ MSP_MenuInfo.HandleIndependentLookInput();
UpdateMenuPosition();
}
- void OnEnable()
- {
- independentHeadTurn = false;
- returnIndependentHeadTurn = false;
- prevIndependentHeadTurn = false;
- }
-
- void OnDisable()
- {
- independentHeadTurn = false;
- returnIndependentHeadTurn = false;
- prevIndependentHeadTurn = false;
- }
-
public void CreateWorldAnchors()
{
//VR specific anchor
@@ -99,39 +81,6 @@ public class MainMenuHelper : MonoBehaviour
HandleVRPosition();
return;
}
-
- float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
- bool independentHeadTurnChanged = CVRInputManager.Instance.independentHeadTurn != prevIndependentHeadTurn;
- if (independentHeadTurnChanged)
- {
- prevIndependentHeadTurn = CVRInputManager.Instance.independentHeadTurn;
- //if pressing but not already enabled
- if (prevIndependentHeadTurn)
- {
- if (!independentHeadTurn && angle == 0f)
- {
- UpdateWorldAnchors();
- MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
- independentHeadTurn = true;
- }
- returnIndependentHeadTurn = false;
- }
- else
- {
- returnIndependentHeadTurn = true;
- }
- }
-
- if (returnIndependentHeadTurn)
- {
- if (angle == 0f)
- {
- independentHeadTurn = false;
- returnIndependentHeadTurn = false;
- MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
- }
- }
-
HandleDesktopPosition();
}
@@ -139,8 +88,7 @@ public class MainMenuHelper : MonoBehaviour
public void HandleDesktopPosition()
{
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableMMHelper) return;
-
- Transform activeAnchor = independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
+ Transform activeAnchor = MSP_MenuInfo.independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f);
transform.eulerAngles = activeAnchor.eulerAngles;
transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.AspectRatio;
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index a0f467a..e2b5fce 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -27,11 +27,6 @@ public class QuickMenuHelper : MonoBehaviour
public Transform worldAnchor;
public Transform handAnchor;
- static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
- private bool independentHeadTurn = false;
- private bool returnIndependentHeadTurn = false;
- private bool prevIndependentHeadTurn = false;
-
void Start()
{
Instance = this;
@@ -40,23 +35,10 @@ public class QuickMenuHelper : MonoBehaviour
void LateUpdate()
{
+ MSP_MenuInfo.HandleIndependentLookInput();
UpdateMenuPosition();
}
- void OnEnable()
- {
- independentHeadTurn = false;
- returnIndependentHeadTurn = false;
- prevIndependentHeadTurn = false;
- }
-
- void OnDisable()
- {
- independentHeadTurn = false;
- returnIndependentHeadTurn = false;
- prevIndependentHeadTurn = false;
- }
-
public void CreateWorldAnchors()
{
//VR specific anchor
@@ -69,7 +51,6 @@ public class QuickMenuHelper : MonoBehaviour
public void UpdateWorldAnchors()
{
if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
-
worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
}
@@ -81,39 +62,6 @@ public class QuickMenuHelper : MonoBehaviour
HandleVRPosition();
return;
}
-
- float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
- bool independentHeadTurnChanged = CVRInputManager.Instance.independentHeadTurn != prevIndependentHeadTurn;
- if (independentHeadTurnChanged)
- {
- prevIndependentHeadTurn = CVRInputManager.Instance.independentHeadTurn;
- //if pressing but not already enabled
- if (prevIndependentHeadTurn)
- {
- if (!independentHeadTurn && angle == 0f)
- {
- UpdateWorldAnchors();
- MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
- independentHeadTurn = true;
- }
- returnIndependentHeadTurn = false;
- }
- else
- {
- returnIndependentHeadTurn = true;
- }
- }
-
- if (returnIndependentHeadTurn)
- {
- if (angle == 0f)
- {
- independentHeadTurn = false;
- returnIndependentHeadTurn = false;
- MSP_MenuInfo.ToggleDesktopInputMethod(!prevIndependentHeadTurn);
- }
- }
-
HandleDesktopPosition();
}
@@ -122,7 +70,7 @@ public class QuickMenuHelper : MonoBehaviour
{
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableQMHelper) return;
- Transform activeAnchor = independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
+ Transform activeAnchor = MSP_MenuInfo.independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
transform.eulerAngles = activeAnchor.eulerAngles;
transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
index 3961816..0e56fbf 100644
--- a/MenuScalePatch/MSP_Menus.cs
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -1,4 +1,5 @@
using System;
+using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -32,11 +33,29 @@ public class MSP_MenuInfo
public static void ToggleDesktopInputMethod(bool flag)
{
if (MetaPort.Instance.isUsingVr) return;
- MelonLoader.MelonLogger.Msg("Toggled Desktop Input");
PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
CVRInputManager.Instance.inputEnabled = !flag;
RootLogic.Instance.ToggleMouse(flag);
CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
Traverse.Create(CVR_MenuManager.Instance).Field("_desktopMouseMode").SetValue(flag);
}
+
+ static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
+ public static bool independentHeadTurn = false;
+
+ public static void HandleIndependentLookInput()
+ {
+ //angle of independent look axis
+ float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
+ bool isPressed = CVRInputManager.Instance.independentHeadTurn;
+ if (isPressed && !independentHeadTurn)
+ {
+ independentHeadTurn = true;
+ MSP_MenuInfo.ToggleDesktopInputMethod(false);
+ }else if (!isPressed && independentHeadTurn && angle == 0f)
+ {
+ independentHeadTurn = false;
+ MSP_MenuInfo.ToggleDesktopInputMethod(true);
+ }
+ }
}
\ No newline at end of file
From 367a16746963e4395aada669c81362d5b0f1a934 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 3 Jan 2023 21:38:23 -0600
Subject: [PATCH 21/41] polish my pain
---
MenuScalePatch/HarmonyPatches.cs | 33 +++++++++++------------
MenuScalePatch/Helpers/MainMenuHelper.cs | 12 ++-------
MenuScalePatch/Helpers/QuickMenuHelper.cs | 12 ++-------
MenuScalePatch/MSP_Menus.cs | 27 ++++++++++---------
MenuScalePatch/Main.cs | 8 +-----
5 files changed, 35 insertions(+), 57 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index 97e38aa..8f601d8 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -1,12 +1,9 @@
using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
-using ABI_RC.Core;
-using cohtml;
using HarmonyLib;
using NAK.Melons.MenuScalePatch.Helpers;
using UnityEngine;
-using MenuScalePatch.Helpers;
namespace NAK.Melons.MenuScalePatch.HarmonyPatches;
@@ -25,7 +22,7 @@ internal class HarmonyPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
- private static void SetQMScale(float avatarHeight, ref float ____scaleFactor, out bool __runOriginal)
+ private static void Prefix_CVR_MenuManager_SetScale(float avatarHeight, ref float ____scaleFactor, out bool __runOriginal)
{
____scaleFactor = avatarHeight / 1.8f;
if (MetaPort.Instance.isUsingVr) ____scaleFactor *= 0.5f;
@@ -35,7 +32,7 @@ internal class HarmonyPatches
[HarmonyPrefix]
[HarmonyPatch(typeof(ViewManager), "SetScale")]
- private static void CheckMMScale(out bool __runOriginal)
+ private static void Prefix_ViewManager_SetScale(out bool __runOriginal)
{
//bitch
__runOriginal = false;
@@ -47,8 +44,10 @@ internal class HarmonyPatches
[HarmonyPatch(typeof(CVR_MenuManager), "UpdateMenuPosition")]
private static void Prefix_CVR_MenuManager_UpdateMenuPosition(out bool __runOriginal)
{
+ //fuck u
__runOriginal = false;
}
+
[HarmonyPrefix]
[HarmonyPatch(typeof(ViewManager), "UpdateMenuPosition")]
private static void Prefix_ViewManager_UpdateMenuPosition(ref float ___cachedScreenAspectRatio, out bool __runOriginal)
@@ -63,7 +62,7 @@ internal class HarmonyPatches
//Set QM stuff
[HarmonyPostfix]
[HarmonyPatch(typeof(CVR_MenuManager), "Start")]
- private static void SetupQMHelper(ref CVR_MenuManager __instance, ref GameObject ____leftVrAnchor)
+ private static void Postfix_CVR_MenuManager_Start(ref CVR_MenuManager __instance, ref GameObject ____leftVrAnchor)
{
QuickMenuHelper helper = __instance.quickMenu.gameObject.AddComponent();
helper.handAnchor = ____leftVrAnchor.transform;
@@ -72,7 +71,7 @@ internal class HarmonyPatches
//Set MM stuff
[HarmonyPostfix]
[HarmonyPatch(typeof(ViewManager), "Start")]
- private static void SetupMMHelper(ref ViewManager __instance)
+ private static void Postfix_ViewManager_Start(ref ViewManager __instance)
{
__instance.gameObject.AddComponent();
}
@@ -80,7 +79,7 @@ internal class HarmonyPatches
//hook quickmenu open/close
[HarmonyPrefix]
[HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
- private static void Postfix_CVR_MenuManager_ToggleQuickMenu(bool show, ref bool ____quickMenuOpen)
+ private static void Prefix_CVR_MenuManager_ToggleQuickMenu(bool show, ref bool ____quickMenuOpen)
{
if (QuickMenuHelper.Instance == null) return;
if (show != ____quickMenuOpen)
@@ -91,14 +90,6 @@ internal class HarmonyPatches
QuickMenuHelper.Instance.enabled = show;
}
- //add independent head movement to important input
- [HarmonyPostfix]
- [HarmonyPatch(typeof(InputModuleMouseKeyboard), "UpdateImportantInput")]
- private static void Postfix_InputModuleMouseKeyboard_UpdateImportantInput(ref CVRInputManager ____inputManager)
- {
- ____inputManager.independentHeadTurn |= Input.GetKey(KeyCode.LeftAlt);
- }
-
//hook menu open/close
[HarmonyPrefix]
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
@@ -113,10 +104,18 @@ internal class HarmonyPatches
MainMenuHelper.Instance.enabled = show;
}
+ //add independent head movement to important input
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(InputModuleMouseKeyboard), "UpdateImportantInput")]
+ private static void Postfix_InputModuleMouseKeyboard_UpdateImportantInput(ref CVRInputManager ____inputManager)
+ {
+ ____inputManager.independentHeadTurn |= Input.GetKey(KeyCode.LeftAlt);
+ }
+
//Support for changing VRMode during runtime.
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerSetup), "CalibrateAvatar")]
- private static void CheckVRModeOnSwitch()
+ private static void Postfix_PlayerSetup_CalibrateAvatar()
{
MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
}
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index 5959276..2df6d1b 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -1,16 +1,8 @@
-using ABI_RC.Core.InteractionSystem;
-using ABI_RC.Core.Player;
+using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
-using ABI_RC.Core;
-using ABI_RC.Systems.MovementSystem;
-using cohtml;
-using HarmonyLib;
-using MelonLoader;
using UnityEngine;
-using System.Reflection;
-using NAK.Melons.MenuScalePatch.Helpers;
-namespace MenuScalePatch.Helpers;
+namespace NAK.Melons.MenuScalePatch.Helpers;
//TODO: Implement desktop ratio scaling back to MM
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index e2b5fce..834251f 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -1,16 +1,8 @@
-using ABI_RC.Core.InteractionSystem;
-using ABI_RC.Core.Player;
+using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
-using ABI_RC.Core;
-using ABI_RC.Systems.MovementSystem;
-using cohtml;
-using HarmonyLib;
-using MelonLoader;
using UnityEngine;
-using System.Reflection;
-using NAK.Melons.MenuScalePatch.Helpers;
-namespace MenuScalePatch.Helpers;
+namespace NAK.Melons.MenuScalePatch.Helpers;
/**
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
index 0e56fbf..290781c 100644
--- a/MenuScalePatch/MSP_Menus.cs
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -1,16 +1,11 @@
-using System;
-using System.Reflection;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using UnityEngine;
+using ABI_RC.Core;
using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
-using ABI_RC.Core;
using ABI_RC.Systems.MovementSystem;
using HarmonyLib;
+using System.Reflection;
+using UnityEngine;
namespace NAK.Melons.MenuScalePatch.Helpers;
@@ -46,16 +41,22 @@ public class MSP_MenuInfo
public static void HandleIndependentLookInput()
{
//angle of independent look axis
- float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
- bool isPressed = CVRInputManager.Instance.independentHeadTurn;
+ bool isPressed = CVRInputManager.Instance.independentHeadTurn || CVRInputManager.Instance.independentHeadToggle;
if (isPressed && !independentHeadTurn)
{
independentHeadTurn = true;
MSP_MenuInfo.ToggleDesktopInputMethod(false);
- }else if (!isPressed && independentHeadTurn && angle == 0f)
+ QuickMenuHelper.Instance.UpdateWorldAnchors();
+ MainMenuHelper.Instance.UpdateWorldAnchors();
+ }
+ else if (!isPressed && independentHeadTurn)
{
- independentHeadTurn = false;
- MSP_MenuInfo.ToggleDesktopInputMethod(true);
+ float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
+ if (angle == 0f)
+ {
+ independentHeadTurn = false;
+ MSP_MenuInfo.ToggleDesktopInputMethod(true);
+ }
}
}
}
\ No newline at end of file
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
index 812989b..72a78d2 100644
--- a/MenuScalePatch/Main.cs
+++ b/MenuScalePatch/Main.cs
@@ -1,10 +1,4 @@
-using ABI_RC.Core.InteractionSystem;
-using ABI_RC.Core.Player;
-using ABI_RC.Core.Savior;
-using cohtml;
-using HarmonyLib;
-using MelonLoader;
-using UnityEngine;
+using MelonLoader;
using NAK.Melons.MenuScalePatch.Helpers;
namespace NAK.Melons.MenuScalePatch;
From 73bbc2a7c58dcbfbff2c06b833b3d9696b35b1f7 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Tue, 3 Jan 2023 22:45:31 -0600
Subject: [PATCH 22/41] a
---
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index ab7045d..64804cf 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "4.0.1";
+ public const string Version = "4.1.1";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
From 5d4b7e354aa138d2992e2f5783c59f5c7bc65f70 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Thu, 2 Feb 2023 22:25:35 -0600
Subject: [PATCH 23/41] i want no life
---
MenuScalePatch/HarmonyPatches.cs | 162 +++++++++++++++++++---
MenuScalePatch/Helpers/MainMenuHelper.cs | 20 ++-
MenuScalePatch/Helpers/QuickMenuHelper.cs | 17 ++-
MenuScalePatch/MSP_Menus.cs | 31 +++--
MenuScalePatch/Main.cs | 27 ++--
MenuScalePatch/MenuScalePatch.csproj | 3 +
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
MenuScalePatch/format.json | 8 +-
8 files changed, 208 insertions(+), 62 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index 8f601d8..999c87d 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -3,6 +3,8 @@ using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
using HarmonyLib;
using NAK.Melons.MenuScalePatch.Helpers;
+using System.Reflection;
+using System.Reflection.Emit;
using UnityEngine;
namespace NAK.Melons.MenuScalePatch.HarmonyPatches;
@@ -20,43 +22,64 @@ namespace NAK.Melons.MenuScalePatch.HarmonyPatches;
[HarmonyPatch]
internal class HarmonyPatches
{
+ //stuff needed on start
+ [HarmonyPostfix]
+ [HarmonyPatch(typeof(PlayerSetup), "Start")]
+ private static void Postfix_PlayerSetup_Start()
+ {
+ try
+ {
+ MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
+ MenuScalePatch.UpdateAllSettings();
+ QuickMenuHelper.Instance.CreateWorldAnchors();
+ MainMenuHelper.Instance.CreateWorldAnchors();
+ }
+ catch (System.Exception e)
+ {
+ MenuScalePatch.Logger.Error(e);
+ }
+ }
+
[HarmonyPrefix]
[HarmonyPatch(typeof(CVR_MenuManager), "SetScale")]
- private static void Prefix_CVR_MenuManager_SetScale(float avatarHeight, ref float ____scaleFactor, out bool __runOriginal)
+ private static bool Prefix_CVR_MenuManager_SetScale(float avatarHeight, ref float ____scaleFactor)
{
____scaleFactor = avatarHeight / 1.8f;
if (MetaPort.Instance.isUsingVr) ____scaleFactor *= 0.5f;
MSP_MenuInfo.ScaleFactor = ____scaleFactor;
- __runOriginal = false;
+ if (!MSP_MenuInfo.PlayerAnchorMenus)
+ {
+ QuickMenuHelper.Instance.NeedsPositionUpdate = true;
+ MainMenuHelper.Instance.NeedsPositionUpdate = true;
+ }
+ return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ViewManager), "SetScale")]
- private static void Prefix_ViewManager_SetScale(out bool __runOriginal)
+ private static bool Prefix_ViewManager_SetScale()
{
- //bitch
- __runOriginal = false;
+ return false;
}
//nuke UpdateMenuPosition methods
//there are 2 Jobs calling this each second, which is fucking my shit
[HarmonyPrefix]
[HarmonyPatch(typeof(CVR_MenuManager), "UpdateMenuPosition")]
- private static void Prefix_CVR_MenuManager_UpdateMenuPosition(out bool __runOriginal)
+ private static bool Prefix_CVR_MenuManager_UpdateMenuPosition()
{
- //fuck u
- __runOriginal = false;
+ return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ViewManager), "UpdateMenuPosition")]
- private static void Prefix_ViewManager_UpdateMenuPosition(ref float ___cachedScreenAspectRatio, out bool __runOriginal)
+ private static bool Prefix_ViewManager_UpdateMenuPosition(ref float ___cachedScreenAspectRatio)
{
//this is called once a second, so ill fix their dumb aspect ratio shit
float ratio = (float)Screen.width / (float)Screen.height;
float clamp = Mathf.Clamp(ratio, 0f, 1.8f);
MSP_MenuInfo.AspectRatio = 1.7777779f / clamp;
- __runOriginal = false;
+ return false;
}
//Set QM stuff
@@ -64,8 +87,16 @@ internal class HarmonyPatches
[HarmonyPatch(typeof(CVR_MenuManager), "Start")]
private static void Postfix_CVR_MenuManager_Start(ref CVR_MenuManager __instance, ref GameObject ____leftVrAnchor)
{
- QuickMenuHelper helper = __instance.quickMenu.gameObject.AddComponent();
- helper.handAnchor = ____leftVrAnchor.transform;
+ try
+ {
+ QuickMenuHelper helper = __instance.quickMenu.gameObject.AddComponent();
+ helper.handAnchor = ____leftVrAnchor.transform;
+ helper.enabled = false;
+ }
+ catch (System.Exception e)
+ {
+ MenuScalePatch.Logger.Error(e);
+ }
}
//Set MM stuff
@@ -73,35 +104,71 @@ internal class HarmonyPatches
[HarmonyPatch(typeof(ViewManager), "Start")]
private static void Postfix_ViewManager_Start(ref ViewManager __instance)
{
- __instance.gameObject.AddComponent();
+ try
+ {
+ MainMenuHelper helper = __instance.gameObject.AddComponent();
+ helper.enabled = false;
+ }
+ catch (System.Exception e)
+ {
+ MenuScalePatch.Logger.Error(e);
+ }
}
//hook quickmenu open/close
[HarmonyPrefix]
[HarmonyPatch(typeof(CVR_MenuManager), "ToggleQuickMenu", new Type[] { typeof(bool) })]
- private static void Prefix_CVR_MenuManager_ToggleQuickMenu(bool show, ref bool ____quickMenuOpen)
+ private static bool Prefix_CVR_MenuManager_ToggleQuickMenu(bool show, ref CVR_MenuManager __instance, ref bool ____quickMenuOpen)
{
- if (QuickMenuHelper.Instance == null) return;
+ if (QuickMenuHelper.Instance == null) return true;
if (show != ____quickMenuOpen)
{
- QuickMenuHelper.Instance.UpdateWorldAnchors();
+ ____quickMenuOpen = show;
+ __instance.quickMenu.enabled = show;
+ __instance.quickMenuAnimator.SetBool("Open", show);
+ QuickMenuHelper.Instance.enabled = show;
+ QuickMenuHelper.Instance.UpdateWorldAnchors(show);
+ //shouldnt run if switching menus on desktop
+ if (!MetaPort.Instance.isUsingVr)
+ {
+ if (!show && MainMenuHelper.Instance.enabled)
+ {
+ return false;
+ }
+ ViewManager.Instance.UiStateToggle(false);
+ }
MSP_MenuInfo.ToggleDesktopInputMethod(show);
+ CVRPlayerManager.Instance.ReloadAllNameplates();
}
- QuickMenuHelper.Instance.enabled = show;
+ return false;
}
//hook menu open/close
[HarmonyPrefix]
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
- private static void Postfix_ViewManager_UiStateToggle(bool show, ref bool ____gameMenuOpen)
+ private static bool Postfix_ViewManager_UiStateToggle(bool show, ref ViewManager __instance, ref bool ____gameMenuOpen)
{
- if (MainMenuHelper.Instance == null) return;
+ if (MainMenuHelper.Instance == null) return true;
if (show != ____gameMenuOpen)
{
- MainMenuHelper.Instance.UpdateWorldAnchors();
+ ____gameMenuOpen = show;
+ __instance.gameMenuView.enabled = show;
+ __instance.uiMenuAnimator.SetBool("Open", show);
+ MainMenuHelper.Instance.enabled = show;
+ MainMenuHelper.Instance.UpdateWorldAnchors(show);
+ //shouldnt run if switching menus on desktop
+ if (!MetaPort.Instance.isUsingVr)
+ {
+ if (!show && QuickMenuHelper.Instance.enabled)
+ {
+ return false;
+ }
+ CVR_MenuManager.Instance.ToggleQuickMenu(false);
+ }
MSP_MenuInfo.ToggleDesktopInputMethod(show);
+ CVRPlayerManager.Instance.ReloadAllNameplates();
}
- MainMenuHelper.Instance.enabled = show;
+ return false;
}
//add independent head movement to important input
@@ -117,6 +184,57 @@ internal class HarmonyPatches
[HarmonyPatch(typeof(PlayerSetup), "CalibrateAvatar")]
private static void Postfix_PlayerSetup_CalibrateAvatar()
{
- MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
+ try
+ {
+ MSP_MenuInfo.CameraTransform = PlayerSetup.Instance.GetActiveCamera().transform;
+ }
+ catch (System.Exception e)
+ {
+ MenuScalePatch.Logger.Error(e);
+ }
+ }
+
+ //[HarmonyTranspiler]
+ //[HarmonyPatch(typeof(ControllerRay), "LateUpdate")]
+ private static IEnumerable Transpiler_ControllerRay_UpdateInput(
+ IEnumerable instructions, ILGenerator il)
+ {
+
+ // Stop calling move mouse events on the menus, the ones that instantiate and the send the event (easy)
+ // Makes this: "component.View.MouseEvent(mouseEventData1);" go POOF
+ instructions = new CodeMatcher(instructions)
+ .MatchForward(false,
+ new CodeMatch(OpCodes.Ldloc_S),
+ new CodeMatch(i => i.opcode == OpCodes.Callvirt && i.operand is MethodInfo { Name: "get_View" }),
+ new CodeMatch(OpCodes.Ldloc_S),
+ new CodeMatch(i => i.opcode == OpCodes.Callvirt && i.operand is MethodInfo { Name: "MouseEvent" }))
+ .Repeat(matcher => matcher
+ .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop))
+ .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop))
+ .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop))
+ .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop))
+ )
+ .InstructionEnumeration();
+
+ // Look for the if flag2 and replace flag 2 with false, for the ones that create the event and send inline (hard ;_;)
+ // Makes this: "if (flag2 && this._mouseDownOnMenu != ControllerRay.Menu.None || ..." into:
+ // this: "if (false && this._mouseDownOnMenu != ControllerRay.Menu.None || ..."
+ instructions = new CodeMatcher(instructions)
+ .MatchForward(false,
+ new CodeMatch(OpCodes.Ldloc_2),
+ new CodeMatch(OpCodes.Brfalse),
+ new CodeMatch(OpCodes.Ldarg_0),
+ new CodeMatch(i =>
+ i.opcode == OpCodes.Ldfld && i.operand is FieldInfo { Name: "_mouseDownOnMenu" }),
+ new CodeMatch(OpCodes.Brtrue),
+ new CodeMatch(OpCodes.Ldarg_0),
+ new CodeMatch(i =>
+ i.opcode == OpCodes.Ldfld && i.operand is FieldInfo { Name: "_mouseDownOnMenu" }),
+ new CodeMatch(OpCodes.Ldc_I4_1),
+ new CodeMatch(OpCodes.Bne_Un))
+ .SetOpcodeAndAdvance(OpCodes.Ldc_I4_0) // replace flag2 with false
+ .InstructionEnumeration();
+
+ return instructions;
}
}
\ No newline at end of file
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index 2df6d1b..6930cf6 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -2,6 +2,7 @@
using ABI_RC.Core.Savior;
using UnityEngine;
+
namespace NAK.Melons.MenuScalePatch.Helpers;
//TODO: Implement desktop ratio scaling back to MM
@@ -14,22 +15,25 @@ namespace NAK.Melons.MenuScalePatch.Helpers;
**/
-[DefaultExecutionOrder(999999)]
+[DefaultExecutionOrder(20000)]
public class MainMenuHelper : MonoBehaviour
{
public static MainMenuHelper Instance;
public Transform worldAnchor;
+ public bool NeedsPositionUpdate;
- void Start()
+ void Awake()
{
Instance = this;
- CreateWorldAnchors();
}
void LateUpdate()
{
- MSP_MenuInfo.HandleIndependentLookInput();
- UpdateMenuPosition();
+ if (MSP_MenuInfo.UseIndependentHeadTurn)
+ MSP_MenuInfo.HandleIndependentLookInput();
+ if (MSP_MenuInfo.PlayerAnchorMenus)
+ UpdateMenuPosition();
+ if (NeedsPositionUpdate) UpdateMenuPosition();
}
public void CreateWorldAnchors()
@@ -41,7 +45,7 @@ public class MainMenuHelper : MonoBehaviour
worldAnchor = vrAnchor.transform;
}
- public void UpdateWorldAnchors()
+ public void UpdateWorldAnchors(bool updateMenuPos = false)
{
if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
@@ -64,10 +68,12 @@ public class MainMenuHelper : MonoBehaviour
worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
}
+ if (updateMenuPos) UpdateMenuPosition();
}
public void UpdateMenuPosition()
{
+ NeedsPositionUpdate = false;
if (MetaPort.Instance.isUsingVr)
{
HandleVRPosition();
@@ -94,4 +100,4 @@ public class MainMenuHelper : MonoBehaviour
transform.position = worldAnchor.position;
transform.eulerAngles = worldAnchor.eulerAngles;
}
-}
\ No newline at end of file
+}
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index 834251f..1c713b9 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -12,23 +12,26 @@ namespace NAK.Melons.MenuScalePatch.Helpers;
**/
-[DefaultExecutionOrder(999999)]
+[DefaultExecutionOrder(20000)]
public class QuickMenuHelper : MonoBehaviour
{
public static QuickMenuHelper Instance;
public Transform worldAnchor;
public Transform handAnchor;
+ public bool NeedsPositionUpdate;
- void Start()
+ void Awake()
{
Instance = this;
- CreateWorldAnchors();
}
void LateUpdate()
{
- MSP_MenuInfo.HandleIndependentLookInput();
- UpdateMenuPosition();
+ if (MSP_MenuInfo.UseIndependentHeadTurn)
+ MSP_MenuInfo.HandleIndependentLookInput();
+ if (MSP_MenuInfo.PlayerAnchorMenus || MetaPort.Instance.isUsingVr)
+ UpdateMenuPosition();
+ if (NeedsPositionUpdate) UpdateMenuPosition();
}
public void CreateWorldAnchors()
@@ -40,15 +43,17 @@ public class QuickMenuHelper : MonoBehaviour
worldAnchor = vrAnchor.transform;
}
- public void UpdateWorldAnchors()
+ public void UpdateWorldAnchors(bool updateMenuPos = false)
{
if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
+ if (updateMenuPos) UpdateMenuPosition();
}
public void UpdateMenuPosition()
{
+ NeedsPositionUpdate = false;
if (MetaPort.Instance.isUsingVr)
{
HandleVRPosition();
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
index 290781c..facd5e0 100644
--- a/MenuScalePatch/MSP_Menus.cs
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -12,33 +12,38 @@ namespace NAK.Melons.MenuScalePatch.Helpers;
public class MSP_MenuInfo
{
//Shared Info
- public static float ScaleFactor = 1f;
- public static float AspectRatio = 1f;
- public static Transform CameraTransform;
+ internal static float ScaleFactor = 1f;
+ internal static float AspectRatio = 1f;
+ internal static Transform CameraTransform;
//Settings...?
- public static bool WorldAnchorQM;
+ internal static bool WorldAnchorQM = false;
+ internal static bool UseIndependentHeadTurn = true;
+ internal static bool PlayerAnchorMenus = true;
//if other mods need to disable?
- public static bool DisableQMHelper;
- public static bool DisableQMHelper_VR;
- public static bool DisableMMHelper;
- public static bool DisableMMHelper_VR;
+ internal static bool DisableQMHelper;
+ internal static bool DisableQMHelper_VR;
+ internal static bool DisableMMHelper;
+ internal static bool DisableMMHelper_VR;
- public static void ToggleDesktopInputMethod(bool flag)
+ //reflection (traverse sucks ass)
+ private static readonly FieldInfo _desktopMouseMode = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
+
+ internal static void ToggleDesktopInputMethod(bool flag)
{
if (MetaPort.Instance.isUsingVr) return;
PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
CVRInputManager.Instance.inputEnabled = !flag;
RootLogic.Instance.ToggleMouse(flag);
CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
- Traverse.Create(CVR_MenuManager.Instance).Field("_desktopMouseMode").SetValue(flag);
+ _desktopMouseMode.SetValue(CVR_MenuManager.Instance, flag);
}
- static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
- public static bool independentHeadTurn = false;
+ internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
+ internal static bool independentHeadTurn = false;
- public static void HandleIndependentLookInput()
+ internal static void HandleIndependentLookInput()
{
//angle of independent look axis
bool isPressed = CVRInputManager.Instance.independentHeadTurn || CVRInputManager.Instance.independentHeadToggle;
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
index 72a78d2..72eae7d 100644
--- a/MenuScalePatch/Main.cs
+++ b/MenuScalePatch/Main.cs
@@ -5,22 +5,31 @@ namespace NAK.Melons.MenuScalePatch;
public class MenuScalePatch : MelonMod
{
- private static MelonPreferences_Category m_categoryMenuScalePatch;
- private static MelonPreferences_Entry m_entryWorldAnchorVRQM;
+ internal static MelonLogger.Instance Logger;
+ internal static MelonPreferences_Category m_categoryMenuScalePatch;
+ internal static MelonPreferences_Entry
+ m_entryWorldAnchorVRQM,
+ m_entryUseIndependentHeadTurn,
+ m_entryPlayerAnchorMenus;
public override void OnInitializeMelon()
{
m_categoryMenuScalePatch = MelonPreferences.CreateCategory(nameof(MenuScalePatch));
- m_entryWorldAnchorVRQM = m_categoryMenuScalePatch.CreateEntry("World Anchor VR QM", false, description: "Should place QM in World Space while VR.");
-
+ //m_entryWorldAnchorVRQM = m_categoryMenuScalePatch.CreateEntry("World Anchor VR QM", false, description: "Should place QM in World Space while VR.");
+ m_entryUseIndependentHeadTurn = m_categoryMenuScalePatch.CreateEntry("Use Independent Head Turn", true, description: "Should you be able to use independent head turn in a menu while in Desktop?");
+ m_entryPlayerAnchorMenus = m_categoryMenuScalePatch.CreateEntry("Player Anchor Menus", true, description: "Should the menus be anchored to & constantly follow the player?");
+
foreach (var setting in m_categoryMenuScalePatch.Entries)
{
setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);
}
- }
- private void UpdateAllSettings()
- {
- MSP_MenuInfo.WorldAnchorQM = m_entryWorldAnchorVRQM.Value;
+ Logger = LoggerInstance;
}
- private void OnUpdateSettings(object arg1, object arg2) => UpdateAllSettings();
+ internal static void UpdateAllSettings()
+ {
+ //MSP_MenuInfo.WorldAnchorQM = m_entryWorldAnchorVRQM.Value;
+ MSP_MenuInfo.UseIndependentHeadTurn = m_entryUseIndependentHeadTurn.Value;
+ MSP_MenuInfo.PlayerAnchorMenus = m_entryPlayerAnchorMenus.Value;
+ }
+ private static void OnUpdateSettings(object arg1, object arg2) => UpdateAllSettings();
}
\ No newline at end of file
diff --git a/MenuScalePatch/MenuScalePatch.csproj b/MenuScalePatch/MenuScalePatch.csproj
index 655b3bd..7293ed3 100644
--- a/MenuScalePatch/MenuScalePatch.csproj
+++ b/MenuScalePatch/MenuScalePatch.csproj
@@ -21,6 +21,9 @@
C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll
+
+ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll
+
C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index 64804cf..34cef9b 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "4.1.1";
+ public const string Version = "4.0.0";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index 02f7943..d91654b 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -1,12 +1,12 @@
{
"_id": 95,
"name": "MenuScalePatch",
- "modversion": "3.0.0",
+ "modversion": "4.0.0",
"gameversion": "2022r170",
"loaderversion": "0.5.7",
"modtype": "Mod",
"author": "NotAKidoS",
- "description": "Corrects MM and QM position when avatar is being scaled.\n\nDesktop menus will now always follow camera while open.",
+ "description": "Corrects MM and QM position when avatar is being scaled.\n\nOptional setting to enable Independent Head Turn while in menus.\nOptional setting to force menus to always follow player.",
"searchtags": [
"menu",
"scale",
@@ -16,8 +16,8 @@
"requirements": [
"None"
],
- "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v3.0.0/MenuScalePatch.dll",
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.0.0/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
- "changelog": "Removed collision scaling feature as it is now native.\nAdjusted QM scaling for VR.\nAdded menu correction for Desktop so you can use menus while moving.\nImmediate viewpoint correction for Desktop during scaling.",
+ "changelog": "- Added option for menus to be attached to you in Desktop and VR.\n- Added option to use independent head movement while in a menu.",
"embedcolor": "804221"
}
\ No newline at end of file
From e0a6e910df58e66905d4c136e276052ce99ab861 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Thu, 2 Feb 2023 22:52:33 -0600
Subject: [PATCH 24/41] bumpo
---
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
MenuScalePatch/format.json | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index 34cef9b..c86a95e 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "4.0.0";
+ public const string Version = "4.2.0";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index d91654b..ac72f19 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -1,7 +1,7 @@
{
"_id": 95,
"name": "MenuScalePatch",
- "modversion": "4.0.0",
+ "modversion": "4.2.0",
"gameversion": "2022r170",
"loaderversion": "0.5.7",
"modtype": "Mod",
@@ -16,7 +16,7 @@
"requirements": [
"None"
],
- "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.0.0/MenuScalePatch.dll",
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.0/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
"changelog": "- Added option for menus to be attached to you in Desktop and VR.\n- Added option to use independent head movement while in a menu.",
"embedcolor": "804221"
From c8ee3e152726bff4eb49d49304206de549375657 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Thu, 9 Feb 2023 19:14:27 -0600
Subject: [PATCH 25/41] remove unused transpiler, fix up mousemode
---
MenuScalePatch/HarmonyPatches.cs | 44 ----------------------------
MenuScalePatch/MSP_Menus.cs | 12 +++++---
MenuScalePatch/MenuScalePatch.csproj | 4 +--
3 files changed, 10 insertions(+), 50 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index 999c87d..29b44ab 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -193,48 +193,4 @@ internal class HarmonyPatches
MenuScalePatch.Logger.Error(e);
}
}
-
- //[HarmonyTranspiler]
- //[HarmonyPatch(typeof(ControllerRay), "LateUpdate")]
- private static IEnumerable Transpiler_ControllerRay_UpdateInput(
- IEnumerable instructions, ILGenerator il)
- {
-
- // Stop calling move mouse events on the menus, the ones that instantiate and the send the event (easy)
- // Makes this: "component.View.MouseEvent(mouseEventData1);" go POOF
- instructions = new CodeMatcher(instructions)
- .MatchForward(false,
- new CodeMatch(OpCodes.Ldloc_S),
- new CodeMatch(i => i.opcode == OpCodes.Callvirt && i.operand is MethodInfo { Name: "get_View" }),
- new CodeMatch(OpCodes.Ldloc_S),
- new CodeMatch(i => i.opcode == OpCodes.Callvirt && i.operand is MethodInfo { Name: "MouseEvent" }))
- .Repeat(matcher => matcher
- .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop))
- .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop))
- .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop))
- .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop))
- )
- .InstructionEnumeration();
-
- // Look for the if flag2 and replace flag 2 with false, for the ones that create the event and send inline (hard ;_;)
- // Makes this: "if (flag2 && this._mouseDownOnMenu != ControllerRay.Menu.None || ..." into:
- // this: "if (false && this._mouseDownOnMenu != ControllerRay.Menu.None || ..."
- instructions = new CodeMatcher(instructions)
- .MatchForward(false,
- new CodeMatch(OpCodes.Ldloc_2),
- new CodeMatch(OpCodes.Brfalse),
- new CodeMatch(OpCodes.Ldarg_0),
- new CodeMatch(i =>
- i.opcode == OpCodes.Ldfld && i.operand is FieldInfo { Name: "_mouseDownOnMenu" }),
- new CodeMatch(OpCodes.Brtrue),
- new CodeMatch(OpCodes.Ldarg_0),
- new CodeMatch(i =>
- i.opcode == OpCodes.Ldfld && i.operand is FieldInfo { Name: "_mouseDownOnMenu" }),
- new CodeMatch(OpCodes.Ldc_I4_1),
- new CodeMatch(OpCodes.Bne_Un))
- .SetOpcodeAndAdvance(OpCodes.Ldc_I4_0) // replace flag2 with false
- .InstructionEnumeration();
-
- return instructions;
- }
}
\ No newline at end of file
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
index facd5e0..b8e0c92 100644
--- a/MenuScalePatch/MSP_Menus.cs
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -28,16 +28,20 @@ public class MSP_MenuInfo
internal static bool DisableMMHelper_VR;
//reflection (traverse sucks ass)
- private static readonly FieldInfo _desktopMouseMode = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
+ private static readonly FieldInfo _desktopMouseModeQM = typeof(ViewManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
+ private static readonly FieldInfo _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
internal static void ToggleDesktopInputMethod(bool flag)
{
if (MetaPort.Instance.isUsingVr) return;
- PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
- CVRInputManager.Instance.inputEnabled = !flag;
+
+ _desktopMouseModeQM.SetValue(ViewManager.Instance, flag);
+ _desktopMouseModeMM.SetValue(CVR_MenuManager.Instance, flag);
+
RootLogic.Instance.ToggleMouse(flag);
+ CVRInputManager.Instance.inputEnabled = !flag;
+ PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
- _desktopMouseMode.SetValue(CVR_MenuManager.Instance, flag);
}
internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
diff --git a/MenuScalePatch/MenuScalePatch.csproj b/MenuScalePatch/MenuScalePatch.csproj
index 7293ed3..72168e2 100644
--- a/MenuScalePatch/MenuScalePatch.csproj
+++ b/MenuScalePatch/MenuScalePatch.csproj
@@ -16,13 +16,13 @@
C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll
- ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll
+ C:\Program Files (x86)\\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll
C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll
- ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll
+ C:\Program Files (x86)\\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll
C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll
From 4faca22005a6a34baa04ef0cc93509fb0dbbce4c Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Thu, 9 Feb 2023 19:14:36 -0600
Subject: [PATCH 26/41] Update AssemblyInfo.cs
---
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index c86a95e..8323208 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "4.2.0";
+ public const string Version = "4.2.1";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
From 299d9db2df83aabb6e7d484a51f5061ade881503 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Thu, 9 Feb 2023 19:18:36 -0600
Subject: [PATCH 27/41] Update format.json
---
MenuScalePatch/format.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index ac72f19..7595e68 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -1,7 +1,7 @@
{
"_id": 95,
"name": "MenuScalePatch",
- "modversion": "4.2.0",
+ "modversion": "4.2.1",
"gameversion": "2022r170",
"loaderversion": "0.5.7",
"modtype": "Mod",
@@ -16,7 +16,7 @@
"requirements": [
"None"
],
- "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.0/MenuScalePatch.dll",
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.1/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
"changelog": "- Added option for menus to be attached to you in Desktop and VR.\n- Added option to use independent head movement while in a menu.",
"embedcolor": "804221"
From 3d74277e5c2999f78ed2ad85c506ca7257c476fe Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Thu, 9 Feb 2023 20:03:11 -0600
Subject: [PATCH 28/41] fix namespace
---
MenuScalePatch/Properties/AssemblyInfo.cs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index 8323208..a3d3264 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -1,18 +1,18 @@
using MelonLoader;
-using MenuScalePatch.Properties;
+using NAK.Melons.MenuScalePatch.Properties;
using System.Reflection;
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
-[assembly: AssemblyTitle(nameof(MenuScalePatch))]
+[assembly: AssemblyTitle(nameof(NAK.Melons.MenuScalePatch))]
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
-[assembly: AssemblyProduct(nameof(MenuScalePatch))]
+[assembly: AssemblyProduct(nameof(NAK.Melons.MenuScalePatch))]
[assembly: MelonInfo(
typeof(NAK.Melons.MenuScalePatch.MenuScalePatch),
- nameof(MenuScalePatch),
+ nameof(NAK.Melons.MenuScalePatch),
AssemblyInfoParams.Version,
AssemblyInfoParams.Author,
downloadLink: "https://github.com/NotAKidOnSteam/MenuScalePatch"
@@ -22,7 +22,7 @@ using System.Reflection;
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
-namespace MenuScalePatch.Properties;
+namespace NAK.Melons.MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
public const string Version = "4.2.1";
From 483e103a97f76532e7487b272ea4f1651acf4a8c Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Thu, 9 Feb 2023 20:17:29 -0600
Subject: [PATCH 29/41] organizational changes
---
MenuScalePatch/Helpers/MainMenuHelper.cs | 3 ++-
MenuScalePatch/Helpers/QuickMenuHelper.cs | 3 ++-
MenuScalePatch/MSP_Menus.cs | 13 ++++++-------
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index 6930cf6..1beed8b 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -33,7 +33,8 @@ public class MainMenuHelper : MonoBehaviour
MSP_MenuInfo.HandleIndependentLookInput();
if (MSP_MenuInfo.PlayerAnchorMenus)
UpdateMenuPosition();
- if (NeedsPositionUpdate) UpdateMenuPosition();
+ if (NeedsPositionUpdate)
+ UpdateMenuPosition();
}
public void CreateWorldAnchors()
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index 1c713b9..716ae71 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -31,7 +31,8 @@ public class QuickMenuHelper : MonoBehaviour
MSP_MenuInfo.HandleIndependentLookInput();
if (MSP_MenuInfo.PlayerAnchorMenus || MetaPort.Instance.isUsingVr)
UpdateMenuPosition();
- if (NeedsPositionUpdate) UpdateMenuPosition();
+ if (NeedsPositionUpdate)
+ UpdateMenuPosition();
}
public void CreateWorldAnchors()
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
index b8e0c92..b0e1617 100644
--- a/MenuScalePatch/MSP_Menus.cs
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -3,7 +3,6 @@ using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
using ABI_RC.Systems.MovementSystem;
-using HarmonyLib;
using System.Reflection;
using UnityEngine;
@@ -28,8 +27,11 @@ public class MSP_MenuInfo
internal static bool DisableMMHelper_VR;
//reflection (traverse sucks ass)
- private static readonly FieldInfo _desktopMouseModeQM = typeof(ViewManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
- private static readonly FieldInfo _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
+ internal static readonly FieldInfo _desktopMouseModeQM = typeof(ViewManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
+ internal static readonly FieldInfo _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
+ internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
+
+ internal static bool independentHeadTurn = false;
internal static void ToggleDesktopInputMethod(bool flag)
{
@@ -37,16 +39,13 @@ public class MSP_MenuInfo
_desktopMouseModeQM.SetValue(ViewManager.Instance, flag);
_desktopMouseModeMM.SetValue(CVR_MenuManager.Instance, flag);
-
+
RootLogic.Instance.ToggleMouse(flag);
CVRInputManager.Instance.inputEnabled = !flag;
PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
}
- internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
- internal static bool independentHeadTurn = false;
-
internal static void HandleIndependentLookInput()
{
//angle of independent look axis
From 10f5fa49d7d850c1558d8cdcc4397ab1b9b71284 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Thu, 9 Feb 2023 22:59:29 -0600
Subject: [PATCH 30/41] Update README.md
---
README.md | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/README.md b/README.md
index 4a8dc6c..24e3752 100644
--- a/README.md
+++ b/README.md
@@ -23,22 +23,9 @@ https://user-images.githubusercontent.com/37721153/189479474-41e93dff-a695-42f2-
Here is the block of text where I tell you this mod is not affiliated or endorsed by ABI.
https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games
-> I am not affiliated with ABI in any official capacity, these mods are not endorsed or outright permitted by ABI and are subject to scrutiny.
+> This mod is an independent creation and is not affiliated with, supported by or approved by Alpha Blend Interactive.
-> Neither I nor these mods are in any way affiliated with Alpha Blend Interactive and/or ChilloutVR. Using these modifications might cause issues with the performance, security or stability of the game. Use at your own risk.
+> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use.
-> Any modifications that are not approved can get your ABI account terminated and such this modification is following the "modding guidelines" at the best it could be.
-> They reserve the right to punish users using my mod.
-> If you are scared of using modifications in your game do not install mods.
+> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive.
-> I do not affiliate ABI and the mod is not supported by ABI.
-
-> Me and this modification are in no affiliation with ABI and not supported by ABI.
-
-> This mod is not affiliated with Alpha Blend Interactive. The mod comes with no warranty. Use at your own risk, as I am not responsible for any misuse.
-
-> I'm not affiliated with Alpha Blend Interactive and this mod is not officially supported by the game.
-
-> When releasing mods to the public, it is required to state, that the mod authors and modification are in no affiliation with ABI and not supported by ABI. :trollface:
-
-> i ran out of places to steal disclaimers from
From 7cc8dfc6e5475b0aef59479eeae6cc85e1d1df15 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Sun, 12 Feb 2023 04:51:21 -0600
Subject: [PATCH 31/41] Don't disable CohtmlView, only enable it.
Fixed hitching & potential crash when opening menu after a long time of it being closed. Misread the source code when remaking the method, so I assumed the CohtmlView was disabled when closing menu.
---
MenuScalePatch/HarmonyPatches.cs | 4 ++--
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
MenuScalePatch/format.json | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index 29b44ab..0f59836 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -124,7 +124,7 @@ internal class HarmonyPatches
if (show != ____quickMenuOpen)
{
____quickMenuOpen = show;
- __instance.quickMenu.enabled = show;
+ __instance.quickMenu.enabled = true;
__instance.quickMenuAnimator.SetBool("Open", show);
QuickMenuHelper.Instance.enabled = show;
QuickMenuHelper.Instance.UpdateWorldAnchors(show);
@@ -152,7 +152,7 @@ internal class HarmonyPatches
if (show != ____gameMenuOpen)
{
____gameMenuOpen = show;
- __instance.gameMenuView.enabled = show;
+ __instance.gameMenuView.enabled = true;
__instance.uiMenuAnimator.SetBool("Open", show);
MainMenuHelper.Instance.enabled = show;
MainMenuHelper.Instance.UpdateWorldAnchors(show);
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index a3d3264..cf44392 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace NAK.Melons.MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "4.2.1";
+ public const string Version = "4.2.2";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index 7595e68..3f7ac68 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -1,7 +1,7 @@
{
"_id": 95,
"name": "MenuScalePatch",
- "modversion": "4.2.1",
+ "modversion": "4.2.2",
"gameversion": "2022r170",
"loaderversion": "0.5.7",
"modtype": "Mod",
@@ -16,8 +16,8 @@
"requirements": [
"None"
],
- "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.1/MenuScalePatch.dll",
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.2/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
- "changelog": "- Added option for menus to be attached to you in Desktop and VR.\n- Added option to use independent head movement while in a menu.",
+ "changelog": "- Fixed hitching & potential crash when opening menu after a long time of it being closed.\n- Don't disable CohtmlView, only enable it.'",
"embedcolor": "804221"
}
\ No newline at end of file
From d15b4469607b089c5a3e6529a1639d6c59335329 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Sun, 12 Feb 2023 05:12:23 -0600
Subject: [PATCH 32/41] bump
---
MenuScalePatch/Main.cs | 2 +-
MenuScalePatch/format.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
index 72eae7d..e87f2fe 100644
--- a/MenuScalePatch/Main.cs
+++ b/MenuScalePatch/Main.cs
@@ -8,7 +8,7 @@ public class MenuScalePatch : MelonMod
internal static MelonLogger.Instance Logger;
internal static MelonPreferences_Category m_categoryMenuScalePatch;
internal static MelonPreferences_Entry
- m_entryWorldAnchorVRQM,
+ //m_entryWorldAnchorVRQM,
m_entryUseIndependentHeadTurn,
m_entryPlayerAnchorMenus;
public override void OnInitializeMelon()
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index 3f7ac68..ef90bf1 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -18,6 +18,6 @@
],
"downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.2/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
- "changelog": "- Fixed hitching & potential crash when opening menu after a long time of it being closed.\n- Don't disable CohtmlView, only enable it.'",
+ "changelog": "- Fixed hitching & potential crash when opening menu after a long time of it being closed. Don't disable CohtmlView, only enable it.",
"embedcolor": "804221"
}
\ No newline at end of file
From 0b035646d1824a7a62ec8aaf93a2b6ea1e4786cc Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Wed, 15 Feb 2023 05:21:03 -0600
Subject: [PATCH 33/41] losing it
---
MenuScalePatch/HarmonyPatches.cs | 8 +++-----
MenuScalePatch/Helpers/MainMenuHelper.cs | 16 ++++++++++------
MenuScalePatch/Helpers/QuickMenuHelper.cs | 16 ++++++++++------
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
4 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index 0f59836..ac38eb2 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -91,7 +91,6 @@ internal class HarmonyPatches
{
QuickMenuHelper helper = __instance.quickMenu.gameObject.AddComponent();
helper.handAnchor = ____leftVrAnchor.transform;
- helper.enabled = false;
}
catch (System.Exception e)
{
@@ -106,8 +105,7 @@ internal class HarmonyPatches
{
try
{
- MainMenuHelper helper = __instance.gameObject.AddComponent();
- helper.enabled = false;
+ __instance.gameObject.AddComponent();
}
catch (System.Exception e)
{
@@ -126,7 +124,7 @@ internal class HarmonyPatches
____quickMenuOpen = show;
__instance.quickMenu.enabled = true;
__instance.quickMenuAnimator.SetBool("Open", show);
- QuickMenuHelper.Instance.enabled = show;
+ QuickMenuHelper.Instance.MenuIsOpen = show;
QuickMenuHelper.Instance.UpdateWorldAnchors(show);
//shouldnt run if switching menus on desktop
if (!MetaPort.Instance.isUsingVr)
@@ -154,7 +152,7 @@ internal class HarmonyPatches
____gameMenuOpen = show;
__instance.gameMenuView.enabled = true;
__instance.uiMenuAnimator.SetBool("Open", show);
- MainMenuHelper.Instance.enabled = show;
+ MainMenuHelper.Instance.MenuIsOpen = show;
MainMenuHelper.Instance.UpdateWorldAnchors(show);
//shouldnt run if switching menus on desktop
if (!MetaPort.Instance.isUsingVr)
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index 1beed8b..d1d2ef4 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -21,6 +21,7 @@ public class MainMenuHelper : MonoBehaviour
public static MainMenuHelper Instance;
public Transform worldAnchor;
public bool NeedsPositionUpdate;
+ public bool MenuIsOpen;
void Awake()
{
@@ -29,12 +30,15 @@ public class MainMenuHelper : MonoBehaviour
void LateUpdate()
{
- if (MSP_MenuInfo.UseIndependentHeadTurn)
- MSP_MenuInfo.HandleIndependentLookInput();
- if (MSP_MenuInfo.PlayerAnchorMenus)
- UpdateMenuPosition();
- if (NeedsPositionUpdate)
- UpdateMenuPosition();
+ if (MenuIsOpen)
+ {
+ if (MSP_MenuInfo.UseIndependentHeadTurn)
+ MSP_MenuInfo.HandleIndependentLookInput();
+ if (MSP_MenuInfo.PlayerAnchorMenus)
+ UpdateMenuPosition();
+ if (NeedsPositionUpdate)
+ UpdateMenuPosition();
+ }
}
public void CreateWorldAnchors()
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index 716ae71..5836f89 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -19,6 +19,7 @@ public class QuickMenuHelper : MonoBehaviour
public Transform worldAnchor;
public Transform handAnchor;
public bool NeedsPositionUpdate;
+ public bool MenuIsOpen;
void Awake()
{
@@ -27,12 +28,15 @@ public class QuickMenuHelper : MonoBehaviour
void LateUpdate()
{
- if (MSP_MenuInfo.UseIndependentHeadTurn)
- MSP_MenuInfo.HandleIndependentLookInput();
- if (MSP_MenuInfo.PlayerAnchorMenus || MetaPort.Instance.isUsingVr)
- UpdateMenuPosition();
- if (NeedsPositionUpdate)
- UpdateMenuPosition();
+ if (MenuIsOpen)
+ {
+ if (MSP_MenuInfo.UseIndependentHeadTurn)
+ MSP_MenuInfo.HandleIndependentLookInput();
+ if (MSP_MenuInfo.PlayerAnchorMenus || MetaPort.Instance.isUsingVr)
+ UpdateMenuPosition();
+ if (NeedsPositionUpdate)
+ UpdateMenuPosition();
+ }
}
public void CreateWorldAnchors()
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index cf44392..2c4d733 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace NAK.Melons.MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "4.2.2";
+ public const string Version = "4.2.3";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
From 3248dd6335152f342a45d39db1973bb2a9f99fc1 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Wed, 15 Feb 2023 05:26:18 -0600
Subject: [PATCH 34/41] w
---
MenuScalePatch/HarmonyPatches.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index ac38eb2..f8cac64 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -129,7 +129,7 @@ internal class HarmonyPatches
//shouldnt run if switching menus on desktop
if (!MetaPort.Instance.isUsingVr)
{
- if (!show && MainMenuHelper.Instance.enabled)
+ if (!show && MainMenuHelper.Instance.MenuIsOpen)
{
return false;
}
@@ -144,7 +144,7 @@ internal class HarmonyPatches
//hook menu open/close
[HarmonyPrefix]
[HarmonyPatch(typeof(ViewManager), "UiStateToggle", new Type[] { typeof(bool) })]
- private static bool Postfix_ViewManager_UiStateToggle(bool show, ref ViewManager __instance, ref bool ____gameMenuOpen)
+ private static bool Prefix_ViewManager_UiStateToggle(bool show, ref ViewManager __instance, ref bool ____gameMenuOpen)
{
if (MainMenuHelper.Instance == null) return true;
if (show != ____gameMenuOpen)
@@ -157,7 +157,7 @@ internal class HarmonyPatches
//shouldnt run if switching menus on desktop
if (!MetaPort.Instance.isUsingVr)
{
- if (!show && QuickMenuHelper.Instance.enabled)
+ if (!show && QuickMenuHelper.Instance.MenuIsOpen)
{
return false;
}
From a8cd7122a87f7828b36edddeca1f8baf588a7d39 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Fri, 3 Mar 2023 16:41:48 -0600
Subject: [PATCH 35/41] let menu update position when closed
---
MenuScalePatch/HarmonyPatches.cs | 18 ++++++------------
MenuScalePatch/Helpers/QuickMenuHelper.cs | 2 +-
MenuScalePatch/MSP_Menus.cs | 12 ++++++------
MenuScalePatch/Main.cs | 4 ++--
4 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index f8cac64..68aaa18 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -1,10 +1,9 @@
-using ABI_RC.Core.InteractionSystem;
+using ABI_RC.Core;
+using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
using HarmonyLib;
using NAK.Melons.MenuScalePatch.Helpers;
-using System.Reflection;
-using System.Reflection.Emit;
using UnityEngine;
namespace NAK.Melons.MenuScalePatch.HarmonyPatches;
@@ -12,11 +11,6 @@ namespace NAK.Melons.MenuScalePatch.HarmonyPatches;
/**
ViewManager.SetScale runs once a second when it should only run when aspect ratio changes- CVR bug
assuming its caused by cast from int to float getting the screen size, something floating point bleh
-
- ViewManager.UpdatePosition & CVR_MenuManager.UpdatePosition are called every second in a scheduled job.
- (its why ViewManager.SetScale is called, because MM uses aspect ratio in scale calculation)
-
- I nuke those methods. Fuck them. I cannot disable the jobs though...
**/
[HarmonyPatch]
@@ -68,7 +62,7 @@ internal class HarmonyPatches
[HarmonyPatch(typeof(CVR_MenuManager), "UpdateMenuPosition")]
private static bool Prefix_CVR_MenuManager_UpdateMenuPosition()
{
- return false;
+ return !QuickMenuHelper.Instance.MenuIsOpen;
}
[HarmonyPrefix]
@@ -79,7 +73,7 @@ internal class HarmonyPatches
float ratio = (float)Screen.width / (float)Screen.height;
float clamp = Mathf.Clamp(ratio, 0f, 1.8f);
MSP_MenuInfo.AspectRatio = 1.7777779f / clamp;
- return false;
+ return !MainMenuHelper.Instance.MenuIsOpen;
}
//Set QM stuff
@@ -179,8 +173,8 @@ internal class HarmonyPatches
//Support for changing VRMode during runtime.
[HarmonyPostfix]
- [HarmonyPatch(typeof(PlayerSetup), "CalibrateAvatar")]
- private static void Postfix_PlayerSetup_CalibrateAvatar()
+ [HarmonyPatch(typeof(CVRTools), "ConfigureHudAffinity")]
+ private static void Postfix_CVRTools_ConfigureHudAffinity()
{
try
{
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index 5836f89..7a893e4 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -36,7 +36,7 @@ public class QuickMenuHelper : MonoBehaviour
UpdateMenuPosition();
if (NeedsPositionUpdate)
UpdateMenuPosition();
- }
+ }
}
public void CreateWorldAnchors()
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
index b0e1617..5268e30 100644
--- a/MenuScalePatch/MSP_Menus.cs
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -20,13 +20,13 @@ public class MSP_MenuInfo
internal static bool UseIndependentHeadTurn = true;
internal static bool PlayerAnchorMenus = true;
- //if other mods need to disable?
- internal static bool DisableQMHelper;
- internal static bool DisableQMHelper_VR;
- internal static bool DisableMMHelper;
- internal static bool DisableMMHelper_VR;
+ //Debug/Integration
+ public static bool DisableQMHelper;
+ public static bool DisableQMHelper_VR;
+ public static bool DisableMMHelper;
+ public static bool DisableMMHelper_VR;
- //reflection (traverse sucks ass)
+ //reflection
internal static readonly FieldInfo _desktopMouseModeQM = typeof(ViewManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
internal static readonly FieldInfo _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
diff --git a/MenuScalePatch/Main.cs b/MenuScalePatch/Main.cs
index e87f2fe..3f8387f 100644
--- a/MenuScalePatch/Main.cs
+++ b/MenuScalePatch/Main.cs
@@ -7,7 +7,7 @@ public class MenuScalePatch : MelonMod
{
internal static MelonLogger.Instance Logger;
internal static MelonPreferences_Category m_categoryMenuScalePatch;
- internal static MelonPreferences_Entry
+ internal static MelonPreferences_Entry
//m_entryWorldAnchorVRQM,
m_entryUseIndependentHeadTurn,
m_entryPlayerAnchorMenus;
@@ -17,7 +17,7 @@ public class MenuScalePatch : MelonMod
//m_entryWorldAnchorVRQM = m_categoryMenuScalePatch.CreateEntry("World Anchor VR QM", false, description: "Should place QM in World Space while VR.");
m_entryUseIndependentHeadTurn = m_categoryMenuScalePatch.CreateEntry("Use Independent Head Turn", true, description: "Should you be able to use independent head turn in a menu while in Desktop?");
m_entryPlayerAnchorMenus = m_categoryMenuScalePatch.CreateEntry("Player Anchor Menus", true, description: "Should the menus be anchored to & constantly follow the player?");
-
+
foreach (var setting in m_categoryMenuScalePatch.Entries)
{
setting.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings);
From ff70ae9652727fbe6afb37d82eee9f9b98dbf617 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Fri, 3 Mar 2023 17:57:22 -0600
Subject: [PATCH 36/41] tweaks to head turn
---
MenuScalePatch/HarmonyPatches.cs | 2 ++
MenuScalePatch/Helpers/MainMenuHelper.cs | 24 ++++++++++++-----------
MenuScalePatch/Helpers/QuickMenuHelper.cs | 23 ++++++++++++----------
MenuScalePatch/MSP_Menus.cs | 14 ++++++-------
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
MenuScalePatch/format.json | 6 +++---
6 files changed, 39 insertions(+), 32 deletions(-)
diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs
index 68aaa18..445a258 100644
--- a/MenuScalePatch/HarmonyPatches.cs
+++ b/MenuScalePatch/HarmonyPatches.cs
@@ -62,6 +62,7 @@ internal class HarmonyPatches
[HarmonyPatch(typeof(CVR_MenuManager), "UpdateMenuPosition")]
private static bool Prefix_CVR_MenuManager_UpdateMenuPosition()
{
+ if (QuickMenuHelper.Instance == null) return true;
return !QuickMenuHelper.Instance.MenuIsOpen;
}
@@ -69,6 +70,7 @@ internal class HarmonyPatches
[HarmonyPatch(typeof(ViewManager), "UpdateMenuPosition")]
private static bool Prefix_ViewManager_UpdateMenuPosition(ref float ___cachedScreenAspectRatio)
{
+ if (MainMenuHelper.Instance == null) return true;
//this is called once a second, so ill fix their dumb aspect ratio shit
float ratio = (float)Screen.width / (float)Screen.height;
float clamp = Mathf.Clamp(ratio, 0f, 1.8f);
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index d1d2ef4..a46eaad 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -30,14 +30,16 @@ public class MainMenuHelper : MonoBehaviour
void LateUpdate()
{
- if (MenuIsOpen)
+ if (!MenuIsOpen) return;
+
+ if (MSP_MenuInfo.PlayerAnchorMenus || NeedsPositionUpdate)
{
- if (MSP_MenuInfo.UseIndependentHeadTurn)
- MSP_MenuInfo.HandleIndependentLookInput();
- if (MSP_MenuInfo.PlayerAnchorMenus)
- UpdateMenuPosition();
- if (NeedsPositionUpdate)
- UpdateMenuPosition();
+ UpdateMenuPosition();
+ }
+
+ if (MSP_MenuInfo.UseIndependentHeadTurn)
+ {
+ MSP_MenuInfo.HandleIndependentLookInput();
}
}
@@ -64,13 +66,13 @@ public class MainMenuHelper : MonoBehaviour
}
else
{
- worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
+ worldAnchor.rotation = MSP_MenuInfo.CameraTransform.rotation;
}
worldAnchor.position = MSP_MenuInfo.CameraTransform.position + MSP_MenuInfo.CameraTransform.forward * 2f * MSP_MenuInfo.ScaleFactor;
}
else
{
- worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
+ worldAnchor.rotation = MSP_MenuInfo.CameraTransform.rotation;
worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
}
if (updateMenuPos) UpdateMenuPosition();
@@ -93,8 +95,8 @@ public class MainMenuHelper : MonoBehaviour
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableMMHelper) return;
Transform activeAnchor = MSP_MenuInfo.independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f);
- transform.eulerAngles = activeAnchor.eulerAngles;
transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.AspectRatio;
+ transform.rotation = activeAnchor.rotation;
}
//VR Main Menu
@@ -103,6 +105,6 @@ public class MainMenuHelper : MonoBehaviour
if (worldAnchor == null || MSP_MenuInfo.DisableMMHelper_VR) return;
transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor * 1.8f, 0.9f * MSP_MenuInfo.ScaleFactor * 1.8f, 1f);
transform.position = worldAnchor.position;
- transform.eulerAngles = worldAnchor.eulerAngles;
+ transform.rotation = worldAnchor.rotation;
}
}
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index 7a893e4..cb9514c 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -28,14 +28,16 @@ public class QuickMenuHelper : MonoBehaviour
void LateUpdate()
{
- if (MenuIsOpen)
+ if (!MenuIsOpen) return;
+
+ if (MSP_MenuInfo.PlayerAnchorMenus || NeedsPositionUpdate || MetaPort.Instance.isUsingVr)
{
- if (MSP_MenuInfo.UseIndependentHeadTurn)
- MSP_MenuInfo.HandleIndependentLookInput();
- if (MSP_MenuInfo.PlayerAnchorMenus || MetaPort.Instance.isUsingVr)
- UpdateMenuPosition();
- if (NeedsPositionUpdate)
- UpdateMenuPosition();
+ UpdateMenuPosition();
+ }
+
+ if (MSP_MenuInfo.UseIndependentHeadTurn)
+ {
+ MSP_MenuInfo.HandleIndependentLookInput();
}
}
@@ -51,7 +53,8 @@ public class QuickMenuHelper : MonoBehaviour
public void UpdateWorldAnchors(bool updateMenuPos = false)
{
if (worldAnchor == null || MSP_MenuInfo.CameraTransform == null) return;
- worldAnchor.eulerAngles = MSP_MenuInfo.CameraTransform.eulerAngles;
+
+ worldAnchor.rotation = MSP_MenuInfo.CameraTransform.rotation;
worldAnchor.position = MSP_MenuInfo.CameraTransform.position;
if (updateMenuPos) UpdateMenuPosition();
}
@@ -74,7 +77,7 @@ public class QuickMenuHelper : MonoBehaviour
Transform activeAnchor = MSP_MenuInfo.independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
- transform.eulerAngles = activeAnchor.eulerAngles;
+ transform.rotation = activeAnchor.rotation;
transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
}
@@ -86,8 +89,8 @@ public class QuickMenuHelper : MonoBehaviour
if (MSP_MenuInfo.WorldAnchorQM)
{
transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
- transform.eulerAngles = worldAnchor.eulerAngles;
transform.position = worldAnchor.position + worldAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
+ transform.rotation = worldAnchor.rotation;
return;
}
transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
index 5268e30..769570a 100644
--- a/MenuScalePatch/MSP_Menus.cs
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -1,6 +1,5 @@
using ABI_RC.Core;
using ABI_RC.Core.InteractionSystem;
-using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
using ABI_RC.Systems.MovementSystem;
using System.Reflection;
@@ -31,7 +30,7 @@ public class MSP_MenuInfo
internal static readonly FieldInfo _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
- internal static bool independentHeadTurn = false;
+ internal static bool isIndependentHeadTurn = false;
internal static void ToggleDesktopInputMethod(bool flag)
{
@@ -42,7 +41,6 @@ public class MSP_MenuInfo
RootLogic.Instance.ToggleMouse(flag);
CVRInputManager.Instance.inputEnabled = !flag;
- PlayerSetup.Instance._movementSystem.disableCameraControl = flag;
CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
}
@@ -50,20 +48,22 @@ public class MSP_MenuInfo
{
//angle of independent look axis
bool isPressed = CVRInputManager.Instance.independentHeadTurn || CVRInputManager.Instance.independentHeadToggle;
- if (isPressed && !independentHeadTurn)
+ if (isPressed && !isIndependentHeadTurn)
{
- independentHeadTurn = true;
+ isIndependentHeadTurn = true;
MSP_MenuInfo.ToggleDesktopInputMethod(false);
QuickMenuHelper.Instance.UpdateWorldAnchors();
MainMenuHelper.Instance.UpdateWorldAnchors();
}
- else if (!isPressed && independentHeadTurn)
+ else if (!isPressed && isIndependentHeadTurn)
{
float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
if (angle == 0f)
{
- independentHeadTurn = false;
+ isIndependentHeadTurn = false;
MSP_MenuInfo.ToggleDesktopInputMethod(true);
+ QuickMenuHelper.Instance.NeedsPositionUpdate = true;
+ MainMenuHelper.Instance.NeedsPositionUpdate = true;
}
}
}
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index 2c4d733..bd53329 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace NAK.Melons.MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "4.2.3";
+ public const string Version = "4.2.5";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index ef90bf1..25e723d 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -1,7 +1,7 @@
{
"_id": 95,
"name": "MenuScalePatch",
- "modversion": "4.2.2",
+ "modversion": "4.2.5",
"gameversion": "2022r170",
"loaderversion": "0.5.7",
"modtype": "Mod",
@@ -16,8 +16,8 @@
"requirements": [
"None"
],
- "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.2/MenuScalePatch.dll",
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.4/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
- "changelog": "- Fixed hitching & potential crash when opening menu after a long time of it being closed. Don't disable CohtmlView, only enable it.",
+ "changelog": "- Tweaked independent head turn implementation. Menu will now recenter after head has returned to target angle.",
"embedcolor": "804221"
}
\ No newline at end of file
From 3ebd7432273f991dddcf79c3f0fd215142a1e955 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Fri, 3 Mar 2023 18:44:49 -0600
Subject: [PATCH 37/41] tweak head turn return to respect X angles
Head turn would be janky if Y angle reached 0 before X axis reached target angle.
---
MenuScalePatch/Helpers/MainMenuHelper.cs | 2 +-
MenuScalePatch/Helpers/QuickMenuHelper.cs | 2 +-
MenuScalePatch/MSP_Menus.cs | 8 ++++++--
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index a46eaad..53887dc 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -93,7 +93,7 @@ public class MainMenuHelper : MonoBehaviour
public void HandleDesktopPosition()
{
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableMMHelper) return;
- Transform activeAnchor = MSP_MenuInfo.independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
+ Transform activeAnchor = MSP_MenuInfo.isIndependentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f);
transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.AspectRatio;
transform.rotation = activeAnchor.rotation;
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index cb9514c..8de8e81 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -75,7 +75,7 @@ public class QuickMenuHelper : MonoBehaviour
{
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableQMHelper) return;
- Transform activeAnchor = MSP_MenuInfo.independentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
+ Transform activeAnchor = MSP_MenuInfo.isIndependentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
transform.localScale = new Vector3(1f * MSP_MenuInfo.ScaleFactor, 1f * MSP_MenuInfo.ScaleFactor, 1f);
transform.rotation = activeAnchor.rotation;
transform.position = activeAnchor.position + activeAnchor.transform.forward * 1f * MSP_MenuInfo.ScaleFactor;
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
index 769570a..23a86c1 100644
--- a/MenuScalePatch/MSP_Menus.cs
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -28,7 +28,9 @@ public class MSP_MenuInfo
//reflection
internal static readonly FieldInfo _desktopMouseModeQM = typeof(ViewManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
internal static readonly FieldInfo _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance);
+ internal static readonly FieldInfo ms_followAngleX = typeof(MovementSystem).GetField("_followAngleX", BindingFlags.NonPublic | BindingFlags.Instance);
internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance);
+ internal static readonly FieldInfo ms_manualAngleX = typeof(MovementSystem).GetField("_manualAngleX", BindingFlags.NonPublic | BindingFlags.Instance);
internal static bool isIndependentHeadTurn = false;
@@ -57,8 +59,10 @@ public class MSP_MenuInfo
}
else if (!isPressed && isIndependentHeadTurn)
{
- float angle = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
- if (angle == 0f)
+ float angleX = (float)ms_followAngleX.GetValue(MovementSystem.Instance);
+ float angleY = (float)ms_followAngleY.GetValue(MovementSystem.Instance);
+ float manualAngleX = (float)ms_manualAngleX.GetValue(MovementSystem.Instance);
+ if (angleY == 0f && angleX == manualAngleX)
{
isIndependentHeadTurn = false;
MSP_MenuInfo.ToggleDesktopInputMethod(true);
From b4dfbcc2ef3709a6a4717ec1806b0adcf989f575 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Fri, 3 Mar 2023 18:56:56 -0600
Subject: [PATCH 38/41] bump
---
MenuScalePatch/Helpers/MainMenuHelper.cs | 4 ++--
MenuScalePatch/Helpers/QuickMenuHelper.cs | 2 +-
MenuScalePatch/MSP_Menus.cs | 2 +-
MenuScalePatch/format.json | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index 53887dc..2491e68 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -31,7 +31,7 @@ public class MainMenuHelper : MonoBehaviour
void LateUpdate()
{
if (!MenuIsOpen) return;
-
+
if (MSP_MenuInfo.PlayerAnchorMenus || NeedsPositionUpdate)
{
UpdateMenuPosition();
@@ -39,7 +39,7 @@ public class MainMenuHelper : MonoBehaviour
if (MSP_MenuInfo.UseIndependentHeadTurn)
{
- MSP_MenuInfo.HandleIndependentLookInput();
+ MSP_MenuInfo.HandleIndependentHeadTurnInput();
}
}
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index 8de8e81..c5c2aae 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -37,7 +37,7 @@ public class QuickMenuHelper : MonoBehaviour
if (MSP_MenuInfo.UseIndependentHeadTurn)
{
- MSP_MenuInfo.HandleIndependentLookInput();
+ MSP_MenuInfo.HandleIndependentHeadTurnInput();
}
}
diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs
index 23a86c1..aae26d2 100644
--- a/MenuScalePatch/MSP_Menus.cs
+++ b/MenuScalePatch/MSP_Menus.cs
@@ -46,7 +46,7 @@ public class MSP_MenuInfo
CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag;
}
- internal static void HandleIndependentLookInput()
+ internal static void HandleIndependentHeadTurnInput()
{
//angle of independent look axis
bool isPressed = CVRInputManager.Instance.independentHeadTurn || CVRInputManager.Instance.independentHeadToggle;
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index 25e723d..7430e67 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -16,8 +16,8 @@
"requirements": [
"None"
],
- "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.4/MenuScalePatch.dll",
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.5/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
- "changelog": "- Tweaked independent head turn implementation. Menu will now recenter after head has returned to target angle.",
+ "changelog": "- Fixed hitching & potential crash when opening menu after a long time of it being closed. Don't disable CohtmlView, only enable it.\n- Let game update menu position while its closed.\n- Tweaked independent head turn handling to ensure menu is correctly positioned on recenter if PlayerAnchorMenus is disabled.",
"embedcolor": "804221"
}
\ No newline at end of file
From 8525bbd0196fa4ecc9a234e31f84a4a925be13e7 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Fri, 3 Mar 2023 19:06:38 -0600
Subject: [PATCH 39/41] why vr rig
---
MenuScalePatch/Helpers/MainMenuHelper.cs | 4 +++-
MenuScalePatch/Helpers/QuickMenuHelper.cs | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index 2491e68..ee45723 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -47,7 +47,7 @@ public class MainMenuHelper : MonoBehaviour
{
//VR specific anchor
GameObject vrAnchor = new GameObject("MSP_MMVR_Anchor");
- vrAnchor.transform.parent = PlayerSetup.Instance.vrCameraRig.transform;
+ vrAnchor.transform.parent = PlayerSetup.Instance.transform;
vrAnchor.transform.localPosition = Vector3.zero;
worldAnchor = vrAnchor.transform;
}
@@ -93,6 +93,7 @@ public class MainMenuHelper : MonoBehaviour
public void HandleDesktopPosition()
{
if (MSP_MenuInfo.CameraTransform == null || MSP_MenuInfo.DisableMMHelper) return;
+
Transform activeAnchor = MSP_MenuInfo.isIndependentHeadTurn ? worldAnchor : MSP_MenuInfo.CameraTransform;
transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor, 0.9f * MSP_MenuInfo.ScaleFactor, 1f);
transform.position = activeAnchor.position + activeAnchor.forward * 1f * MSP_MenuInfo.ScaleFactor * MSP_MenuInfo.AspectRatio;
@@ -103,6 +104,7 @@ public class MainMenuHelper : MonoBehaviour
public void HandleVRPosition()
{
if (worldAnchor == null || MSP_MenuInfo.DisableMMHelper_VR) return;
+
transform.localScale = new Vector3(1.6f * MSP_MenuInfo.ScaleFactor * 1.8f, 0.9f * MSP_MenuInfo.ScaleFactor * 1.8f, 1f);
transform.position = worldAnchor.position;
transform.rotation = worldAnchor.rotation;
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index c5c2aae..d329fe9 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -45,7 +45,7 @@ public class QuickMenuHelper : MonoBehaviour
{
//VR specific anchor
GameObject vrAnchor = new GameObject("MSP_QMVR_Anchor");
- vrAnchor.transform.parent = PlayerSetup.Instance.vrCameraRig.transform;
+ vrAnchor.transform.parent = PlayerSetup.Instance.transform;
vrAnchor.transform.localPosition = Vector3.zero;
worldAnchor = vrAnchor.transform;
}
From 0fb1649ace6ed96bf48743be2626fb7562d32648 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Sat, 4 Mar 2023 20:26:37 -0600
Subject: [PATCH 40/41] undo change- parent to vrCameraRig
vrCameraRig transform is scaled alongside avatar during scaling, which handles the local offset of the menu while scaling in VR
this does not change how the menus function on desktop, as the transforms are only placed based on position from camera, not the parent container object
---
MenuScalePatch/Helpers/MainMenuHelper.cs | 2 +-
MenuScalePatch/Helpers/QuickMenuHelper.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/MenuScalePatch/Helpers/MainMenuHelper.cs b/MenuScalePatch/Helpers/MainMenuHelper.cs
index ee45723..b41ff44 100644
--- a/MenuScalePatch/Helpers/MainMenuHelper.cs
+++ b/MenuScalePatch/Helpers/MainMenuHelper.cs
@@ -47,7 +47,7 @@ public class MainMenuHelper : MonoBehaviour
{
//VR specific anchor
GameObject vrAnchor = new GameObject("MSP_MMVR_Anchor");
- vrAnchor.transform.parent = PlayerSetup.Instance.transform;
+ vrAnchor.transform.parent = PlayerSetup.Instance.vrCameraRig.transform;
vrAnchor.transform.localPosition = Vector3.zero;
worldAnchor = vrAnchor.transform;
}
diff --git a/MenuScalePatch/Helpers/QuickMenuHelper.cs b/MenuScalePatch/Helpers/QuickMenuHelper.cs
index d329fe9..c5c2aae 100644
--- a/MenuScalePatch/Helpers/QuickMenuHelper.cs
+++ b/MenuScalePatch/Helpers/QuickMenuHelper.cs
@@ -45,7 +45,7 @@ public class QuickMenuHelper : MonoBehaviour
{
//VR specific anchor
GameObject vrAnchor = new GameObject("MSP_QMVR_Anchor");
- vrAnchor.transform.parent = PlayerSetup.Instance.transform;
+ vrAnchor.transform.parent = PlayerSetup.Instance.vrCameraRig.transform;
vrAnchor.transform.localPosition = Vector3.zero;
worldAnchor = vrAnchor.transform;
}
From 76e4e61fc3a26cca25a1f575bb2303e80b399545 Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Sat, 4 Mar 2023 20:31:32 -0600
Subject: [PATCH 41/41] bump
---
MenuScalePatch/Properties/AssemblyInfo.cs | 2 +-
MenuScalePatch/format.json | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/MenuScalePatch/Properties/AssemblyInfo.cs b/MenuScalePatch/Properties/AssemblyInfo.cs
index bd53329..c74bca0 100644
--- a/MenuScalePatch/Properties/AssemblyInfo.cs
+++ b/MenuScalePatch/Properties/AssemblyInfo.cs
@@ -25,6 +25,6 @@ using System.Reflection;
namespace NAK.Melons.MenuScalePatch.Properties;
internal static class AssemblyInfoParams
{
- public const string Version = "4.2.5";
+ public const string Version = "4.2.6";
public const string Author = "NotAKidoS";
}
\ No newline at end of file
diff --git a/MenuScalePatch/format.json b/MenuScalePatch/format.json
index 7430e67..717ab3b 100644
--- a/MenuScalePatch/format.json
+++ b/MenuScalePatch/format.json
@@ -1,7 +1,7 @@
{
"_id": 95,
"name": "MenuScalePatch",
- "modversion": "4.2.5",
+ "modversion": "4.2.6",
"gameversion": "2022r170",
"loaderversion": "0.5.7",
"modtype": "Mod",
@@ -16,8 +16,8 @@
"requirements": [
"None"
],
- "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.5/MenuScalePatch.dll",
+ "downloadlink": "https://github.com/NotAKidOnSteam/MenuScalePatch/releases/download/v4.2.6/MenuScalePatch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/MenuScalePatch/",
- "changelog": "- Fixed hitching & potential crash when opening menu after a long time of it being closed. Don't disable CohtmlView, only enable it.\n- Let game update menu position while its closed.\n- Tweaked independent head turn handling to ensure menu is correctly positioned on recenter if PlayerAnchorMenus is disabled.",
- "embedcolor": "804221"
+ "changelog": "- Fixed hitching & potential crash when opening menu after a long time of it being closed. Don't disable CohtmlView, only enable it.\n- Let game update menu position while its closed.\n- Tweaked independent head turn handling to ensure menu is correctly positioned on recenter if PlayerAnchorMenus is disabled.\n- Undo change to which transform to parent menu anchors.",
+ "embedcolor": "363020"
}
\ No newline at end of file