diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1a98d3a..4b833cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,6 +49,6 @@ jobs: - name: Create Release run: | $short_sha="${{ github.sha }}".Substring(0,7) - gh release create ${{ steps.tag_version.outputs.new_tag }}-$short_sha ./builds/Release/net472/KeyboardOSC.dll --title "KeyboardOSC Build $short_sha" --prerelease --notes "${{ steps.tag_version.outputs.changelog }}" + gh release create ${{ steps.tag_version.outputs.new_tag }}-$short_sha --title "KeyboardOSC Build $short_sha" --prerelease --notes "${{ steps.tag_version.outputs.changelog }} ./builds/Release/net472/KeyboardOSC.dll ./BepInEx.cfg" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/BepInEx.cfg b/BepInEx.cfg new file mode 100644 index 0000000..87e3959 --- /dev/null +++ b/BepInEx.cfg @@ -0,0 +1,151 @@ +[Caching] + +## Enable/disable assembly metadata cache +## Enabling this will speed up discovery of plugins and patchers by caching the metadata of all types BepInEx discovers. +# Setting type: Boolean +# Default value: true +EnableAssemblyCache = true + +[Chainloader] + +## If enabled, hides BepInEx Manager GameObject from Unity. +## This can fix loading issues in some games that attempt to prevent BepInEx from being loaded. +## Use this only if you know what this option means, as it can affect functionality of some older plugins. +## +# Setting type: Boolean +# Default value: false +HideManagerGameObject = true + +[Harmony.Logger] + +## Specifies which Harmony log channels to listen to. +## NOTE: IL channel dumps the whole patch methods, use only when needed! +# Setting type: LogChannel +# Default value: Warn, Error +# Acceptable values: None, Info, IL, Warn, Error, Debug, All +# Multiple values can be set at the same time by separating them with , (e.g. Debug, Warning) +LogChannels = Warn, Error + +[Logging] + +## Enables showing unity log messages in the BepInEx logging system. +# Setting type: Boolean +# Default value: true +UnityLogListening = true + +## If enabled, writes Standard Output messages to Unity log +## NOTE: By default, Unity does so automatically. Only use this option if no console messages are visible in Unity log +## +# Setting type: Boolean +# Default value: false +LogConsoleToUnityLog = false + +[Logging.Console] + +## Enables showing a console for log output. +# Setting type: Boolean +# Default value: false +Enabled = false + +## If enabled, will prevent closing the console (either by deleting the close button or in other platform-specific way). +# Setting type: Boolean +# Default value: false +PreventClose = false + +## If true, console is set to the Shift-JIS encoding, otherwise UTF-8 encoding. +# Setting type: Boolean +# Default value: false +ShiftJisEncoding = false + +## Hints console manager on what handle to assign as StandardOut. Possible values: +## Auto - lets BepInEx decide how to redirect console output +## ConsoleOut - prefer redirecting to console output; if possible, closes original standard output +## StandardOut - prefer redirecting to standard output; if possible, closes console out +## +# Setting type: ConsoleOutRedirectType +# Default value: Auto +# Acceptable values: Auto, ConsoleOut, StandardOut +StandardOutType = Auto + +## Which log levels to show in the console output. +# Setting type: LogLevel +# Default value: Fatal, Error, Warning, Message, Info +# Acceptable values: None, Fatal, Error, Warning, Message, Info, Debug, All +# Multiple values can be set at the same time by separating them with , (e.g. Debug, Warning) +LogLevels = Fatal, Error, Warning, Message, Info + +[Logging.Disk] + +## Include unity log messages in log file output. +# Setting type: Boolean +# Default value: false +WriteUnityLog = false + +## Appends to the log file instead of overwriting, on game startup. +# Setting type: Boolean +# Default value: false +AppendLog = false + +## Enables writing log messages to disk. +# Setting type: Boolean +# Default value: true +Enabled = true + +## Which log leves are saved to the disk log output. +# Setting type: LogLevel +# Default value: Fatal, Error, Warning, Message, Info +# Acceptable values: None, Fatal, Error, Warning, Message, Info, Debug, All +# Multiple values can be set at the same time by separating them with , (e.g. Debug, Warning) +LogLevels = Fatal, Error, Warning, Message, Info + +[Preloader] + +## Enables or disables runtime patches. +## This should always be true, unless you cannot start the game due to a Harmony related issue (such as running .NET Standard runtime) or you know what you're doing. +# Setting type: Boolean +# Default value: true +ApplyRuntimePatches = true + +## Specifies which MonoMod backend to use for Harmony patches. Auto uses the best available backend. +## This setting should only be used for development purposes (e.g. debugging in dnSpy). Other code might override this setting. +# Setting type: MonoModBackend +# Default value: auto +# Acceptable values: auto, dynamicmethod, methodbuilder, cecil +HarmonyBackend = auto + +## If enabled, BepInEx will save patched assemblies into BepInEx/DumpedAssemblies. +## This can be used by developers to inspect and debug preloader patchers. +# Setting type: Boolean +# Default value: false +DumpAssemblies = false + +## If enabled, BepInEx will load patched assemblies from BepInEx/DumpedAssemblies instead of memory. +## This can be used to be able to load patched assemblies into debuggers like dnSpy. +## If set to true, will override DumpAssemblies. +# Setting type: Boolean +# Default value: false +LoadDumpedAssemblies = false + +## If enabled, BepInEx will call Debugger.Break() once before loading patched assemblies. +## This can be used with debuggers like dnSpy to install breakpoints into patched assemblies before they are loaded. +# Setting type: Boolean +# Default value: false +BreakBeforeLoadAssemblies = false + +[Preloader.Entrypoint] + +## The local filename of the assembly to target. +# Setting type: String +# Default value: UnityEngine.CoreModule.dll +Assembly = UnityEngine.CoreModule.dll + +## The name of the type in the entrypoint assembly to search for the entrypoint method. +# Setting type: String +# Default value: Application +Type = Application + +## The name of the method in the specified entrypoint assembly and type to hook and load Chainloader from. +# Setting type: String +# Default value: .cctor +Method = .cctor + diff --git a/KeyboardOSC/Patches.cs b/KeyboardOSC/Patches.cs index 8ef27c0..bb85df2 100644 --- a/KeyboardOSC/Patches.cs +++ b/KeyboardOSC/Patches.cs @@ -14,7 +14,7 @@ public static class Patches private static readonly ManualLogSource Logger = Plugin.PluginLogger; public static Harmony Harmony; - public static void DoPatches() + public static void PatchAll() { Harmony = new Harmony("nwnt.keyboardosc"); // patch key presses diff --git a/KeyboardOSC/Plugin.cs b/KeyboardOSC/Plugin.cs index a7a8ca8..b88d9db 100644 --- a/KeyboardOSC/Plugin.cs +++ b/KeyboardOSC/Plugin.cs @@ -1,6 +1,9 @@ using System; +using System.IO; using System.Reflection; +using System.Threading; using BepInEx; +using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using KeyboardOSC.XScripts; @@ -11,13 +14,13 @@ namespace KeyboardOSC { - [BepInPlugin("nwnt.keyboardosc", "KeyboardOSC", "1.0.0.0")] + [BepInPlugin("nwnt.keyboardosc", "KeyboardOSC", "1.0.1.1")] public class Plugin : BaseUnityPlugin { public static Plugin Instance; public static ManualLogSource PluginLogger; - public static bool IsFirstOpen = true; - public static bool IsChatModeActive = false; + private static bool _isDebugConfig; + public static bool IsChatModeActive; public Overlay_Manager overlayManager; public KeyboardInputHandler inputHandler; public GameObject chatButtonObj; @@ -26,18 +29,29 @@ public class Plugin : BaseUnityPlugin public static MethodInfo ReleaseStickyKeys; - private void Start() + private void Awake() { +#if DEBUG + _isDebugConfig = true; +#endif PluginLogger = Logger; - Logger.LogWarning("Starting Pre-setup"); if (Instance != null) Destroy(this); + PluginSettings.ConfigFile = Config; + PluginSettings.Init(); + if (!Environment.CommandLine.Contains("-batchmode") || _isDebugConfig) return; + Logger.LogWarning("XSOverlay runs in batchmode normally (headless, without a window)."); + Logger.LogWarning("To see extended logs launch XSOverlay directly."); + } + + private void Start() + { + Logger.LogWarning("It works! Starting Pre-setup"); Instance = this; Console.Title = "XSO BepInEx Console"; ReleaseStickyKeys = AccessTools.Method(typeof(KeyboardInputHandler), "ReleaseStickyKeys"); - Patches.DoPatches(); - - + Patches.PatchAll(); + ServerBridge.Instance.CommandMap["Keyboard"] = delegate { InitializeKeyboard(); @@ -71,13 +85,13 @@ private void SetupAdditionalGameObjects() chatButtonObj.transform.Find("Image").GetComponent().sprite = "chat".GetSprite(); chatButtonObj.Rename("OSC Keyboard Mode"); - + // Create typing bar var oscBarRoot = new GameObject("TypingBarOverlay"); oscBarRoot.SetActive(false); keyboardWindowObj.SetActive(false); oscBarRoot.AddComponent(); - + oscBarWindowObj = Instantiate(keyboardWindow.gameObject, oscBarRoot.transform); oscBarWindowObj.Rename("TypingBar Overlay"); oscBarWindowObj.DestroyComponent(); @@ -88,7 +102,7 @@ private void SetupAdditionalGameObjects() oscBarWindowObj.GetComponent().OverlayTopLevelObject = oscBarRoot; oscBarWindow.overlayName = "chatbar"; oscBarWindow.overlayKey = "chatbar"; - + oscBarWindow.isMoveable = false; @@ -142,12 +156,12 @@ private void SetupAdditionalGameObjects() var newTrans = overlay.transform; var newPos = newTrans.position; const float offset = 0.155f; - obwTransform.position = newPos + newTrans.up * offset ; + obwTransform.position = newPos + newTrans.up * offset; obwTransform.rotation = newTrans.rotation; }; kbBackground.transform.localPosition = Vector3.zero; - + kbBackground.GetComponent().sizeDelta = new Vector2(4130, 475); camTrans.position = canvasTrans.position; @@ -176,7 +190,7 @@ public void ToggleChatMode() { var chatButton = chatButtonObj.GetComponent