public bool GetBooleanPreference(PreferenceKey key) { if (_preferences.ContainsKey(key)) { return(_preferences[key]); } return(true); }
//------------------------Preference methods for storing and retrieving objects---------------------------------------- public void UpdateCustomPref(PreferenceKey key, object obj) { string json = JsonUtility.ToJson(obj); Debug.Log(json); PlayerPrefs.SetString(key.ToString(), json); Debug.Log("Custom Preference Updated"); }
public bool GetBoolPref(PreferenceKey Pref) { if (PlayerPrefs.HasKey(Pref.ToString())) { if (PlayerPrefs.GetInt(Pref.ToString()) == 1) { return(true); } } return(false); }
public static string GetValue(PreferenceKey key) { int keyIndex = (int)key; if (UserPreferences is null) { InitializePreferences(); } if (UserPreferences.ContainsKey(keyIndex)) { return(UserPreferences[keyIndex]); } else { return(""); } }
public static bool LoadAndDeserializePreferences() { string prefsPath = GetPreferencesFilePath(); if (!File.Exists(prefsPath)) { return(false); } string[] iniRows = File.ReadAllText(prefsPath).Replace("\r", "").Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string iniRow in iniRows) { string[] keyValue = iniRow.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries); PreferenceKey key = (PreferenceKey)int.Parse(keyValue[0]); string value = Encoding.UTF8.GetString(BitUtility.BytesFromHex(keyValue[1])); SetValue(key, value, false); } return(true); }
public bool GetBooleanPreference(PreferenceKey key) { Context ctx = Application.Context; ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(ctx); switch (key) { case PreferenceKey.remember_keyfile: return(prefs.GetBoolean(ctx.Resources.GetString(Resource.String.keyfile_key), ctx.Resources.GetBoolean(Resource.Boolean.keyfile_default))); case PreferenceKey.UseFileTransactions: return(prefs.GetBoolean(ctx.Resources.GetString(Resource.String.UseFileTransactions_key), true)); case PreferenceKey.CheckForFileChangesOnSave: return(prefs.GetBoolean(ctx.Resources.GetString(Resource.String.CheckForFileChangesOnSave_key), true)); default: throw new Exception("unexpected key!"); } }
public static void SetValue(PreferenceKey key, string newValue, bool save = true) { int keyIndex = (int)key; if (UserPreferences is null) { InitializePreferences(); } if (UserPreferences.ContainsKey(keyIndex)) { UserPreferences[keyIndex] = newValue; } else { UserPreferences.Add(keyIndex, newValue); } if (save) { SerializeAndSavePreferences(); } }
public string GetStringPref(PreferenceKey Pref) { return(PlayerPrefs.GetString(Pref.ToString())); }
public void UpdateStringPref(PreferenceKey pref, string value) { PlayerPrefs.SetString(pref.ToString(), value); }
public float GetFloatPref(PreferenceKey Pref, float Default) { return(PlayerPrefs.GetFloat(Pref.ToString(), Default)); }
public void UpdateFloatPref(PreferenceKey Pref, float value) { PlayerPrefs.SetFloat(Pref.ToString(), value); }
public void SetPreference(PreferenceKey key, bool value) { _preferences[key] = value; }
public void UpdateBoolpref(PreferenceKey Pref, bool value) { PlayerPrefs.SetInt(Pref.ToString(), (value ? 1 : 0)); }
public object GetCustomPref(PreferenceKey key, Type t) { string json = PlayerPrefs.GetString(key.ToString()); return(JsonUtility.FromJson(json, t)); }
public bool GetBooleanPreference(PreferenceKey key) { if (_preferences.ContainsKey(key)) return _preferences[key]; return true; }
public void UpdateIntPref(PreferenceKey Pref, int value) { PlayerPrefs.SetInt(Pref.ToString(), value); }
public int GetIntPref(PreferenceKey Pref, int Default) { return(PlayerPrefs.GetInt(Pref.ToString(), Default)); }
public UserPreferencesInput(PreferenceKey preferenceKey, string preferenceValue) { PreferenceKey = preferenceKey; PreferenceValue = preferenceValue; }