Merge pull request #275 from kalilistic/log-settings

add open log at startup and persistent log settings
This commit is contained in:
goaaats 2021-03-29 03:53:53 +02:00 committed by GitHub
commit fc0e89cd09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 5 deletions

View file

@ -34,6 +34,8 @@ namespace Dalamud
public bool PrintPluginsWelcomeMsg { get; set; } = true;
public bool AutoUpdatePlugins { get; set; } = false;
public bool LogAutoScroll { get; set; } = true;
public bool LogOpenAtStartup { get; set; }
[JsonIgnore]
public string ConfigPath;

View file

@ -26,6 +26,9 @@ namespace Dalamud.Interface
public DalamudInterface(Dalamud dalamud) {
this.dalamud = dalamud;
if (dalamud.Configuration.LogOpenAtStartup) {
OpenLog();
}
}
private bool isImguiDrawDemoWindow = false;
@ -97,7 +100,7 @@ namespace Dalamud.Interface
ImGui.Separator();
if (ImGui.MenuItem("Open Log window"))
{
this.logWindow = new DalamudLogWindow(this.dalamud.CommandManager);
this.logWindow = new DalamudLogWindow(this.dalamud.CommandManager, this.dalamud.Configuration);
this.isImguiDrawLogWindow = true;
}
if (ImGui.BeginMenu("Set log level..."))
@ -336,7 +339,7 @@ namespace Dalamud.Interface
}
public void OpenLog() {
this.logWindow = new DalamudLogWindow(this.dalamud.CommandManager);
this.logWindow = new DalamudLogWindow(this.dalamud.CommandManager, this.dalamud.Configuration);
this.isImguiDrawLogWindow = true;
}

View file

@ -13,15 +13,20 @@ namespace Dalamud.Interface
{
class DalamudLogWindow : IDisposable {
private readonly CommandManager commandManager;
private bool autoScroll = true;
private readonly DalamudConfiguration configuration;
private bool autoScroll;
private bool openAtStartup;
private readonly List<(string line, Vector4 color)> logText = new List<(string line, Vector4 color)>();
private readonly object renderLock = new object();
private string commandText = string.Empty;
public DalamudLogWindow(CommandManager commandManager) {
public DalamudLogWindow(CommandManager commandManager, DalamudConfiguration configuration) {
this.commandManager = commandManager;
this.configuration = configuration;
this.autoScroll = configuration.LogAutoScroll;
this.openAtStartup = configuration.LogOpenAtStartup;
SerilogEventSink.Instance.OnLogLine += Serilog_OnLogLine;
}
@ -71,7 +76,14 @@ namespace Dalamud.Interface
// Options menu
if (ImGui.BeginPopup("Options"))
{
ImGui.Checkbox("Auto-scroll", ref this.autoScroll);
if (ImGui.Checkbox("Auto-scroll", ref this.autoScroll)) {
this.configuration.LogAutoScroll = this.autoScroll;
this.configuration.Save();
};
if (ImGui.Checkbox("Open at startup", ref this.openAtStartup)) {
this.configuration.LogOpenAtStartup = this.openAtStartup;
this.configuration.Save();
};
ImGui.EndPopup();
}