public static string GetString(string section, string name) { MelonPreferences_Category category = MelonPreferences.GetCategory(section); if (category == null) { return(null); } MelonPreferences_Entry entry = category.GetEntry(name); if (entry == null) { return(null); } return(entry.GetValueAsString()); }
public static void SetString(string section, string name, string value) { MelonPreferences_Category category = MelonPreferences.GetCategory(section); if (category == null) { return; } MelonPreferences_Entry entry = category.GetEntry(name); if (entry == null) { return; } switch (entry) { case MelonPreferences_Entry <string> stringEntry: stringEntry.Value = value; break; case MelonPreferences_Entry <int> intEntry: if (int.TryParse(value, out var parsedInt)) { intEntry.Value = parsedInt; } break; case MelonPreferences_Entry <float> floatEntry: if (float.TryParse(value, out var parsedFloat)) { floatEntry.Value = parsedFloat; } break; case MelonPreferences_Entry <bool> boolEntry: if (value.ToLower().StartsWith("true") || value.ToLower().StartsWith("false")) { boolEntry.Value = value.ToLower().StartsWith("true"); } break; } }
public static string GetCategoryDisplayName(string key) => MelonPreferences.GetCategory(key)?.DisplayName;