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

Commit 23723a4

Browse files
committed
Some more unstrip fixes, and a few cleanups
1 parent dab7ecd commit 23723a4

25 files changed

+922
-671
lines changed

src/CachedObjects/CacheObjectBase.cs

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public abstract class CacheObjectBase
2727
public string RichTextName => m_richTextName ?? GetRichTextName();
2828
private string m_richTextName;
2929

30-
public bool CanWrite => m_canWrite ?? (bool)(m_canWrite = GetCanWrite());
30+
public bool CanWrite => m_canWrite ?? GetCanWrite();
3131
private bool? m_canWrite;
3232

3333
public virtual void Init() { }
@@ -114,51 +114,45 @@ public object[] ParseArguments()
114114
type = type.GetElementType();
115115
}
116116

117-
if (string.IsNullOrEmpty(input))
117+
if (!string.IsNullOrEmpty(input))
118118
{
119-
// No input, see if there is a default value.
120-
if (HasDefaultValue(m_arguments[i]))
119+
if (type == typeof(string))
121120
{
122-
parsedArgs.Add(m_arguments[i].DefaultValue);
121+
parsedArgs.Add(input);
123122
continue;
124123
}
124+
else
125+
{
126+
try
127+
{
128+
var arg = type.GetMethod("Parse", new Type[] { typeof(string) })
129+
.Invoke(null, new object[] { input });
125130

126-
// Try add a null arg I guess
127-
parsedArgs.Add(null);
128-
continue;
131+
parsedArgs.Add(arg);
132+
continue;
133+
}
134+
catch
135+
{
136+
ExplorerCore.Log($"Argument #{i} '{m_arguments[i].Name}' ({type.Name}), could not parse input '{input}'.");
137+
}
138+
}
129139
}
130140

131-
// strings can obviously just be used directly
132-
if (type == typeof(string))
141+
// No input, see if there is a default value.
142+
if (HasDefaultValue(m_arguments[i]))
133143
{
134-
parsedArgs.Add(input);
144+
parsedArgs.Add(m_arguments[i].DefaultValue);
135145
continue;
136146
}
137-
else
138-
{
139-
try
140-
{
141-
var arg = type.GetMethod("Parse", new Type[] { typeof(string) })
142-
.Invoke(null, new object[] { input });
143-
parsedArgs.Add(arg);
144-
continue;
145-
}
146-
catch
147-
{
148-
ExplorerCore.Log($"Argument #{i} '{m_arguments[i].Name}' ({type.Name}), could not parse input '{input}'.");
149-
}
150-
}
147+
148+
// Try add a null arg I guess
149+
parsedArgs.Add(null);
151150
}
152151

153152
return parsedArgs.ToArray();
154153
}
155154

156-
public static bool HasDefaultValue(ParameterInfo arg) =>
157-
#if NET35
158-
arg.DefaultValue != null;
159-
#else
160-
arg.HasDefaultValue;
161-
#endif
155+
public static bool HasDefaultValue(ParameterInfo arg) => arg.DefaultValue != DBNull.Value;
162156

163157
// ========= Gui Draw ==========
164158

@@ -246,7 +240,7 @@ public void Draw(Rect window, float labelWidth = 215f)
246240
$"<color={UIStyles.Syntax.StructGreen}>{cm.GenericArgs[i].Name}</color>",
247241
new GUILayoutOption[] { GUILayout.Width(15) }
248242
);
249-
cm.GenericArgInput[i] = GUILayout.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) });
243+
cm.GenericArgInput[i] = GUIUnstrip.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) });
250244
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
251245
GUILayout.Label(types, new GUILayoutOption[0]);
252246

@@ -274,7 +268,7 @@ public void Draw(Rect window, float labelWidth = 215f)
274268

275269
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
276270
GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) });
277-
m_argumentInput[i] = GUILayout.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) });
271+
m_argumentInput[i] = GUIUnstrip.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) });
278272
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
279273
GUILayout.Label(label, new GUILayoutOption[0]);
280274

@@ -350,11 +344,13 @@ public void Draw(Rect window, float labelWidth = 215f)
350344
private bool GetCanWrite()
351345
{
352346
if (MemInfo is FieldInfo fi)
353-
return !(fi.IsLiteral && !fi.IsInitOnly);
347+
m_canWrite = !(fi.IsLiteral && !fi.IsInitOnly);
354348
else if (MemInfo is PropertyInfo pi)
355-
return pi.CanWrite;
349+
m_canWrite = pi.CanWrite;
356350
else
357-
return false;
351+
m_canWrite = false;
352+
353+
return (bool)m_canWrite;
358354
}
359355

360356
private string GetRichTextName()

src/CachedObjects/Struct/CacheColor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,25 @@ public override void DrawValue(Rect window, float width)
6464
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
6565
GUIUnstrip.Space(whitespace);
6666
GUILayout.Label("R:", new GUILayoutOption[] { GUILayout.Width(30) });
67-
r = GUILayout.TextField(r, new GUILayoutOption[] { GUILayout.Width(120) });
67+
r = GUIUnstrip.TextField(r, new GUILayoutOption[] { GUILayout.Width(120) });
6868
GUILayout.EndHorizontal();
6969

