Example #1
0
 public MelonPreference(string value, MelonPreferenceType type, bool hidden, string displayText)
 {
     Value       = value;
     ValueEdited = value;
     Type        = type;
     Hidden      = hidden;
     DisplayText = displayText;
 }
Example #2
0
 private static void Register(string section, string name, string defaultValue, string displayText, MelonPreferenceType type, bool hideFromList)
 {
     if (prefs.TryGetValue(section, out Dictionary <string, MelonPreference> prefsInSection))
     {
         if (prefsInSection.TryGetValue(name, out MelonPreference pref))
         {
             MelonLogger.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 MelonPreference(toStoreValue, type, hideFromList, (displayText ?? "") == "" ? name : displayText));
         }
     }
     else
     {
         Dictionary <string, MelonPreference> dic = new Dictionary <string, MelonPreference>();
         string toStoreValue = defaultValue;
         if (ConfigFile.HasKey(section, name))
         {
             toStoreValue = ConfigFile.GetString(section, name, defaultValue);
         }
         else
         {
             ConfigFile.SetString(section, name, defaultValue);
         }
         dic.Add(name, new MelonPreference(toStoreValue, type, hideFromList, (displayText ?? "") == "" ? name : displayText));
         prefs.Add(section, dic);
     }
 }