mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 21:24:16 +01:00
chore: clean up config to not require paths
This commit is contained in:
parent
aaf271886c
commit
4f92d5c79e
3 changed files with 18 additions and 9 deletions
|
|
@ -31,12 +31,21 @@ namespace Dalamud
|
|||
|
||||
public string LastVersion { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string ConfigPath;
|
||||
|
||||
public static DalamudConfiguration Load(string path) {
|
||||
return JsonConvert.DeserializeObject<DalamudConfiguration>(File.ReadAllText(path));
|
||||
var deserialized = JsonConvert.DeserializeObject<DalamudConfiguration>(File.ReadAllText(path));
|
||||
deserialized.ConfigPath = path;
|
||||
|
||||
return deserialized;
|
||||
}
|
||||
|
||||
public void Save(string path) {
|
||||
File.WriteAllText(path, JsonConvert.SerializeObject(this, Formatting.Indented));
|
||||
/// <summary>
|
||||
/// Save the configuration at the path it was loaded from.
|
||||
/// </summary>
|
||||
public void Save() {
|
||||
File.WriteAllText(this.ConfigPath, JsonConvert.SerializeObject(this, Formatting.Indented));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -501,7 +501,7 @@ namespace Dalamud {
|
|||
|
||||
this.Configuration.BadWords.Add(arguments);
|
||||
|
||||
this.Configuration.Save(this.StartInfo.ConfigurationPath);
|
||||
this.Configuration.Save();
|
||||
|
||||
Framework.Gui.Chat.Print(string.Format(Loc.Localize("DalamudMuted", "Muted \"{0}\"."), arguments));
|
||||
}
|
||||
|
|
@ -515,7 +515,7 @@ namespace Dalamud {
|
|||
return;
|
||||
}
|
||||
|
||||
this.Configuration.Save(this.StartInfo.ConfigurationPath);
|
||||
this.Configuration.Save();
|
||||
|
||||
foreach (var word in this.Configuration.BadWords) Framework.Gui.Chat.Print($"\"{word}\"");
|
||||
}
|
||||
|
|
@ -526,7 +526,7 @@ namespace Dalamud {
|
|||
|
||||
this.Configuration.BadWords.RemoveAll(x => x == arguments);
|
||||
|
||||
this.Configuration.Save(this.StartInfo.ConfigurationPath);
|
||||
this.Configuration.Save();
|
||||
|
||||
Framework.Gui.Chat.Print(string.Format(Loc.Localize("DalamudUnmuted", "Unmuted \"{0}\"."), arguments));
|
||||
}
|
||||
|
|
@ -622,7 +622,7 @@ namespace Dalamud {
|
|||
|
||||
Framework.Gui.Chat.Print($"Set bonus notifications for {argParts[0]}({rouletteIndex}) to {role}");
|
||||
Framework.Gui.Chat.Print(string.Format(Loc.Localize("DalamudBonusSet", "Set bonus notifications for {0}({1}) to {2}"), argParts[0], rouletteIndex, role));
|
||||
this.Configuration.Save(this.StartInfo.ConfigurationPath);
|
||||
this.Configuration.Save();
|
||||
|
||||
return;
|
||||
|
||||
|
|
@ -659,7 +659,7 @@ namespace Dalamud {
|
|||
this.Configuration.LanguageOverride = null;
|
||||
}
|
||||
|
||||
this.Configuration.Save(this.StartInfo.ConfigurationPath);
|
||||
this.Configuration.Save();
|
||||
}
|
||||
|
||||
private int RouletteSlugToKey(string slug) => slug.ToLower() switch {
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ namespace Dalamud.Game {
|
|||
});
|
||||
|
||||
this.dalamud.Configuration.LastVersion = assemblyVersion;
|
||||
this.dalamud.Configuration.Save(this.dalamud.StartInfo.ConfigurationPath);
|
||||
this.dalamud.Configuration.Save();
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue