using System;
using System.Collections.Generic;
using System.IO;
using Dalamud.Game.Text;
using Newtonsoft.Json;
using Serilog;
namespace Dalamud.Configuration
{
///
/// Class containing Dalamud settings.
///
[Serializable]
internal class DalamudConfiguration
{
[JsonIgnore]
private string configPath;
///
/// Delegate for the event that occurs when the dalamud configuration is saved.
///
/// The current dalamud configuration.
public delegate void DalamudConfigurationSavedDelegate(DalamudConfiguration dalamudConfiguration);
///
/// Event that occurs when dalamud configuration is saved.
///
public event DalamudConfigurationSavedDelegate OnDalamudConfigurationSaved;
///
/// 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; }
///
/// Gets or sets a value indicating whether or not Dalamud testing builds should be used.
///
public bool DoDalamudTest { get; set; }
///
/// 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; }
///
/// Gets or sets a value indicating whether or not Dalamud should add buttons to the system menu.
///
public bool DoButtonsSystemMenu { get; set; } = true;
///
/// 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; }
///
/// Gets or sets a value indicating whether or not docking should be globally enabled in ImGui.
///
public bool IsDocking { get; set; }
///
/// Gets or sets a value indicating whether viewports should always be disabled.
///
public bool IsDisableViewport { get; set; } = true;
///
/// Gets or sets a value indicating whether or not navigation via a gamepad should be globally enabled in ImGui.
///
public bool IsGamepadNavigationEnabled { get; set; } = true;
///
/// 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
{
deserialized = JsonConvert.DeserializeObject(File.ReadAllText(path));
}
catch (Exception ex)
{
Log.Warning(ex, "Failed to load DalamudConfiguration at {0}", path);
deserialized = new DalamudConfiguration();
}
deserialized.configPath = path;
return deserialized;
}
///
/// Save the configuration at the path it was loaded from.
///
public void Save()
{
File.WriteAllText(this.configPath, JsonConvert.SerializeObject(this, Formatting.Indented));
this.OnDalamudConfigurationSaved?.Invoke(this);
}
}
}