7070
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
7171
GUIUnstrip.Space(whitespace);
7272
GUILayout.Label("G:", new GUILayoutOption[] { GUILayout.Width(30) });
73-
g = GUILayout.TextField(g, new GUILayoutOption[] { GUILayout.Width(120) });
73+
g = GUIUnstrip.TextField(g, new GUILayoutOption[] { GUILayout.Width(120) });
7474
GUILayout.EndHorizontal();
7575

7676
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
7777
GUIUnstrip.Space(whitespace);
7878
GUILayout.Label("B:", new GUILayoutOption[] { GUILayout.Width(30) });
79-
b = GUILayout.TextField(b, new GUILayoutOption[] { GUILayout.Width(120) });
79+
b = GUIUnstrip.TextField(b, new GUILayoutOption[] { GUILayout.Width(120) });
8080
GUILayout.EndHorizontal();
8181

8282
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
8383
GUIUnstrip.Space(whitespace);
8484
GUILayout.Label("A:", new GUILayoutOption[] { GUILayout.Width(30) });
85-
a = GUILayout.TextField(a, new GUILayoutOption[] { GUILayout.Width(120) });
85+
a = GUIUnstrip.TextField(a, new GUILayoutOption[] { GUILayout.Width(120) });
8686
GUILayout.EndHorizontal();
8787

8888
// draw set value button

src/CachedObjects/Struct/CacheEnum.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Explorer
1010
public class CacheEnum : CacheObjectBase
1111
{
1212
// public Type EnumType;
13-
public string[] EnumNames;
13+
public string[] EnumNames = new string[0];
1414

1515
public override void Init()
1616
{

src/CachedObjects/Struct/CacheEnumFlags.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,21 @@ public override void Init()
1717
{
1818
base.Init();
1919

20-
if (ValueType != null)
21-
{
22-
m_enabledFlags = new bool[EnumNames.Length];
23-
24-
UpdateValue();
25-
}
20+
UpdateValue();
2621
}
2722

2823
public override void UpdateValue()
2924
{
3025
base.UpdateValue();
3126

27+
if (Value == null) return;
28+
3229
try
3330
{
3431
var enabledNames = Value.ToString().Split(',').Select(it => it.Trim());
3532

33+
m_enabledFlags = new bool[EnumNames.Length];
34+
3635
for (int i = 0; i < EnumNames.Length; i++)
3736
{
3837
m_enabledFlags[i] = enabledNames.Contains(EnumNames[i]);

src/CachedObjects/Struct/CachePrimitive.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ private void DrawBitwise()
186186
}
187187
}
188188

189-
m_bitwiseOperatorInput = GUILayout.TextField(m_bitwiseOperatorInput, new GUILayoutOption[] { GUILayout.Width(55) });
189+
m_bitwiseOperatorInput = GUIUnstrip.TextField(m_bitwiseOperatorInput, new GUILayoutOption[] { GUILayout.Width(55) });
190190

191191
GUILayout.EndHorizontal();
192192
}
193193

194194
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
195195
GUILayout.Label($"<color=cyan>Binary:</color>", new GUILayoutOption[] { GUILayout.Width(60) });
196-
m_binaryInput = GUILayout.TextField(m_binaryInput, new GUILayoutOption[0]);
196+
m_binaryInput = GUIUnstrip.TextField(m_binaryInput, new GUILayoutOption[0]);
197197
if (CanWrite)
198198
{
199199
if (GUILayout.Button("Apply", new GUILayoutOption[0]))

src/CachedObjects/Struct/CacheQuaternion.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ public override void DrawValue(Rect window, float width)
5959
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
6060
GUIUnstrip.Space(whitespace);
6161
GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
62-
x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
62+
x = GUIUnstrip.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
6363
GUILayout.EndHorizontal();
6464

6565
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
6666
GUIUnstrip.Space(whitespace);
6767
GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
68-
y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
68+
y = GUIUnstrip.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
6969
GUILayout.EndHorizontal();
7070

7171
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
7272
GUIUnstrip.Space(whitespace);
7373
GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) });
74-
z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) });
74+
z = GUIUnstrip.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) });
7575
GUILayout.EndHorizontal();
7676

7777
// draw set value button

src/CachedObjects/Struct/CacheRect.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,25 @@ public override void DrawValue(Rect window, float width)
6161
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
6262
GUIUnstrip.Space(whitespace);
6363
GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
64-
x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
64+
x = GUIUnstrip.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
6565
GUILayout.EndHorizontal();
6666

6767
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
6868
GUIUnstrip.Space(whitespace);
6969
GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
70-
y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
70+
y = GUIUnstrip.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
7171
GUILayout.EndHorizontal();
7272

7373
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
7474
GUIUnstrip.Space(whitespace);
7575
GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) });
76-
w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) });
76+
w = GUIUnstrip.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) });
7777
GUILayout.EndHorizontal();
7878

