mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 13:14:17 +01:00
fix: warnings, don't use singleton
This commit is contained in:
parent
c287e28832
commit
0a4051b3cc
2 changed files with 21 additions and 18 deletions
|
|
@ -60,7 +60,7 @@ namespace Dalamud.Interface.Internal
|
||||||
this.creditsWindow = new CreditsWindow(dalamud) { IsOpen = false };
|
this.creditsWindow = new CreditsWindow(dalamud) { IsOpen = false };
|
||||||
this.dataWindow = new DataWindow(dalamud) { IsOpen = false };
|
this.dataWindow = new DataWindow(dalamud) { IsOpen = false };
|
||||||
this.gamepadModeNotifierWindow = new GamepadModeNotifierWindow();
|
this.gamepadModeNotifierWindow = new GamepadModeNotifierWindow();
|
||||||
this.consoleWindow = new ConsoleWindow { IsOpen = this.dalamud.Configuration.LogOpenAtStartup };
|
this.consoleWindow = new ConsoleWindow(dalamud) { IsOpen = this.dalamud.Configuration.LogOpenAtStartup };
|
||||||
this.pluginStatWindow = new PluginStatWindow(dalamud) { IsOpen = false };
|
this.pluginStatWindow = new PluginStatWindow(dalamud) { IsOpen = false };
|
||||||
this.pluginWindow = new PluginInstallerWindow(dalamud) { IsOpen = false };
|
this.pluginWindow = new PluginInstallerWindow(dalamud) { IsOpen = false };
|
||||||
this.scratchpadWindow = new ScratchpadWindow(dalamud) { IsOpen = false };
|
this.scratchpadWindow = new ScratchpadWindow(dalamud) { IsOpen = false };
|
||||||
|
|
@ -155,7 +155,7 @@ namespace Dalamud.Interface.Internal
|
||||||
public void OpenGamepadModeNotifierWindow() => this.gamepadModeNotifierWindow.IsOpen = true;
|
public void OpenGamepadModeNotifierWindow() => this.gamepadModeNotifierWindow.IsOpen = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the <see cref="LogWindow"/>.
|
/// Opens the <see cref="ConsoleWindow"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void OpenLogWindow() => this.consoleWindow.IsOpen = true;
|
public void OpenLogWindow() => this.consoleWindow.IsOpen = true;
|
||||||
|
|
||||||
|
|
@ -227,7 +227,7 @@ namespace Dalamud.Interface.Internal
|
||||||
public void ToggleGamepadModeNotifierWindow() => this.gamepadModeNotifierWindow.Toggle();
|
public void ToggleGamepadModeNotifierWindow() => this.gamepadModeNotifierWindow.Toggle();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Toggles the <see cref="LogWindow"/>.
|
/// Toggles the <see cref="ConsoleWindow"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ToggleLogWindow() => this.consoleWindow.Toggle();
|
public void ToggleLogWindow() => this.consoleWindow.Toggle();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class ConsoleWindow : Window, IDisposable
|
internal class ConsoleWindow : Window, IDisposable
|
||||||
{
|
{
|
||||||
|
private readonly Dalamud dalamud;
|
||||||
|
|
||||||
private readonly List<LogEntry> logText = new();
|
private readonly List<LogEntry> logText = new();
|
||||||
private readonly object renderLock = new();
|
private readonly object renderLock = new();
|
||||||
|
|
||||||
|
|
@ -44,11 +46,13 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
/// Initializes a new instance of the <see cref="ConsoleWindow"/> class.
|
/// Initializes a new instance of the <see cref="ConsoleWindow"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dalamud">The Dalamud instance.</param>
|
/// <param name="dalamud">The Dalamud instance.</param>
|
||||||
public ConsoleWindow()
|
public ConsoleWindow(Dalamud dalamud)
|
||||||
: base("Dalamud Console")
|
: base("Dalamud Console")
|
||||||
{
|
{
|
||||||
this.autoScroll = Dalamud.Instance.Configuration.LogAutoScroll;
|
this.dalamud = dalamud;
|
||||||
this.openAtStartup = Dalamud.Instance.Configuration.LogOpenAtStartup;
|
|
||||||
|
this.autoScroll = this.dalamud.Configuration.LogAutoScroll;
|
||||||
|
this.openAtStartup = this.dalamud.Configuration.LogOpenAtStartup;
|
||||||
SerilogEventSink.Instance.OnLogLine += this.OnLogLine;
|
SerilogEventSink.Instance.OnLogLine += this.OnLogLine;
|
||||||
|
|
||||||
this.Size = new Vector2(500, 400);
|
this.Size = new Vector2(500, 400);
|
||||||
|
|
@ -110,22 +114,22 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
{
|
{
|
||||||
if (ImGui.Checkbox("Auto-scroll", ref this.autoScroll))
|
if (ImGui.Checkbox("Auto-scroll", ref this.autoScroll))
|
||||||
{
|
{
|
||||||
Dalamud.Instance.Configuration.LogAutoScroll = this.autoScroll;
|
this.dalamud.Configuration.LogAutoScroll = this.autoScroll;
|
||||||
Dalamud.Instance.Configuration.Save();
|
this.dalamud.Configuration.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.Checkbox("Open at startup", ref this.openAtStartup))
|
if (ImGui.Checkbox("Open at startup", ref this.openAtStartup))
|
||||||
{
|
{
|
||||||
Dalamud.Instance.Configuration.LogOpenAtStartup = this.openAtStartup;
|
this.dalamud.Configuration.LogOpenAtStartup = this.openAtStartup;
|
||||||
Dalamud.Instance.Configuration.Save();
|
this.dalamud.Configuration.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
var prevLevel = (int)Dalamud.Instance.LogLevelSwitch.MinimumLevel;
|
var prevLevel = (int)this.dalamud.LogLevelSwitch.MinimumLevel;
|
||||||
if (ImGui.Combo("Log Level", ref prevLevel, Enum.GetValues(typeof(LogEventLevel)).Cast<LogEventLevel>().Select(x => x.ToString()).ToArray(), 6))
|
if (ImGui.Combo("Log Level", ref prevLevel, Enum.GetValues(typeof(LogEventLevel)).Cast<LogEventLevel>().Select(x => x.ToString()).ToArray(), 6))
|
||||||
{
|
{
|
||||||
Dalamud.Instance.LogLevelSwitch.MinimumLevel = (LogEventLevel)prevLevel;
|
this.dalamud.LogLevelSwitch.MinimumLevel = (LogEventLevel)prevLevel;
|
||||||
Dalamud.Instance.Configuration.LogLevel = (LogEventLevel)prevLevel;
|
this.dalamud.Configuration.LogLevel = (LogEventLevel)prevLevel;
|
||||||
Dalamud.Instance.Configuration.Save();
|
this.dalamud.Configuration.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TEST */
|
/* TEST */
|
||||||
|
|
@ -321,7 +325,6 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
if (getFocus)
|
if (getFocus)
|
||||||
ImGui.SetKeyboardFocusHere(-1); // Auto focus previous widget
|
ImGui.SetKeyboardFocusHere(-1); // Auto focus previous widget
|
||||||
|
|
||||||
|
|
||||||
if (hadColor)
|
if (hadColor)
|
||||||
ImGui.PopStyleColor();
|
ImGui.PopStyleColor();
|
||||||
|
|
||||||
|
|
@ -353,10 +356,10 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastCmdSuccess = Dalamud.Instance.CommandManager.ProcessCommand("/" + this.commandText);
|
this.lastCmdSuccess = this.dalamud.CommandManager.ProcessCommand("/" + this.commandText);
|
||||||
this.commandText = string.Empty;
|
this.commandText = string.Empty;
|
||||||
|
|
||||||
//TODO: Force scroll to bottom
|
// TODO: Force scroll to bottom
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -384,7 +387,7 @@ namespace Dalamud.Interface.Internal.Windows
|
||||||
|
|
||||||
// TODO: Improve this, add partial completion
|
// TODO: Improve this, add partial completion
|
||||||
// https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp#L6443-L6484
|
// https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp#L6443-L6484
|
||||||
var candidates = Dalamud.Instance.CommandManager.Commands.Where(x => x.Key.Contains("/" + words[0])).ToList();
|
var candidates = this.dalamud.CommandManager.Commands.Where(x => x.Key.Contains("/" + words[0])).ToList();
|
||||||
if (candidates.Count > 0)
|
if (candidates.Count > 0)
|
||||||
{
|
{
|
||||||
ptr.DeleteChars(0, ptr.BufTextLen);
|
ptr.DeleteChars(0, ptr.BufTextLen);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue