TraceLogger - improve FastUpdate to still log but not update the screen. Cleanup and merge two similar function calls, slight change to form title

This commit is contained in:
adelikat 2016-02-24 20:56:16 -05:00
parent 1635cf9b30
commit 52ef67a12f
2 changed files with 18 additions and 42 deletions

View File

@ -130,27 +130,27 @@
this.toolStripSeparator1,
this.ExitMenuItem});
this.FileSubMenu.Name = "FileSubMenu";
this.FileSubMenu.Size = new System.Drawing.Size(35, 20);
this.FileSubMenu.Size = new System.Drawing.Size(37, 20);
this.FileSubMenu.Text = "&File";
//
// SaveLogMenuItem
//
this.SaveLogMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.SaveAs;
this.SaveLogMenuItem.Name = "SaveLogMenuItem";
this.SaveLogMenuItem.Size = new System.Drawing.Size(132, 22);
this.SaveLogMenuItem.Size = new System.Drawing.Size(134, 22);
this.SaveLogMenuItem.Text = "&Save Log";
this.SaveLogMenuItem.Click += new System.EventHandler(this.SaveLogMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(129, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(131, 6);
//
// ExitMenuItem
//
this.ExitMenuItem.Name = "ExitMenuItem";
this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
this.ExitMenuItem.Size = new System.Drawing.Size(132, 22);
this.ExitMenuItem.Size = new System.Drawing.Size(134, 22);
this.ExitMenuItem.Text = "E&xit";
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
//
@ -160,7 +160,7 @@
this.CopyMenuItem,
this.SelectAllMenuItem});
this.EditSubMenu.Name = "EditSubMenu";
this.EditSubMenu.Size = new System.Drawing.Size(37, 20);
this.EditSubMenu.Size = new System.Drawing.Size(39, 20);
this.EditSubMenu.Text = "Edit";
//
// CopyMenuItem
@ -168,7 +168,7 @@
this.CopyMenuItem.Name = "CopyMenuItem";
this.CopyMenuItem.ShortcutKeyDisplayString = "";
this.CopyMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
this.CopyMenuItem.Size = new System.Drawing.Size(156, 22);
this.CopyMenuItem.Size = new System.Drawing.Size(164, 22);
this.CopyMenuItem.Text = "&Copy";
this.CopyMenuItem.Click += new System.EventHandler(this.CopyMenuItem_Click);
//
@ -177,7 +177,7 @@
this.SelectAllMenuItem.Name = "SelectAllMenuItem";
this.SelectAllMenuItem.ShortcutKeyDisplayString = "";
this.SelectAllMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
this.SelectAllMenuItem.Size = new System.Drawing.Size(156, 22);
this.SelectAllMenuItem.Size = new System.Drawing.Size(164, 22);
this.SelectAllMenuItem.Text = "Select &All";
this.SelectAllMenuItem.Click += new System.EventHandler(this.SelectAllMenuItem_Click);
//
@ -186,13 +186,13 @@
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.MaxLinesMenuItem});
this.OptionsSubMenu.Name = "OptionsSubMenu";
this.OptionsSubMenu.Size = new System.Drawing.Size(58, 20);
this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20);
this.OptionsSubMenu.Text = "&Settings";
//
// MaxLinesMenuItem
//
this.MaxLinesMenuItem.Name = "MaxLinesMenuItem";
this.MaxLinesMenuItem.Size = new System.Drawing.Size(152, 22);
this.MaxLinesMenuItem.Size = new System.Drawing.Size(154, 22);
this.MaxLinesMenuItem.Text = "&Set Max Lines...";
this.MaxLinesMenuItem.Click += new System.EventHandler(this.MaxLinesMenuItem_Click);
//
@ -297,7 +297,7 @@
this.MinimumSize = new System.Drawing.Size(400, 230);
this.Name = "TraceLogger";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "TraceLogger";
this.Text = "Trace Logger";
this.Load += new System.EventHandler(this.TraceLogger_Load);
this.TracerBox.ResumeLayout(false);
this.menuStrip1.ResumeLayout(false);

View File

@ -77,21 +77,22 @@ namespace BizHawk.Client.EmuHawk
public void UpdateValues()
{
TraceView.BlazingFast = !GlobalWin.MainForm.EmulatorPaused;
_instructions.AddRange(Tracer.TakeContents());
if (ToWindowRadio.Checked)
{
TraceView.BlazingFast = !GlobalWin.MainForm.EmulatorPaused;
LogToWindow();
}
else
{
LogToFile();
DumpToDisk(_logFile);
}
}
public void FastUpdate()
{
// TODO: get instructions, but don't draw on screen
UpdateValues();
_instructions.AddRange(Tracer.TakeContents());
}
public void Restart()
@ -108,33 +109,11 @@ namespace BizHawk.Client.EmuHawk
SetTracerBoxTitle();
}
// TODO: LogToFile and DumpListTODisk have a lot of repeated code
private void LogToFile()
{
var todo = Tracer.TakeContents();
if (todo.Any())
{
using (var sw = new StreamWriter(_logFile.FullName, true))
{
int pad = todo.Max(i => i.Disassembly.Length) + 4;
foreach (var instruction in todo)
{
sw.WriteLine(instruction.Disassembly.PadRight(pad)
+ instruction.RegisterInfo
);
}
sw.Write(Tracer.TakeContents());
}
}
}
private void DumpListToDisk(FileSystemInfo file)
private void DumpToDisk(FileSystemInfo file)
{
using (var sw = new StreamWriter(file.FullName))
{
int pad = _instructions.Max(i => i.Disassembly.Length) + 4;
int pad = _instructions.Any() ? _instructions.Max(i => i.Disassembly.Length) + 4 : 0;
foreach (var instruction in _instructions)
{
@ -147,9 +126,6 @@ namespace BizHawk.Client.EmuHawk
private void LogToWindow()
{
_instructions.AddRange(Tracer.TakeContents());
if (_instructions.Count >= MaxLines)
{
_instructions.RemoveRange(0, _instructions.Count - MaxLines);
@ -234,7 +210,7 @@ namespace BizHawk.Client.EmuHawk
var file = GetFileFromUser();
if (file != null)
{
DumpListToDisk(file);
DumpToDisk(file);
GlobalWin.OSD.AddMessage("Log dumped to " + file.FullName);
}
}