@@ -44,12 +44,9 @@ public bool CanWrite
44
44
}
45
45
}
46
46
47
- // ===== Abstract/Virtual Methods ===== //
48
-
49
47
public virtual void Init ( ) { }
50
- public abstract void DrawValue ( Rect window , float width ) ;
51
48
52
- // ===== Static Methods ===== //
49
+ public abstract void DrawValue ( Rect window , float width ) ;
53
50
54
51
/// <summary>
55
52
/// Get CacheObject from only an object instance
@@ -205,11 +202,8 @@ private static CacheObjectBase GetCacheObjectImpl(object obj, MemberInfo memberI
205
202
}
206
203
207
204
holder . m_argumentInput = new string [ holder . m_arguments . Length ] ;
208
-
209
- if ( ! holder . HasParameters )
210
- {
211
- holder . UpdateValue ( ) ;
212
- }
205
+
206
+ holder . UpdateValue ( ) ;
213
207
214
208
holder . Init ( ) ;
215
209
@@ -229,7 +223,18 @@ public static bool CanProcessArgs(ParameterInfo[] parameters)
229
223
return true ;
230
224
}
231
225
232
- // ======== Instance Methods =========
226
+ public float CalcWhitespace ( Rect window )
227
+ {
228
+ if ( ! ( this is IExpandHeight ) ) return 0f ;
229
+
230
+ float whitespace = ( this as IExpandHeight ) . WhiteSpace ;
231
+ if ( whitespace > 0 )
232
+ {
233
+ ClampLabelWidth ( window , ref whitespace ) ;
234
+ }
235
+
236
+ return whitespace ;
237
+ }
233
238
234
239
public object [ ] ParseArguments ( )
235
240
{
@@ -247,16 +252,20 @@ public object[] ParseArguments()
247
252
{
248
253
try
249
254
{
250
- parsedArgs . Add ( type . GetMethod ( "Parse" , new Type [ ] { typeof ( string ) } ) . Invoke ( null , new object [ ] { input } ) ) ;
255
+ parsedArgs . Add ( type . GetMethod ( "Parse" , new Type [ ] { typeof ( string ) } )
256
+ . Invoke ( null , new object [ ] { input } ) ) ;
251
257
}
252
258
catch
253
259
{
254
- //MelonLogger.Log($"Unable to parse '{input}' to type '{type.Name}'");
255
-
256
- // try add a null arg i guess
257
- parsedArgs . Add ( null ) ;
258
-
259
- //break;
260
+ if ( m_arguments [ i ] . HasDefaultValue )
261
+ {
262
+ parsedArgs . Add ( m_arguments [ i ] . DefaultValue ) ;
263
+ }
264
+ else
265
+ {
266
+ // Try add a null arg I guess
267
+ parsedArgs . Add ( null ) ;
268
+ }
260
269
}
261
270
}
262
271
}
@@ -271,6 +280,12 @@ public virtual void UpdateValue()
271
280
return ;
272
281
}
273
282
283
+ if ( HasParameters && ! m_isEvaluating )
284
+ {
285
+ // Need to enter parameters first
286
+ return ;
287
+ }
288
+
274
289
try
275
290
{
276
291
if ( MemInfo . MemberType == MemberTypes . Field )
@@ -332,7 +347,7 @@ public void SetValue()
332
347
}
333
348
}
334
349
335
- // ========= Instance Gui Draw ==========
350
+ // ========= Gui Draw ==========
336
351
337
352
public const float MAX_LABEL_WIDTH = 400f ;
338
353
public const string EVALUATE_LABEL = "<color=lime>Evaluate</color>" ;
@@ -375,10 +390,18 @@ public void Draw(Rect window, float labelWidth = 215f)
375
390
var input = m_argumentInput [ i ] ;
376
391
var type = m_arguments [ i ] . ParameterType . Name ;
377
392
393
+ var label = "<color=#2df7b2>" + type + "</color> <color=#a6e9e9>" + name + "</color>" ;
394
+ if ( m_arguments [ i ] . HasDefaultValue )
395
+ {
396
+ label = $ "<i>[{ label } = { m_arguments [ i ] . DefaultValue } ]</i>";
397
+ }
398
+
378
399
GUILayout . BeginHorizontal ( null ) ;
379
- GUILayout . Label ( i . ToString ( ) , new GUILayoutOption [ ] { GUILayout . Width ( 30 ) } ) ;
400
+
401
+ GUILayout . Label ( i . ToString ( ) , new GUILayoutOption [ ] { GUILayout . Width ( 20 ) } ) ;
380
402
m_argumentInput [ i ] = GUILayout . TextField ( input , new GUILayoutOption [ ] { GUILayout . Width ( 150 ) } ) ;
381
- GUILayout . Label ( "<color=#2df7b2>" + type + "</color> <color=cyan>" + name + "</color>" , null ) ;
403
+ GUILayout . Label ( label , null ) ;
404
+
382
405
GUILayout . EndHorizontal ( ) ;
383
406
}
384
407
@@ -438,7 +461,11 @@ public void Draw(Rect window, float labelWidth = 215f)
438
461
{
439
462
GUILayout . Label ( "<color=red>Reflection failed!</color> (" + ReflectionException + ")" , null ) ;
440
463
}
441
- else if ( Value == null && MemInfo ? . MemberType != MemberTypes . Method )
464
+ else if ( ( HasParameters || this is CacheMethod ) && ! m_evaluated )
465
+ {
466
+ GUILayout . Label ( $ "<color=grey><i>Not yet evaluated</i></color> (<color=#2df7b2>{ ValueTypeName } </color>)", null ) ;
467
+ }
468
+ else if ( Value == null && ! ( this is CacheMethod ) )
442
469
{
443
470
GUILayout . Label ( "<i>null (" + ValueTypeName + ")</i>" , null ) ;
444
471
}
@@ -463,7 +490,7 @@ private string GetRichTextName()
463
490
464
491
m_richTextName = $ "<color=#2df7b2>{ MemInfo . DeclaringType . Name } </color>.<color={ memberColor } >{ MemInfo . Name } </color>";
465
492
466
- if ( m_arguments . Length > 0 )
493
+ if ( m_arguments . Length > 0 || this is CacheMethod )
467
494
{
468
495
m_richTextName += "(" ;
469
496
var _params = "" ;
0 commit comments