Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 748e0ca

Browse files
committed
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).
1 parent b4b5f1e commit 748e0ca

File tree

10 files changed

+113
-4
lines changed

10 files changed

+113
-4
lines changed

src/CachedObjects/Object/CacheDictionary.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ public override void DrawValue(Rect window, float width)
269269
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
270270
GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) });
271271

272+
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
272273
GUILayout.Label("Key:", new GUILayoutOption[] { GUILayout.Width(40) });
273274
key.DrawValue(window, (window.width / 2) - 80f);
274275

src/Config/ModConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class ModConfig
1515

1616
public KeyCode Main_Menu_Toggle = KeyCode.F7;
1717
public Vector2 Default_Window_Size = new Vector2(550, 700);
18+
public int Default_Page_Limit = 20;
1819

1920
public static void OnLoad()
2021
{

src/Explorer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243
<Compile Include="Extensions\ReflectionExtensions.cs" />
244244
<Compile Include="Helpers\InputHelper.cs" />
245245
<Compile Include="Menu\CursorControl.cs" />
246+
<Compile Include="Menu\MainMenu\Pages\OptionsPage.cs" />
246247
<Compile Include="Tests\TestClass.cs" />
247248
<Compile Include="UnstripFixes\GUIUnstrip.cs" />
248249
<Compile Include="UnstripFixes\Internal_LayoutUtility.cs" />

src/ExplorerCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Explorer
55
public class ExplorerCore
66
{
77
public const string NAME = "Explorer (" + PLATFORM + ", " + MODLOADER + ")";
8-
public const string VERSION = "1.8.2";
8+
public const string VERSION = "1.8.21";
99
public const string AUTHOR = "Sinai";
1010
public const string GUID = "com.sinai.explorer";
1111

src/Helpers/PageHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public int ItemsPerPage
2121
CalculateMaxOffset();
2222
}
2323
}
24-
private int m_itemsPerPage = 20;
24+
private int m_itemsPerPage = ModConfig.Instance.Default_Page_Limit;
2525

2626
public int ItemCount
2727
{

src/Menu/MainMenu/MainMenu.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@ public MainMenu()
1717
Pages.Add(new ScenePage());
1818
Pages.Add(new SearchPage());
1919
Pages.Add(new ConsolePage());
20+
Pages.Add(new OptionsPage());
2021

2122
for (int i = 0; i < Pages.Count; i++)
2223
{
2324
var page = Pages[i];
2425
page.Init();
26+
27+
// If page failed to init, it will remove itself from the list. Lower the iterate counter.
28+
if (!Pages.Contains(page)) i--;
2529
}
2630
}
2731

2832
public const int MainWindowID = 5000;
29-
public static Rect MainRect = new Rect(5,5, ModConfig.Instance.Default_Window_Size.x,ModConfig.Instance.Default_Window_Size.y);
33+
public static Rect MainRect = new Rect(5, 5, ModConfig.Instance.Default_Window_Size.x, ModConfig.Instance.Default_Window_Size.y);
3034

