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

Commit e432023

Browse files
committed
1.1.1
1 parent 99a1cac commit e432023

File tree

3 files changed

+131
-9
lines changed

3 files changed

+131
-9
lines changed

BindManager.cs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
//#region
2+
//using System;
3+
//using UnityEngine;
4+
//using System.Collections;
5+
//using UnityEngine.UI;
6+
//using UIExpansionKit.API;
7+
//#endregion
8+
9+
//namespace PlayspaceMover
10+
//{
11+
// public static class BindManager
12+
// {
13+
// public static ICustomShowableLayoutedMenu Page;
14+
// private static GameObject titleObject;
15+
// private static GameObject textObject;
16+
// private static bool Initialized = false;
17+
18+
// public static void Initialize()
19+
// {
20+
// Page = ExpansionKitApi.CreateCustomFullMenuPopup(LayoutDescription.WideSlimList);
21+
22+
// Page.AddLabel("Title", new Action<GameObject>((obj) => { titleObject = obj; }));
23+
// Page.AddLabel("Waiting for key...", new Action<GameObject>((obj) => { textObject = obj; }));
24+
25+
// Page.AddSimpleButton("Accept", new Action(() =>
26+
// {
27+
// AcceptAction?.Invoke(selectedKey);
28+
// fetchingKeys = false;
29+
// Page.Hide();
30+
// }));
31+
32+
// Page.AddSimpleButton("Cancel", new Action(() =>
33+
// {
34+
35+
// CancelAction?.Invoke();
36+
// fetchingKeys = false;
37+
// Page.Hide();
38+
// }));
39+
40+
// Initialized = true;
41+
// }
42+
43+
44+
// public static void Show(string title, Action<KeyCode> acceptAction, Action cancelAction)
45+
// {
46+
// if (!Initialized) return;
47+
// selectedKey = KeyCode.None;
48+
// AcceptAction = acceptAction;
49+
// CancelAction = cancelAction;
50+
// Page.Show();
51+
52+
// if (titleObject != null && titleObject.GetComponentInChildren<Text>() != null) titleObject.GetComponentInChildren<Text>().text = title;
53+
54+
// fetchingKeys = true;
55+
// MelonLoader.MelonCoroutines.Start(WaitForKey());
56+
// }
57+
58+
// private static Action<KeyCode> AcceptAction;
59+
// private static Action CancelAction;
60+
61+
// private static bool fetchingKeys = false;
62+
// public static IEnumerator WaitForKey()
63+
// {
64+
// while (fetchingKeys && textObject != null)
65+
// {
66+
// foreach (KeyCode inputKey in Enum.GetValues(typeof(KeyCode)))
67+
// {
68+
// if ((int)inputKey < 330) continue;
69+
70+
// if (Input.GetKeyDown(inputKey)) selectedKey = inputKey;
71+
// }
72+
73+
// if (textObject != null && selectedKey != KeyCode.None)
74+
// textObject.GetComponentInChildren<Text>().text = "Waiting for key...";
75+
// else if (textObject != null)
76+
// textObject.GetComponentInChildren<Text>().text = selectedKey.ToString();
77+
78+
79+
// yield return new WaitForEndOfFrame();
80+
// }
81+
// yield break;
82+
// }
83+
84+
// private static KeyCode selectedKey = KeyCode.None;
85+
// }
86+
//}

Main.cs

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22
using MelonLoader;
33
using System.Collections;
44
using System.Collections.Generic;
5+
//using System.Linq;
6+
//using System;
7+
//using UIExpansionKit.API;
58
using UnityEngine;
69
#endregion
710

