Compare commits

...

7 Commits

Author SHA1 Message Date
c991cb4b22 1.8.22
* Some performance improvements for the new InputSystem support (affects some 2019.3+ games)
* Fixed a small mistake with left/right mouse button checking.
2020-10-02 18:40:51 +10:00
3971e49ce1 Update README.md 2020-10-01 20:41:48 +10:00
6920ca1129 Update README.md 2020-10-01 20:26:25 +10:00
748e0cabcb 1.8.21
* Fixed a bug when editing a Text Field and the input string is `null`. Only affected Il2Cpp games, appeared in 1.8.0.
* Added a menu page for editing the Explorer Settings in-game, called `Options`.
* Added a new setting for default Items per Page Limit (for all "Pages" in Explorer).
2020-10-01 20:20:52 +10:00
b4b5f1ec93 1.8.2
* Added support for games which use the new InputSystem module and have disabled LegacyInputModule
2020-10-01 18:57:28 +10:00
5afaf85859 Update README.md 2020-10-01 17:16:00 +10:00
b65e417ecb Update GUIUnstrip.cs 2020-09-30 01:59:35 +10:00
17 changed files with 334 additions and 123 deletions

View File

@ -12,6 +12,10 @@
<img src="https://img.shields.io/github/downloads/sinai-dev/Explorer/total.svg" /> <img src="https://img.shields.io/github/downloads/sinai-dev/Explorer/total.svg" />
</p> </p>
<p align="center">
<img src="https://raw.githubusercontent.com/sinai-dev/Explorer/master/overview.png">
</p>
- [Current status](#current-status) - [Current status](#current-status)
- [How to install](#how-to-install) - [How to install](#how-to-install)
- [How to use](#how-to-use) - [How to use](#how-to-use)
@ -58,24 +62,23 @@ Requires [BepInEx](https://github.com/BepInEx/BepInEx) to be installed for your
### Mod Config ### Mod Config
There is a simple Mod Config for the Explorer, which is generated the first time you run it. There is a simple Mod Config for the Explorer. You can access the settings via the "Options" page of the main menu.
This config is generated to `[Game_Directory]\Mods\Explorer\config.xml`. Edit the config while the game is closed if you wish to change it. `Main Menu Toggle` (KeyCode)
`Main_Menu_Toggle` (KeyCode)
* Sets the keybinding for the Main Menu toggle (show/hide all Explorer windows) * Sets the keybinding for the Main Menu toggle (show/hide all Explorer windows)
* See [this article](https://docs.unity3d.com/ScriptReference/KeyCode.html) for a full list of all accepted KeyCodes. * See [this article](https://docs.unity3d.com/ScriptReference/KeyCode.html) for a full list of all accepted KeyCodes.
* Default: `F7` * Default: `F7`
`Default_Window_Size` (Vector2) `Default Window Size` (Vector2)
* Sets the default width and height for all Explorer windows when created. * Sets the default width and height for all Explorer windows when created.
* `x` is width, `y` is height. * `x` is width, `y` is height.
* Default: `<x>550</x> <y>700</y>` * Default: `<x>550</x> <y>700</y>`
## Features `Default Items per Page` (Int)
[![](overview.png)](https://raw.githubusercontent.com/sinai-dev/Explorer/master/overview.png) * Sets the default items per page when viewing lists or search results.
* Default: `20`
<i>An overview of the different Explorer menus.</i> ## Features
### Scene Explorer ### Scene Explorer
@ -144,13 +147,13 @@ public class MenuClass_CursorUpdate
## Building ## Building
If you'd like to build this yourself, everything you need (other than MelonLoader) is included with this repository, there is no need for recursive cloning etc. If you'd like to build this yourself, everything you need (other than MelonLoader and/or BepInEx) is included with this repository.
1. Install MelonLoader for your game. 1. Install MelonLoader or BepInEx for your game.
2. Open the `src\Explorer.csproj` file in a text editor. 2. Open the `src\Explorer.csproj` file in a text editor.
3. Set the relevant `GameFolder` value(s) for the version(s) you want to build, eg. set `MLCppGameFolder` if you want to build for a MelonLoader Il2Cpp game. 3. Set the relevant `GameFolder` values for the versions you want to build, eg. set `MLCppGameFolder` if you want to build for a MelonLoader Il2Cpp game.
4. Open the `src\Explorer.sln` project. 4. Open the `src\Explorer.sln` project.
5. Select `Solution 'Explorer' (1 of 1 project)` in the Solution Explorer panel, and set the <b>Active config</b> to the version you want to build, then build it. 5. Select `Solution 'Explorer' (1 of 1 project)` in the Solution Explorer panel, and set the <b>Active config</b> property to the version you want to build, then build it.
5. The DLLs are built to the `Release\` folder in the root of the repository. 5. The DLLs are built to the `Release\` folder in the root of the repository.
## Credits ## Credits

View File

@ -269,6 +269,7 @@ namespace Explorer
GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUI.skin.label.alignment = TextAnchor.MiddleCenter;
GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) });
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
GUILayout.Label("Key:", new GUILayoutOption[] { GUILayout.Width(40) }); GUILayout.Label("Key:", new GUILayoutOption[] { GUILayout.Width(40) });
key.DrawValue(window, (window.width / 2) - 80f); key.DrawValue(window, (window.width / 2) - 80f);

View File

@ -15,6 +15,7 @@ namespace Explorer
public KeyCode Main_Menu_Toggle = KeyCode.F7; public KeyCode Main_Menu_Toggle = KeyCode.F7;
public Vector2 Default_Window_Size = new Vector2(550, 700); public Vector2 Default_Window_Size = new Vector2(550, 700);
public int Default_Page_Limit = 20;
public static void OnLoad() public static void OnLoad()
{ {
@ -30,9 +31,9 @@ namespace Explorer
} }
// returns true if settings successfully loaded // returns true if settings successfully loaded
public static bool LoadSettings(bool checkExist = true) public static bool LoadSettings()
{ {
if (checkExist && !File.Exists(SETTINGS_PATH)) if (!File.Exists(SETTINGS_PATH))
return false; return false;
try try
@ -50,9 +51,9 @@ namespace Explorer
return Instance != null; return Instance != null;
} }
public static void SaveSettings(bool checkExist = true) public static void SaveSettings()
{ {
if (checkExist && File.Exists(SETTINGS_PATH)) if (File.Exists(SETTINGS_PATH))
File.Delete(SETTINGS_PATH); File.Delete(SETTINGS_PATH);
using (var file = File.Create(SETTINGS_PATH)) using (var file = File.Create(SETTINGS_PATH))

View File

@ -34,6 +34,7 @@
<BIECppGameFolder>D:\Steam\steamapps\common\Outward - Il2Cpp</BIECppGameFolder> <BIECppGameFolder>D:\Steam\steamapps\common\Outward - Il2Cpp</BIECppGameFolder>
<!-- Set this to the BepInEx Mono Game folder, without the ending '\' character. --> <!-- Set this to the BepInEx Mono Game folder, without the ending '\' character. -->
<BIEMonoGameFolder>D:\Steam\steamapps\common\Outward</BIEMonoGameFolder> <BIEMonoGameFolder>D:\Steam\steamapps\common\Outward</BIEMonoGameFolder>
<!-- <BIEMonoGameFolder>D:\source\Unity Projects\! My Unity Games\NewInputSystemTest\_BUILD</BIEMonoGameFolder> -->
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_ML_Cpp|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_ML_Cpp|AnyCPU' ">
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
@ -242,6 +243,7 @@
<Compile Include="Extensions\ReflectionExtensions.cs" /> <Compile Include="Extensions\ReflectionExtensions.cs" />
<Compile Include="Helpers\InputHelper.cs" /> <Compile Include="Helpers\InputHelper.cs" />
<Compile Include="Menu\CursorControl.cs" /> <Compile Include="Menu\CursorControl.cs" />
<Compile Include="Menu\MainMenu\Pages\OptionsPage.cs" />
<Compile Include="Tests\TestClass.cs" /> <Compile Include="Tests\TestClass.cs" />
<Compile Include="UnstripFixes\GUIUnstrip.cs" /> <Compile Include="UnstripFixes\GUIUnstrip.cs" />
<Compile Include="UnstripFixes\Internal_LayoutUtility.cs" /> <Compile Include="UnstripFixes\Internal_LayoutUtility.cs" />

View File

@ -66,7 +66,7 @@ namespace Explorer
new ExplorerCore(); new ExplorerCore();
HarmonyInstance.PatchAll(); //HarmonyInstance.PatchAll();
} }
void LoadMCS() void LoadMCS()

View File

@ -4,23 +4,23 @@ namespace Explorer
{ {
public class ExplorerCore public class ExplorerCore
{ {
public const string NAME = "Explorer (" + PLATFORM + ", " + MODLOADER + ")"; public const string NAME = "Explorer (" + PLATFORM + ", " + MODLOADER + ")";
public const string VERSION = "1.8.1"; public const string VERSION = "1.8.22";
public const string AUTHOR = "Sinai"; public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.explorer"; public const string GUID = "com.sinai.explorer";
public const string MODLOADER =
#if ML
"MelonLoader";
#else
"BepInEx";
#endif
public const string PLATFORM = public const string PLATFORM =
#if CPP #if CPP
"Il2Cpp"; "Il2Cpp";
#else #else
"Mono"; "Mono";
#endif #endif
public const string MODLOADER =
#if ML
"MelonLoader";
#else
"BepInEx";
#endif
public static ExplorerCore Instance { get; private set; } public static ExplorerCore Instance { get; private set; }
@ -30,11 +30,10 @@ namespace Explorer
ModConfig.OnLoad(); ModConfig.OnLoad();
InputHelper.Init();
new MainMenu(); new MainMenu();
new WindowManager(); new WindowManager();
InputHelper.Init();
CursorControl.Init(); CursorControl.Init();
Log($"{NAME} {VERSION} initialized."); Log($"{NAME} {VERSION} initialized.");

View File

@ -5,94 +5,201 @@ using UnityEngine;
namespace Explorer namespace Explorer
{ {
/// <summary> /// <summary>
/// Version-agnostic UnityEngine Input module using Reflection. /// Version-agnostic Input module using Reflection.
/// </summary> /// </summary>
public static class InputHelper public static class InputHelper
{ {
// If Input module failed to load at all // If no Input modules loaded at all
public static bool NO_INPUT; public static bool NO_INPUT;
// Base UnityEngine.Input class // If using new InputSystem module
private static Type Input => _input ?? (_input = ReflectionHelpers.GetTypeByName("UnityEngine.Input")); public static bool USING_NEW_INPUT;
// Cached Types
private static Type TInput => _input ?? (_input = ReflectionHelpers.GetTypeByName("UnityEngine.Input"));
private static Type _input; private static Type _input;
// Cached member infos private static Type TKeyboard => _keyboard ?? (_keyboard = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Keyboard"));
private static PropertyInfo _mousePosition; private static Type _keyboard;
private static MethodInfo _getKey;
private static MethodInfo _getKeyDown; private static Type TMouse => _mouse ?? (_mouse = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Mouse"));
private static MethodInfo _getMouseButton; private static Type _mouse;
private static MethodInfo _getMouseButtonDown;
private static Type TKey => _key ?? (_key = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Key"));
private static Type _key;
// Cached member infos (new system)
private static PropertyInfo _btnIsPressedProp;
private static PropertyInfo _btnWasPressedProp;
private static object CurrentKeyboard => _currentKeyboard ?? (_currentKeyboard = _kbCurrentProp.GetValue(null, null));
private static object _currentKeyboard;
private static PropertyInfo _kbCurrentProp;
private static PropertyInfo _kbIndexer;
private static object CurrentMouse => _currentMouse ?? (_currentMouse = _mouseCurrentProp.GetValue(null, null));
private static object _currentMouse;
private static PropertyInfo _mouseCurrentProp;
private static object LeftMouseButton => _lmb ?? (_lmb = _leftButtonProp.GetValue(CurrentMouse, null));
private static object _lmb;
private static PropertyInfo _leftButtonProp;
private static object RightMouseButton => _rmb ?? (_rmb = _rightButtonProp.GetValue(CurrentMouse, null));
private static object _rmb;
private static PropertyInfo _rightButtonProp;
private static object MousePositionInfo => _pos ?? (_pos = _positionProp.GetValue(CurrentMouse, null));
private static object _pos;
private static PropertyInfo _positionProp;
private static MethodInfo _readVector2InputMethod;
// Cached member infos (legacy)
private static PropertyInfo _mousePositionProp;
private static MethodInfo _getKeyMethod;
private static MethodInfo _getKeyDownMethod;
private static MethodInfo _getMouseButtonMethod;
private static MethodInfo _getMouseButtonDownMethod;
public static void Init() public static void Init()
{ {
if (Input == null && !TryManuallyLoadInput()) if (TKeyboard != null || TryLoadModule("Unity.InputSystem", TKeyboard))
{ {
NO_INPUT = true; InitNewInput();
return; }
else if (TInput != null || TryLoadModule("UnityEngine.Input", TInput))
{
InitLegacyInput();
}
else
{
ExplorerCore.LogWarning("Could not find any Input module!");
NO_INPUT = true;
} }
// Cache reflection now that we know Input is loaded
_mousePosition = Input.GetProperty("mousePosition");
_getKey = Input.GetMethod("GetKey", new Type[] { typeof(KeyCode) });
_getKeyDown = Input.GetMethod("GetKeyDown", new Type[] { typeof(KeyCode) });
_getMouseButton = Input.GetMethod("GetMouseButton", new Type[] { typeof(int) });
_getMouseButtonDown = Input.GetMethod("GetMouseButtonDown", new Type[] { typeof(int) });
} }
#pragma warning disable IDE1006 // Camel-case property (Unity style) private static bool TryLoadModule(string dll, Type check) => ReflectionHelpers.LoadModule(dll) && check != null;
public static Vector3 mousePosition
private static void InitNewInput()
{
ExplorerCore.Log("Initializing new InputSystem support...");
USING_NEW_INPUT = true;
_kbCurrentProp = TKeyboard.GetProperty("current");
_kbIndexer = TKeyboard.GetProperty("Item", new Type[] { TKey });
var btnControl = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Controls.ButtonControl");
_btnIsPressedProp = btnControl.GetProperty("isPressed");
_btnWasPressedProp = btnControl.GetProperty("wasPressedThisFrame");
_mouseCurrentProp = TMouse.GetProperty("current");
_leftButtonProp = TMouse.GetProperty("leftButton");
_rightButtonProp = TMouse.GetProperty("rightButton");
_positionProp = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Pointer")
.GetProperty("position");
_readVector2InputMethod = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.InputControl`1")
.MakeGenericType(typeof(Vector2))
.GetMethod("ReadValue");
}
private static void InitLegacyInput()
{
ExplorerCore.Log("Initializing Legacy Input support...");
_mousePositionProp = TInput.GetProperty("mousePosition");
_getKeyMethod = TInput.GetMethod("GetKey", new Type[] { typeof(KeyCode) });
_getKeyDownMethod = TInput.GetMethod("GetKeyDown", new Type[] { typeof(KeyCode) });
_getMouseButtonMethod = TInput.GetMethod("GetMouseButton", new Type[] { typeof(int) });
_getMouseButtonDownMethod = TInput.GetMethod("GetMouseButtonDown", new Type[] { typeof(int) });
}
public static Vector3 MousePosition
{ {
get get
{ {
if (NO_INPUT) return Vector3.zero; if (NO_INPUT)
return (Vector3)_mousePosition.GetValue(null, null); return Vector3.zero;
if (USING_NEW_INPUT)
return (Vector2)_readVector2InputMethod.Invoke(MousePositionInfo, new object[0]);
return (Vector3)_mousePositionProp.GetValue(null, null);
} }
} }
#pragma warning restore IDE1006
public static bool GetKeyDown(KeyCode key) public static bool GetKeyDown(KeyCode key)
{ {
if (NO_INPUT) return false; if (NO_INPUT) return false;
return (bool)_getKeyDown.Invoke(null, new object[] { key });
if (USING_NEW_INPUT)
{
var parsedKey = Enum.Parse(TKey, key.ToString());
var actualKey = _kbIndexer.GetValue(CurrentKeyboard, new object[] { parsedKey });
return (bool)_btnWasPressedProp.GetValue(actualKey, null);
}
return (bool)_getKeyDownMethod.Invoke(null, new object[] { key });
} }
public static bool GetKey(KeyCode key) public static bool GetKey(KeyCode key)
{ {
if (NO_INPUT) return false; if (NO_INPUT) return false;
return (bool)_getKey.Invoke(null, new object[] { key });
if (USING_NEW_INPUT)
{
var parsed = Enum.Parse(TKey, key.ToString());
var actualKey = _kbIndexer.GetValue(CurrentKeyboard, new object[] { parsed });
return (bool)_btnIsPressedProp.GetValue(actualKey, null);
}
return (bool)_getKeyMethod.Invoke(null, new object[] { key });
} }
/// <param name="btn">1 = left, 2 = middle, 3 = right, etc</param> /// <param name="btn">0 = left, 1 = right, 2 = middle.</param>
public static bool GetMouseButtonDown(int btn) public static bool GetMouseButtonDown(int btn)
{ {
if (NO_INPUT) return false; if (NO_INPUT) return false;
return (bool)_getMouseButtonDown.Invoke(null, new object[] { btn });
if (USING_NEW_INPUT)
{
object actualBtn;
switch (btn)
{
case 0: actualBtn = LeftMouseButton; break;
case 1: actualBtn = RightMouseButton; break;
default: throw new NotImplementedException();
}
return (bool)_btnWasPressedProp.GetValue(actualBtn, null);
}
return (bool)_getMouseButtonDownMethod.Invoke(null, new object[] { btn });
} }
/// <param name="btn">1 = left, 2 = middle, 3 = right, etc</param> /// <param name="btn">0 = left, 1 = right, 2 = middle.</param>
public static bool GetMouseButton(int btn) public static bool GetMouseButton(int btn)
{ {
if (NO_INPUT) return false; if (NO_INPUT) return false;
return (bool)_getMouseButton.Invoke(null, new object[] { btn });
}
private static bool TryManuallyLoadInput() if (USING_NEW_INPUT)
{ {
ExplorerCore.Log("UnityEngine.Input is null, trying to load manually...."); object actualBtn;
switch (btn)
{
case 0: actualBtn = LeftMouseButton; break;
case 1: actualBtn = RightMouseButton; break;
default: throw new NotImplementedException();
}
if ((ReflectionHelpers.LoadModule("UnityEngine.InputLegacyModule") || ReflectionHelpers.LoadModule("UnityEngine.CoreModule")) return (bool)_btnIsPressedProp.GetValue(actualBtn, null);
&& Input != null)
{
ExplorerCore.Log("Ok!");
return true;
}
else
{
ExplorerCore.Log("Could not load Input module!");
return false;
} }
return (bool)_getMouseButtonMethod.Invoke(null, new object[] { btn });
} }
} }
} }

View File

@ -21,7 +21,7 @@ namespace Explorer
CalculateMaxOffset(); CalculateMaxOffset();
} }
} }
private int m_itemsPerPage = 20; private int m_itemsPerPage = ModConfig.Instance.Default_Page_Limit;
public int ItemCount public int ItemCount
{ {

View File

@ -33,7 +33,7 @@ namespace Explorer
if (!UnityHelpers.MainCamera) if (!UnityHelpers.MainCamera)
return; return;
var ray = UnityHelpers.MainCamera.ScreenPointToRay(InputHelper.mousePosition); var ray = UnityHelpers.MainCamera.ScreenPointToRay(InputHelper.MousePosition);
if (Physics.Raycast(ray, out RaycastHit hit, 1000f)) if (Physics.Raycast(ray, out RaycastHit hit, 1000f))
{ {
@ -61,7 +61,7 @@ namespace Explorer
{ {
if (m_objUnderMouseName != "") if (m_objUnderMouseName != "")
{ {
var pos = InputHelper.mousePosition; var pos = InputHelper.MousePosition;
var rect = new Rect( var rect = new Rect(
pos.x - (Screen.width / 2), // x pos.x - (Screen.width / 2), // x
Screen.height - pos.y - 50, // y Screen.height - pos.y - 50, // y

View File

@ -17,16 +17,20 @@ namespace Explorer
Pages.Add(new ScenePage()); Pages.Add(new ScenePage());
Pages.Add(new SearchPage()); Pages.Add(new SearchPage());
Pages.Add(new ConsolePage()); Pages.Add(new ConsolePage());
Pages.Add(new OptionsPage());
for (int i = 0; i < Pages.Count; i++) for (int i = 0; i < Pages.Count; i++)
{ {
var page = Pages[i]; var page = Pages[i];
page.Init(); page.Init();
// If page failed to init, it will remove itself from the list. Lower the iterate counter.
if (!Pages.Contains(page)) i--;
} }
} }
public const int MainWindowID = 5000; public const int MainWindowID = 5000;
public static Rect MainRect = new Rect(5,5, ModConfig.Instance.Default_Window_Size.x,ModConfig.Instance.Default_Window_Size.y); public static Rect MainRect = new Rect(5, 5, ModConfig.Instance.Default_Window_Size.x, ModConfig.Instance.Default_Window_Size.y);
public static readonly List<WindowPage> Pages = new List<WindowPage>(); public static readonly List<WindowPage> Pages = new List<WindowPage>();
private static int m_currentPage = 0; private static int m_currentPage = 0;

View File

@ -45,6 +45,7 @@ namespace Explorer
MethodInput = @"// This is a basic C# console. MethodInput = @"// This is a basic C# console.
// Some common using directives are added by default, you can add more below. // Some common using directives are added by default, you can add more below.
// If you want to return some output, Debug.Log() or MelonLogger.Log() it. // If you want to return some output, Debug.Log() or MelonLogger.Log() it.
" "
#if ML #if ML
+ @"MelonLogger.Log(""hello world"");"; + @"MelonLogger.Log(""hello world"");";

View File

@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Explorer.Tests;
using UnityEngine;
namespace Explorer
{
public class OptionsPage : WindowPage
{
public override string Name => "Options";
public string toggleKeyInputString = "";
public Vector2 defaultSizeInputVector;
public int defaultPageLimit;
private CacheObjectBase toggleKeyInput;
private CacheObjectBase defaultSizeInput;
private CacheObjectBase defaultPageLimitInput;
public override void Init()
{
toggleKeyInputString = ModConfig.Instance.Main_Menu_Toggle.ToString();
toggleKeyInput = CacheFactory.GetTypeAndCacheObject(typeof(OptionsPage).GetField("toggleKeyInputString"), this);
defaultSizeInputVector = ModConfig.Instance.Default_Window_Size;
defaultSizeInput = CacheFactory.GetTypeAndCacheObject(typeof(OptionsPage).GetField("defaultSizeInputVector"), this);
defaultPageLimit = ModConfig.Instance.Default_Page_Limit;
defaultPageLimitInput = CacheFactory.GetTypeAndCacheObject(typeof(OptionsPage).GetField("defaultPageLimit"), this);
}
public override void Update() { }
public override void DrawWindow()
{
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
GUILayout.Label("<color=orange><size=16><b>Settings</b></size></color>", new GUILayoutOption[0]);
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
GUILayout.BeginVertical(GUIContent.none, GUI.skin.box, new GUILayoutOption[0]);
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
GUILayout.Label($"Menu Toggle Key:", new GUILayoutOption[] { GUILayout.Width(215f) });
toggleKeyInput.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
GUILayout.Label($"Default Window Size:", new GUILayoutOption[] { GUILayout.Width(215f) });
defaultSizeInput.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
GUILayout.Label($"Default Items per Page:", new GUILayoutOption[] { GUILayout.Width(215f) });
defaultPageLimitInput.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
GUILayout.EndHorizontal();
if (GUILayout.Button("<color=lime><b>Apply and Save</b></color>", new GUILayoutOption[0]))
{
ApplyAndSave();
}
GUILayout.EndVertical();
//GUIUnstrip.Space(10f);
//GUI.skin.label.alignment = TextAnchor.MiddleCenter;
//GUILayout.Label("<color=orange><size=16><b>Other</b></size></color>", new GUILayoutOption[0]);
//GUI.skin.label.alignment = TextAnchor.MiddleLeft;
//GUILayout.BeginVertical(GUIContent.none, GUI.skin.box, new GUILayoutOption[0]);
//if (GUILayout.Button("Inspect Test Class", new GUILayoutOption[0]))
//{
// WindowManager.InspectObject(TestClass.Instance, out bool _);
//}
//GUILayout.EndVertical();
}
private void ApplyAndSave()
{
if (Enum.Parse(typeof(KeyCode), toggleKeyInputString) is KeyCode key)
{
ModConfig.Instance.Main_Menu_Toggle = key;
}
else
{
ExplorerCore.LogWarning($"Could not parse '{toggleKeyInputString}' to KeyCode!");
}
ModConfig.Instance.Default_Window_Size = defaultSizeInputVector;
ModConfig.Instance.Default_Page_Limit = defaultPageLimit;
ModConfig.SaveSettings();
}
}
}

View File

@ -10,7 +10,7 @@ namespace Explorer
{ {
public static ScenePage Instance; public static ScenePage Instance;
public override string Name { get => "Scene Explorer"; } public override string Name { get => "Scenes"; }
public PageHelper Pages = new PageHelper(); public PageHelper Pages = new PageHelper();

View File

@ -38,7 +38,7 @@ namespace Explorer
//var r = GUILayoutUtility.GetLastRect(); //var r = GUILayoutUtility.GetLastRect();
var r = Internal_LayoutUtility.GetLastRect(); var r = Internal_LayoutUtility.GetLastRect();
var mousePos = InputHelper.mousePosition; var mousePos = InputHelper.MousePosition;
try try
{ {
@ -125,7 +125,7 @@ namespace Explorer
//var r = GUILayoutUtility.GetLastRect(); //var r = GUILayoutUtility.GetLastRect();
var r = GUILayoutUtility.GetLastRect(); var r = GUILayoutUtility.GetLastRect();
var mousePos = InputHelper.mousePosition; var mousePos = InputHelper.MousePosition;
var mouse = GUIUnstrip.ScreenToGUIPoint(new Vector2(mousePos.x, Screen.height - mousePos.y)); var mouse = GUIUnstrip.ScreenToGUIPoint(new Vector2(mousePos.x, Screen.height - mousePos.y));
if (r.Contains(mouse) && InputHelper.GetMouseButtonDown(0)) if (r.Contains(mouse) && InputHelper.GetMouseButtonDown(0))
@ -150,6 +150,7 @@ namespace Explorer
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
#endif #endif
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
return _rect; return _rect;
} }

View File

@ -189,7 +189,7 @@ namespace Explorer
private static bool RectContainsMouse(Rect rect) private static bool RectContainsMouse(Rect rect)
{ {
var mousePos = InputHelper.mousePosition; var mousePos = InputHelper.MousePosition;
return rect.Contains(new Vector2(mousePos.x, Screen.height - mousePos.y)); return rect.Contains(new Vector2(mousePos.x, Screen.height - mousePos.y));
} }

View File

@ -17,7 +17,7 @@ namespace Explorer
#if CPP #if CPP
return Internal.TextField(text, options); return Internal.TextField(text, options);
#else #else
return GUIUnstrip.TextField(text, options); return GUILayout.TextField(text, options);
#endif #endif
} }
@ -75,63 +75,50 @@ namespace Explorer
#endif #endif
} }
#if CPP
public static bool RepeatButton(string text, params GUILayoutOption[] options) public static bool RepeatButton(string text, params GUILayoutOption[] options)
{ {
return Internal.DoRepeatButton(GUIContent.Temp(text), GUI.skin.button, options);
}
#else
public static bool RepeatButton(string text, params GUILayoutOption[] args)
{
return GUILayout.RepeatButton(text, args);
}
#endif
#if CPP #if CPP
return Internal.DoRepeatButton(GUIContent.Temp(text), GUI.skin.button, options);
#else
return GUILayout.RepeatButton(text, options);
#endif
}
public static void BeginArea(Rect screenRect, GUIStyle style) public static void BeginArea(Rect screenRect, GUIStyle style)
{ {
Internal.BeginArea(screenRect, GUIContent.none, style);
}
#else
public static void BeginArea(Rect rect, GUIStyle skin)
{
GUILayout.BeginArea(rect, skin);
}
#endif
#if CPP #if CPP
Internal.BeginArea(screenRect, GUIContent.none, style);
#else
GUILayout.BeginArea(screenRect, style);
#endif
}
static public void EndArea() static public void EndArea()
{ {
Internal.EndArea();
}
#else
public static void EndArea()
{
GUILayout.EndArea();
}
#endif
#if CPP #if CPP
Internal.EndArea();
#else
GUILayout.EndArea();
#endif
}
public static Vector2 BeginScrollView(Vector2 scroll, params GUILayoutOption[] options) public static Vector2 BeginScrollView(Vector2 scroll, params GUILayoutOption[] options)
{ {
#if CPP
return Internal.BeginScrollView(scroll, options); return Internal.BeginScrollView(scroll, options);
#else
return GUILayout.BeginScrollView(scroll, options);
#endif
} }
public static void EndScrollView(bool handleScrollWheel = true) public static void EndScrollView(bool handleScrollWheel = true)
{ {
#if CPP
Internal.EndScrollView(handleScrollWheel); Internal.EndScrollView(handleScrollWheel);
}
#else #else
public static Vector2 BeginScrollView(Vector2 scroll, params GUILayoutOption[] options)
{
return GUILayout.BeginScrollView(scroll, options);
}
public static void EndScrollView()
{
GUILayout.EndScrollView(); GUILayout.EndScrollView();
}
#endif #endif
}
} }
} }

View File

@ -109,6 +109,8 @@ namespace Explorer.UnstripInternals
public static string TextField(string text, GUILayoutOption[] options) public static string TextField(string text, GUILayoutOption[] options)
{ {
text = text ?? "";
int controlID = GUIUtility.GetControlID(FocusType.Keyboard); int controlID = GUIUtility.GetControlID(FocusType.Keyboard);
GUIContent guicontent = GUIContent.Temp(text); GUIContent guicontent = GUIContent.Temp(text);
bool flag = GUIUtility.keyboardControl != controlID; bool flag = GUIUtility.keyboardControl != controlID;
@ -267,7 +269,7 @@ namespace Explorer.UnstripInternals
#endregion #endregion
#region Scrolling #region Scrolling
private static Il2CppSystem.Object GetStateObject(Il2CppSystem.Type type, int controlID) private static Il2CppSystem.Object GetStateObject(Il2CppSystem.Type type, int controlID)
{ {
@ -653,7 +655,9 @@ namespace Explorer.UnstripInternals
#endregion #endregion
} }
public static class UnstripExtensions #region Extensions
public static class Extensions
{ {
public static Rect Unstripped_GetLast(this GUILayoutGroup group) public static Rect Unstripped_GetLast(this GUILayoutGroup group)
{ {
@ -670,5 +674,7 @@ namespace Explorer.UnstripInternals
return result; return result;
} }
} }
#endregion
} }
#endif #endif