3135
public static readonly List<WindowPage> Pages = new List<WindowPage>();
3236
private static int m_currentPage = 0;
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Explorer.Tests;
6+
using UnityEngine;
7+
8+
namespace Explorer
9+
{
10+
public class OptionsPage : WindowPage
11+
{
12+
public override string Name => "Options";
13+
14+
public string toggleKeyInputString = "";
15+
public Vector2 defaultSizeInputVector;
16+
public int defaultPageLimit;
17+
18+
private CacheObjectBase toggleKeyInput;
19+
private CacheObjectBase defaultSizeInput;
20+
private CacheObjectBase defaultPageLimitInput;
21+
22+
public override void Init()
23+
{
24+
toggleKeyInputString = ModConfig.Instance.Main_Menu_Toggle.ToString();
25+
toggleKeyInput = CacheFactory.GetTypeAndCacheObject(typeof(OptionsPage).GetField("toggleKeyInputString"), this);
26+
27+
defaultSizeInputVector = ModConfig.Instance.Default_Window_Size;
28+
defaultSizeInput = CacheFactory.GetTypeAndCacheObject(typeof(OptionsPage).GetField("defaultSizeInputVector"), this);
29+
30+
defaultPageLimit = ModConfig.Instance.Default_Page_Limit;
31+
defaultPageLimitInput = CacheFactory.GetTypeAndCacheObject(typeof(OptionsPage).GetField("defaultPageLimit"), this);
32+
}
33+
34+
public override void Update() { }
35+
36+
public override void DrawWindow()
37+
{
38+
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
39+
GUILayout.Label("<color=orange><size=16><b>Settings</b></size></color>", new GUILayoutOption[0]);
40+
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
41+
42+
GUILayout.BeginVertical(GUIContent.none, GUI.skin.box, new GUILayoutOption[0]);
43+
44+
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
45+
GUILayout.Label($"Menu Toggle Key:", new GUILayoutOption[] { GUILayout.Width(215f) });
46+
toggleKeyInput.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
47+
GUILayout.EndHorizontal();
48+
49+
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
50+
GUILayout.Label($"Default Window Size:", new GUILayoutOption[] { GUILayout.Width(215f) });
51+
defaultSizeInput.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
52+
GUILayout.EndHorizontal();
53+
54+
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
55+
GUILayout.Label($"Default Items per Page:", new GUILayoutOption[] { GUILayout.Width(215f) });
56+
defaultPageLimitInput.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
57+
GUILayout.EndHorizontal();
58+
59+
if (GUILayout.Button("<color=lime><b>Apply and Save</b></color>", new GUILayoutOption[0]))
60+
{
61+
ApplyAndSave();
62+
}
63+
64+
GUILayout.EndVertical();
65+
66+
//GUIUnstrip.Space(10f);
67+
68+
//GUI.skin.label.alignment = TextAnchor.MiddleCenter;
69+
//GUILayout.Label("<color=orange><size=16><b>Other</b></size></color>", new GUILayoutOption[0]);
70+
//GUI.skin.label.alignment = TextAnchor.MiddleLeft;
71+
72+
//GUILayout.BeginVertical(GUIContent.none, GUI.skin.box, new GUILayoutOption[0]);
73+
74+
//if (GUILayout.Button("Inspect Test Class", new GUILayoutOption[0]))
75+
//{
76+
// WindowManager.InspectObject(TestClass.Instance, out bool _);
77+
//}
78+
79+
//GUILayout.EndVertical();
80+
}
81+
82+
private void ApplyAndSave()
83+
{
84+
if (Enum.Parse(typeof(KeyCode), toggleKeyInputString) is KeyCode key)
85+
{
86+
ModConfig.Instance.Main_Menu_Toggle = key;
87+
}
88+
else
89+
{
90+
ExplorerCore.LogWarning($"Could not parse '{toggleKeyInputString}' to KeyCode!");
91+
}
92+
93+
ModConfig.Instance.Default_Window_Size = defaultSizeInputVector;
94+
ModConfig.Instance.Default_Page_Limit = defaultPageLimit;
95+
96+
ModConfig.SaveSettings();
97+
}
98+
}
99+
}

src/Menu/MainMenu/Pages/ScenePage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class ScenePage : WindowPage
1010
{
1111
public static ScenePage Instance;
1212

13-
public override string Name { get => "Scene Explorer"; }
13+
public override string Name { get => "Scenes"; }
1414

1515
public PageHelper Pages = new PageHelper();
1616

src/Menu/ResizeDrag.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public static Rect ResizeWindow(Rect _rect, int ID)
150150
GUILayout.EndHorizontal();
151151

152152
#endif
153+
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
153154

154155
return _rect;
155156
}

src/UnstripFixes/Internal.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ private static GUIStyle GetSpaceStyle()
109109

110110
public static string TextField(string text, GUILayoutOption[] options)
111111
{
112+
text = text ?? "";
113+
112114
int controlID = GUIUtility.GetControlID(FocusType.Keyboard);
113115
GUIContent guicontent = GUIContent.Temp(text);
114116
bool flag = GUIUtility.keyboardControl != controlID;

0 commit comments

Comments
 (0)