From 7a93659dd229dd28ea76f881b0fd22f8edcc794d Mon Sep 17 00:00:00 2001
From: goat <16760685+goaaats@users.noreply.github.com>
Date: Thu, 1 Apr 2021 22:52:02 +0200
Subject: [PATCH] refactor: new code style in DalamudConfiguration.cs
---
Dalamud/Configuration/DalamudConfiguration.cs | 92 +++++++++++++++++--
Dalamud/Dalamud.cs | 1 +
Dalamud/Interface/DalamudLogWindow.cs | 2 +
3 files changed, 86 insertions(+), 9 deletions(-)
diff --git a/Dalamud/Configuration/DalamudConfiguration.cs b/Dalamud/Configuration/DalamudConfiguration.cs
index 1ee8af5ad..342fd1908 100644
--- a/Dalamud/Configuration/DalamudConfiguration.cs
+++ b/Dalamud/Configuration/DalamudConfiguration.cs
@@ -1,46 +1,119 @@
using System;
using System.Collections.Generic;
using System.IO;
-using Dalamud.Configuration;
+
using Dalamud.Game.Chat;
using Newtonsoft.Json;
using Serilog;
-namespace Dalamud
+namespace Dalamud.Configuration
{
+ ///
+ /// Class containing Dalamud settings.
+ ///
[Serializable]
internal class DalamudConfiguration
{
+ [JsonIgnore]
+ private string configPath;
+
+ ///
+ /// Gets or sets a list of muted works.
+ ///
public List BadWords { get; set; }
+ ///
+ /// Gets or sets a value indicating whether or not the taskbar should flash once a duty is found.
+ ///
public bool DutyFinderTaskbarFlash { get; set; } = true;
+
+ ///
+ /// Gets or sets a value indicating whether or not a message should be sent in chat once a duty is found.
+ ///
public bool DutyFinderChatMessage { get; set; } = true;
+ ///
+ /// Gets or sets the language code to load Dalamud localization with.
+ ///
public string LanguageOverride { get; set; }
+ ///
+ /// Gets or sets the last loaded Dalamud version.
+ ///
public string LastVersion { get; set; }
+ ///
+ /// Gets or sets the chat type used by default for plugin messages.
+ ///
public XivChatType GeneralChatType { get; set; } = XivChatType.Debug;
+ ///
+ /// Gets or sets a value indicating whether or not plugin testing builds should be shown.
+ ///
public bool DoPluginTest { get; set; } = false;
+
+ ///
+ /// Gets or sets a value indicating whether or not Dalamud testing builds should be used.
+ ///
public bool DoDalamudTest { get; set; } = false;
+
+ ///
+ /// Gets or sets a list of custom repos.
+ ///
public List ThirdRepoList { get; set; } = new List();
+
+ ///
+ /// Gets or sets a list of hidden plugins.
+ ///
public List HiddenPluginInternalName { get; set; } = new List();
+ ///
+ /// Gets or sets the global UI scale.
+ ///
public float GlobalUiScale { get; set; } = 1.0f;
+
+ ///
+ /// Gets or sets a value indicating whether or not plugin UI should be hidden.
+ ///
public bool ToggleUiHide { get; set; } = true;
+
+ ///
+ /// Gets or sets a value indicating whether or not plugin UI should be hidden during cutscenes.
+ ///
public bool ToggleUiHideDuringCutscenes { get; set; } = true;
+
+ ///
+ /// Gets or sets a value indicating whether or not plugin UI should be hidden during GPose.
+ ///
public bool ToggleUiHideDuringGpose { get; set; } = true;
+ ///
+ /// Gets or sets a value indicating whether or not a message containing detailed plugin information should be sent at login.
+ ///
public bool PrintPluginsWelcomeMsg { get; set; } = true;
+
+ ///
+ /// Gets or sets a value indicating whether or not plugins should be auto-updated.
+ ///
public bool AutoUpdatePlugins { get; set; } = false;
+
+ ///
+ /// Gets or sets a value indicating whether or not the debug log should scroll automatically.
+ ///
public bool LogAutoScroll { get; set; } = true;
+
+ ///
+ /// Gets or sets a value indicating whether or not the debug log should open at startup.
+ ///
public bool LogOpenAtStartup { get; set; }
- [JsonIgnore]
- public string ConfigPath;
-
- public static DalamudConfiguration Load(string path) {
+ ///
+ /// Load a configuration from the provided path.
+ ///
+ /// The path to load the configuration file from.
+ /// The deserialized configuration file.
+ public static DalamudConfiguration Load(string path)
+ {
DalamudConfiguration deserialized;
try
{
@@ -52,7 +125,7 @@ namespace Dalamud
deserialized = new DalamudConfiguration();
}
- deserialized.ConfigPath = path;
+ deserialized.configPath = path;
return deserialized;
}
@@ -60,8 +133,9 @@ namespace Dalamud
///
/// Save the configuration at the path it was loaded from.
///
- public void Save() {
- File.WriteAllText(this.ConfigPath, JsonConvert.SerializeObject(this, Formatting.Indented));
+ public void Save()
+ {
+ File.WriteAllText(this.configPath, JsonConvert.SerializeObject(this, Formatting.Indented));
}
}
}
diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs
index 330770064..78a3404a6 100644
--- a/Dalamud/Dalamud.cs
+++ b/Dalamud/Dalamud.cs
@@ -3,6 +3,7 @@ using System.Diagnostics;
using System.IO;
using System.Threading;
+using Dalamud.Configuration;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.Chat.SeStringHandling;
diff --git a/Dalamud/Interface/DalamudLogWindow.cs b/Dalamud/Interface/DalamudLogWindow.cs
index 9da1269be..6dbebdb6d 100644
--- a/Dalamud/Interface/DalamudLogWindow.cs
+++ b/Dalamud/Interface/DalamudLogWindow.cs
@@ -4,6 +4,8 @@ using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
+
+using Dalamud.Configuration;
using Dalamud.Game.Command;
using ImGuiNET;
using Serilog;