diff --git a/src/CachedObjects/CacheList.cs b/src/CachedObjects/CacheList.cs
index 88d17e4..2c39b7f 100644
--- a/src/CachedObjects/CacheList.cs
+++ b/src/CachedObjects/CacheList.cs
@@ -11,8 +11,7 @@ namespace Explorer
public class CacheList : CacheObjectBase
{
public bool IsExpanded { get; set; }
- public int ArrayOffset { get; set; }
- public int ArrayLimit { get; set; } = 20;
+ public PageHelper Pages = new PageHelper();
public float WhiteSpace = 215f;
public float ButtonWidthOffset = 290f;
@@ -230,18 +229,6 @@ namespace Explorer
{
list.Add(null);
}
-
- //var type = ReflectionHelpers.GetActualType(obj);
-
- //if (obj is Il2CppSystem.Object iObj)
- //{
- // obj = iObj.Il2CppCast(type);
- //}
-
- //var cached = GetCacheObject(obj, null, null, type);
- //cached.UpdateValue();
-
- //list.Add(cached);
}
m_cachedEntries = list.ToArray();
@@ -286,51 +273,51 @@ namespace Explorer
if (IsExpanded)
{
- float whitespace = WhiteSpace;
-
+ float whitespace = WhiteSpace;
if (whitespace > 0)
{
ClampLabelWidth(window, ref whitespace);
}
- if (count > ArrayLimit)
+ Pages.Count = count;
+
+ if (count > Pages.PageLimit)
{
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace);
- int maxOffset = (int)Mathf.Ceil((float)(count / (decimal)ArrayLimit)) - 1;
- GUILayout.Label($"Page {ArrayOffset + 1}/{maxOffset + 1}", new GUILayoutOption[] { GUILayout.Width(80) });
+ //int maxOffset = (int)Mathf.Ceil((float)(count / (decimal)ArrayLimit)) - 1;
+ Pages.CalculateMaxOffset();
+
+ //GUILayout.Label($"Page {PH.ArrayOffset + 1}/{maxOffset + 1}", new GUILayoutOption[] { GUILayout.Width(80) });
+ Pages.CurrentPageLabel();
+
// prev/next page buttons
if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(60) }))
{
- if (ArrayOffset > 0) ArrayOffset--;
+ Pages.TurnPage(Turn.Left);
}
if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(60) }))
{
- if (ArrayOffset < maxOffset) ArrayOffset++;
- }
- GUILayout.Label("Limit: ", new GUILayoutOption[] { GUILayout.Width(50) });
- var limit = this.ArrayLimit.ToString();
- limit = GUILayout.TextField(limit, new GUILayoutOption[] { GUILayout.Width(50) });
- if (limit != ArrayLimit.ToString() && int.TryParse(limit, out int i))
- {
- ArrayLimit = i;
+ Pages.TurnPage(Turn.Right);
}
+ Pages.DrawLimitInputArea();
+
GUILayout.Space(5);
}
- int offset = ArrayOffset * ArrayLimit;
+ //int offset = ArrayOffset * ArrayLimit;
+ //if (offset >= count)
+ //{
+ // offset = 0;
+ // ArrayOffset = 0;
+ //}
+ int offset = Pages.CalculateOffsetIndex();
- if (offset >= count)
- {
- offset = 0;
- ArrayOffset = 0;
- }
-
- for (int i = offset; i < offset + ArrayLimit && i < count; i++)
+ for (int i = offset; i < offset + Pages.PageLimit && i < count; i++)
{
var entry = m_cachedEntries[i];
diff --git a/src/CppExplorer.cs b/src/CppExplorer.cs
index c630e27..933bd4a 100644
--- a/src/CppExplorer.cs
+++ b/src/CppExplorer.cs
@@ -12,7 +12,7 @@ namespace Explorer
public class CppExplorer : MelonMod
{
public const string GUID = "com.sinai.cppexplorer";
- public const string VERSION = "1.5.1";
+ public const string VERSION = "1.5.2";
public const string AUTHOR = "Sinai";
public const string NAME = "CppExplorer"
diff --git a/src/CppExplorer.csproj b/src/CppExplorer.csproj
index cc1ea50..22c6d8b 100644
--- a/src/CppExplorer.csproj
+++ b/src/CppExplorer.csproj
@@ -60,9 +60,7 @@
..\..\..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnhollowerBaseLib.dll
False
-
-
..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.dll
False
@@ -91,9 +89,7 @@
..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.UI.dll
False
-
-
..\..\..\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.dll
False
@@ -122,7 +118,6 @@
..\..\..\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.UI.dll
False
-
@@ -135,6 +130,7 @@
+
diff --git a/src/Helpers/PageHelper.cs b/src/Helpers/PageHelper.cs
new file mode 100644
index 0000000..a402e0c
--- /dev/null
+++ b/src/Helpers/PageHelper.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using UnityEngine;
+
+namespace Explorer
+{
+ public enum Turn
+ {
+ Left,
+ Right
+ }
+
+ public class PageHelper
+ {
+ public int PageOffset { get; set; }
+ public int PageLimit { get; set; } = 20;
+ public int Count { get; set; }
+ public int MaxOffset { get; set; } = -1;
+
+ public int CalculateMaxOffset()
+ {
+ return MaxOffset = (int)Mathf.Ceil((float)(Count / (decimal)PageLimit)) - 1;
+ }
+
+ public void CurrentPageLabel()
+ {
+ var orig = GUI.skin.label.alignment;
+ GUI.skin.label.alignment = TextAnchor.MiddleCenter;
+
+ GUILayout.Label($"Page {PageOffset + 1}/{MaxOffset + 1}", new GUILayoutOption[] { GUILayout.Width(80) });
+
+ GUI.skin.label.alignment = orig;
+ }
+
+ public void TurnPage(Turn direction)
+ {
+ var _ = Vector2.zero;
+ TurnPage(direction, ref _);
+ }
+
+ public void TurnPage(Turn direction, ref Vector2 scroll)
+ {
+ if (direction == Turn.Left)
+ {
+ if (PageOffset > 0)
+ {
+ PageOffset--;
+ scroll = Vector2.zero;
+ }
+ }
+ else
+ {
+ if (PageOffset < MaxOffset)
+ {
+ PageOffset++;
+ scroll = Vector2.zero;
+ }
+ }
+ }
+
+ public int CalculateOffsetIndex()
+ {
+ int offset = PageOffset * PageLimit;
+
+ if (offset >= Count)
+ {
+ offset = 0;
+ PageOffset = 0;
+ }
+
+ return offset;
+ }
+
+ public void DrawLimitInputArea()
+ {
+ GUILayout.Label("Limit: ", new GUILayoutOption[] { GUILayout.Width(50) });
+ var limit = this.PageLimit.ToString();
+ limit = GUILayout.TextField(limit, new GUILayoutOption[] { GUILayout.Width(50) });
+ if (limit != PageLimit.ToString() && int.TryParse(limit, out int i))
+ {
+ PageLimit = i;
+ }
+ }
+ }
+}
diff --git a/src/MainMenu/Pages/ScenePage.cs b/src/MainMenu/Pages/ScenePage.cs
index 437e80b..3d9a2c2 100644
--- a/src/MainMenu/Pages/ScenePage.cs
+++ b/src/MainMenu/Pages/ScenePage.cs
@@ -14,9 +14,7 @@ namespace Explorer
public override string Name { get => "Scene Explorer"; set => base.Name = value; }
- private int m_pageOffset = 0;
- private int m_limit = 20;
- private int m_currentTotalCount = 0;
+ public PageHelper Pages = new PageHelper();
private float m_timeOfLastUpdate = -1f;
@@ -46,14 +44,14 @@ namespace Explorer
SetTransformTarget(null);
}
- public void CheckOffset(ref int offset, int childCount)
- {
- if (offset >= childCount)
- {
- offset = 0;
- m_pageOffset = 0;
- }
- }
+ //public void CheckOffset(ref int offset, int childCount)
+ //{
+ // if (offset >= childCount)
+ // {
+ // offset = 0;
+ // m_pageOffset = 0;
+ // }
+ //}
public override void Update()
{
@@ -63,7 +61,6 @@ namespace Explorer
m_timeOfLastUpdate = Time.time;
m_objectList = new List();
- int offset = m_pageOffset * m_limit;
var allTransforms = new List();
@@ -86,15 +83,14 @@ namespace Explorer
}
}
- m_currentTotalCount = allTransforms.Count;
+ Pages.Count = allTransforms.Count;
- // make sure offset doesn't exceed count
- CheckOffset(ref offset, m_currentTotalCount);
+ int offset = Pages.CalculateOffsetIndex();
// sort by childcount
allTransforms.Sort((a, b) => b.childCount.CompareTo(a.childCount));
- for (int i = offset; i < offset + m_limit && i < m_currentTotalCount; i++)
+ for (int i = offset; i < offset + Pages.PageLimit && i < Pages.Count; i++)
{
var child = allTransforms[i];
m_objectList.Add(new GameObjectCache(child.gameObject));
@@ -128,7 +124,7 @@ namespace Explorer
{
m_searchResults = SearchSceneObjects(m_searchInput);
m_searching = true;
- m_currentTotalCount = m_searchResults.Count;
+ Pages.Count = m_searchResults.Count;
}
public void CancelSearch()
@@ -242,33 +238,21 @@ namespace Explorer
{
GUILayout.BeginHorizontal(null);
- GUILayout.Label("Limit per page: ", new GUILayoutOption[] { GUILayout.Width(100) });
- var limit = m_limit.ToString();
- limit = GUILayout.TextField(limit, new GUILayoutOption[] { GUILayout.Width(30) });
- if (int.TryParse(limit, out int lim))
- {
- m_limit = lim;
- }
+ Pages.DrawLimitInputArea();
- // prev/next page buttons
- if (m_currentTotalCount > m_limit)
+ if (Pages.Count > Pages.PageLimit)
{
- int count = m_currentTotalCount;
- int maxOffset = (int)Mathf.Ceil((float)(count / (decimal)m_limit)) - 1;
- if (GUILayout.Button("< Prev", null))
+ if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) }))
{
- if (m_pageOffset > 0) m_pageOffset--;
- m_timeOfLastUpdate = -1f;
+ Pages.TurnPage(Turn.Left, ref this.scroll);
Update();
}
- GUI.skin.label.alignment = TextAnchor.MiddleCenter;
- GUILayout.Label($"Page {m_pageOffset + 1}/{maxOffset + 1}", new GUILayoutOption[] { GUILayout.Width(80) });
+ Pages.CurrentPageLabel();
- if (GUILayout.Button("Next >", null))
+ if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) }))
{
- if (m_pageOffset < maxOffset) m_pageOffset++;
- m_timeOfLastUpdate = -1f;
+ Pages.TurnPage(Turn.Right, ref this.scroll);
Update();
}
}
@@ -342,15 +326,9 @@ namespace Explorer
if (m_searchResults.Count > 0)
{
- int offset = m_pageOffset * m_limit;
+ int offset = Pages.CalculateOffsetIndex();
- if (offset >= m_searchResults.Count)
- {
- offset = 0;
- m_pageOffset = 0;
- }
-
- for (int i = offset; i < offset + m_limit && i < m_searchResults.Count; i++)
+ for (int i = offset; i < offset + Pages.PageLimit && i < m_searchResults.Count; i++)
{
var obj = m_searchResults[i];
diff --git a/src/MainMenu/Pages/SearchPage.cs b/src/MainMenu/Pages/SearchPage.cs
index 7011131..abab30c 100644
--- a/src/MainMenu/Pages/SearchPage.cs
+++ b/src/MainMenu/Pages/SearchPage.cs
@@ -5,11 +5,7 @@ using System.Linq;
using System.Text;
using UnityEngine;
using System.Reflection;
-using UnityEngine.SceneManagement;
-using Object = UnityEngine.Object;
-using UnhollowerRuntimeLib;
using MelonLoader;
-using UnhollowerBaseLib;
namespace Explorer
{
@@ -21,11 +17,11 @@ namespace Explorer
private string m_searchInput = "";
private string m_typeInput = "";
- private int m_limit = 20;
- private int m_pageOffset = 0;
- //private List