3 Commits

Author SHA1 Message Date
art0007i 7e118874ce Merge branch 'master' of https://github.com/art0007i/ResoniteImGuiLib 2024-12-20 22:32:32 +01:00
art0007i 1c8b0cbdc3 minor fixes 2024-12-20 22:32:25 +01:00
art0007i 65c276b617 link example 2024-09-02 15:24:09 +02:00
3 changed files with 22 additions and 11 deletions
+3 -1
View File
@@ -2,9 +2,11 @@
A [ResoniteModLoader](https://github.com/resonite-modding-group/ResoniteModLoader) mod for [Resonite](https://resonite.com/) that is a library which allows modders to use [ImGuiUnityInject](https://github.com/art0007i/ImGuiUnityInject) in resonite. A [ResoniteModLoader](https://github.com/resonite-modding-group/ResoniteModLoader) mod for [Resonite](https://resonite.com/) that is a library which allows modders to use [ImGuiUnityInject](https://github.com/art0007i/ImGuiUnityInject) in resonite.
Example usage can be found here: https://github.com/art0007i/ImGuiExample
## Installation ## Installation
1. Install [ResoniteModLoader](https://github.com/resonite-modding-group/ResoniteModLoader). 1. Install [ResoniteModLoader](https://github.com/resonite-modding-group/ResoniteModLoader).
1. Place [ResoniteImGuiLib.dll](https://github.com/art0007i/ResoniteImGuiLib/releases/latest/download/ResoniteImGuiLib.dll) into your `rml_mods` folder. This folder should be at `C:\Program Files (x86)\Steam\steamapps\common\Resonite\rml_mods` for a default install. You can create it if it's missing, or if you launch the game once with ResoniteModLoader installed it will create the folder for you. 1. Place [ResoniteImGuiLib.dll](https://github.com/art0007i/ResoniteImGuiLib/releases/latest/download/ResoniteImGuiLib.dll) into your `rml_mods` folder. This folder should be at `C:\Program Files (x86)\Steam\steamapps\common\Resonite\rml_mods` for a default install. You can create it if it's missing, or if you launch the game once with ResoniteModLoader installed it will create the folder for you.
2. Place [ImGuiUnityInject.dll](https://github.com/art0007i/ImGuiUnityInject/releases/latest/download/ImGuiUnityInject.dll) into your `rml_libs` folder. 2. Place [ImGuiUnityInject.dll](https://github.com/art0007i/ImGuiUnityInject/releases/latest/download/ImGuiUnityInject.dll) into your `rml_libs` folder.
3. Place the files from [ImGuiUnityInject/Plugins](https://github.com/art0007i/ImGuiUnityInject/tree/master/Plugins) into your `Resonite_Data/Plugins/x86_64` folder. 3. Place the files from [ImGuiUnityInject/Plugins](https://github.com/art0007i/ImGuiUnityInject/tree/master/Plugins) into your `Resonite_Data/Plugins/x86_64` folder.
1. Start the game. If you want to verify that the mod is working you can check your Resonite logs. 1. Start the game. If you want to verify that the mod is working you can check your Resonite logs.
+3 -3
View File
@@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("art0007i")] [assembly: AssemblyCompany("art0007i")]
[assembly: AssemblyProduct("ResoniteImGuiLib")] [assembly: AssemblyProduct("ResoniteImGuiLib")]
[assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0")] [assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.0.0")] [assembly: AssemblyFileVersion("1.1.0")]
+16 -7
View File
@@ -8,6 +8,7 @@ using ImGuiUnityInject;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using System.Linq; using System.Linq;
using UnityFrooxEngineRunner; using UnityFrooxEngineRunner;
using System.Collections.Generic;
namespace ResoniteImGuiLib; namespace ResoniteImGuiLib;
@@ -19,9 +20,17 @@ public static class ImGuiLib
} }
public static ImGuiInstance GetOrCreateInstance(string name = "global", ImGuiReady onReady = null) public static ImGuiInstance GetOrCreateInstance(string name = "global", ImGuiReady onReady = null)
{ {
return ImGuiInstance.GetOrCreate((gui, isNew) => return ImGuiInstance.GetOrCreate(name, (gui, isNew) =>
{ {
if (isNew) gui._camera = SceneManager.GetActiveScene().GetRootGameObjects().Where(go => go.name == "FrooxEngine").First().GetComponent<FrooxEngineRunner>().OverlayCamera; if (isNew)
{
gui._camera = SceneManager.GetActiveScene().GetRootGameObjects().Where(go => go.name == "FrooxEngine").First().GetComponent<FrooxEngineRunner>().OverlayCamera;
gui.Layout += () =>
{
var io = ImGui.GetIO();
ResoniteImGuiLib.WantCapture[name] = (io.WantCaptureMouse, io.WantCaptureKeyboard);
};
}
if (onReady != null) onReady(gui, isNew); if (onReady != null) onReady(gui, isNew);
else gui.enabled = true; else gui.enabled = true;
@@ -33,21 +42,21 @@ public class ResoniteImGuiLib : ResoniteMod
{ {
public override string Name => "ResoniteImGuiLib"; public override string Name => "ResoniteImGuiLib";
public override string Author => "art0007i"; public override string Author => "art0007i";
public override string Version => "1.0.0"; public override string Version => "1.1.0";
public override string Link => "https://github.com/art0007i/ResoniteImGuiLib/"; public override string Link => "https://github.com/art0007i/ResoniteImGuiLib/";
public override void OnEngineInit() public override void OnEngineInit()
{ {
Harmony harmony = new Harmony("me.art0007i.ResoniteImGuiLib"); Harmony harmony = new Harmony("me.art0007i.ResoniteImGuiLib");
harmony.PatchAll(); harmony.PatchAll();
} }
internal static Dictionary<string, (bool, bool)> WantCapture = new();
[HarmonyPatch(typeof(MouseDriver), "UpdateMouse")] [HarmonyPatch(typeof(MouseDriver), "UpdateMouse")]
class CursorUpdatePatch class CursorUpdatePatch
{ {
public static bool Prefix(Mouse mouse) public static bool Prefix(Mouse mouse)
{ {
var io = ImGui.GetIO(); if (WantCapture.Any(x=>x.Value.Item1))
if (io.WantCaptureMouse)
{ {
mouse.LeftButton.UpdateState(false); mouse.LeftButton.UpdateState(false);
mouse.RightButton.UpdateState(false); mouse.RightButton.UpdateState(false);
@@ -72,7 +81,7 @@ public class ResoniteImGuiLib : ResoniteMod
{ {
public static bool Prefix() public static bool Prefix()
{ {
if (ImGui.GetIO().WantCaptureKeyboard) if (WantCapture.Any(x => x.Value.Item2))
{ {
return false; return false;
} }
@@ -84,7 +93,7 @@ public class ResoniteImGuiLib : ResoniteMod
{ {
public static bool Prefix(ref bool __result) public static bool Prefix(ref bool __result)
{ {
if (ImGui.GetIO().WantCaptureKeyboard) if (WantCapture.Any(x => x.Value.Item2))
{ {
__result = false; __result = false;
return false; return false;