minor fixes

This commit is contained in:
art0007i
2024-12-20 22:32:25 +01:00
parent 8610ea2180
commit 1c8b0cbdc3
2 changed files with 19 additions and 10 deletions
+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;