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

Commit

Permalink
1.8.21
Browse files Browse the repository at this point in the history
* 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).
  • Loading branch information
sinai-dev committed Oct 1, 2020
1 parent b4b5f1e commit 748e0ca
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/CachedObjects/Object/CacheDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public override void DrawValue(Rect window, float width)
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);

Expand Down
1 change: 1 addition & 0 deletions src/Config/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ModConfig

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()
{
Expand Down
1 change: 1 addition & 0 deletions src/Explorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
2 changes: 1 addition & 1 deletion src/ExplorerCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/PageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public int ItemsPerPage
CalculateMaxOffset();
}
}
private int m_itemsPerPage = 20;
private int m_itemsPerPage = ModConfig.Instance.Default_Page_Limit;

public int ItemCount
{
Expand Down
6 changes: 5 additions & 1 deletion src/Menu/MainMenu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ public MainMenu()
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;
Expand Down
99 changes: 99 additions & 0 deletions src/Menu/MainMenu/Pages/OptionsPage.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
2 changes: 1 addition & 1 deletion src/Menu/MainMenu/Pages/ScenePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ScenePage : WindowPage
{
public static ScenePage Instance;

public override string Name { get => "Scene Explorer"; }
public override string Name { get => "Scenes"; }

public PageHelper Pages = new PageHelper();

Expand Down
1 change: 1 addition & 0 deletions src/Menu/ResizeDrag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public static Rect ResizeWindow(Rect _rect, int ID)
GUILayout.EndHorizontal();

#endif
GUI.skin.label.alignment = TextAnchor.MiddleLeft;

return _rect;
}
Expand Down
2 changes: 2 additions & 0 deletions src/UnstripFixes/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ private static GUIStyle GetSpaceStyle()

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;
Expand Down

0 comments on commit 748e0ca

Please sign in to comment.