7979
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
8080
GUIUnstrip.Space(whitespace);
8181
GUILayout.Label("H:", new GUILayoutOption[] { GUILayout.Width(30) });
82-
h = GUILayout.TextField(h, new GUILayoutOption[] { GUILayout.Width(120) });
82+
h = GUIUnstrip.TextField(h, new GUILayoutOption[] { GUILayout.Width(120) });
8383
GUILayout.EndHorizontal();
8484

8585
// draw set value button

src/CachedObjects/Struct/CacheVector.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ public override void DrawValue(Rect window, float width)
101101
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
102102
GUIUnstrip.Space(whitespace);
103103
GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
104-
x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
104+
x = GUIUnstrip.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
105105
GUILayout.EndHorizontal();
106106

107107
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
108108
GUIUnstrip.Space(whitespace);
109109
GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
110-
y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
110+
y = GUIUnstrip.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
111111
GUILayout.EndHorizontal();
112112

113113
if (VectorSize > 2)
@@ -116,7 +116,7 @@ public override void DrawValue(Rect window, float width)
116116
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
117117
GUIUnstrip.Space(whitespace);
118118
GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) });
119-
z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) });
119+
z = GUIUnstrip.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) });
120120
GUILayout.EndHorizontal();
121121
}
122122
if (VectorSize > 3)
@@ -125,7 +125,7 @@ public override void DrawValue(Rect window, float width)
125125
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
126126
GUIUnstrip.Space(whitespace);
127127
GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) });
128-
w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) });
128+
w = GUIUnstrip.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) });
129129
GUILayout.EndHorizontal();
130130
}
131131

src/Explorer.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<FileAlignment>512</FileAlignment>
1212
<Deterministic>true</Deterministic>
1313
<TargetFrameworkProfile />
14+
<OutputPath>..\Release\Explorer.MelonLoader.Il2Cpp\</OutputPath>
15+
<DefineConstants>CPP,ML</DefineConstants>
1416
<IsCpp>true</IsCpp>
1517
<IsMelonLoader>true</IsMelonLoader>
1618
<IsNet35>false</IsNet35>
@@ -25,6 +27,7 @@
2527
<AssemblyName>Explorer</AssemblyName>
2628
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
2729
<MLCppGameFolder>D:\Steam\steamapps\common\Hellpoint</MLCppGameFolder>
30+
<!--<MLCppGameFolder>D:\source\Unity Projects\Test\_BUILD</MLCppGameFolder>-->
2831
<!-- Set this to the MelonLoader Mono Game folder, without the ending '\' character. -->
2932
<MLMonoGameFolder>D:\Steam\steamapps\common\Outward</MLMonoGameFolder>
3033
<!-- Set this to the BepInEx Il2Cpp Game folder, without the ending '\' character. -->
@@ -241,17 +244,16 @@
241244
<Compile Include="Menu\CursorControl.cs" />
242245
<Compile Include="Tests\TestClass.cs" />
243246
<Compile Include="UnstripFixes\GUIUnstrip.cs" />
244-
<Compile Include="UnstripFixes\LayoutUtilityUnstrip.cs" />
245-
<Compile Include="UnstripFixes\ScrollViewStateUnstrip.cs" />
247+
<Compile Include="UnstripFixes\Internal_LayoutUtility.cs" />
246248
<Compile Include="Extensions\UnityExtensions.cs" />
247249
<Compile Include="Helpers\PageHelper.cs" />
248250
<Compile Include="Helpers\ReflectionHelpers.cs" />
249251
<Compile Include="Menu\UIHelpers.cs" />
250252
<Compile Include="Helpers\UnityHelpers.cs" />
251253
<Compile Include="Menu\InspectUnderMouse.cs" />
252254
<Compile Include="CachedObjects\CacheObjectBase.cs" />
253-
<Compile Include="UnstripFixes\SliderHandlerUnstrip.cs" />
254-
<Compile Include="UnstripFixes\UnstripExtensions.cs" />
255+
<Compile Include="UnstripFixes\Internal_ScrollViewState.cs" />
256+
<Compile Include="UnstripFixes\Internal_SliderHandler.cs" />
255257
<Compile Include="Menu\ResizeDrag.cs" />
256258
<Compile Include="Menu\Windows\TabViewWindow.cs" />
257259
<Compile Include="Menu\Windows\UIWindow.cs" />
@@ -267,6 +269,8 @@
267269
<Compile Include="Menu\MainMenu\Pages\SearchPage.cs" />
268270
<Compile Include="Menu\UIStyles.cs" />
269271
<Compile Include="Properties\AssemblyInfo.cs" />
272+
<Compile Include="UnstripFixes\Internal.cs" />
273+
<Compile Include="UnstripFixes\Internal_SliderState.cs" />
270274
</ItemGroup>
271275
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
272276
</Project>

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.0";
8+
public const string VERSION = "1.8.1";
99
public const string AUTHOR = "Sinai";
1010
public const string GUID = "com.sinai.explorer";
1111

0 commit comments

Comments
 (0)