/*
<copyright file="BGEditorEMParameters.cs" company="BansheeGz">
    Copyright (c) 2019-2024 All Rights Reserved
</copyright>
*/

using UnityEditor;

namespace BansheeGz.BGDatabase.Editor
{
    public static class BGEditorEMParameters
    {
        public static void SetBool(string key, bool value) => EditorPrefs.SetBool(key, value);

        public static void SetBool(string key, ref bool b, bool value)
        {
            b = value;
            SetBool(key, value);
        }

        public static void SetInt(string key, int value) => EditorPrefs.SetInt(key, value);

        public static void SetInt(string key, ref int b, int value)
        {
            b = value;
            SetInt(key, value);
        }

        public static void SetString(string key, string value) => EditorPrefs.SetString(key, value);

        public static void SetString(string key, ref string b, string value)
        {
            b = value;
            SetString(key, value);
        }

        public static void SetFloat(string key, float value) => EditorPrefs.SetFloat(key, value);

        public static void SetFloat(string key, ref float b, float value)
        {
            b = value;
            SetFloat(key, value);
        }

        public static long ReadStringAsLong(string key)
        {
            var value = EditorPrefs.GetString(key);
            if (string.IsNullOrEmpty(value)) return 0;
            try
            {
                return long.Parse(value);
            }
            catch
            {
                return 0;
            }
        }

        public static bool GetBool(string key) => EditorPrefs.GetBool(key);
        public static string GetString(string key) => EditorPrefs.GetString(key);

        public static int GetInt(string key) => EditorPrefs.GetInt(key);
    }
}