tracelogger settings

This commit is contained in:
goyuken 2014-12-22 19:01:21 +00:00
parent fea5156c31
commit 808e17c3f7
6 changed files with 44 additions and 180 deletions

View File

@ -328,9 +328,11 @@ namespace BizHawk.Client.Common
public Color HexHighlightFreezeColor = Color.Violet;
// Trace Logger Settings
/*
public ToolDialogSettings TraceLoggerSettings = new ToolDialogSettings();
public bool TraceLoggerAutoLoad = false;
public int TraceLoggerMaxLines = 100000;
*/
// Video dumping settings
public string VideoWriter = "";

View File

@ -417,11 +417,6 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.Tools.Load<SNESGraphicsDebugger>();
}
if (Global.Config.TraceLoggerAutoLoad)
{
GlobalWin.Tools.Load<TraceLogger>();
}
if (Global.Config.GenericDebuggerAutoload)
{
GlobalWin.Tools.Load<GenericDebugger>();

View File

@ -113,7 +113,6 @@ namespace BizHawk.Client.EmuHawk
private static void AttachSettingHooks(IToolFormAutoConfig tool, ToolDialogSettings settings)
{
var form = (Form)tool;
ToolStripItemCollection dest = null;
foreach (Control c in form.Controls)
{
@ -125,6 +124,7 @@ namespace BizHawk.Client.EmuHawk
if (submenu.Text.Contains("Settings"))
{
dest = submenu.DropDownItems;
dest.Add(new ToolStripSeparator());
break;
}
}
@ -140,15 +140,17 @@ namespace BizHawk.Client.EmuHawk
if (dest == null)
throw new InvalidOperationException("IToolFormAutoConfig must have menu to bind to!");
dest.Add("Save Window Position");
dest.Add("Stay on Top");
dest.Add("Float from Parent");
dest.Add("Auto Load");
int idx = dest.Count;
(dest[0] as ToolStripMenuItem).Checked = settings.SaveWindowPosition;
(dest[1] as ToolStripMenuItem).Checked = settings.TopMost;
(dest[2] as ToolStripMenuItem).Checked = settings.FloatingWindow;
(dest[3] as ToolStripMenuItem).Checked = settings.AutoLoad;
dest.Add("Save Window &Position");
dest.Add("Stay on &Top");
dest.Add("&Float from Parent");
dest.Add("&Autoload");
(dest[idx+0] as ToolStripMenuItem).Checked = settings.SaveWindowPosition;
(dest[idx + 1] as ToolStripMenuItem).Checked = settings.TopMost;
(dest[idx + 2] as ToolStripMenuItem).Checked = settings.FloatingWindow;
(dest[idx + 3] as ToolStripMenuItem).Checked = settings.AutoLoad;
form.TopMost = settings.TopMost;
@ -173,27 +175,27 @@ namespace BizHawk.Client.EmuHawk
settings.Height = form.Bottom - form.Top;
};
dest[0].Click += (o, e) =>
dest[idx + 0].Click += (o, e) =>
{
bool val = !(o as ToolStripMenuItem).Checked;
settings.SaveWindowPosition = val;
(o as ToolStripMenuItem).Checked = val;
};
dest[1].Click += (o, e) =>
dest[idx + 1].Click += (o, e) =>
{
bool val = !(o as ToolStripMenuItem).Checked;
settings.TopMost = val;
(o as ToolStripMenuItem).Checked = val;
form.TopMost = val;
};
dest[2].Click += (o, e) =>
dest[idx + 2].Click += (o, e) =>
{
bool val = !(o as ToolStripMenuItem).Checked;
settings.FloatingWindow = val;
(o as ToolStripMenuItem).Checked = val;
form.Owner = val ? null : GlobalWin.MainForm;
};
dest[3].Click += (o, e) =>
dest[idx + 3].Click += (o, e) =>
{
bool val = !(o as ToolStripMenuItem).Checked;
settings.AutoLoad = val;

View File

@ -43,11 +43,6 @@
this.SelectAllMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.MaxLinesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.AutoloadMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.BrowseBox = new System.Windows.Forms.Button();
this.FileBox = new System.Windows.Forms.TextBox();
@ -55,8 +50,6 @@
this.ToWindowRadio = new System.Windows.Forms.RadioButton();
this.ClearButton = new System.Windows.Forms.Button();
this.LoggingEnabled = new System.Windows.Forms.CheckBox();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.RestoreDefaultSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.TracerBox.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.groupBox2.SuspendLayout();
@ -91,11 +84,13 @@
this.TraceView.ItemCount = 0;
this.TraceView.Location = new System.Drawing.Point(8, 18);
this.TraceView.Name = "TraceView";
this.TraceView.SelectAllInProgress = false;
this.TraceView.selectedItem = -1;
this.TraceView.Size = new System.Drawing.Size(603, 414);
this.TraceView.TabIndex = 4;
this.TraceView.TabStop = false;
this.TraceView.UseCompatibleStateImageBehavior = false;
this.TraceView.UseCustomBackground = true;
this.TraceView.View = System.Windows.Forms.View.Details;
//
// Script
@ -129,27 +124,27 @@
this.toolStripSeparator1,
this.ExitMenuItem});
this.FileSubMenu.Name = "FileSubMenu";
this.FileSubMenu.Size = new System.Drawing.Size(37, 20);
this.FileSubMenu.Size = new System.Drawing.Size(35, 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(134, 22);
this.SaveLogMenuItem.Size = new System.Drawing.Size(132, 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(131, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(129, 6);
//
// ExitMenuItem
//
this.ExitMenuItem.Name = "ExitMenuItem";
this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
this.ExitMenuItem.Size = new System.Drawing.Size(134, 22);
this.ExitMenuItem.Size = new System.Drawing.Size(132, 22);
this.ExitMenuItem.Text = "E&xit";
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
//
@ -159,7 +154,7 @@
this.CopyMenuItem,
this.SelectAllMenuItem});
this.EditSubMenu.Name = "EditSubMenu";
this.EditSubMenu.Size = new System.Drawing.Size(39, 20);
this.EditSubMenu.Size = new System.Drawing.Size(37, 20);
this.EditSubMenu.Text = "Edit";
//
// CopyMenuItem
@ -167,7 +162,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(164, 22);
this.CopyMenuItem.Size = new System.Drawing.Size(156, 22);
this.CopyMenuItem.Text = "&Copy";
this.CopyMenuItem.Click += new System.EventHandler(this.CopyMenuItem_Click);
//
@ -176,66 +171,25 @@
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(164, 22);
this.SelectAllMenuItem.Size = new System.Drawing.Size(156, 22);
this.SelectAllMenuItem.Text = "Select &All";
this.SelectAllMenuItem.Click += new System.EventHandler(this.SelectAllMenuItem_Click);
//
// OptionsSubMenu
//
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.MaxLinesMenuItem,
this.toolStripSeparator2,
this.AutoloadMenuItem,
this.SaveWindowPositionMenuItem,
this.AlwaysOnTopMenuItem,
this.FloatingWindowMenuItem,
this.toolStripSeparator3,
this.RestoreDefaultSettingsMenuItem});
this.MaxLinesMenuItem});
this.OptionsSubMenu.Name = "OptionsSubMenu";
this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20);
this.OptionsSubMenu.Text = "&Options";
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
this.OptionsSubMenu.Size = new System.Drawing.Size(58, 20);
this.OptionsSubMenu.Text = "&Settings";
//
// MaxLinesMenuItem
//
this.MaxLinesMenuItem.Name = "MaxLinesMenuItem";
this.MaxLinesMenuItem.Size = new System.Drawing.Size(199, 22);
this.MaxLinesMenuItem.Size = new System.Drawing.Size(152, 22);
this.MaxLinesMenuItem.Text = "&Set Max Lines...";
this.MaxLinesMenuItem.Click += new System.EventHandler(this.MaxLinesMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(196, 6);
//
// AutoloadMenuItem
//
this.AutoloadMenuItem.Name = "AutoloadMenuItem";
this.AutoloadMenuItem.Size = new System.Drawing.Size(199, 22);
this.AutoloadMenuItem.Text = "&Autoload";
this.AutoloadMenuItem.Click += new System.EventHandler(this.AutoloadMenuItem_Click);
//
// SaveWindowPositionMenuItem
//
this.SaveWindowPositionMenuItem.Name = "SaveWindowPositionMenuItem";
this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(199, 22);
this.SaveWindowPositionMenuItem.Text = "&Save Window Position";
this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click);
//
// AlwaysOnTopMenuItem
//
this.AlwaysOnTopMenuItem.Name = "AlwaysOnTopMenuItem";
this.AlwaysOnTopMenuItem.Size = new System.Drawing.Size(199, 22);
this.AlwaysOnTopMenuItem.Text = "&Always on Top";
this.AlwaysOnTopMenuItem.Click += new System.EventHandler(this.AlwaysOnTopMenuItem_Click);
//
// FloatingWindowMenuItem
//
this.FloatingWindowMenuItem.Name = "FloatingWindowMenuItem";
this.FloatingWindowMenuItem.Size = new System.Drawing.Size(199, 22);
this.FloatingWindowMenuItem.Text = "&Floating Window";
this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click);
//
// groupBox2
//
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
@ -323,18 +277,6 @@
this.LoggingEnabled.UseVisualStyleBackColor = true;
this.LoggingEnabled.CheckedChanged += new System.EventHandler(this.LoggingEnabled_CheckedChanged);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(196, 6);
//
// RestoreDefaultSettingsMenuItem
//
this.RestoreDefaultSettingsMenuItem.Name = "RestoreDefaultSettingsMenuItem";
this.RestoreDefaultSettingsMenuItem.Size = new System.Drawing.Size(199, 22);
this.RestoreDefaultSettingsMenuItem.Text = "Restore Default Settings";
this.RestoreDefaultSettingsMenuItem.Click += new System.EventHandler(this.RestoreDefaultSettingsMenuItem_Click);
//
// TraceLogger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -374,12 +316,9 @@
private System.Windows.Forms.CheckBox LoggingEnabled;
private System.Windows.Forms.Button ClearButton;
private System.Windows.Forms.ToolStripMenuItem OptionsSubMenu;
private System.Windows.Forms.ToolStripMenuItem AutoloadMenuItem;
private VirtualListView TraceView;
public System.Windows.Forms.ColumnHeader Script;
private System.Windows.Forms.ToolStripMenuItem MaxLinesMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem SaveWindowPositionMenuItem;
private System.Windows.Forms.RadioButton ToFileRadio;
private System.Windows.Forms.RadioButton ToWindowRadio;
private System.Windows.Forms.TextBox FileBox;
@ -387,9 +326,5 @@
private System.Windows.Forms.ToolStripMenuItem EditSubMenu;
private System.Windows.Forms.ToolStripMenuItem CopyMenuItem;
private System.Windows.Forms.ToolStripMenuItem SelectAllMenuItem;
private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem;
private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem RestoreDefaultSettingsMenuItem;
}
}

