mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-15 13:57:31 +08:00
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).
This commit is contained in:
parent
b4b5f1ec93
commit
748e0cabcb
@ -269,6 +269,7 @@ namespace Explorer
|
||||
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
|
||||
GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||
|
||||
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
|
||||
GUILayout.Label("Key:", new GUILayoutOption[] { GUILayout.Width(40) });
|
||||
key.DrawValue(window, (window.width / 2) - 80f);
|
||||
|
||||
|
@ -15,6 +15,7 @@ namespace Explorer
|
||||
|
||||
public KeyCode Main_Menu_Toggle = KeyCode.F7;
|
||||
public Vector2 Default_Window_Size = new Vector2(550, 700);
|
||||
public int Default_Page_Limit = 20;
|
||||
|
||||
public static void OnLoad()
|
||||
{
|
||||
|
@ -243,6 +243,7 @@
|
||||
<Compile Include="Extensions\ReflectionExtensions.cs" />
|
||||
<Compile Include="Helpers\InputHelper.cs" />
|
||||
<Compile Include="Menu\CursorControl.cs" />
|
||||
<Compile Include="Menu\MainMenu\Pages\OptionsPage.cs" />
|
||||
<Compile Include="Tests\TestClass.cs" />
|
||||
<Compile Include="UnstripFixes\GUIUnstrip.cs" />
|
||||
<Compile Include="UnstripFixes\Internal_LayoutUtility.cs" />
|
||||
|
@ -5,7 +5,7 @@ namespace Explorer
|
||||
public class ExplorerCore
|
||||
{
|
||||
public const string NAME = "Explorer (" + PLATFORM + ", " + MODLOADER + ")";
|
||||
public const string VERSION = "1.8.2";
|
||||
public const string VERSION = "1.8.21";
|
||||
public const string AUTHOR = "Sinai";
|
||||
public const string GUID = "com.sinai.explorer";
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace Explorer
|
||||
CalculateMaxOffset();
|
||||
}
|
||||
}
|
||||
private int m_itemsPerPage = 20;
|
||||
private int m_itemsPerPage = ModConfig.Instance.Default_Page_Limit;
|
||||
|
||||
public int ItemCount
|
||||
{
|
||||
|
@ -17,16 +17,20 @@ namespace Explorer
|
||||
Pages.Add(new ScenePage());
|
||||
Pages.Add(new SearchPage());
|
||||
Pages.Add(new ConsolePage());
|
||||
Pages.Add(new OptionsPage());
|
||||
|
||||
for (int i = 0; i < Pages.Count; i++)
|
||||
{
|
||||
var page = Pages[i];
|
||||
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 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>();
|
||||
private static int m_currentPage = 0;
|
||||
|
99
src/Menu/MainMenu/Pages/OptionsPage.cs
Normal file
99
src/Menu/MainMenu/Pages/OptionsPage.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ namespace Explorer
|
||||
{
|
||||
public static ScenePage Instance;
|
||||
|
||||
public override string Name { get => "Scene Explorer"; }
|
||||
public override string Name { get => "Scenes"; }
|
||||
|
||||
public PageHelper Pages = new PageHelper();
|
||||
|
||||
|
@ -150,6 +150,7 @@ namespace Explorer
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
#endif
|
||||
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
|
||||
|
||||
return _rect;
|
||||
}
|
||||
|
@ -109,6 +109,8 @@ namespace Explorer.UnstripInternals
|
||||
|
||||
public static string TextField(string text, GUILayoutOption[] options)
|
||||
{
|
||||
text = text ?? "";
|
||||
|
||||
int controlID = GUIUtility.GetControlID(FocusType.Keyboard);
|
||||
GUIContent guicontent = GUIContent.Temp(text);
|
||||
bool flag = GUIUtility.keyboardControl != controlID;
|
||||
|
Loading…
x
Reference in New Issue
Block a user