pass in mainform to log window stuff

This commit is contained in:
adelikat 2019-12-29 14:16:44 -06:00
parent c2ff680992
commit ab812ab081
4 changed files with 11 additions and 9 deletions

View File

@ -226,7 +226,7 @@ namespace BizHawk.Client.EmuHawk
}
}
public static void ShowConsole()
public static void ShowConsole(MainForm parent)
{
if (ConsoleVisible) return;
ConsoleVisible = true;
@ -241,7 +241,7 @@ namespace BizHawk.Client.EmuHawk
_logStream = new LogStream();
Log.HACK_LOG_STREAM = _logStream;
Console.SetOut(new StreamWriter(_logStream) { AutoFlush = true });
_window = new LogWindow();
_window = new LogWindow(parent);
_window.Show();
_logStream.Emit = str => { _window.Append(str); };
}

View File

@ -18,23 +18,25 @@ namespace BizHawk.Client.EmuHawk
//TODO: only show add to game db when this is a Rom details dialog
//Let user decide what type (instead of always adding it as a good dump)
private readonly List<string> _lines = new List<string>();
private readonly MainForm _mainForm;
public LogWindow()
public LogWindow(MainForm mainForm)
{
_mainForm = mainForm;
InitializeComponent();
Closing += (o, e) =>
{
Global.Config.ShowLogWindow = false;
GlobalWin.MainForm.NotifyLogWindowClosing();
mainForm.NotifyLogWindowClosing();
LogConsole.NotifyLogWindowClosing();
SaveConfigSettings();
};
ListView_ClientSizeChanged(null, null);
}
public static void ShowReport(string title, string report, IWin32Window parent)
public static void ShowReport(string title, string report, MainForm parent)
{
using var dlg = new LogWindow();
using var dlg = new LogWindow(parent);
var ss = report.Split('\n');
foreach (var s in ss)
{
@ -151,7 +153,7 @@ namespace BizHawk.Client.EmuHawk
var userDb = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb_user.txt");
Global.Game.Status = gameDbEntry.Status = picker.PickedStatus;
Database.SaveDatabaseEntry(userDb, gameDbEntry);
GlobalWin.MainForm.UpdateDumpIcon();
_mainForm.UpdateDumpIcon();
HideShowGameDbButton();
}
}

View File

@ -851,7 +851,7 @@ namespace BizHawk.Client.EmuHawk
if (Config.ShowLogWindow)
{
LogConsole.ShowConsole();
LogConsole.ShowConsole(this);
}
else
{

View File

@ -225,7 +225,7 @@ namespace BizHawk.Client.EmuHawk
Game = GameInfo.NullInstance;
if (Config.ShowLogWindow && !OSTailoredCode.IsUnixHost)
{
LogConsole.ShowConsole();
LogConsole.ShowConsole(this);
DisplayLogWindowMenuItem.Checked = true;
}