Exemple #1
0
 protected override void OnRenderGUI(int layer)
 {
     if (GetDictState(out CorruptionState keyState, out string infoKey, out CorruptionState valueState, out string infoValue))
     {
         foreach (DictItem item in _dictValue.Value.Items)
         {
             GUILayout.BeginVertical(GUI.skin.box);
             DrawTypeItemLabel(string.Concat("Key: ", item.KeySection.ValueString), GetTypeString(item.KeySection.GetSafeValueType(), item.KeySection.ValueType), infoKey, keyState);
             DrawTypeItemLabel(string.Concat("Value: ", item.ValueSection.ValueString), GetTypeString(item.ValueSection.GetSafeValueType(), item.ValueSection.ValueType), infoValue, valueState);
             GUILayout.EndVertical();
         }
     }
     else if (GetArrayState(out CorruptionState arrayState, out string arrayInfo))
     {
         for (int i = 0; i < _arrayValue.Value.Items.Length; i++)
         {
             SaveableValueSection entry = _arrayValue.Value.Items[i];
             GUILayout.BeginVertical(GUI.skin.box);
             DrawTypeItemLabel(string.Concat(i, ": ", entry.ValueString), GetTypeString(entry.GetSafeValueType(), entry.ValueType), arrayInfo, arrayState);
             GUILayout.EndVertical();
         }
     }
     else
     {
         GetCorruptStateWithInfo(out CorruptionState state, out string info);
         DrawTypeItemLabel(_valueSection.ValueString, GetTypeString(_valueSection.GetSafeValueType(), _valueSection.ValueType), info, state);
     }
 }
Exemple #2
0
            private bool GetArrayState(out CorruptionState arrayState, out string info)
            {
                info       = string.Empty;
                arrayState = CorruptionState.None;

                if (IsArray)
                {
                    if (_arrayValue.Value.Items.Length > 0)
                    {
                        if (_keyEntry.TryGetExpectedArrayType(out Type expectedArrayType))
                        {
                            SaveableValueSection item = _arrayValue.Value.Items[0];
                            arrayState = item.GetSafeValueType() != null && expectedArrayType.IsAssignableFrom(item.GetSafeValueType()) ? CorruptionState.None : CorruptionState.Error;

                            if (arrayState == CorruptionState.Error)
                            {
                                if (item.GetSafeValueType() == null)
                                {
                                    info = TYPE_NOT_FOUND_INFO_MESSAGE;
                                }
                                else
                                {
                                    info = string.Format(EXPECTED_TYPE_INFO_MESSAGE_F, expectedArrayType.Name, item.GetSafeValueType().Name);
                                }
                            }
                        }
                    }
                    return(true);
                }

                return(false);
            }
Exemple #3
0
 public ValItem(StorageKeyEntry keyEntry, SaveableValueSection valueSection) : base(keyEntry.StorageKey)
 {
     _keyEntry     = keyEntry;
     _valueSection = valueSection;
     if (_valueSection.GetSafeValueType() == typeof(SaveableDict))
     {
         _dictValue = (SaveableDict)_valueSection.GetValue();
     }
     else if (_valueSection.GetSafeValueType() == typeof(SaveableArray))
     {
         _arrayValue = (SaveableArray)_valueSection.GetValue();
     }
 }