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

Commit 6adaaf5

Browse files
committed
1.5.4
* Implemented manual unstripping for ScrollView and Resize, should now work on any Unity 2018 or 2019 game. * Fixed a bug with page view on the Scene Explorer * Back-end cleanups
1 parent 5de7713 commit 6adaaf5

17 files changed

+1001
-102
lines changed

src/CachedObjects/CacheGameObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class CacheGameObject : CacheObjectBase
1212
{
1313
public override void DrawValue(Rect window, float width)
1414
{
15-
UIHelpers.GameobjButton(Value, null, false, width);
15+
UIHelpers.GOButton(Value, null, false, width);
1616
}
1717

1818
public override void UpdateValue()

src/CachedObjects/CacheList.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,15 @@ public override void DrawValue(Rect window, float width)
279279
ClampLabelWidth(window, ref whitespace);
280280
}
281281

282-
Pages.Count = count;
282+
Pages.ItemCount = count;
283283

284-
if (count > Pages.PageLimit)
284+
if (count > Pages.ItemsPerPage)
285285
{
286286
GUILayout.EndHorizontal();
287287
GUILayout.BeginHorizontal(null);
288288

289289
GUILayout.Space(whitespace);
290-
291-
//int maxOffset = (int)Mathf.Ceil((float)(count / (decimal)ArrayLimit)) - 1;
292-
Pages.CalculateMaxOffset();
293-
294-
//GUILayout.Label($"Page {PH.ArrayOffset + 1}/{maxOffset + 1}", new GUILayoutOption[] { GUILayout.Width(80) });
290+
295291
Pages.CurrentPageLabel();
296292

297293
// prev/next page buttons
@@ -317,7 +313,7 @@ public override void DrawValue(Rect window, float width)
317313
//}
318314
int offset = Pages.CalculateOffsetIndex();
319315

320-
for (int i = offset; i < offset + Pages.PageLimit && i < count; i++)
316+
for (int i = offset; i < offset + Pages.ItemsPerPage && i < count; i++)
321317
{
322318
var entry = m_cachedEntries[i];
323319

src/CppExplorer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Explorer
1212
public class CppExplorer : MelonMod
1313
{
1414
public const string GUID = "com.sinai.cppexplorer";
15-
public const string VERSION = "1.5.3";
15+
public const string VERSION = "1.5.4";
1616
public const string AUTHOR = "Sinai";
1717

1818
public const string NAME = "CppExplorer"

src/CppExplorer.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<DebugSymbols>false</DebugSymbols>
1919
<DebugType>none</DebugType>
2020
<Optimize>false</Optimize>
21-
<OutputPath>..\Release\</OutputPath>
22-
<DefineConstants>DEBUG</DefineConstants>
21+
<OutputPath>..\Release\2019\</OutputPath>
22+
<DefineConstants>Release_2019</DefineConstants>
2323
<ErrorReport>prompt</ErrorReport>
2424
<WarningLevel>4</WarningLevel>
2525
<PlatformTarget>x64</PlatformTarget>
@@ -30,7 +30,7 @@
3030
<DebugSymbols>false</DebugSymbols>
3131
<DebugType>none</DebugType>
3232
<Optimize>false</Optimize>
33-
<OutputPath>..\Release\</OutputPath>
33+
<OutputPath>..\Release\2018\</OutputPath>
3434
<DefineConstants>Release_Unity2018</DefineConstants>
3535
<ErrorReport>prompt</ErrorReport>
3636
<WarningLevel>4</WarningLevel>
@@ -44,7 +44,7 @@
4444
</Reference>
4545
<Reference Include="mcs">
4646
<HintPath>..\lib\mcs.dll</HintPath>
47-
<Private>False</Private>
47+
<Private>True</Private>
4848
</Reference>
4949
<Reference Include="MelonLoader.ModHandler">
5050
<HintPath>..\..\..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\MelonLoader.ModHandler.dll</HintPath>
@@ -129,13 +129,17 @@
129129
<Compile Include="CachedObjects\CacheMethod.cs" />
130130
<Compile Include="CppExplorer.cs" />
131131
<Compile Include="Extensions\ReflectionExtensions.cs" />
132+
<Compile Include="Unstripping\GUIUnstrip.cs" />
133+
<Compile Include="Unstripping\ScrollViewStateUnstrip.cs" />
132134
<Compile Include="Extensions\UnityExtensions.cs" />
133135
<Compile Include="Helpers\PageHelper.cs" />
134136
<Compile Include="Helpers\ReflectionHelpers.cs" />
135137
<Compile Include="Helpers\UIHelpers.cs" />
136138
<Compile Include="Helpers\UnityHelpers.cs" />
137139
<Compile Include="MainMenu\InspectUnderMouse.cs" />
138140
<Compile Include="CachedObjects\CacheObjectBase.cs" />
141+
<Compile Include="Unstripping\SliderHandlerUnstrip.cs" />
142+
<Compile Include="Unstripping\UnstripExtensions.cs" />
139143
<Compile Include="Windows\ResizeDrag.cs" />
140144
<Compile Include="Windows\TabViewWindow.cs" />
141145
<Compile Include="Windows\UIWindow.cs" />

src/Extensions/UnityExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using UnhollowerBaseLib;
67
using UnityEngine;
78

89
namespace Explorer

src/Helpers/PageHelper.cs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,31 @@ public enum Turn
1616
public class PageHelper
1717
{
1818
public int PageOffset { get; set; }
19-
public int PageLimit { get; set; } = 20;
20-
public int Count { get; set; }
21-
public int MaxOffset { get; set; } = -1;
19+
public int ItemsPerPage { get; set; } = 20;
20+
public int ItemCount
21+
{
22+
get => m_count;
23+
set
24+
{
25+
m_count = value;
26+
CalculateMaxOffset();
27+
}
28+
}
29+
private int m_count;
30+
31+
public int MaxPageOffset { get; private set; } = -1;
2232

23-
public int CalculateMaxOffset()
33+
private int CalculateMaxOffset()
2434
{
25-
return MaxOffset = (int)Mathf.Ceil((float)(Count / (decimal)PageLimit)) - 1;
35+
return MaxPageOffset = (int)Mathf.Ceil((float)(ItemCount / (decimal)ItemsPerPage)) - 1;
2636
}
2737

2838
public void CurrentPageLabel()
2939
{
3040
var orig = GUI.skin.label.alignment;
3141
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
3242

33-
GUILayout.Label($"Page {PageOffset + 1}/{MaxOffset + 1}", new GUILayoutOption[] { GUILayout.Width(80) });
43+
GUILayout.Label($"Page {PageOffset + 1}/{MaxPageOffset + 1}", new GUILayoutOption[] { GUILayout.Width(80) });
3444

3545
GUI.skin.label.alignment = orig;
3646
}
@@ -53,7 +63,7 @@ public void TurnPage(Turn direction, ref Vector2 scroll)
5363
}
5464
else
5565
{
56-
if (PageOffset < MaxOffset)
66+
if (PageOffset < MaxPageOffset)
5767
{
5868
PageOffset++;
5969
scroll = Vector2.zero;
@@ -63,9 +73,9 @@ public void TurnPage(Turn direction, ref Vector2 scroll)
6373

6474
public int CalculateOffsetIndex()
6575
{
66-
int offset = PageOffset * PageLimit;
76+
int offset = PageOffset * ItemsPerPage;
6777

68-
if (offset >= Count)
78+
if (offset >= ItemCount)
6979
{
7080
offset = 0;
7181
PageOffset = 0;
@@ -77,11 +87,11 @@ public int CalculateOffsetIndex()
7787
public void DrawLimitInputArea()
7888
{
7989
GUILayout.Label("Limit: ", new GUILayoutOption[] { GUILayout.Width(50) });
80-
var limit = this.PageLimit.ToString();
90+
var limit = this.ItemsPerPage.ToString();
8191
limit = GUILayout.TextField(limit, new GUILayoutOption[] { GUILayout.Width(50) });
82-
if (limit != PageLimit.ToString() && int.TryParse(limit, out int i))
92+
if (limit != ItemsPerPage.ToString() && int.TryParse(limit, out int i))
8393
{
84-
PageLimit = i;
94+
ItemsPerPage = i;
8595
}
8696
}
8797
}

src/Helpers/UIHelpers.cs

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,15 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using System.Reflection;
7+
using UnhollowerRuntimeLib;
68
using UnityEngine;
79
using Object = UnityEngine.Object;
810

911
namespace Explorer
1012
{
1113
public class UIHelpers
1214
{
13-
private static bool ScrollUnstrippingFailed = false;
14-
15-
public static Vector2 BeginScrollView(Vector2 scroll) => BeginScrollView(scroll, null);
16-
17-
public static Vector2 BeginScrollView(Vector2 scroll, GUIStyle style, params GUILayoutOption[] layoutOptions)
18-
{
19-
if (ScrollUnstrippingFailed) return scroll;
20-
21-
try
22-
{
23-
if (style != null)
24-
return GUILayout.BeginScrollView(scroll, style, layoutOptions);
25-
else
26-
return GUILayout.BeginScrollView(scroll, layoutOptions);
27-
}
28-
catch
29-
{
30-
ScrollUnstrippingFailed = true;
31-
return scroll;
32-
}
33-
}
34-
35-
public static void EndScrollView()
36-
{
37-
if (ScrollUnstrippingFailed) return;
38-
39-
GUILayout.EndScrollView();
40-
}
41-
4215
// helper for "Instantiate" button on UnityEngine.Objects
4316
public static void InstantiateButton(Object obj, float width = 100)
4417
{
@@ -51,13 +24,13 @@ public static void InstantiateButton(Object obj, float width = 100)
5124
}
5225

5326
// helper for drawing a styled button for a GameObject or Transform
54-
public static void GameobjButton(object _obj, Action<Transform> specialInspectMethod = null, bool showSmallInspectBtn = true, float width = 380)
27+
public static void GOButton(object _obj, Action<Transform> specialInspectMethod = null, bool showSmallInspectBtn = true, float width = 380)
5528
{
5629
var obj = (_obj as GameObject) ?? (_obj as Transform).gameObject;
5730

58-
bool children = obj.transform.childCount > 0;
31+
bool hasChild = obj.transform.childCount > 0;
5932

60-
string label = children ? "[" + obj.transform.childCount + " children] " : "";
33+
string label = hasChild ? $"[{obj.transform.childCount} children] " : "";
6134
label += obj.name;
6235

6336
bool enabled = obj.activeSelf;
@@ -80,10 +53,10 @@ public static void GameobjButton(object _obj, Action<Transform> specialInspectMe
8053
color = Color.red;
8154
}
8255

83-
FastGameobjButton(_obj, color, label, obj.activeSelf, specialInspectMethod, showSmallInspectBtn, width);
56+
GOButton_Impl(_obj, color, label, obj.activeSelf, specialInspectMethod, showSmallInspectBtn, width);
8457
}
8558

86-
public static void FastGameobjButton(object _obj, Color activeColor, string label, bool enabled, Action<Transform> specialInspectMethod = null, bool showSmallInspectBtn = true, float width = 380)
59+
public static void GOButton_Impl(object _obj, Color activeColor, string label, bool enabled, Action<Transform> specialInspectMethod = null, bool showSmallInspectBtn = true, float width = 380)
8760
{
8861
var obj = _obj as GameObject ?? (_obj as Transform).gameObject;
8962

src/MainMenu/MainMenu.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ private void MainWindow(int id)
7575

7676
var page = Pages[m_currentPage];
7777

78-
page.scroll = UIHelpers.BeginScrollView(page.scroll);
78+
page.scroll = GUIUnstrip.BeginScrollView(page.scroll);
7979

8080
page.DrawWindow();
8181

82-
UIHelpers.EndScrollView();
82+
GUIUnstrip.EndScrollView();
8383

8484
MainRect = ResizeDrag.ResizeWindow(MainRect, MainWindowID);
8585

src/MainMenu/Pages/ScenePage.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ public override void Update()
8383
}
8484
}
8585

86-
Pages.Count = allTransforms.Count;
86+
Pages.ItemCount = allTransforms.Count;
8787

8888
int offset = Pages.CalculateOffsetIndex();
8989

9090
// sort by childcount
9191
allTransforms.Sort((a, b) => b.childCount.CompareTo(a.childCount));
9292

93-
for (int i = offset; i < offset + Pages.PageLimit && i < Pages.Count; i++)
93+
for (int i = offset; i < offset + Pages.ItemsPerPage && i < Pages.ItemCount; i++)
9494
{
9595
var child = allTransforms[i];
9696
m_objectList.Add(new GameObjectCache(child.gameObject));
@@ -124,7 +124,7 @@ public void Search()
124124
{
125125
m_searchResults = SearchSceneObjects(m_searchInput);
126126
m_searching = true;
127-
Pages.Count = m_searchResults.Count;
127+
Pages.ItemCount = m_searchResults.Count;
128128
}
129129

130130
public void CancelSearch()
@@ -240,11 +240,13 @@ private void DrawPageButtons()
240240

241241
Pages.DrawLimitInputArea();
242242

243-
if (Pages.Count > Pages.PageLimit)
243+
if (Pages.ItemCount > Pages.ItemsPerPage)
244244
{
245245
if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) }))
246246
{
247247
Pages.TurnPage(Turn.Left, ref this.scroll);
248+
249+
m_timeOfLastUpdate = -1f;
248250
Update();
249251
}
250252

@@ -253,6 +255,8 @@ private void DrawPageButtons()
253255
if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) }))
254256
{
255257
Pages.TurnPage(Turn.Right, ref this.scroll);
258+
259+
m_timeOfLastUpdate = -1f;
256260
Update();
257261
}
258262
}
@@ -303,7 +307,7 @@ private void DrawGameObjectList()
303307
}
304308
else
305309
{
306-
UIHelpers.FastGameobjButton(obj.RefGameObject,
310+
UIHelpers.GOButton_Impl(obj.RefGameObject,
307311
obj.EnabledColor,
308312
obj.Label,
309313
obj.RefGameObject.activeSelf,
@@ -328,13 +332,13 @@ private void DrawSearchResultsList()
328332
{
329333
int offset = Pages.CalculateOffsetIndex();
330334

331-
for (int i = offset; i < offset + Pages.PageLimit && i < m_searchResults.Count; i++)
335+
for (int i = offset; i < offset + Pages.ItemsPerPage && i < m_searchResults.Count; i++)
332336
{
333337
var obj = m_searchResults[i];
334338

335339
if (obj.RefGameObject)
336340
{
337-
UIHelpers.FastGameobjButton(obj.RefGameObject,
341+
UIHelpers.GOButton_Impl(obj.RefGameObject,
338342
obj.EnabledColor,
339343
obj.Label,
340344
obj.RefGameObject.activeSelf,

src/MainMenu/Pages/SearchPage.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private void CacheResults(IEnumerable results)
7575
m_searchResults.Add(cache);
7676
}
7777

78-
Pages.Count = m_searchResults.Count;
78+
Pages.ItemCount = m_searchResults.Count;
7979
Pages.PageOffset = 0;
8080
}
8181

@@ -104,17 +104,16 @@ public override void DrawWindow()
104104
GUI.skin.label.alignment = TextAnchor.UpperLeft;
105105

106106
int count = m_searchResults.Count;
107-
Pages.CalculateMaxOffset();
108107

109108
GUILayout.BeginHorizontal(null);
110109

111110
Pages.DrawLimitInputArea();
112111

113-
if (count > Pages.PageLimit)
112+
if (count > Pages.ItemsPerPage)
114113
{
115114
// prev/next page buttons
116115

117-
if (Pages.Count > Pages.PageLimit)
116+
if (Pages.ItemCount > Pages.ItemsPerPage)
118117
{
119118
if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) }))
120119
{
@@ -132,7 +131,7 @@ public override void DrawWindow()
132131

133132
GUILayout.EndHorizontal();
134133

135-
resultsScroll = UIHelpers.BeginScrollView(resultsScroll);
134+
resultsScroll = GUIUnstrip.BeginScrollView(resultsScroll);
136135

137136
var _temprect = new Rect(MainMenu.MainRect.x, MainMenu.MainRect.y, MainMenu.MainRect.width + 160, MainMenu.MainRect.height);
138137

@@ -142,7 +141,7 @@ public override void DrawWindow()
142141
//if (offset >= count) m_pageOffset = 0;
143142
int offset = Pages.CalculateOffsetIndex();
144143

145-
for (int i = offset; i < offset + Pages.PageLimit && i < count; i++)
144+
for (int i = offset; i < offset + Pages.ItemsPerPage && i < count; i++)
146145
{
147146
m_searchResults[i].Draw(MainMenu.MainRect, 0f);
148147
//m_searchResults[i].DrawValue(MainMenu.MainRect);
@@ -153,7 +152,7 @@ public override void DrawWindow()
153152
GUILayout.Label("<color=red><i>No results found!</i></color>", null);
154153
}
155154

156-
UIHelpers.EndScrollView();
155+
GUIUnstrip.EndScrollView();
157156
GUILayout.EndVertical();
158157
}
159158
catch

0 commit comments

Comments
 (0)