From 07ecbccf1925f84deb3efba87f3969ab1e00f901 Mon Sep 17 00:00:00 2001 From: Lucas Date: Tue, 2 Feb 2021 18:12:07 -0300 Subject: [PATCH] v1.1.3 --- Buttons/SingleButton.cs | 3 +- DesktopCamera.csproj | 42 +-------- FUNDING.yml | 1 + Main.cs | 184 ++++++++++++++++++++++------------------ README.md | 5 +- Utils/CameraUtils.cs | 52 ++++++++---- Utils/VRCUtils.cs | 6 +- 7 files changed, 145 insertions(+), 148 deletions(-) create mode 100644 FUNDING.yml diff --git a/Buttons/SingleButton.cs b/Buttons/SingleButton.cs index 00739d8..042a446 100644 --- a/Buttons/SingleButton.cs +++ b/Buttons/SingleButton.cs @@ -31,8 +31,7 @@ public void setButtonPosition(int x, int y) { } public void setTooltip(string tooltip) { - button.GetComponent().text = tooltip; - button.GetComponent().alternateText = tooltip; + button.GetComponent().field_Public_String_0 = tooltip; } public void setInteractable(bool interactable) { diff --git a/DesktopCamera.csproj b/DesktopCamera.csproj index 566052f..f223a7d 100644 --- a/DesktopCamera.csproj +++ b/DesktopCamera.csproj @@ -44,51 +44,17 @@ C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\Il2Cppmscorlib.dll - - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\Il2CppSystem.dll - - - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\Il2CppSystem.Configuration.dll - - - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\Il2CppSystem.Core.dll - - - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\Il2CppSystem.Runtime.Serialization.dll - - - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\Il2CppSystem.Windows.Forms.dll - - - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\Il2CppSystem.Xml.dll - - - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\Il2CppSystem.Xml.Linq.dll - - - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\MelonLoader.ModHandler.dll + + C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\MelonLoader.dll False C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\Newtonsoft.Json.dll - - - - - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnhollowerBaseLib.dll - - False - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnhollowerRuntimeLib.dll - - - False - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.dll - False C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.CoreModule.dll @@ -105,10 +71,6 @@ False C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.UnityWebRequestModule.dll - - False - C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\VRCCore-Standalone.dll - False C:\Program Files (x86)\Steam\steamapps\common\VRChat\MelonLoader\Managed\VRCSDK3.dll diff --git a/FUNDING.yml b/FUNDING.yml new file mode 100644 index 0000000..2ff37c4 --- /dev/null +++ b/FUNDING.yml @@ -0,0 +1 @@ +patreon: nitrog0d \ No newline at end of file diff --git a/Main.cs b/Main.cs index bd3c81e..a8f7cf5 100644 --- a/Main.cs +++ b/Main.cs @@ -16,7 +16,7 @@ public static class ModBuildInfo { public const string Name = "DesktopCamera"; public const string Author = "nitro."; public const string Company = null; - public const string Version = "1.1.2"; + public const string Version = "1.1.3"; public const string DownloadLink = "https://github.com/nitrog0d/DesktopCamera/releases/latest/download/DesktopCamera.dll"; public const string GameDeveloper = "VRChat"; public const string Game = "VRChat"; @@ -35,17 +35,17 @@ public class Main : MelonMod { private static float CameraSpeedAlt = 0.020f; public override void OnApplicationStart() { - MelonLogger.Log("Mod loaded."); - MelonPrefs.RegisterCategory(ModCategory, "DesktopCamera"); - MelonPrefs.RegisterInt(ModCategory, CameraSpeedPref, 5, "Basic camera speed"); - MelonPrefs.RegisterInt(ModCategory, CameraSpeedAltPref, 20, "Alt camera speed (ALT pressed)"); - OnModSettingsApplied(); + MelonLogger.Msg("Mod loaded."); + MelonPreferences.CreateCategory(ModCategory, "DesktopCamera"); + MelonPreferences.CreateEntry(ModCategory, CameraSpeedPref, 5, "Basic camera speed"); + MelonPreferences.CreateEntry(ModCategory, CameraSpeedAltPref, 20, "Alt camera speed (ALT pressed)"); + OnPreferencesSaved(); } - public override void OnModSettingsApplied() { - CameraSpeed = MelonPrefs.GetInt(ModCategory, CameraSpeedPref); - CameraSpeedAlt = MelonPrefs.GetInt(ModCategory, CameraSpeedAltPref); + public override void OnPreferencesSaved() { + CameraSpeed = MelonPreferences.GetEntryValue(ModCategory, CameraSpeedPref); + CameraSpeedAlt = MelonPreferences.GetEntryValue(ModCategory, CameraSpeedAltPref); CameraSpeed /= 1000; CameraSpeedAlt /= 1000; @@ -55,6 +55,18 @@ public override void VRChat_OnUiManagerInit() { MelonCoroutines.Start(Setup()); } + /* + // Code from DDAkebono, it was a temporary replacement for VRChat_OnUiManagerInit + private static int scenesLoaded = 0; + + public override void OnSceneWasLoaded(int buildIndex, string sceneName) { + scenesLoaded++; + + if (scenesLoaded != 2) return; + + MelonCoroutines.Start(Setup()); + }*/ + private SingleButton cameraMovementButton = null; private IEnumerator Setup() { @@ -65,6 +77,7 @@ private IEnumerator Setup() { //yield return request.SendWebRequest(); + MelonLogger.Msg("Checking mod version..."); var asyncOperation = request.SendWebRequest(); // yield return doesn't work for now, so I had to change it to this. @@ -80,11 +93,17 @@ private IEnumerator Setup() { var response = JsonConvert.DeserializeObject(request.downloadHandler.text); if (response.result == "OUTDATED") { updated = false; - latest = response.latest; } - } catch (Exception) { } + latest = response.latest; + } catch (Exception) { + MelonLogger.Error("Failed to check version!"); + } + } else { + MelonLogger.Error("Failed to check version!"); } + MelonLogger.Msg(updated ? $"You're updated! Latest version: {latest}" : $"A new version of the mod ({latest}) has been found, please update."); + var quickMenu = VRCUtils.GetQuickMenu(); if (!updated) quickMenu.transform.Find("ShortcutMenu/CameraButton").GetComponentInChildren().text = "Camera\nUpdate\navailable!"; @@ -108,7 +127,7 @@ private IEnumerator Setup() { var qmBoxCollider = quickMenu.GetComponent(); - // Thank you Janni9009#1751 <3 + // Thank you JanNyaa (Janni9009#1751) <3 if (qmBoxCollider.size.y < 3768) qmBoxCollider.size += new Vector3(0f, 840f, 0f); quickMenu.transform.Find("QuickMenu_NewElements/_CONTEXT/QM_Context_ToolTip/_ToolTipPanel/Text").GetComponent().supportRichText = true; @@ -132,11 +151,11 @@ private IEnumerator Setup() { var cameraButton = new SingleButton("Camera", "Camera\nOff", "Toggles the Camera", 0, 0, cameraMenu); cameraButton.setAction((Action)(() => { Settings.cameraEnabled = !Settings.cameraEnabled; - cameraButton.setText("Camera\nOn" : "red>Off") + ""); + cameraButton.setText("Camera\nOn" : "red>Off") + ""); CameraUtils.SetCameraMode(Settings.cameraEnabled ? CameraUtils.CameraMode.Photo : CameraUtils.CameraMode.Off); })); - var movementBehaviourButton = new SingleButton("MovementBehaviour", "Movement\nBehaviour\nNone", "Cycles the Camera's movement behaviour", 1, 0, cameraMenu); + var movementBehaviourButton = new SingleButton("MovementBehaviour", "Movement\nBehaviour\nNone", "Cycles the Camera's movement behaviour", 1, 0, cameraMenu); movementBehaviourButton.setAction((Action)(() => { if (Settings.cameraEnabled) { var cameraBehaviour = CameraUtils.GetCameraBehaviour(); @@ -152,12 +171,12 @@ private IEnumerator Setup() { behaviour = "None"; break; } - movementBehaviourButton.setText("Movement\nBehaviour\n" + behaviour + ""); + movementBehaviourButton.setText("Movement\nBehaviour\n" + behaviour + ""); CameraUtils.CycleCameraBehaviour(); } })); - var movementSpaceButton = new SingleButton("MovementSpace", "Movement\nSpace\nAttached", "Cycles the Camera's movement space", 2, 0, cameraMenu); + var movementSpaceButton = new SingleButton("MovementSpace", "Movement\nSpace\nAttached", "Cycles the Camera's movement space", 2, 0, cameraMenu); movementSpaceButton.setAction((Action)(() => { if (Settings.cameraEnabled) { var cameraSpace = CameraUtils.GetCameraSpace(); @@ -173,7 +192,7 @@ private IEnumerator Setup() { space = "Attached"; break; } - movementSpaceButton.setText("Movement\nSpace\n" + space + ""); + movementSpaceButton.setText("Movement\nSpace\n" + space + ""); CameraUtils.CycleCameraSpace(); if (CameraUtils.GetCameraSpace() == CameraUtils.CameraSpace.World) Settings.allowCameraMovement = true; else Settings.allowCameraMovement = false; } @@ -183,11 +202,11 @@ private IEnumerator Setup() { pinMenuButton.setAction((Action)(() => { if (Settings.cameraEnabled) { CameraUtils.TogglePinMenu(); - pinMenuButton.setText("Pin Menu\nOn" : "red>Off") + ""); + pinMenuButton.setText("Pin Menu\nOn" : "red>Off") + ""); } })); - var switchPinButton = new SingleButton("CyclePin", "Cycle Pin\nPin 1", "Cycles between 3 pins (aka profiles)", 1, 1, cameraMenu); + var switchPinButton = new SingleButton("CyclePin", "Cycle Pin\nPin 1", "Cycles between 3 pins (aka profiles)", 1, 1, cameraMenu); switchPinButton.setAction((Action)(() => { if (Settings.cameraEnabled) { var currentPin = CameraUtils.GetCurrentPin(); @@ -207,7 +226,7 @@ private IEnumerator Setup() { pin = "Pin 1"; break; } - switchPinButton.setText("Cycle Pin\n" + pin + ""); + switchPinButton.setText("Cycle Pin\n" + pin + ""); // Needed to initialize the buttons apparently CameraUtils.TogglePinMenu(); CameraUtils.TogglePinMenu(); @@ -215,73 +234,73 @@ private IEnumerator Setup() { } })); - var timer1Button = new SingleButton("Timer1", "Timer\n3 seconds", "Takes a picture after 3 seconds", 3, 0, cameraMenu); + var timer1Button = new SingleButton("Timer1", "Timer\n3s", "Takes a picture after 3 seconds", 3, 0, cameraMenu); timer1Button.setAction((Action)(() => { if (Settings.cameraEnabled) { CameraUtils.TakePicture(3); } })); - var timer2Button = new SingleButton("Timer2", "Timer\n5 seconds", "Takes a picture after 5 seconds", 3, 1, cameraMenu); + var timer2Button = new SingleButton("Timer2", "Timer\n5s", "Takes a picture after 5 seconds", 3, 1, cameraMenu); timer2Button.setAction((Action)(() => { if (Settings.cameraEnabled) { CameraUtils.TakePicture(5); } })); - var timer3Button = new SingleButton("Timer3", "Timer\n10 seconds", "Takes a picture after 10 seconds", 3, 2, cameraMenu); + var timer3Button = new SingleButton("Timer3", "Timer\n10s", "Takes a picture after 10 seconds", 3, 2, cameraMenu); timer3Button.setAction((Action)(() => { if (Settings.cameraEnabled) { CameraUtils.TakePicture(10); } })); - var cameraScaleButton = new SingleButton("CameraScale", "Camera\nScale\nNormal", "Changes the Camera's scale", 2, 1, cameraMenu); + var cameraScaleButton = new SingleButton("CameraScale", "Camera\nScale\nNormal", "Changes the Camera's scale", 2, 1, cameraMenu); cameraScaleButton.setAction((Action)(() => { if (Settings.cameraEnabled) { string scale = "?"; switch (Settings.cameraScale) { case CameraUtils.CameraScale.Normal: scale = "Medium"; - VRCUtils.GetUserCameraController().viewFinder.transform.localScale = new Vector3(1.5f, 1f, 1.5f); + CameraUtils.GetViewFinder().transform.localScale = new Vector3(1.5f, 1f, 1.5f); Settings.cameraScale = CameraUtils.CameraScale.Medium; break; case CameraUtils.CameraScale.Medium: scale = "Big"; - VRCUtils.GetUserCameraController().viewFinder.transform.localScale = new Vector3(2f, 1f, 2f); + CameraUtils.GetViewFinder().transform.localScale = new Vector3(2f, 1f, 2f); Settings.cameraScale = CameraUtils.CameraScale.Big; break; case CameraUtils.CameraScale.Big: scale = "Normal"; - VRCUtils.GetUserCameraController().viewFinder.transform.localScale = new Vector3(1f, 1f, 1f); + CameraUtils.GetViewFinder().transform.localScale = new Vector3(1f, 1f, 1f); Settings.cameraScale = CameraUtils.CameraScale.Normal; break; } - cameraScaleButton.setText("Camera\nScale\n" + scale + ""); + cameraScaleButton.setText("Camera\nScale\n" + scale + ""); } })); - var toggleArrowKeysButton = new SingleButton("ArrowKeys", "Arrow Keys\nOn", "Allows you to change the camera position\nand rotation using arrow keys and numpad keys\n(for more info check the GitHub page)", 0, 2, cameraMenu); + var toggleArrowKeysButton = new SingleButton("ArrowKeys", "Arrow Keys\nOn", "Allows you to change the camera position\nand rotation using arrow keys and numpad keys\n(for more info check the GitHub page)", 0, 2, cameraMenu); toggleArrowKeysButton.setAction((Action)(() => { Settings.arrowKeysEnabled = !Settings.arrowKeysEnabled; - toggleArrowKeysButton.setText("Arrow Keys\nOn" : "red>Off") + ""); + toggleArrowKeysButton.setText("Arrow Keys\nOn" : "red>Off") + ""); })); var rotateAroundUserCameraButton = new SingleButton("RotateAroundUserCamera", "Rotate\nAround\nUser Camera\nOff", "Makes the camera rotate around the user's camera\ninstead of just saying bye bye\n(for more info check the GitHub page)", 1, 2, cameraMenu); rotateAroundUserCameraButton.setAction((Action)(() => { Settings.rotateAroundUserCamera = !Settings.rotateAroundUserCamera; - rotateAroundUserCameraButton.setText("Rotate\nAround\nUser Camera\nOn" : "red>Off") + ""); + rotateAroundUserCameraButton.setText("Rotate\nAround\nUser Camera\nOn" : "red>Off") + ""); })); var toggleLockButton = new SingleButton("ToggleLock", "Lock\nOff", "Toggles the Lock (Camera pickup)", 4, -1, cameraMenu); toggleLockButton.setAction((Action)(() => { if (Settings.cameraEnabled) { - toggleLockButton.setText("Lock\n().pickupable ? "#845bff>On" : "red>Off") + ""); + toggleLockButton.setText("Lock\n().pickupable ? "#ff73fa>On" : "red>Off") + ""); CameraUtils.ToggleLock(); } })); - var gitHubButton = new SingleButton("GitHubPage", "" + (updated ? "GitHub\nPage" : "GitHub Page\nUpdate\navailable!"), "Opens the GitHub page of the mod\nMod created by nitro.#0007\nVersion: " + ModBuildInfo.Version + (updated ? "" : "\nNew version found (" + latest + "), update it in the GitHub page."), -1, -1, cameraMenu); + var gitHubButton = new SingleButton("GitHubPage", "" + (updated ? "GitHub\nPage" : "GitHub Page\nUpdate\navailable!"), "Opens the GitHub page of the mod\nMod created by nitro. ♥\nVersion: " + ModBuildInfo.Version + (updated ? "" : "\nNew version found (" + latest + "), update it in the GitHub page."), -1, -1, cameraMenu); gitHubButton.setAction((Action)(() => { Application.OpenURL(updated ? "https://github.com/nitrog0d/DesktopCamera" : "https://github.com/nitrog0d/DesktopCamera/releases"); })); @@ -291,7 +310,7 @@ private IEnumerator Setup() { var child = filtersMenu.transform.GetChild(i); if (child.name == "BackButton") { child.localPosition = SingleButton.getButtonPositionFor(4, 2); - child.GetComponent().text = "Go Back to the Camera Menu"; + child.GetComponent().field_Public_String_0 = "Go Back to the Camera Menu"; child.GetComponent