@@ -28,46 +28,38 @@ public enum ValueState
28
28
public abstract class CacheObjectBase
29
29
{
30
30
public ICacheObjectController Owner { get ; set ; }
31
-
32
31
public CacheObjectCell CellView { get ; internal set ; }
33
32
34
33
public object Value { get ; protected set ; }
35
34
public Type FallbackType { get ; protected set ; }
36
- public bool LastValueWasNull { get ; private set ; }
37
-
38
- public ValueState State = ValueState . NotEvaluated ;
39
- public Type LastValueType ;
35
+ public ValueState State { get ; set ; }
36
+ public Exception LastException { get ; protected set ; }
37
+ bool valueIsNull ;
38
+ Type currentValueType ;
40
39
40
+ // InteractiveValues
41
41
public InteractiveValue IValue { get ; private set ; }
42
42
public Type CurrentIValueType { get ; private set ; }
43
43
public bool SubContentShowWanted { get ; private set ; }
44
44
45
+ // UI
45
46
public string NameLabelText { get ; protected set ; }
46
47
public string NameLabelTextRaw { get ; protected set ; }
47
48
public string ValueLabelText { get ; protected set ; }
48
49
50
+ // Abstract
49
51
public abstract bool ShouldAutoEvaluate { get ; }
50
52
public abstract bool HasArguments { get ; }
51
53
public abstract bool CanWrite { get ; }
52
- public Exception LastException { get ; protected set ; }
54
+
55
+ protected const string NOT_YET_EVAL = "<color=grey>Not yet evaluated</color>" ;
53
56
54
57
public virtual void SetFallbackType ( Type fallbackType )
55
58
{
56
59
this . FallbackType = fallbackType ;
57
60
this . ValueLabelText = GetValueLabel ( ) ;
58
61
}
59
62
60
- protected const string NOT_YET_EVAL = "<color=grey>Not yet evaluated</color>" ;
61
-
62
- public virtual void ReleasePooledObjects ( )
63
- {
64
- if ( this . IValue != null )
65
- ReleaseIValue ( ) ;
66
-
67
- if ( this . CellView != null )
68
- UnlinkFromView ( ) ;
69
- }
70
-
71
63
public virtual void SetView ( CacheObjectCell cellView )
72
64
{
73
65
this . CellView = cellView ;
@@ -86,6 +78,15 @@ public virtual void UnlinkFromView()
86
78
this . IValue . UIRoot . transform . SetParent ( InactiveIValueHolder . transform , false ) ;
87
79
}
88
80
81
+ public virtual void ReleasePooledObjects ( )
82
+ {
83
+ if ( this . IValue != null )
84
+ ReleaseIValue ( ) ;
85
+
86
+ if ( this . CellView != null )
87
+ UnlinkFromView ( ) ;
88
+ }
89
+
89
90
// Updating and applying values
90
91
91
92
// The only method which sets the CacheObjectBase.Value
@@ -130,18 +131,18 @@ protected virtual void ProcessOnEvaluate()
130
131
131
132
if ( LastException != null )
132
133
{
133
- LastValueWasNull = true ;
134
- LastValueType = FallbackType ;
134
+ valueIsNull = true ;
135
+ currentValueType = FallbackType ;
135
136
State = ValueState . Exception ;
136
137
}
137
138
else if ( Value . IsNullOrDestroyed ( ) )
138
139
{
139
- LastValueWasNull = true ;
140
+ valueIsNull = true ;
140
141
State = GetStateForType ( FallbackType ) ;
141
142
}
142
143
else
143
144
{
144
- LastValueWasNull = false ;
145
+ valueIsNull = false ;
145
146
State = GetStateForType ( Value . GetActualType ( ) ) ;
146
147
}
147
148
@@ -163,10 +164,10 @@ protected virtual void ProcessOnEvaluate()
163
164
164
165
public ValueState GetStateForType ( Type type )
165
166
{
166
- if ( LastValueType == type && ( State != ValueState . Exception || LastException != null ) )
167
+ if ( currentValueType == type && ( State != ValueState . Exception || LastException != null ) )
167
168
return State ;
168
169
169
- LastValueType = type ;
170
+ currentValueType = type ;
170
171
if ( type == typeof ( bool ) )
171
172
return ValueState . Boolean ;
172
173
else if ( type . IsPrimitive || type == typeof ( decimal ) )
@@ -189,7 +190,7 @@ public ValueState GetStateForType(Type type)
189
190
190
191
protected string GetValueLabel ( )
191
192
{
192
- string label = "" ;
193
+ string label = string . Empty ;
193
194
194
195
switch ( State )
195
196
{
@@ -206,19 +207,19 @@ protected string GetValueLabel()
206
207
207
208
// and valuestruct also doesnt want it if we can parse it
208
209
case ValueState . ValueStruct :
209
- if ( ParseUtility . CanParse ( LastValueType ) )
210
+ if ( ParseUtility . CanParse ( currentValueType ) )
210
211
return null ;
211
212
break ;
212
213
213
214
// string wants it trimmed to max 200 chars
214
215
case ValueState . String :
215
- if ( ! LastValueWasNull )
216
+ if ( ! valueIsNull )
216
217
return $ "\" { ToStringUtility . PruneString ( Value as string , 200 , 5 ) } \" ";
217
218
break ;
218
219
219
220
// try to prefix the count of the collection for lists and dicts
220
221
case ValueState . Collection :
221
- if ( ! LastValueWasNull )
222
+ if ( ! valueIsNull )
222
223
{
223
224
if ( Value is IList iList )
224
225
label = $ "[{ iList . Count } ] ";
@@ -230,7 +231,7 @@ protected string GetValueLabel()
230
231
break ;
231
232
232
233
case ValueState . Dictionary :
233
- if ( ! LastValueWasNull )
234
+ if ( ! valueIsNull )
234
235
{
235
236
if ( Value is IDictionary iDict )
236
237
label = $ "[{ iDict . Count } ] ";
@@ -291,7 +292,7 @@ public virtual void SetDataToCell(CacheObjectCell cell)
291
292
SetValueState ( cell , new ( false , typeLabelActive : true , inputActive : true , applyActive : CanWrite ) ) ;
292
293
break ;
293
294
case ValueState . String :
294
- if ( LastValueWasNull )
295
+ if ( valueIsNull )
295
296
SetValueState ( cell , new ( true , subContentButtonActive : true ) ) ;
296
297
else
297
298
SetValueState ( cell , new ( true , false , SignatureHighlighter . StringOrange , subContentButtonActive : true ) ) ;
@@ -301,17 +302,17 @@ public virtual void SetDataToCell(CacheObjectCell cell)
301
302
break ;
302
303
case ValueState . Color :
303
304
case ValueState . ValueStruct :
304
- if ( ParseUtility . CanParse ( LastValueType ) )
305
+ if ( ParseUtility . CanParse ( currentValueType ) )
305
306
SetValueState ( cell , new ( false , false , null , true , false , true , CanWrite , true , true ) ) ;
306
307
else
307
308
SetValueState ( cell , new ( true , inspectActive : true , subContentButtonActive : true ) ) ;
308
309
break ;
309
310
case ValueState . Collection :
310
311
case ValueState . Dictionary :
311
- SetValueState ( cell , new ( true , inspectActive : ! LastValueWasNull , subContentButtonActive : ! LastValueWasNull ) ) ;
312
+ SetValueState ( cell , new ( true , inspectActive : ! valueIsNull , subContentButtonActive : ! valueIsNull ) ) ;
312
313
break ;
313
314
case ValueState . Unsupported :
314
- SetValueState ( cell , new ( true , inspectActive : ! LastValueWasNull ) ) ;
315
+ SetValueState ( cell , new ( true , inspectActive : ! valueIsNull ) ) ;
315
316
break ;
316
317
}
317
318
@@ -333,7 +334,7 @@ protected virtual void SetValueState(CacheObjectCell cell, ValueStateArgs args)
333
334
// Type label (for primitives)
334
335
cell . TypeLabel . gameObject . SetActive ( args . typeLabelActive ) ;
335
336
if ( args . typeLabelActive )
336
- cell . TypeLabel . text = SignatureHighlighter . Parse ( LastValueType , false ) ;
337
+ cell . TypeLabel . text = SignatureHighlighter . Parse ( currentValueType , false ) ;
337
338
338
339
// toggle for bools
339
340
cell . Toggle . gameObject . SetActive ( args . toggleActive ) ;
@@ -348,7 +349,7 @@ protected virtual void SetValueState(CacheObjectCell cell, ValueStateArgs args)
348
349
cell . InputField . UIRoot . SetActive ( args . inputActive ) ;
349
350
if ( args . inputActive )
350
351
{
351
- cell . InputField . Text = ParseUtility . ToStringForInput ( Value , LastValueType ) ;
352
+ cell . InputField . Text = ParseUtility . ToStringForInput ( Value , currentValueType ) ;
352
353
cell . InputField . Component . readOnly = ! CanWrite ;
353
354
}
354
355
@@ -357,12 +358,12 @@ protected virtual void SetValueState(CacheObjectCell cell, ValueStateArgs args)
357
358
358
359
// Inspect button only if last value not null.
359
360
if ( cell . InspectButton != null )
360
- cell . InspectButton . Component . gameObject . SetActive ( args . inspectActive && ! LastValueWasNull ) ;
361
+ cell . InspectButton . Component . gameObject . SetActive ( args . inspectActive && ! valueIsNull ) ;
361
362
362
363
// set subcontent button if needed, and for null strings and exceptions
363
364
cell . SubContentButton . Component . gameObject . SetActive (
364
365
args . subContentButtonActive
365
- && ( ! LastValueWasNull || State == ValueState . String || State == ValueState . Exception ) ) ;
366
+ && ( ! valueIsNull || State == ValueState . String || State == ValueState . Exception ) ) ;
366
367
}
367
368
368
369
// CacheObjectCell Apply
@@ -373,7 +374,7 @@ public virtual void OnCellApplyClicked()
373
374
SetUserValue ( this . CellView . Toggle . isOn ) ;
374
375
else
375
376
{
376
- if ( ParseUtility . TryParse ( CellView . InputField . Text , LastValueType , out object value , out Exception ex ) )
377
+ if ( ParseUtility . TryParse ( CellView . InputField . Text , currentValueType , out object value , out Exception ex ) )
377
378
{
378
379
SetUserValue ( value ) ;
379
380
}
0 commit comments