Trace Logger - some code clean up, some tiny speedups, and implement a few small tweaks like Always on Top, and Select All
This commit is contained in:
parent
9ccc214667
commit
0ed9d832c7
|
@ -290,6 +290,7 @@ namespace BizHawk.Client.Common
|
|||
//Trace Logger Settings
|
||||
public bool TraceLoggerAutoLoad = false;
|
||||
public bool TraceLoggerSaveWindowPosition = true;
|
||||
public bool TraceLoggerOnTop = false;
|
||||
public int TraceLoggerMaxLines = 100000;
|
||||
public int TraceLoggerWndx = -1;
|
||||
public int TraceLoggerWndy = -1;
|
||||
|
|
|
@ -28,291 +28,310 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TraceLogger));
|
||||
this.TracerBox = new System.Windows.Forms.GroupBox();
|
||||
this.TraceView = new BizHawk.Client.EmuHawk.VirtualListView();
|
||||
this.Script = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.menuStrip1 = new MenuStripEx();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveLogToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.copyAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.setMaxWindowLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveWindowPositionToolStripMenuItem = 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();
|
||||
this.ToFileRadio = new System.Windows.Forms.RadioButton();
|
||||
this.ToWindowRadio = new System.Windows.Forms.RadioButton();
|
||||
this.ClearButton = new System.Windows.Forms.Button();
|
||||
this.LoggingEnabled = new System.Windows.Forms.CheckBox();
|
||||
this.TracerBox.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// TracerBox
|
||||
//
|
||||
this.TracerBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TraceLogger));
|
||||
this.TracerBox = new System.Windows.Forms.GroupBox();
|
||||
this.TraceView = new BizHawk.Client.EmuHawk.VirtualListView();
|
||||
this.Script = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.menuStrip1 = new MenuStripEx();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SaveLogMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.EditSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.CopyMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
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.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.BrowseBox = new System.Windows.Forms.Button();
|
||||
this.FileBox = new System.Windows.Forms.TextBox();
|
||||
this.ToFileRadio = new System.Windows.Forms.RadioButton();
|
||||
this.ToWindowRadio = new System.Windows.Forms.RadioButton();
|
||||
this.ClearButton = new System.Windows.Forms.Button();
|
||||
this.LoggingEnabled = new System.Windows.Forms.CheckBox();
|
||||
this.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.TracerBox.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// TracerBox
|
||||
//
|
||||
this.TracerBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.TracerBox.Controls.Add(this.TraceView);
|
||||
this.TracerBox.Location = new System.Drawing.Point(12, 27);
|
||||
this.TracerBox.Name = "TracerBox";
|
||||
this.TracerBox.Size = new System.Drawing.Size(620, 444);
|
||||
this.TracerBox.TabIndex = 1;
|
||||
this.TracerBox.TabStop = false;
|
||||
this.TracerBox.Text = "Trace log";
|
||||
//
|
||||
// TraceView
|
||||
//
|
||||
this.TraceView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
this.TracerBox.Controls.Add(this.TraceView);
|
||||
this.TracerBox.Location = new System.Drawing.Point(12, 27);
|
||||
this.TracerBox.Name = "TracerBox";
|
||||
this.TracerBox.Size = new System.Drawing.Size(620, 444);
|
||||
this.TracerBox.TabIndex = 1;
|
||||
this.TracerBox.TabStop = false;
|
||||
this.TracerBox.Text = "Trace log";
|
||||
//
|
||||
// TraceView
|
||||
//
|
||||
this.TraceView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.TraceView.CheckBoxes = true;
|
||||
this.TraceView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.TraceView.CheckBoxes = true;
|
||||
this.TraceView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.Script});
|
||||
this.TraceView.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.TraceView.FullRowSelect = true;
|
||||
this.TraceView.GridLines = true;
|
||||
this.TraceView.HideSelection = false;
|
||||
this.TraceView.ItemCount = 0;
|
||||
this.TraceView.Location = new System.Drawing.Point(8, 18);
|
||||
this.TraceView.Name = "TraceView";
|
||||
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.View = System.Windows.Forms.View.Details;
|
||||
this.TraceView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TraceView_KeyDown);
|
||||
//
|
||||
// Script
|
||||
//
|
||||
this.Script.Text = "Instructions";
|
||||
this.Script.Width = 599;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.ClickThrough = true;
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.TraceView.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.TraceView.FullRowSelect = true;
|
||||
this.TraceView.GridLines = true;
|
||||
this.TraceView.HideSelection = false;
|
||||
this.TraceView.ItemCount = 0;
|
||||
this.TraceView.Location = new System.Drawing.Point(8, 18);
|
||||
this.TraceView.Name = "TraceView";
|
||||
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.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// Script
|
||||
//
|
||||
this.Script.Text = "Instructions";
|
||||
this.Script.Width = 599;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.ClickThrough = true;
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItem1,
|
||||
this.fileToolStripMenuItem,
|
||||
this.editToolStripMenuItem,
|
||||
this.optionsToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(644, 24);
|
||||
this.menuStrip1.TabIndex = 2;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(12, 20);
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveLogToolStripMenuItem,
|
||||
this.FileSubMenu,
|
||||
this.EditSubMenu,
|
||||
this.OptionsSubMenu});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(644, 24);
|
||||
this.menuStrip1.TabIndex = 2;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(12, 20);
|
||||
//
|
||||
// FileSubMenu
|
||||
//
|
||||
this.FileSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SaveLogMenuItem,
|
||||
this.toolStripSeparator1,
|
||||
this.exitToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "&File";
|
||||
//
|
||||
// saveLogToolStripMenuItem
|
||||
//
|
||||
this.saveLogToolStripMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.SaveAs;
|
||||
this.saveLogToolStripMenuItem.Name = "saveLogToolStripMenuItem";
|
||||
this.saveLogToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
|
||||
this.saveLogToolStripMenuItem.Text = "&Save Log";
|
||||
this.saveLogToolStripMenuItem.Click += new System.EventHandler(this.saveLogToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(131, 6);
|
||||
//
|
||||
// exitToolStripMenuItem
|
||||
//
|
||||
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||
this.exitToolStripMenuItem.ShortcutKeyDisplayString = "Alt+F4";
|
||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
|
||||
this.exitToolStripMenuItem.Text = "E&xit";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
//
|
||||
// editToolStripMenuItem
|
||||
//
|
||||
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.copyAllToolStripMenuItem});
|
||||
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
|
||||
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
|
||||
this.editToolStripMenuItem.Text = "Edit";
|
||||
//
|
||||
// copyAllToolStripMenuItem
|
||||
//
|
||||
this.copyAllToolStripMenuItem.Name = "copyAllToolStripMenuItem";
|
||||
this.copyAllToolStripMenuItem.ShortcutKeyDisplayString = "Ctrl+C";
|
||||
this.copyAllToolStripMenuItem.Size = new System.Drawing.Size(161, 22);
|
||||
this.copyAllToolStripMenuItem.Text = "Copy All";
|
||||
this.copyAllToolStripMenuItem.Click += new System.EventHandler(this.copyAllToolStripMenuItem_Click);
|
||||
//
|
||||
// optionsToolStripMenuItem
|
||||
//
|
||||
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.setMaxWindowLinesToolStripMenuItem,
|
||||
this.ExitMenuItem});
|
||||
this.FileSubMenu.Name = "FileSubMenu";
|
||||
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(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(131, 6);
|
||||
//
|
||||
// ExitMenuItem
|
||||
//
|
||||
this.ExitMenuItem.Name = "ExitMenuItem";
|
||||
this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
|
||||
this.ExitMenuItem.Size = new System.Drawing.Size(134, 22);
|
||||
this.ExitMenuItem.Text = "E&xit";
|
||||
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
|
||||
//
|
||||
// EditSubMenu
|
||||
//
|
||||
this.EditSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.CopyMenuItem,
|
||||
this.SelectAllMenuItem});
|
||||
this.EditSubMenu.Name = "EditSubMenu";
|
||||
this.EditSubMenu.Size = new System.Drawing.Size(39, 20);
|
||||
this.EditSubMenu.Text = "Edit";
|
||||
//
|
||||
// CopyMenuItem
|
||||
//
|
||||
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.Text = "&Copy";
|
||||
this.CopyMenuItem.Click += new System.EventHandler(this.CopyMenuItem_Click);
|
||||
//
|
||||
// SelectAllMenuItem
|
||||
//
|
||||
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.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.autoloadToolStripMenuItem,
|
||||
this.saveWindowPositionToolStripMenuItem});
|
||||
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
|
||||
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
|
||||
this.optionsToolStripMenuItem.Text = "&Options";
|
||||
this.optionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.optionsToolStripMenuItem_DropDownOpened);
|
||||
//
|
||||
// setMaxWindowLinesToolStripMenuItem
|
||||
//
|
||||
this.setMaxWindowLinesToolStripMenuItem.Name = "setMaxWindowLinesToolStripMenuItem";
|
||||
this.setMaxWindowLinesToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
|
||||
this.setMaxWindowLinesToolStripMenuItem.Text = "&Set Max Window Lines...";
|
||||
this.setMaxWindowLinesToolStripMenuItem.Click += new System.EventHandler(this.setMaxWindowLinesToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator2
|
||||
//
|
||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
this.toolStripSeparator2.Size = new System.Drawing.Size(198, 6);
|
||||
//
|
||||
// autoloadToolStripMenuItem
|
||||
//
|
||||
this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem";
|
||||
this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
|
||||
this.autoloadToolStripMenuItem.Text = "&Autoload";
|
||||
this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click);
|
||||
//
|
||||
// saveWindowPositionToolStripMenuItem
|
||||
//
|
||||
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
|
||||
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(201, 22);
|
||||
this.saveWindowPositionToolStripMenuItem.Text = "&Save Window Position";
|
||||
this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click);
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.AutoloadMenuItem,
|
||||
this.SaveWindowPositionMenuItem,
|
||||
this.AlwaysOnTopMenuItem});
|
||||
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);
|
||||
//
|
||||
// MaxLinesMenuItem
|
||||
//
|
||||
this.MaxLinesMenuItem.Name = "MaxLinesMenuItem";
|
||||
this.MaxLinesMenuItem.Size = new System.Drawing.Size(191, 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(188, 6);
|
||||
//
|
||||
// AutoloadMenuItem
|
||||
//
|
||||
this.AutoloadMenuItem.Name = "AutoloadMenuItem";
|
||||
this.AutoloadMenuItem.Size = new System.Drawing.Size(191, 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(191, 22);
|
||||
this.SaveWindowPositionMenuItem.Text = "&Save Window Position";
|
||||
this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click);
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBox2.Controls.Add(this.BrowseBox);
|
||||
this.groupBox2.Controls.Add(this.FileBox);
|
||||
this.groupBox2.Controls.Add(this.ToFileRadio);
|
||||
this.groupBox2.Controls.Add(this.ToWindowRadio);
|
||||
this.groupBox2.Controls.Add(this.ClearButton);
|
||||
this.groupBox2.Controls.Add(this.LoggingEnabled);
|
||||
this.groupBox2.Location = new System.Drawing.Point(12, 477);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(620, 50);
|
||||
this.groupBox2.TabIndex = 3;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Control";
|
||||
//
|
||||
// BrowseBox
|
||||
//
|
||||
this.BrowseBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.BrowseBox.Location = new System.Drawing.Point(477, 19);
|
||||
this.BrowseBox.Name = "BrowseBox";
|
||||
this.BrowseBox.Size = new System.Drawing.Size(54, 23);
|
||||
this.BrowseBox.TabIndex = 20;
|
||||
this.BrowseBox.Text = "&Browse";
|
||||
this.BrowseBox.UseVisualStyleBackColor = true;
|
||||
this.BrowseBox.Visible = false;
|
||||
this.BrowseBox.Click += new System.EventHandler(this.BrowseBox_Click);
|
||||
//
|
||||
// FileBox
|
||||
//
|
||||
this.FileBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.groupBox2.Controls.Add(this.BrowseBox);
|
||||
this.groupBox2.Controls.Add(this.FileBox);
|
||||
this.groupBox2.Controls.Add(this.ToFileRadio);
|
||||
this.groupBox2.Controls.Add(this.ToWindowRadio);
|
||||
this.groupBox2.Controls.Add(this.ClearButton);
|
||||
this.groupBox2.Controls.Add(this.LoggingEnabled);
|
||||
this.groupBox2.Location = new System.Drawing.Point(12, 477);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(620, 50);
|
||||
this.groupBox2.TabIndex = 3;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Control";
|
||||
//
|
||||
// BrowseBox
|
||||
//
|
||||
this.BrowseBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.BrowseBox.Location = new System.Drawing.Point(477, 19);
|
||||
this.BrowseBox.Name = "BrowseBox";
|
||||
this.BrowseBox.Size = new System.Drawing.Size(54, 23);
|
||||
this.BrowseBox.TabIndex = 20;
|
||||
this.BrowseBox.Text = "&Browse";
|
||||
this.BrowseBox.UseVisualStyleBackColor = true;
|
||||
this.BrowseBox.Visible = false;
|
||||
this.BrowseBox.Click += new System.EventHandler(this.BrowseBox_Click);
|
||||
//
|
||||
// FileBox
|
||||
//
|
||||
this.FileBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.FileBox.Location = new System.Drawing.Point(229, 20);
|
||||
this.FileBox.Name = "FileBox";
|
||||
this.FileBox.ReadOnly = true;
|
||||
this.FileBox.Size = new System.Drawing.Size(242, 20);
|
||||
this.FileBox.TabIndex = 15;
|
||||
this.FileBox.TabStop = false;
|
||||
this.FileBox.Visible = false;
|
||||
//
|
||||
// ToFileRadio
|
||||
//
|
||||
this.ToFileRadio.AutoSize = true;
|
||||
this.ToFileRadio.Location = new System.Drawing.Point(173, 22);
|
||||
this.ToFileRadio.Name = "ToFileRadio";
|
||||
this.ToFileRadio.Size = new System.Drawing.Size(50, 17);
|
||||
this.ToFileRadio.TabIndex = 10;
|
||||
this.ToFileRadio.Text = "to file";
|
||||
this.ToFileRadio.UseVisualStyleBackColor = true;
|
||||
this.ToFileRadio.CheckedChanged += new System.EventHandler(this.ToFileRadio_CheckedChanged);
|
||||
//
|
||||
// ToWindowRadio
|
||||
//
|
||||
this.ToWindowRadio.AutoSize = true;
|
||||
this.ToWindowRadio.Checked = true;
|
||||
this.ToWindowRadio.Location = new System.Drawing.Point(94, 22);
|
||||
this.ToWindowRadio.Name = "ToWindowRadio";
|
||||
this.ToWindowRadio.Size = new System.Drawing.Size(73, 17);
|
||||
this.ToWindowRadio.TabIndex = 5;
|
||||
this.ToWindowRadio.TabStop = true;
|
||||
this.ToWindowRadio.Text = "to window";
|
||||
this.ToWindowRadio.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ClearButton
|
||||
//
|
||||
this.ClearButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ClearButton.Location = new System.Drawing.Point(564, 19);
|
||||
this.ClearButton.Name = "ClearButton";
|
||||
this.ClearButton.Size = new System.Drawing.Size(47, 23);
|
||||
this.ClearButton.TabIndex = 25;
|
||||
this.ClearButton.Text = "&Clear";
|
||||
this.ClearButton.UseVisualStyleBackColor = true;
|
||||
this.ClearButton.Click += new System.EventHandler(this.ClearButton_Click);
|
||||
//
|
||||
// LoggingEnabled
|
||||
//
|
||||
this.LoggingEnabled.Appearance = System.Windows.Forms.Appearance.Button;
|
||||
this.LoggingEnabled.AutoSize = true;
|
||||
this.LoggingEnabled.Location = new System.Drawing.Point(9, 19);
|
||||
this.LoggingEnabled.Name = "LoggingEnabled";
|
||||
this.LoggingEnabled.Size = new System.Drawing.Size(55, 23);
|
||||
this.LoggingEnabled.TabIndex = 1;
|
||||
this.LoggingEnabled.Text = "&Logging";
|
||||
this.LoggingEnabled.UseVisualStyleBackColor = true;
|
||||
this.LoggingEnabled.CheckedChanged += new System.EventHandler(this.LoggingEnabled_CheckedChanged);
|
||||
//
|
||||
// TraceLogger
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(644, 539);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.TracerBox);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.KeyPreview = true;
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.MinimumSize = new System.Drawing.Size(400, 230);
|
||||
this.Name = "TraceLogger";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "TraceLogger";
|
||||
this.Load += new System.EventHandler(this.TraceLogger_Load);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TraceLogger_KeyDown);
|
||||
this.TracerBox.ResumeLayout(false);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
this.FileBox.Location = new System.Drawing.Point(229, 20);
|
||||
this.FileBox.Name = "FileBox";
|
||||
this.FileBox.ReadOnly = true;
|
||||
this.FileBox.Size = new System.Drawing.Size(242, 20);
|
||||
this.FileBox.TabIndex = 15;
|
||||
this.FileBox.TabStop = false;
|
||||
this.FileBox.Visible = false;
|
||||
//
|
||||
// ToFileRadio
|
||||
//
|
||||
this.ToFileRadio.AutoSize = true;
|
||||
this.ToFileRadio.Location = new System.Drawing.Point(173, 22);
|
||||
this.ToFileRadio.Name = "ToFileRadio";
|
||||
this.ToFileRadio.Size = new System.Drawing.Size(50, 17);
|
||||
this.ToFileRadio.TabIndex = 10;
|
||||
this.ToFileRadio.Text = "to file";
|
||||
this.ToFileRadio.UseVisualStyleBackColor = true;
|
||||
this.ToFileRadio.CheckedChanged += new System.EventHandler(this.ToFileRadio_CheckedChanged);
|
||||
//
|
||||
// ToWindowRadio
|
||||
//
|
||||
this.ToWindowRadio.AutoSize = true;
|
||||
this.ToWindowRadio.Checked = true;
|
||||
this.ToWindowRadio.Location = new System.Drawing.Point(94, 22);
|
||||
this.ToWindowRadio.Name = "ToWindowRadio";
|
||||
this.ToWindowRadio.Size = new System.Drawing.Size(73, 17);
|
||||
this.ToWindowRadio.TabIndex = 5;
|
||||
this.ToWindowRadio.TabStop = true;
|
||||
this.ToWindowRadio.Text = "to window";
|
||||
this.ToWindowRadio.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ClearButton
|
||||
//
|
||||
this.ClearButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ClearButton.Location = new System.Drawing.Point(564, 19);
|
||||
this.ClearButton.Name = "ClearButton";
|
||||
this.ClearButton.Size = new System.Drawing.Size(47, 23);
|
||||
this.ClearButton.TabIndex = 25;
|
||||
this.ClearButton.Text = "&Clear";
|
||||
this.ClearButton.UseVisualStyleBackColor = true;
|
||||
this.ClearButton.Click += new System.EventHandler(this.ClearButton_Click);
|
||||
//
|
||||
// LoggingEnabled
|
||||
//
|
||||
this.LoggingEnabled.Appearance = System.Windows.Forms.Appearance.Button;
|
||||
this.LoggingEnabled.AutoSize = true;
|
||||
this.LoggingEnabled.Location = new System.Drawing.Point(9, 19);
|
||||
this.LoggingEnabled.Name = "LoggingEnabled";
|
||||
this.LoggingEnabled.Size = new System.Drawing.Size(55, 23);
|
||||
this.LoggingEnabled.TabIndex = 1;
|
||||
this.LoggingEnabled.Text = "&Logging";
|
||||
this.LoggingEnabled.UseVisualStyleBackColor = true;
|
||||
this.LoggingEnabled.CheckedChanged += new System.EventHandler(this.LoggingEnabled_CheckedChanged);
|
||||
//
|
||||
// AlwaysOnTopMenuItem
|
||||
//
|
||||
this.AlwaysOnTopMenuItem.Name = "AlwaysOnTopMenuItem";
|
||||
this.AlwaysOnTopMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.AlwaysOnTopMenuItem.Text = "&Always on Top";
|
||||
this.AlwaysOnTopMenuItem.Click += new System.EventHandler(this.AlwaysOnTopMenuItem_Click);
|
||||
//
|
||||
// TraceLogger
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(644, 539);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.TracerBox);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.KeyPreview = true;
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.MinimumSize = new System.Drawing.Size(400, 230);
|
||||
this.Name = "TraceLogger";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "TraceLogger";
|
||||
this.Load += new System.EventHandler(this.TraceLogger_Load);
|
||||
this.TracerBox.ResumeLayout(false);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
|
@ -321,25 +340,27 @@
|
|||
private System.Windows.Forms.GroupBox TracerBox;
|
||||
private MenuStripEx menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveLogToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem FileSubMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem SaveLogMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.CheckBox LoggingEnabled;
|
||||
private System.Windows.Forms.Button ClearButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
|
||||
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 setMaxWindowLinesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem MaxLinesMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SaveWindowPositionMenuItem;
|
||||
private System.Windows.Forms.RadioButton ToFileRadio;
|
||||
private System.Windows.Forms.RadioButton ToWindowRadio;
|
||||
private System.Windows.Forms.TextBox FileBox;
|
||||
private System.Windows.Forms.Button BrowseBox;
|
||||
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem copyAllToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem EditSubMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem CopyMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SelectAllMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
|
@ -11,49 +12,43 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class TraceLogger : Form, IToolForm
|
||||
{
|
||||
//Refresh rate slider
|
||||
//Make faster, such as not saving to disk until the logging is stopped, dont' add to Instructions list every frame, etc
|
||||
//Remember window size
|
||||
|
||||
private readonly List<string> Instructions = new List<string>();
|
||||
private FileInfo LogFile;
|
||||
|
||||
public bool AskSave() { return true; }
|
||||
public bool UpdateBefore { get { return false; } }
|
||||
// Refresh rate slider
|
||||
// Make faster, such as not saving to disk until the logging is stopped, dont' add to Instructions list every frame, etc
|
||||
// Remember window size
|
||||
private readonly List<string> _instructions = new List<string>();
|
||||
private FileInfo _logFile;
|
||||
|
||||
public TraceLogger()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
TraceView.QueryItemText += TraceView_QueryItemText;
|
||||
TraceView.QueryItemBkColor += TraceView_QueryItemBkColor;
|
||||
TraceView.VirtualMode = true;
|
||||
|
||||
TopMost = Global.Config.TraceLoggerOnTop;
|
||||
Closing += (o, e) => SaveConfigSettings();
|
||||
}
|
||||
|
||||
public void SaveConfigSettings()
|
||||
public bool UpdateBefore
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool AskSave()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SaveConfigSettings()
|
||||
{
|
||||
Global.CoreComm.Tracer.Enabled = false;
|
||||
Global.Config.TraceLoggerWndx = Location.X;
|
||||
Global.Config.TraceLoggerWndy = Location.Y;
|
||||
}
|
||||
|
||||
private void TraceView_QueryItemBkColor(int index, int column, ref Color color)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
private void TraceView_QueryItemText(int index, int column, out string text)
|
||||
{
|
||||
if (index < Instructions.Count)
|
||||
{
|
||||
text = Instructions[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "";
|
||||
}
|
||||
text = index < _instructions.Count ? _instructions[index] : String.Empty;
|
||||
}
|
||||
|
||||
private void TraceLogger_Load(object sender, EventArgs e)
|
||||
|
@ -72,7 +67,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void UpdateValues()
|
||||
{
|
||||
DoInstructions();
|
||||
TraceView.BlazingFast = !GlobalWin.MainForm.EmulatorPaused;
|
||||
if (ToWindowRadio.Checked)
|
||||
{
|
||||
LogToWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
LogToFile();
|
||||
}
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
|
@ -97,16 +100,210 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void ClearList()
|
||||
{
|
||||
Instructions.Clear();
|
||||
_instructions.Clear();
|
||||
TraceView.ItemCount = 0;
|
||||
SetTracerBoxTitle();
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void LogToFile()
|
||||
{
|
||||
using (var sw = new StreamWriter(_logFile.FullName, true))
|
||||
{
|
||||
sw.Write(Global.CoreComm.Tracer.TakeContents());
|
||||
}
|
||||
}
|
||||
|
||||
private void LogToWindow()
|
||||
{
|
||||
var instructions = Global.CoreComm.Tracer.TakeContents().Split('\n');
|
||||
if (!String.IsNullOrWhiteSpace(instructions[0]))
|
||||
{
|
||||
_instructions.AddRange(instructions);
|
||||
}
|
||||
|
||||
if (_instructions.Count >= Global.Config.TraceLoggerMaxLines)
|
||||
{
|
||||
var x = _instructions.Count - Global.Config.TraceLoggerMaxLines;
|
||||
_instructions.RemoveRange(0, x);
|
||||
}
|
||||
|
||||
TraceView.ItemCount = _instructions.Count;
|
||||
}
|
||||
|
||||
private Point GetPromptPoint()
|
||||
{
|
||||
return PointToScreen(
|
||||
new Point(TraceView.Location.X + 30, TraceView.Location.Y + 30)
|
||||
);
|
||||
}
|
||||
|
||||
private void SetTracerBoxTitle()
|
||||
{
|
||||
if (Global.CoreComm.Tracer.Enabled)
|
||||
{
|
||||
if (ToFileRadio.Checked)
|
||||
{
|
||||
TracerBox.Text = "Trace log - logging to file...";
|
||||
}
|
||||
else if (_instructions.Any())
|
||||
{
|
||||
TracerBox.Text = "Trace log - logging - " + _instructions.Count + " instructions";
|
||||
}
|
||||
else
|
||||
{
|
||||
TracerBox.Text = "Trace log - logging...";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_instructions.Any())
|
||||
{
|
||||
TracerBox.Text = "Trace log - " + _instructions.Count + " instructions";
|
||||
}
|
||||
else
|
||||
{
|
||||
TracerBox.Text = "Trace log";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseFile()
|
||||
{
|
||||
// TODO: save the remaining instructions in CoreComm
|
||||
}
|
||||
|
||||
private FileInfo GetFileFromUser()
|
||||
{
|
||||
var sfd = new SaveFileDialog();
|
||||
if (_logFile == null)
|
||||
{
|
||||
sfd.FileName = PathManager.FilesystemSafeName(Global.Game) + ".txt";
|
||||
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPath, null);
|
||||
}
|
||||
else if (!String.IsNullOrWhiteSpace(_logFile.FullName))
|
||||
{
|
||||
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
|
||||
sfd.InitialDirectory = Path.GetDirectoryName(_logFile.FullName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(_logFile.FullName);
|
||||
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPath, null);
|
||||
}
|
||||
|
||||
sfd.Filter = "Text Files (*.txt)|*.txt|Log Files (*.log)|*.log|All Files|*.*";
|
||||
sfd.RestoreDirectory = true;
|
||||
var result = sfd.ShowHawkDialog();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
return new FileInfo(sfd.FileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void DumpListToDisk(FileSystemInfo file)
|
||||
{
|
||||
using (var sw = new StreamWriter(file.FullName))
|
||||
{
|
||||
foreach (var instruction in _instructions)
|
||||
{
|
||||
sw.WriteLine(instruction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
#region Menu Items
|
||||
|
||||
private void SaveLogMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var file = GetFileFromUser();
|
||||
if (file != null)
|
||||
{
|
||||
DumpListToDisk(file);
|
||||
GlobalWin.OSD.AddMessage("Log dumped to " + file.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
private void ExitMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CopyMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var indices = TraceView.SelectedIndices;
|
||||
|
||||
if (indices.Count > 0)
|
||||
{
|
||||
var blob = new StringBuilder();
|
||||
foreach (int index in indices)
|
||||
{
|
||||
blob.AppendLine(_instructions[index]);
|
||||
}
|
||||
|
||||
blob.Remove(blob.Length - 2, 2); // Lazy way to not have a line break at the end
|
||||
Clipboard.SetDataObject(blob.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectAllMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
for (var i = 0; i < _instructions.Count; i++)
|
||||
{
|
||||
TraceView.SelectItem(i, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void MaxLinesMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var prompt = new InputPrompt();
|
||||
prompt.SetMessage("Max lines to display in the window");
|
||||
prompt.SetInitialValue(Global.Config.TraceLoggerMaxLines.ToString());
|
||||
prompt.TextInputType = InputPrompt.InputType.UNSIGNED;
|
||||
prompt._Location = GetPromptPoint();
|
||||
prompt.ShowDialog();
|
||||
if (prompt.UserOK)
|
||||
{
|
||||
var max = int.Parse(prompt.UserText);
|
||||
if (max > 0)
|
||||
{
|
||||
Global.Config.TraceLoggerMaxLines = max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
AutoloadMenuItem.Checked = Global.Config.TraceLoggerAutoLoad;
|
||||
SaveWindowPositionMenuItem.Checked = Global.Config.TraceLoggerSaveWindowPosition;
|
||||
AlwaysOnTopMenuItem.Checked = Global.Config.TraceLoggerOnTop;
|
||||
}
|
||||
|
||||
private void AutoloadMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.TraceLoggerAutoLoad ^= true;
|
||||
}
|
||||
|
||||
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.TraceLoggerSaveWindowPosition ^= true;
|
||||
}
|
||||
|
||||
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.TraceLoggerOnTop ^= true;
|
||||
TopMost = Global.Config.TraceLoggerOnTop;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dialog and ListView Events
|
||||
|
||||
private void LoggingEnabled_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Global.CoreComm.Tracer.Enabled = LoggingEnabled.Checked;
|
||||
|
@ -118,115 +315,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
ClearList();
|
||||
}
|
||||
|
||||
private void DoInstructions()
|
||||
private void BrowseBox_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ToWindowRadio.Checked)
|
||||
var file = GetFileFromUser();
|
||||
if (file != null)
|
||||
{
|
||||
LogToWindow();
|
||||
SetTracerBoxTitle();
|
||||
}
|
||||
else
|
||||
{
|
||||
LogToFile();
|
||||
}
|
||||
}
|
||||
|
||||
private void LogToFile()
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(LogFile.FullName, true))
|
||||
{
|
||||
sw.Write(Global.CoreComm.Tracer.TakeContents());
|
||||
}
|
||||
}
|
||||
|
||||
private void LogToWindow()
|
||||
{
|
||||
string[] instructions = Global.CoreComm.Tracer.TakeContents().Split('\n');
|
||||
if (!String.IsNullOrWhiteSpace(instructions[0]))
|
||||
{
|
||||
foreach (string s in instructions)
|
||||
{
|
||||
Instructions.Add(s);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (Instructions.Count >= Global.Config.TraceLoggerMaxLines)
|
||||
{
|
||||
int x = Instructions.Count - Global.Config.TraceLoggerMaxLines;
|
||||
Instructions.RemoveRange(0, x);
|
||||
}
|
||||
|
||||
TraceView.ItemCount = Instructions.Count;
|
||||
}
|
||||
|
||||
private void autoloadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.TraceLoggerAutoLoad ^= true;
|
||||
}
|
||||
|
||||
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
autoloadToolStripMenuItem.Checked = Global.Config.TraceLoggerAutoLoad;
|
||||
saveWindowPositionToolStripMenuItem.Checked = Global.Config.TraceLoggerSaveWindowPosition;
|
||||
}
|
||||
|
||||
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.TraceLoggerSaveWindowPosition ^= true;
|
||||
}
|
||||
|
||||
private Point GetPromptPoint()
|
||||
{
|
||||
Point p = new Point(TraceView.Location.X + 30, TraceView.Location.Y + 30);
|
||||
return PointToScreen(p);
|
||||
}
|
||||
|
||||
private void setMaxWindowLinesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
InputPrompt p = new InputPrompt();
|
||||
p.SetMessage("Max lines to display in the window");
|
||||
p.SetInitialValue(Global.Config.TraceLoggerMaxLines.ToString());
|
||||
p.TextInputType = InputPrompt.InputType.UNSIGNED;
|
||||
p._Location = GetPromptPoint();
|
||||
p.ShowDialog();
|
||||
if (p.UserOK)
|
||||
{
|
||||
int x = int.Parse(p.UserText);
|
||||
if (x > 0)
|
||||
{
|
||||
Global.Config.TraceLoggerMaxLines = x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetTracerBoxTitle()
|
||||
{
|
||||
if (Global.CoreComm.Tracer.Enabled)
|
||||
{
|
||||
if (ToFileRadio.Checked)
|
||||
{
|
||||
TracerBox.Text = "Trace log - logging to file...";
|
||||
}
|
||||
else if (Instructions.Count > 0)
|
||||
{
|
||||
TracerBox.Text = "Trace log - logging - " + Instructions.Count.ToString() + " instructions";
|
||||
}
|
||||
else
|
||||
{
|
||||
TracerBox.Text = "Trace log - logging...";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Instructions.Count > 0)
|
||||
{
|
||||
TracerBox.Text = "Trace log - " + Instructions.Count.ToString() + " instructions";
|
||||
}
|
||||
else
|
||||
{
|
||||
TracerBox.Text = "Trace log";
|
||||
}
|
||||
_logFile = file;
|
||||
FileBox.Text = _logFile.FullName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,142 +331,38 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
FileBox.Visible = true;
|
||||
BrowseBox.Visible = true;
|
||||
string name = PathManager.FilesystemSafeName(Global.Game);
|
||||
string filename = Path.Combine(PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPath, null), name) + ".txt";
|
||||
LogFile = new FileInfo(filename);
|
||||
if (LogFile.Directory != null && !LogFile.Directory.Exists)
|
||||
var name = PathManager.FilesystemSafeName(Global.Game);
|
||||
var filename = Path.Combine(PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPath, null), name) + ".txt";
|
||||
_logFile = new FileInfo(filename);
|
||||
if (_logFile.Directory != null && !_logFile.Directory.Exists)
|
||||
{
|
||||
LogFile.Directory.Create();
|
||||
_logFile.Directory.Create();
|
||||
}
|
||||
if (LogFile.Exists)
|
||||
|
||||
if (_logFile.Exists)
|
||||
{
|
||||
LogFile.Delete();
|
||||
LogFile.Create();
|
||||
_logFile.Delete();
|
||||
_logFile.Create();
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFile.Create();
|
||||
_logFile.Create();
|
||||
}
|
||||
|
||||
FileBox.Text = LogFile.FullName;
|
||||
FileBox.Text = _logFile.FullName;
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseFile();
|
||||
FileBox.Visible = false;
|
||||
BrowseBox.Visible = false;
|
||||
|
||||
}
|
||||
|
||||
SetTracerBoxTitle();
|
||||
}
|
||||
|
||||
private void CloseFile()
|
||||
{
|
||||
//TODO: save the remaining instructions in CoreComm
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void TraceView_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control && e.KeyCode == Keys.C)
|
||||
{
|
||||
ListView.SelectedIndexCollection indexes = TraceView.SelectedIndices;
|
||||
|
||||
if (indexes.Count > 0)
|
||||
{
|
||||
StringBuilder blob = new StringBuilder();
|
||||
foreach (int x in indexes)
|
||||
{
|
||||
blob.Append(Instructions[x]);
|
||||
blob.Append("\r\n");
|
||||
}
|
||||
blob.Remove(blob.Length - 2, 2); //Lazy way to not have a line break at the end
|
||||
Clipboard.SetDataObject(blob.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BrowseBox_Click(object sender, EventArgs e)
|
||||
{
|
||||
var file = GetFileFromUser();
|
||||
if (file != null)
|
||||
{
|
||||
LogFile = file;
|
||||
FileBox.Text = LogFile.FullName;
|
||||
}
|
||||
}
|
||||
|
||||
private FileInfo GetFileFromUser()
|
||||
{
|
||||
var sfd = new SaveFileDialog();
|
||||
if (LogFile == null)
|
||||
{
|
||||
string name = PathManager.FilesystemSafeName(Global.Game);
|
||||
sfd.FileName = name + ".txt";
|
||||
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPath, null);
|
||||
}
|
||||
else if (!String.IsNullOrWhiteSpace(LogFile.FullName))
|
||||
{
|
||||
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
|
||||
sfd.InitialDirectory = Path.GetDirectoryName(LogFile.FullName);
|
||||
}
|
||||
else
|
||||
{
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(LogFile.FullName);
|
||||
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPath, null);
|
||||
}
|
||||
|
||||
sfd.Filter = "Text Files (*.txt)|*.txt|Log Files (*.log)|*.log|All Files|*.*";
|
||||
sfd.RestoreDirectory = true;
|
||||
var result = sfd.ShowHawkDialog();
|
||||
if (result != DialogResult.OK)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new FileInfo(sfd.FileName);
|
||||
}
|
||||
|
||||
private void saveLogToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var file = GetFileFromUser();
|
||||
if (file != null)
|
||||
{
|
||||
DumpListToDisk(file);
|
||||
GlobalWin.OSD.AddMessage("Log dumped to " + file.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
private void DumpListToDisk(FileInfo file)
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(file.FullName))
|
||||
{
|
||||
foreach (string s in Instructions)
|
||||
{
|
||||
sw.WriteLine(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CopyAllToClipboard()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (string s in Instructions)
|
||||
sb.AppendLine(s);
|
||||
string ss = sb.ToString();
|
||||
if (!string.IsNullOrEmpty(ss))
|
||||
Clipboard.SetText(sb.ToString(), TextDataFormat.Text);
|
||||
}
|
||||
|
||||
private void TraceLogger_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (ModifierKeys.HasFlag(Keys.Control) && e.KeyCode == Keys.C)
|
||||
CopyAllToClipboard();
|
||||
}
|
||||
|
||||
private void copyAllToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CopyAllToClipboard();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,8 +93,7 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
if (logging)
|
||||
{
|
||||
buffer.Append(content);
|
||||
buffer.Append('\n');
|
||||
buffer.AppendLine(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue