Beispiel #1
0
        }                                                   // draw custom editor gui only for init values

        public virtual string Equal(DataboxType _value)
        {
            return("");
        }                                                                   // Used for the cloud sync comparison. Compare the input value with the current value and return a string if there's a change.
 /// <summary>
 /// Used for the cloud sync comparison. Compare the input value with the current value and return a string if there's a change.
 /// </summary>
 /// <param name="_value"></param>
 /// <returns></returns>
 public virtual string Equal(DataboxType _value)
 {
     return("");
 }
Beispiel #3
0
        // Compare changed DB
        public static ChangeLog Compare(OrderedDictionary <string, DataboxObject.Database> _oldDB, OrderedDictionary <string, DataboxObject.Database> _newDB)
        {
            var _modifiedTables  = new List <string>();
            var _modifiedEntries = new List <string>();
            var _modifiedFields  = new List <string>();
            var _modifiedValues  = new List <string>();

            foreach (var db in _oldDB.Keys)
            {
                DataboxObject.Database _existingDB = null;
                if (_newDB.TryGetValue(db, out _existingDB))
                {
                    foreach (var entry in _oldDB[db].entries.Keys)
                    {
                        DataboxObject.DatabaseEntry _existingEntry = null;
                        if (_newDB[db].entries.TryGetValue(entry, out _existingEntry))
                        {
                            foreach (var value in _oldDB[db].entries[entry].data.Keys)
                            {
                                Dictionary <System.Type, DataboxType> _existingValue = null;
                                if (_newDB[db].entries[entry].data.TryGetValue(value, out _existingValue))
                                {
                                    // Compare values
                                    for (int i = 0; i < DataboxEditor.allTypes.Count; i++)
                                    {
                                        DataboxType _t = null;
                                        if (_newDB[db].entries[entry].data[value].TryGetValue(System.Type.GetType(DataboxEditor.allTypes[i]), out _t))
                                        {
                                            DataboxType _e = null;
                                            if (_oldDB[db].entries[entry].data[value].TryGetValue(System.Type.GetType(DataboxEditor.allTypes[i]), out _e))
                                            {
                                                var _results = _t.Equal(_e);

                                                if (!string.IsNullOrEmpty(_results))
                                                {
                                                    _modifiedValues.Add(db + " -> " + entry + " -> " + value + " ( " + _results + " ) ");
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    _modifiedFields.Add(db + " -> " + entry + " -> " + value);
                                }
                            }
                        }
                        else
                        {
                            _modifiedEntries.Add(db + " -> " + entry);
                        }
                    }
                }
                else
                {
                    _modifiedTables.Add(db);
                }
            }

            var _m = new ChangeLog();

            _m.tables  = _modifiedTables;
            _m.entries = _modifiedEntries;
            _m.fields  = _modifiedFields;
            _m.values  = _modifiedValues;

            return(_m);
        }
        void OnValueChanged(DataboxType _data)
        {
            // convert value
            var    _type = _data.GetType().ToString();
            object _v    = null;
            object _init = null;

            switch (_type)
            {
            case "FloatType":
                var _f = (FloatType)_data;
                _v    = _f.Value;
                _init = _f.InitValue;
                break;

            case "IntType":
                var _i = (IntType)_data;
                _v    = _i.Value;
                _init = _i.InitValue;
                break;

            case "StringType":
                var _s = (StringType)_data;
                _v = _s.Value;
                break;

            case "BoolType":
                var _b = (BoolType)_data;
                _v = _b.Value;
                break;
            }

            if (_v != null)
            {
                switch (uiType)
                {
                case UIType.Slider:
                    slider.value = (float)_v;
                    break;

                case UIType.InputField:
                    inputField.text = _v.ToString();
                    break;

                case UIType.Toggle:
                    toggle.isOn = (bool)_v;
                    break;

                case UIType.Text:
                    text.text = _v.ToString();
                    break;

                case UIType.Dropdown:
                    dropdown.value = (int)_v;
                    break;

                case UIType.RectTransform:
                    rTransform.sizeDelta = new Vector2(((float)_v * rTransformWidth) / (float)_init, rTransform.sizeDelta.y);
                    break;
                }
            }
        }