Exemplo n.º 1
0
 public void SaveToFile(bool printmsg = true)
 {
     Preferences.IO.File currentfile = File;
     if (currentfile == null)
     {
         currentfile = MelonPreferences.DefaultFile;
     }
     foreach (MelonPreferences_Entry entry in Entries)
     {
         if (!(entry.DontSaveDefault && entry.GetValueAsString() == entry.GetDefaultValueAsString()) && entry.GetValueAsString() != null)
         {
             currentfile.InsertIntoDocument(Identifier, entry.Identifier, entry.Save());
         }
     }
     try
     {
         currentfile.Save();
     }
     catch (Exception ex)
     {
         MelonLogger.Error($"Error while Saving Preferences to {currentfile.FilePath}: {ex}");
         currentfile.WasError = true;
     }
     if (printmsg)
     {
         MelonLogger.Msg($"MelonPreferences Saved to {currentfile.FilePath}");
     }
     MelonHandler.OnPreferencesSaved();
 }