Skip to content
This repository was archived by the owner on Jan 4, 2022. It is now read-only.

Commit bec6b29

Browse files
committed
jank ass fix for right clicking
1 parent 068c674 commit bec6b29

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

CameraPlus/CameraPlus.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
<WarningLevel>4</WarningLevel>
3333
</PropertyGroup>
3434
<ItemGroup>
35+
<Reference Include="0Harmony">
36+
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\0Harmony.dll</HintPath>
37+
</Reference>
3538
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
3639
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
3740
</Reference>
@@ -103,6 +106,7 @@
103106
<SubType>Component</SubType>
104107
</Compile>
105108
<Compile Include="Utilities.cs" />
109+
<Compile Include="WindowOverridePatch.cs" />
106110
</ItemGroup>
107111
<ItemGroup>
108112
<None Include="packages.config" />

CameraPlus/CameraPlusBehaviour.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ public virtual void SceneManager_activeSceneChanged(Scene from, Scene to)
325325
return;
326326
}
327327

328-
var pointer = vrPointers[0];
329-
if (pointer == null) return;
328+
var pointer = to.name != "GameCore" ? vrPointers.First() : vrPointers.Last();
330329
if (_moverPointer) Destroy(_moverPointer);
331330
_moverPointer = pointer.gameObject.AddComponent<CameraMoverPointer>();
332331
_moverPointer.Init(this, _cameraCube);

CameraPlus/Plugin.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
using System.Collections.Generic;
55
using System.IO;
66
using System.Linq;
7+
using System.Reflection;
78
using System.Windows.Forms;
9+
using Harmony;
810
using IllusionPlugin;
911
using UnityEngine;
1012
using UnityEngine.SceneManagement;
@@ -19,15 +21,27 @@ public class Plugin : IPlugin
1921
private bool _init;
2022
public static Plugin Instance { get; private set; }
2123
public string Name => "CameraPlus";
22-
public string Version => "v3.2.3";
24+
public string Version => "v3.2.4";
2325

2426
public Action<Scene, Scene> ActiveSceneChanged;
27+
28+
private HarmonyInstance _harmony;
2529

2630
public void OnApplicationStart()
2731
{
2832
if (_init) return;
2933
_init = true;
3034
Instance = this;
35+
36+
_harmony = HarmonyInstance.Create("com.brian91292.beatsaber.cameraplus");
37+
try
38+
{
39+
_harmony.PatchAll(Assembly.GetExecutingAssembly());
40+
}
41+
catch (Exception ex)
42+
{
43+
Plugin.Log("Failed to apply harmony patches!");
44+
}
3145

3246
// Add our default cameraplus camera
3347
CameraUtilities.AddNewCamera("cameraplus");
@@ -61,6 +75,8 @@ IEnumerator DelayedActiveSceneChanged(Scene from, Scene to)
6175
public void OnApplicationQuit()
6276
{
6377
SceneManager.activeSceneChanged -= SceneManager_activeSceneChanged;
78+
79+
_harmony.UnpatchAll("com.brian91292.beatsaber.cameraplus");
6480
}
6581

6682
public void OnLevelWasLoaded(int level)

CameraPlus/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly:AssemblyVersion("3.2.3.0")]
35-
[assembly:AssemblyFileVersion("3.2.3.0")]
34+
[assembly:AssemblyVersion("3.2.4.0")]
35+
[assembly:AssemblyFileVersion("3.2.4.0")]

CameraPlus/WindowOverridePatch.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Harmony;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Runtime.InteropServices;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace CameraPlus
10+
{
11+
[HarmonyPatch(typeof(WindowOverride))]
12+
[HarmonyPatch("WndProc", MethodType.Normal)]
13+
public class WindowOverridePatch
14+
{
15+
private static readonly int WM_RBUTTONDOWN = 516;
16+
private static readonly int WM_RBUTTONUP = 517;
17+
18+
[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "CallWindowProcW")]
19+
private static extern IntPtr CallWindowProc(IntPtr prevWndProc, IntPtr hwnd, uint msg, IntPtr wparam, IntPtr lparam);
20+
21+
public static bool Prefix(WindowOverride __instance, IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam, ref IntPtr __result, IntPtr ____oldWndProcPtr)
22+
{
23+
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONUP)
24+
{
25+
__result = CallWindowProc(____oldWndProcPtr, hWnd, msg, wParam, lParam);
26+
return false;
27+
}
28+
return true;
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)