View File

@ -14,19 +14,18 @@ using BizHawk.Client.EmuHawk.WinFormExtensions;
namespace BizHawk.Client.EmuHawk
{
public partial class TraceLogger : Form, IToolForm
public partial class TraceLogger : Form, IToolFormAutoConfig
{
[RequiredService]
private IDebuggable _debugtarget { get; set; }
private ITracer Tracer { get { return _debugtarget.Tracer; } }
// Refresh rate slider
// Make faster, such as not saving to disk until the logging is stopped, dont' add to Instructions list every frame, etc
[ConfigPersist]
private int MaxLines { get; set; }
private readonly List<string> _instructions = new List<string>();
private FileInfo _logFile;
private int _defaultWidth;
private int _defaultHeight;
public TraceLogger()
{
@ -35,8 +34,9 @@ namespace BizHawk.Client.EmuHawk
TraceView.QueryItemText += TraceView_QueryItemText;
TraceView.VirtualMode = true;
TopMost = Global.Config.TraceLoggerSettings.TopMost;
Closing += (o, e) => SaveConfigSettings();
MaxLines = 10000;
}
public bool UpdateBefore
@ -52,10 +52,6 @@ namespace BizHawk.Client.EmuHawk
private void SaveConfigSettings()
{
Tracer.Enabled = false;
Global.Config.TraceLoggerSettings.Wndx = Location.X;
Global.Config.TraceLoggerSettings.Wndy = Location.Y;
Global.Config.TraceLoggerSettings.Width = Size.Width;
Global.Config.TraceLoggerSettings.Height = Size.Height;
}
private void TraceView_QueryItemText(int index, int column, out string text)
@ -65,19 +61,6 @@ namespace BizHawk.Client.EmuHawk
private void TraceLogger_Load(object sender, EventArgs e)
{
_defaultWidth = Size.Width;
_defaultHeight = Size.Height;
if (Global.Config.TraceLoggerSettings.UseWindowPosition)
{
Location = Global.Config.TraceLoggerSettings.WindowPosition;
}
if (Global.Config.TraceLoggerSettings.UseWindowSize)
{
Size = Global.Config.TraceLoggerSettings.WindowSize;
}
ClearList();
LoggingEnabled.Checked = true;
Tracer.Enabled = true;
@ -99,11 +82,8 @@ namespace BizHawk.Client.EmuHawk
public void FastUpdate()
{
// TODO: think more about this logic
if (!ToWindowRadio.Checked)
{
LogToFile();
}
// never skip instructions when tracelogging!
UpdateValues();
}
@ -136,9 +116,9 @@ namespace BizHawk.Client.EmuHawk
_instructions.AddRange(instructions);
}
if (_instructions.Count >= Global.Config.TraceLoggerMaxLines)
if (_instructions.Count >= MaxLines)
{
_instructions.RemoveRange(0, _instructions.Count - Global.Config.TraceLoggerMaxLines);
_instructions.RemoveRange(0, _instructions.Count - MaxLines);
}
TraceView.ItemCount = _instructions.Count;
@ -224,11 +204,6 @@ namespace BizHawk.Client.EmuHawk
}
}
private void RefreshFloatingWindowControl()
{
Owner = Global.Config.TraceLoggerSettings.FloatingWindow ? null : GlobalWin.MainForm;
}
#region Events
#region Menu Items
@ -282,7 +257,7 @@ namespace BizHawk.Client.EmuHawk
StartLocation = this.ChildPointToScreen(TraceView),
TextInputType = InputPrompt.InputType.Unsigned,
Message = "Max lines to display in the window",
InitialValue = Global.Config.TraceLoggerMaxLines.ToString()
InitialValue = MaxLines.ToString()
};
var result = prompt.ShowHawkDialog();
@ -291,52 +266,11 @@ namespace BizHawk.Client.EmuHawk
var max = int.Parse(prompt.PromptText);
if (max > 0)
{
Global.Config.TraceLoggerMaxLines = max;
MaxLines = max;
}
}
}
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{
AutoloadMenuItem.Checked = Global.Config.TraceLoggerAutoLoad;
SaveWindowPositionMenuItem.Checked = Global.Config.TraceLoggerSettings.SaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Global.Config.TraceLoggerSettings.TopMost;
FloatingWindowMenuItem.Checked = Global.Config.TraceLoggerSettings.FloatingWindow;
}
private void AutoloadMenuItem_Click(object sender, EventArgs e)
{
Global.Config.TraceLoggerAutoLoad ^= true;
}
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{
Global.Config.TraceLoggerSettings.SaveWindowPosition ^= true;
}
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
{
Global.Config.TraceLoggerSettings.TopMost ^= true;
TopMost = Global.Config.TraceLoggerSettings.TopMost;
}
private void FloatingWindowMenuItem_Click(object sender, EventArgs e)
{
Global.Config.TraceLoggerSettings.FloatingWindow ^= true;
RefreshFloatingWindowControl();
}
private void RestoreDefaultSettingsMenuItem_Click(object sender, EventArgs e)
{
Size = new Size(_defaultWidth, _defaultHeight);
Global.Config.TraceLoggerSettings.SaveWindowPosition = true;
Global.Config.TraceLoggerSettings.TopMost = false;
Global.Config.TraceLoggerSettings.FloatingWindow = false;
RefreshFloatingWindowControl();
}
#endregion
#region Dialog and ListView Events
@ -395,12 +329,6 @@ namespace BizHawk.Client.EmuHawk
SetTracerBoxTitle();
}
protected override void OnShown(EventArgs e)
{
RefreshFloatingWindowControl();
base.OnShown(e);
}
#endregion
#endregion

View File

@ -5,6 +5,8 @@
/// </summary>
public interface ITracer
{
// TODO: would it be faster (considering both disk and screen output) to keep the data as a List<string> directly?
bool Enabled { get; set; }
/// <summary>