From c16d3fe2769d29c32b1bb6e87a7d8e73f9ce1676 Mon Sep 17 00:00:00 2001 From: Nyako <24845294+nyakowint@users.noreply.github.com> Date: Thu, 28 Dec 2023 19:06:47 -0500 Subject: [PATCH] The keyboard can now go on your head ... and hands --- KeyboardOSC/Patches.cs | 6 +++++- KeyboardOSC/Plugin.cs | 6 +++++- KeyboardOSC/PluginSettings.cs | 1 + settingsKO.js | 13 ++++++++++--- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/KeyboardOSC/Patches.cs b/KeyboardOSC/Patches.cs index 4cf6ba6..817de44 100644 --- a/KeyboardOSC/Patches.cs +++ b/KeyboardOSC/Patches.cs @@ -12,7 +12,10 @@ namespace KeyboardOSC; public static class Patches { private static Harmony Harmony; - private static WindowAttachementManager.DeviceToAttachTo kbAttachedTo; + + private static WindowAttachementManager.DeviceToAttachTo kbAttachedTo = + WindowAttachementManager.DeviceToAttachTo.None; + private static bool HasSettingsBeenOpenedOnce; public static void PatchAll() @@ -127,6 +130,7 @@ public static void RequestSettingsPatch(string sender, string data) KBCheckForUpdates = PluginSettings.GetSetting("CheckForUpdates").Value, KBLiveSend = PluginSettings.GetSetting("LiveSend").Value, KBTypingIndicator = PluginSettings.GetSetting("TypingIndicator").Value, + KBAttachmentIndex = (int)kbAttachedTo }; var data2 = JsonUtility.ToJson(settings, true); ServerBridge.Instance.SendMessage("UpdateSettings", data2, null, sender); diff --git a/KeyboardOSC/Plugin.cs b/KeyboardOSC/Plugin.cs index 808dc9f..e36f224 100644 --- a/KeyboardOSC/Plugin.cs +++ b/KeyboardOSC/Plugin.cs @@ -206,6 +206,10 @@ private void SetupBar() ChatMode.Setup(oscbarText, charCounterText); + + var trackDevice = keyboardWindowObj.AddComponent(); + trackDevice.TrackedDevice = Unity_Overlay.OverlayTrackedDevice.None; + oscBarRoot.SetActive(true); keyboardWindowObj.SetActive(true); WindowMovementManager.MoveToEdgeOfWindowAndInheritRotation(oscBarWindow, keyboardWindow, @@ -222,7 +226,7 @@ public void RepositionBar(Unity_Overlay barOverlay, Unity_Overlay keebOverlay) public void AttachKeyboard(int anchor) { - WindowMovementManager.WMM_Inst.AttachWindowToDeviceIndex(anchor, overlayManager.Keyboard_Overlay); + WindowMovementManager.WMM_Inst.AttachWindowToDeviceIndex(anchor, Overlay_Manager.Instance.Keyboard_Overlay); } public void ToggleChatMode() diff --git a/KeyboardOSC/PluginSettings.cs b/KeyboardOSC/PluginSettings.cs index 4bd9fdf..50c0237 100644 --- a/KeyboardOSC/PluginSettings.cs +++ b/KeyboardOSC/PluginSettings.cs @@ -37,4 +37,5 @@ public class UiSettings public bool KBCheckForUpdates = false; public bool KBLiveSend = false; public bool KBTypingIndicator = true; + public int KBAttachmentIndex = 0; } \ No newline at end of file diff --git a/settingsKO.js b/settingsKO.js index 45b239f..3156ff5 100644 --- a/settingsKO.js +++ b/settingsKO.js @@ -62,10 +62,10 @@ const SettingsLayout = { _: { KBCheckForUpdates: new SettingsElements.Setting(SettingsElements.UIComponents.Toggle, 'Notify about updates', "The plugin will notify you if there's an update available :D", false), KBLiveSend: new SettingsElements.Setting(SettingsElements.UIComponents.Toggle, 'Live send mode', "Messages will be sent to the chatbox as you type.", false), - KBTypingIndicator: new SettingsElements.Setting(SettingsElements.UIComponents.Toggle, 'Send typing indicator', "Some people prefer to not let people know when they are typing for some reason lol", true), - KBAttachmentIndex: new SettingsElements.Setting(SettingsElements.UIComponents.Dropdown, 'Keyboard Attachment', "put the keyboard on ur head idk", 'Disabled', ['Disabled', 'So no head?', 'Left hand', 'Right hand']), - KBOpenRepo: new SettingsElements.Setting(SettingsElements.UIComponents.Button, 'Plugin Repo', "View this plugin's repo on GitHub", '', '', ''), + KBTypingIndicator: new SettingsElements.Setting(SettingsElements.UIComponents.Toggle, 'Send typing indicator', "Some people prefer to not let people know when they are typing. If this is you here ya go!", true), + KBAttachmentIndex: new SettingsElements.Setting(SettingsElements.UIComponents.Dropdown, 'Keyboard Attachment', "put the keyboard on ur head idk, attaching to your hand basically makes you one handed lool", 'Disabled', ['Disabled', 'So no head?', 'Left hand', 'Right hand']), KBVersionCheck: new SettingsElements.Setting(SettingsElements.UIComponents.Button, 'Check for updates', "Check for updates rn!!!!!", '', '', ''), + KBOpenRepo: new SettingsElements.Setting(SettingsElements.UIComponents.Button, 'Plugin Repo', "View this plugin's repo on GitHub", '', '', ''), KBVersion: new SettingsElements.Setting(SettingsElements.UIComponents.Text, 'KBVersion'), }, }, @@ -527,5 +527,12 @@ function SetMenuStates(data) { var appVersionText = document.getElementById("VersionNumber_Desc"); appVersionText.innerHTML = `Build ${data.VersionNumber}`; + console.log(data) + + if (data.KBVersion) { + var kbVersion = document.getElementById("KBVersion_Desc"); + kbVersion.innerHTML = `KeyboardOSC Version ${data.KBVersion}`; + } + console.log("Settings Updated."); } \ No newline at end of file