Example #1
0
 public static void EndChanges(Vector4[] array, ServerSettings.Serializable setting, bool space = true)
 {
     setting.value = array.ToStringArray();
     if (space)
     {
         SetSpace();
     }
 }
    public static void FixEmptySetting(ServerSettings.Serializable setting)
    {
        setting.value = "";

        // singles
        if (setting.type == ServerSettings.Type.String)
        {
            setting.value = "";
        }
        else if (setting.type == ServerSettings.Type.Int || setting.type == ServerSettings.Type.Float ||
                 setting.type == ServerSettings.Type.Double || setting.type == ServerSettings.Type.Bool)
        {
            setting.value = 0.ToString();
        }
        else if (setting.type == ServerSettings.Type.Vector2)
        {
            setting.value = Vector2.zero.ToString();
        }
        else if (setting.type == ServerSettings.Type.Vector3)
        {
            setting.value = Vector3.zero.ToString();
        }
        else if (setting.type == ServerSettings.Type.Vector4 || setting.type == ServerSettings.Type.Quaternion)
        {
            setting.value = Vector4.zero.ToString();
        }
        else if (setting.type == ServerSettings.Type.Color)
        {
            setting.value = Color.black.ToHex();
        }

        // arrays
        else if (setting.type == ServerSettings.Type.ArrayString)
        {
            string[] array = new string[1];
            array[0]      = "";
            setting.value = array.ToStringArray();
        }
        else if (setting.type == ServerSettings.Type.ArrayInt)
        {
            setting.value = new int[1].ToStringArray();
        }
        else if (setting.type == ServerSettings.Type.ArrayFloat || setting.type == ServerSettings.Type.ArrayDouble)
        {
            setting.value = new float[1].ToStringArray();
        }
        else if (setting.type == ServerSettings.Type.ArrayBool)
        {
            setting.value = new bool[1].ToStringArray();
        }
        else if (setting.type == ServerSettings.Type.ArrayVector2)
        {
            setting.value = new Vector2[1].ToStringArray();
        }
        else if (setting.type == ServerSettings.Type.ArrayVector3)
        {
            setting.value = new Vector3[1].ToStringArray();
        }
        else if (setting.type == ServerSettings.Type.ArrayVector4 || setting.type == ServerSettings.Type.ArrayQuaternion)
        {
            setting.value = new Vector4[1].ToStringArray();
        }
        else if (setting.type == ServerSettings.Type.ArrayColor)
        {
            setting.value = new Color[1].ToStringArray();
        }
    }
    public void SaveKey(string _key)
    {
        if (!settings.ContainsKey(_key))
        {
            return;
        }

        string key = pre + _key;

        ServerSettings.Serializable setting = settings[_key];

        if (setting.type == ServerSettings.Type.String)
        {
            Save.Set(key, setting.value);
        }
        else if (setting.type == ServerSettings.Type.Int)
        {
            Save.Set(key, setting.value.ToInt32());
        }
        else if (setting.type == ServerSettings.Type.Float)
        {
            Save.Set(key, setting.value.ToFloat());
        }
        else if (setting.type == ServerSettings.Type.Double)
        {
            Save.Set(key, setting.value.ToDouble());
        }
        else if (setting.type == ServerSettings.Type.Bool)
        {
            Save.Set(key, setting.value.ToBool());
        }
        else if (setting.type == ServerSettings.Type.Vector2)
        {
            Save.Set(key, setting.value.ToVector2());
        }
        else if (setting.type == ServerSettings.Type.Vector3)
        {
            Save.Set(key, setting.value.ToVector3());
        }
        else if (setting.type == ServerSettings.Type.Vector4)
        {
            Save.Set(key, setting.value.ToVector4());
        }
        else if (setting.type == ServerSettings.Type.Quaternion)
        {
            Save.Set(key, setting.value.ToQuaternion());
        }

        else if (setting.type == ServerSettings.Type.ArrayString)
        {
            Save.Set(key, setting.value.ToArrayString());
        }
        else if (setting.type == ServerSettings.Type.ArrayInt)
        {
            Save.Set(key, setting.value.ToArrayInt32());
        }
        else if (setting.type == ServerSettings.Type.ArrayFloat)
        {
            Save.Set(key, setting.value.ToArrayFloat());
        }
        else if (setting.type == ServerSettings.Type.ArrayDouble)
        {
            Save.Set(key, setting.value.ToArrayDouble());
        }
        else if (setting.type == ServerSettings.Type.ArrayBool)
        {
            Save.Set(key, setting.value.ToArrayBool());
        }
        else if (setting.type == ServerSettings.Type.ArrayVector2)
        {
            Save.Set(key, setting.value.ToArrayVector2());
        }
        else if (setting.type == ServerSettings.Type.ArrayVector3)
        {
            Save.Set(key, setting.value.ToArrayVector3());
        }
        else if (setting.type == ServerSettings.Type.ArrayVector4)
        {
            Save.Set(key, setting.value.ToArrayVector4());
        }
        else if (setting.type == ServerSettings.Type.ArrayQuaternion)
        {
            Save.Set(key, setting.value.ToArrayQuaternion());
        }
    }