diff --git a/lib/UnityEngine.dll b/lib/UnityEngine.dll deleted file mode 100644 index ce772f8..0000000 Binary files a/lib/UnityEngine.dll and /dev/null differ diff --git a/src/Tests/TestClass.cs b/src/CacheObject/Tests/TestClass.cs similarity index 100% rename from src/Tests/TestClass.cs rename to src/CacheObject/Tests/TestClass.cs diff --git a/src/Explorer.csproj b/src/Explorer.csproj index 1f9a6e3..d201fc9 100644 --- a/src/Explorer.csproj +++ b/src/Explorer.csproj @@ -12,7 +12,7 @@ true ..\Release\Explorer.MelonLoader.Il2Cpp\ - CPP,ML + true true false @@ -25,18 +25,22 @@ Explorer ExplorerBeta - D:\Steam\steamapps\common\Hellpoint + D:\Steam\steamapps\common\VRChat D:\Steam\steamapps\common\Outward + + D:\Steam\steamapps\common\Outward\Outward_Data\Managed D:\Steam\steamapps\common\Outward_Il2Cpp D:\Steam\steamapps\common\Outward + + D:\Steam\steamapps\common\Outward\Outward_Data\Managed - v4.7.2 + ..\Release\Explorer.MelonLoader.Il2Cpp\ CPP,ML true @@ -44,7 +48,7 @@ true - v3.5 + ..\Release\Explorer.MelonLoader.Mono\ MONO,ML false @@ -53,7 +57,7 @@ true - v4.7.2 + ..\Release\Explorer.BepInEx.Il2Cpp\ CPP,BIE true @@ -61,7 +65,7 @@ true - v3.5 + ..\Release\Explorer.BepInEx.Mono\ MONO,BIE false @@ -81,24 +85,71 @@ False - + + + --> + + $(MLMonoGameFolder)\MelonLoader\MelonLoader.ModHandler.dll False + + $(MLMonoManagedFolder)\Unity.TextMeshPro.dll + False + + + $(MLMonoManagedFolder)\UnityEngine.dll + False + + + $(MLMonoManagedFolder)\UnityEngine.CoreModule.dll + False + + + $(MLMonoManagedFolder)\UnityEngine.PhysicsModule.dll + False + + + $(MLMonoManagedFolder)\UnityEngine.TextCoreModule.dll + False + + + $(MLMonoManagedFolder)\UnityEngine.TextRenderingModule.dll + False + + + $(MLMonoManagedFolder)\UnityEngine.UI.dll + False + + + $(MLMonoManagedFolder)\UnityEngine.UIModule.dll + False + + + $(MLMonoManagedFolder)\UnityEngine.IMGUIModule.dll + False + + + $(MLMonoManagedFolder)\UnityEngine.ImageConversionModule.dll + False + + @@ -109,7 +160,48 @@ $(BIEMonoGameFolder)\BepInEx\core\0Harmony.dll False + + $(BIEMonoManagedFolder)\Unity.TextMeshPro.dll + False + + + $(BIEMonoManagedFolder)\UnityEngine.dll + False + + + $(BIEMonoManagedFolder)\UnityEngine.CoreModule.dll + False + + + $(BIEMonoManagedFolder)\UnityEngine.PhysicsModule.dll + False + + + $(BIEMonoManagedFolder)\UnityEngine.TextCoreModule.dll + False + + + $(BIEMonoManagedFolder)\UnityEngine.TextRenderingModule.dll + False + + + $(BIEMonoManagedFolder)\UnityEngine.UI.dll + False + + + $(BIEMonoManagedFolder)\UnityEngine.UIModule.dll + False + + + $(BIEMonoManagedFolder)\UnityEngine.IMGUIModule.dll + False + + + $(BIEMonoManagedFolder)\UnityEngine.ImageConversionModule.dll + False + + @@ -165,6 +257,7 @@ False + @@ -247,7 +340,7 @@ - + @@ -256,6 +349,7 @@ + diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index e4be609..77e077c 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -5,6 +5,7 @@ using ExplorerBeta.Config; using ExplorerBeta.Input; using ExplorerBeta.UI; using ExplorerBeta.UI.Main; +using System.Reflection; using UnityEngine; namespace ExplorerBeta @@ -56,6 +57,12 @@ namespace ExplorerBeta InputManager.Init(); ForceUnlockCursor.Init(); +#if CPP + Application.add_logMessageReceived(new Action(LogCallback)); +#else + Application.logMessageReceived += LogCallback; +#endif + ShowMenu = true; Log($"{NAME} initialized."); @@ -89,7 +96,7 @@ namespace ExplorerBeta { m_timeSinceStartup += Time.deltaTime; - if (m_timeSinceStartup > 1f) + if (m_timeSinceStartup > 0.1f) { UIManager.Init(); @@ -115,9 +122,36 @@ namespace ExplorerBeta UIManager.OnSceneChange(); } - public static void Log(object message) + private void LogCallback(string message, string stackTrace, LogType type) + { + if (!DebugConsole.LogUnity) + return; + + message = $"[UNITY] {message}"; + + switch (type) + { + case LogType.Assert: + case LogType.Log: + Log(message); + break; + case LogType.Warning: + LogWarning(message); + break; + case LogType.Exception: + case LogType.Error: + LogError(message); + break; + } + } + + public static void Log(object message, bool unity = false) { DebugConsole.Log(message?.ToString()); + + if (unity) + return; + #if ML MelonLoader.MelonLogger.Log(message?.ToString()); #else @@ -125,23 +159,31 @@ namespace ExplorerBeta #endif } - public static void LogWarning(object message) + public static void LogWarning(object message, bool unity = false) { DebugConsole.Log(message?.ToString(), "FFFF00"); + + if (unity) + return; + #if ML MelonLoader.MelonLogger.LogWarning(message?.ToString()); #else - ExplorerBepInPlugin.Logging?.LogWarning(message?.ToString()); + ExplorerBepInPlugin.Logging?.LogWarning(message?.ToString()); #endif } - public static void LogError(object message) + public static void LogError(object message, bool unity = false) { DebugConsole.Log(message?.ToString(), "FF0000"); + + if (unity) + return; + #if ML MelonLoader.MelonLogger.LogError(message?.ToString()); #else - ExplorerBepInPlugin.Logging?.LogError(message?.ToString()); + ExplorerBepInPlugin.Logging?.LogError(message?.ToString()); #endif } } diff --git a/src/UI/Main/DebugConsole.cs b/src/UI/Main/DebugConsole.cs index f0aa950..b6a2b28 100644 --- a/src/UI/Main/DebugConsole.cs +++ b/src/UI/Main/DebugConsole.cs @@ -6,32 +6,28 @@ using Explorer.Unstrip.ColorUtility; using ExplorerBeta.Input; using ExplorerBeta.Unstrip.Resources; using TMPro; -using UnhollowerRuntimeLib; using UnityEngine; +using UnityEngine.Events; using UnityEngine.UI; +#if CPP +using UnhollowerRuntimeLib; +#endif namespace ExplorerBeta.UI.Main { - // TODO: - // - Maybe hook into Unity's debug logs - // - Buttons for clear, save to file, etc..? - public class DebugConsole { public static DebugConsole Instance { get; private set; } + public static bool LogUnity { get; set; } = true; + public static GameObject CanvasRoot; - //private static GameObject Panel; public readonly List AllMessages; public readonly List MessageHolders; private TMP_InputField m_textInput; - // todo probably put this in UImanager, use for C# console too - //internal static Font m_consoleFont; - //private const int MAX_MESSAGES = 100; - public DebugConsole(GameObject parent) { Instance = this; @@ -53,30 +49,52 @@ namespace ExplorerBeta.UI.Main public void ConstructUI(GameObject parent) { - var obj = UIFactory.CreateHorizontalGroup(parent, new Color(0.1f, 0.1f, 0.1f, 1.0f)); - var mainGroup = obj.GetComponent(); + var mainObj = UIFactory.CreateVerticalGroup(parent, new Color(0.1f, 0.1f, 0.1f, 1.0f)); + var mainGroup = mainObj.GetComponent(); mainGroup.childControlHeight = true; mainGroup.childControlWidth = true; mainGroup.childForceExpandHeight = true; mainGroup.childForceExpandWidth = true; - var mainImage = obj.GetComponent(); + var mainImage = mainObj.GetComponent(); mainImage.maskable = true; - var mask = obj.AddComponent(); + var mask = mainObj.AddComponent(); mask.showMaskGraphic = true; - var mainLayout = obj.AddComponent(); + var mainLayout = mainObj.AddComponent(); + mainLayout.minHeight = 40; mainLayout.preferredHeight = 230; mainLayout.flexibleHeight = 0; - var input = UIFactory.CreateTMPInput(obj); +#region LOG AREA + var logAreaObj = UIFactory.CreateHorizontalGroup(mainObj); + var logAreaGroup = logAreaObj.GetComponent(); + logAreaGroup.childControlHeight = true; + logAreaGroup.childControlWidth = true; + logAreaGroup.childForceExpandHeight = true; + logAreaGroup.childForceExpandWidth = true; - var inputLayout = input.AddComponent(); + var logAreaLayout = logAreaObj.AddComponent(); + logAreaLayout.preferredHeight = 300; + logAreaLayout.flexibleHeight = 50; + + var inputObj = UIFactory.CreateTMPInput(logAreaObj); + + var mainInputGroup = inputObj.GetComponent(); + mainInputGroup.padding.left = 8; + mainInputGroup.padding.right = 8; + mainInputGroup.padding.top = 5; + mainInputGroup.padding.bottom = 5; + + var inputLayout = inputObj.AddComponent(); inputLayout.preferredWidth = 500; inputLayout.flexibleWidth = 9999; - var scroll = UIFactory.CreateScrollbar(obj); + var inputImage = inputObj.GetComponent(); + inputImage.color = new Color(0.05f, 0.05f, 0.05f, 1.0f); + + var scroll = UIFactory.CreateScrollbar(logAreaObj); var scrollLayout = scroll.AddComponent(); scrollLayout.preferredWidth = 25; @@ -86,14 +104,139 @@ namespace ExplorerBeta.UI.Main scroller.direction = Scrollbar.Direction.TopToBottom; var scrollColors = scroller.colors; scrollColors.normalColor = new Color(0.5f, 0.5f, 0.5f, 1.0f); - //try { scrollColors.selectedColor = scrollColors.normalColor; } catch { } scroller.colors = scrollColors; - var tmpInput = input.GetComponent(); + var tmpInput = inputObj.GetComponent(); tmpInput.scrollSensitivity = 15; tmpInput.verticalScrollbar = scroller; - m_textInput = input.GetComponent(); + tmpInput.readOnly = true; + + m_textInput = inputObj.GetComponent(); + +#endregion + +#region BOTTOM BAR + + var bottomBarObj = UIFactory.CreateHorizontalGroup(mainObj); + var topBarLayout = bottomBarObj.AddComponent(); + topBarLayout.minHeight = 40; + topBarLayout.flexibleHeight = 0; + + var bottomGroup = bottomBarObj.GetComponent(); + bottomGroup.padding.left = 10; + bottomGroup.padding.right = 10; + bottomGroup.padding.top = 2; + bottomGroup.padding.bottom = 2; + bottomGroup.spacing = 10; + bottomGroup.childForceExpandHeight = true; + bottomGroup.childForceExpandWidth = false; + bottomGroup.childControlWidth = true; + bottomGroup.childControlHeight = true; + bottomGroup.childAlignment = TextAnchor.MiddleLeft; + + // Debug Console label + + var bottomLabel = UIFactory.CreateLabel(bottomBarObj, TextAnchor.MiddleLeft); + var topBarLabelLayout = bottomLabel.AddComponent(); + topBarLabelLayout.minWidth = 100; + topBarLabelLayout.flexibleWidth = 0; + var topBarText = bottomLabel.GetComponent(); + topBarText.fontStyle = FontStyle.Bold; + topBarText.text = "Debug Console"; + topBarText.fontSize = 14; + + // Hide button + + var hideButtonObj = UIFactory.CreateButton(bottomBarObj); + + var hideBtnText = hideButtonObj.GetComponentInChildren(); + hideBtnText.text = "Hide"; + + var hideButton = hideButtonObj.GetComponent