public CumPreference(string value, CumPreferenceType type, bool hidden, string displayText) { Value = value; ValueEdited = value; Type = type; Hidden = hidden; DisplayText = displayText; }
private static void Register(string section, string name, string defaultValue, string displayText, CumPreferenceType type, bool hideFromList) { if (prefs.TryGetValue(section, out Dictionary <string, CumPreference> prefsInSection)) { if (prefsInSection.TryGetValue(name, out CumPreference pref)) { CumLogger.LogError("Trying to registered Pref " + section + ":" + name + " more than one time"); } else { string toStoreValue = defaultValue; if (ConfigFile.HasKey(section, name)) { toStoreValue = ConfigFile.GetString(section, name, defaultValue); } else { ConfigFile.SetString(section, name, defaultValue); } prefsInSection.Add(name, new CumPreference(toStoreValue, type, hideFromList, (displayText ?? "") == "" ? name : displayText)); } } else { Dictionary <string, CumPreference> dic = new Dictionary <string, CumPreference>(); string toStoreValue = defaultValue; if (ConfigFile.HasKey(section, name)) { toStoreValue = ConfigFile.GetString(section, name, defaultValue); } else { ConfigFile.SetString(section, name, defaultValue); } dic.Add(name, new CumPreference(toStoreValue, type, hideFromList, (displayText ?? "") == "" ? name : displayText)); prefs.Add(section, dic); } }