811
namespace PlayspaceMover
912
{
1013
public static class ModInfo
1114
{
12-
public const string Name = "PlayspaceMover";
13-
public const string Description = "A SteamVR's Playspace clone for Oculus Users";
15+
public const string Name = "OculusPlayspaceMover";
16+
public const string Description = "A SteamVR's Playspace clone for VRChat from Oculus Store";
1417
public const string Author = "Rafa";
1518
public const string Company = "RBX";
16-
public const string Version = "1.1.0";
19+
public const string Version = "1.1.1";
1720
public const string DownloadLink = null;
1821
}
1922

@@ -23,25 +26,55 @@ public class Main : MelonMod
2326
private bool Enabled = true;
2427
private float Strength = 1f;
2528
private float DoubleClickTime = 0.25f;
29+
private bool DisableDoubleClick = false;
30+
private bool DisableLeftHand = false;
31+
private bool DisableRightHand = false;
2632
#endregion
2733

2834
private readonly string Category = "PlayspaceMover";
2935
public override void OnApplicationStart()
3036
{
31-
MelonPrefs.RegisterCategory(Category, "Playspace Mover");
37+
MelonPrefs.RegisterCategory(Category, "Oculus Playspace Mover");
3238
MelonPrefs.RegisterBool(Category, nameof(Enabled), Enabled, "Enabled");
3339
MelonPrefs.RegisterFloat(Category, nameof(Strength), Strength, "Strength");
3440
MelonPrefs.RegisterFloat(Category, nameof(DoubleClickTime), DoubleClickTime, "Double Click Time");
41+
MelonPrefs.RegisterBool(Category, nameof(DisableDoubleClick), DisableDoubleClick, "Disable Double Click");
42+
MelonPrefs.RegisterBool(Category, nameof(DisableLeftHand), DisableLeftHand, "Disable Left Hand");
43+
MelonPrefs.RegisterBool(Category, nameof(DisableRightHand), DisableRightHand, "Disable Right Hand");
44+
3545
ApplySettings();
3646

3747
MelonCoroutines.Start(WaitInitialization());
48+
49+
//if (MelonHandler.Mods.Any(x => x.Info.Name == "UI Expansion Kit"))
50+
//{
51+
// BindManager.Initialize();
52+
53+
// var playspaceSettings = ExpansionKitApi.CreateCustomFullMenuPopup(LayoutDescription.WideSlimList);
54+
// playspaceSettings.AddSimpleButton("Left Hand", new Action(() => BindManager.Show("Left Hand Spacedrag", new Action<KeyCode>(key =>
55+
// {
56+
57+
// }), null)
58+
// ));
59+
60+
// playspaceSettings.AddSimpleButton("Right Hand", new Action(() =>
61+
// BindManager.Show("Right Hand Spacedrag", new Action<KeyCode>(key => {
62+
63+
// }), null)
64+
// ));
65+
66+
// ExpansionKitApi.GetExpandedMenu(ExpandedMenu.SettingsMenu).AddSimpleButton("Oculus Playspace", new Action(() => playspaceSettings.Show()));
67+
//}
3868
}
3969

4070
private void ApplySettings()
4171
{
4272
Enabled = MelonPrefs.GetBool(Category, nameof(Enabled));
4373
Strength = MelonPrefs.GetFloat(Category, nameof(Strength));
4474
DoubleClickTime = MelonPrefs.GetFloat(Category, nameof(DoubleClickTime));
75+
DisableDoubleClick = MelonPrefs.GetBool(Category, nameof(DisableDoubleClick));
76+
DisableLeftHand = MelonPrefs.GetBool(Category, nameof(DisableLeftHand));
77+
DisableRightHand = MelonPrefs.GetBool(Category, nameof(DisableRightHand));
4578
}
4679

4780
public override void OnModSettingsApplied() => ApplySettings();
@@ -66,13 +99,11 @@ private IEnumerator WaitInitialization()
6699
yield break;
67100
}
68101

69-
70-
71102
public override void OnUpdate()
72103
{
73104
if (!Enabled || Camera == null) return;
74105

75-
if (HasDoubleClicked(OVRInput.Button.Three, DoubleClickTime) || HasDoubleClicked(OVRInput.Button.One, DoubleClickTime))
106+
if (!DisableDoubleClick && (HasDoubleClicked(OVRInput.Button.Three, DoubleClickTime) || HasDoubleClicked(OVRInput.Button.One, DoubleClickTime)))
76107
{
77108
Camera.cameraLiftTransform.localPosition = StartPosition;
78109
return;
@@ -86,15 +117,15 @@ public override void OnUpdate()
86117
bool leftTrigger = OVRInput.Get(OVRInput.Button.Three, OVRInput.Controller.Touch);
87118
bool rightTrigger = OVRInput.Get(OVRInput.Button.One, OVRInput.Controller.Touch);
88119

89-
if (leftTrigger)
120+
if (leftTrigger && !DisableLeftHand)
90121
{
91122
Vector3 currentOffset = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch);
92123
Vector3 calculatedOffset = (currentOffset - startingOffset) * -Strength;
93124
startingOffset = currentOffset;
94125
Camera.cameraLiftTransform.localPosition += calculatedOffset;
95126
}
96127

97-
if (rightTrigger)
128+
if (rightTrigger && !DisableRightHand)
98129
{
99130
Vector3 currentOffset = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
100131
Vector3 calculatedOffset = (currentOffset - startingOffset) * -Strength;

PlayspaceMover.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@
6363
<Reference Include="UnityEngine.CoreModule">
6464
<HintPath>A:\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.CoreModule.dll</HintPath>
6565
</Reference>
66+
<Reference Include="UnityEngine.UI, Version=3.7.1.6, Culture=neutral, processorArchitecture=MSIL">
67+
<SpecificVersion>False</SpecificVersion>
68+
<HintPath>A:\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.UI.dll</HintPath>
69+
</Reference>
6670
</ItemGroup>
6771
<ItemGroup>
72+
<Compile Include="BindManager.cs" />
6873
<Compile Include="Main.cs" />
6974
<Compile Include="Properties\AssemblyInfo.cs" />
7075
</ItemGroup>

0 commit comments

Comments
 (0)