diff --git a/src/CxbxDebugger/CxbxDebuggerInstance.Designer.cs b/src/CxbxDebugger/CxbxDebuggerInstance.Designer.cs index 5e1bca50a..73b475d7d 100644 --- a/src/CxbxDebugger/CxbxDebuggerInstance.Designer.cs +++ b/src/CxbxDebugger/CxbxDebuggerInstance.Designer.cs @@ -36,8 +36,6 @@ this.toolStripLabel2 = new System.Windows.Forms.ToolStripLabel(); this.cbFrames = new System.Windows.Forms.ToolStripComboBox(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); - this.statusBar = new System.Windows.Forms.StatusStrip(); - this.lblStatus = new System.Windows.Forms.ToolStripStatusLabel(); this.tabContainer = new System.Windows.Forms.TabControl(); this.tabSummary = new System.Windows.Forms.TabPage(); this.linkLabel3 = new System.Windows.Forms.LinkLabel(); @@ -115,7 +113,6 @@ this.txDisassembly = new CxbxDebugger.RicherTextBox(); this.toolStrip1.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout(); - this.statusBar.SuspendLayout(); this.tabContainer.SuspendLayout(); this.tabSummary.SuspendLayout(); this.tabDisassembly.SuspendLayout(); @@ -161,11 +158,11 @@ this.lbConsole.Dock = System.Windows.Forms.DockStyle.Fill; this.lbConsole.FormattingEnabled = true; this.lbConsole.ItemHeight = 20; - this.lbConsole.Location = new System.Drawing.Point(4, 361); + this.lbConsole.Location = new System.Drawing.Point(4, 425); this.lbConsole.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.lbConsole.Name = "lbConsole"; this.lbConsole.ScrollAlwaysVisible = true; - this.lbConsole.Size = new System.Drawing.Size(1093, 79); + this.lbConsole.Size = new System.Drawing.Size(1185, 96); this.lbConsole.TabIndex = 2; // // toolStrip1 @@ -181,7 +178,7 @@ this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Padding = new System.Windows.Forms.Padding(0, 0, 3, 0); this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this.toolStrip1.Size = new System.Drawing.Size(1101, 33); + this.toolStrip1.Size = new System.Drawing.Size(1193, 33); this.toolStrip1.TabIndex = 7; this.toolStrip1.Text = "toolStrip1"; // @@ -215,39 +212,19 @@ // this.tableLayoutPanel3.ColumnCount = 1; this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel3.Controls.Add(this.statusBar, 0, 2); this.tableLayoutPanel3.Controls.Add(this.tabContainer, 0, 0); this.tableLayoutPanel3.Controls.Add(this.lbConsole, 0, 1); this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 33); this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tableLayoutPanel3.Name = "tableLayoutPanel3"; - this.tableLayoutPanel3.RowCount = 3; + this.tableLayoutPanel3.RowCount = 2; this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 80F)); this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(1101, 476); + this.tableLayoutPanel3.Size = new System.Drawing.Size(1193, 526); this.tableLayoutPanel3.TabIndex = 9; // - // statusBar - // - this.statusBar.Dock = System.Windows.Forms.DockStyle.Fill; - this.statusBar.ImageScalingSize = new System.Drawing.Size(24, 24); - this.statusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.lblStatus}); - this.statusBar.Location = new System.Drawing.Point(0, 445); - this.statusBar.Name = "statusBar"; - this.statusBar.Padding = new System.Windows.Forms.Padding(2, 0, 21, 0); - this.statusBar.Size = new System.Drawing.Size(1101, 31); - this.statusBar.TabIndex = 10; - this.statusBar.Text = "statusStrip1"; - // - // lblStatus - // - this.lblStatus.Name = "lblStatus"; - this.lblStatus.Size = new System.Drawing.Size(60, 24); - this.lblStatus.Text = "Ready"; - // // tabContainer // this.tabContainer.Controls.Add(this.tabSummary); @@ -263,7 +240,7 @@ this.tabContainer.Multiline = true; this.tabContainer.Name = "tabContainer"; this.tabContainer.SelectedIndex = 0; - this.tabContainer.Size = new System.Drawing.Size(1093, 346); + this.tabContainer.Size = new System.Drawing.Size(1185, 410); this.tabContainer.TabIndex = 3; // // tabSummary @@ -277,7 +254,7 @@ this.tabSummary.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tabSummary.Name = "tabSummary"; this.tabSummary.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabSummary.Size = new System.Drawing.Size(1085, 313); + this.tabSummary.Size = new System.Drawing.Size(1177, 377); this.tabSummary.TabIndex = 6; this.tabSummary.Text = "Summary"; this.tabSummary.UseVisualStyleBackColor = true; @@ -345,7 +322,7 @@ this.tabDisassembly.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tabDisassembly.Name = "tabDisassembly"; this.tabDisassembly.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabDisassembly.Size = new System.Drawing.Size(1085, 309); + this.tabDisassembly.Size = new System.Drawing.Size(1085, 337); this.tabDisassembly.TabIndex = 0; this.tabDisassembly.Text = "Disassembly"; this.tabDisassembly.UseVisualStyleBackColor = true; @@ -372,7 +349,7 @@ // splitContainer2.Panel2 // this.splitContainer2.Panel2.Controls.Add(this.txDisassembly); - this.splitContainer2.Size = new System.Drawing.Size(1077, 299); + this.splitContainer2.Size = new System.Drawing.Size(1077, 327); this.splitContainer2.SplitterDistance = 34; this.splitContainer2.SplitterWidth = 6; this.splitContainer2.TabIndex = 2; @@ -455,7 +432,7 @@ this.tabBreakpoints.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tabBreakpoints.Name = "tabBreakpoints"; this.tabBreakpoints.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabBreakpoints.Size = new System.Drawing.Size(1085, 309); + this.tabBreakpoints.Size = new System.Drawing.Size(1085, 337); this.tabBreakpoints.TabIndex = 1; this.tabBreakpoints.Text = "Breakpoints"; this.tabBreakpoints.UseVisualStyleBackColor = true; @@ -475,7 +452,7 @@ // splitContainer3.Panel2 // this.splitContainer3.Panel2.Controls.Add(this.clbBreakpoints); - this.splitContainer3.Size = new System.Drawing.Size(1077, 299); + this.splitContainer3.Size = new System.Drawing.Size(1077, 327); this.splitContainer3.SplitterDistance = 357; this.splitContainer3.SplitterWidth = 6; this.splitContainer3.TabIndex = 5; @@ -491,7 +468,7 @@ this.groupBox4.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.groupBox4.Name = "groupBox4"; this.groupBox4.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.groupBox4.Size = new System.Drawing.Size(351, 122); + this.groupBox4.Size = new System.Drawing.Size(351, 150); this.groupBox4.TabIndex = 5; this.groupBox4.TabStop = false; this.groupBox4.Text = "Interrupts"; @@ -600,7 +577,7 @@ this.clbBreakpoints.Location = new System.Drawing.Point(0, 0); this.clbBreakpoints.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.clbBreakpoints.Name = "clbBreakpoints"; - this.clbBreakpoints.Size = new System.Drawing.Size(714, 299); + this.clbBreakpoints.Size = new System.Drawing.Size(714, 327); this.clbBreakpoints.TabIndex = 0; this.clbBreakpoints.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.clbBreakpoints_ItemCheck); this.clbBreakpoints.KeyDown += new System.Windows.Forms.KeyEventHandler(this.clbBreakpoints_KeyDown); @@ -612,7 +589,7 @@ this.tabWatch.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tabWatch.Name = "tabWatch"; this.tabWatch.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabWatch.Size = new System.Drawing.Size(1085, 309); + this.tabWatch.Size = new System.Drawing.Size(1085, 337); this.tabWatch.TabIndex = 2; this.tabWatch.Text = "File Watcher"; this.tabWatch.UseVisualStyleBackColor = true; @@ -631,7 +608,7 @@ // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.lbOpenedFiles); - this.splitContainer1.Size = new System.Drawing.Size(1077, 299); + this.splitContainer1.Size = new System.Drawing.Size(1077, 327); this.splitContainer1.SplitterDistance = 755; this.splitContainer1.SplitterWidth = 6; this.splitContainer1.TabIndex = 3; @@ -649,7 +626,7 @@ this.lvFileDetails.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.lvFileDetails.MultiSelect = false; this.lvFileDetails.Name = "lvFileDetails"; - this.lvFileDetails.Size = new System.Drawing.Size(755, 299); + this.lvFileDetails.Size = new System.Drawing.Size(755, 327); this.lvFileDetails.TabIndex = 2; this.lvFileDetails.UseCompatibleStateImageBehavior = false; this.lvFileDetails.View = System.Windows.Forms.View.Details; @@ -677,7 +654,7 @@ this.lbOpenedFiles.Location = new System.Drawing.Point(0, 0); this.lbOpenedFiles.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.lbOpenedFiles.Name = "lbOpenedFiles"; - this.lbOpenedFiles.Size = new System.Drawing.Size(316, 299); + this.lbOpenedFiles.Size = new System.Drawing.Size(316, 327); this.lbOpenedFiles.TabIndex = 0; // // tabMemory @@ -687,7 +664,7 @@ this.tabMemory.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tabMemory.Name = "tabMemory"; this.tabMemory.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabMemory.Size = new System.Drawing.Size(1085, 309); + this.tabMemory.Size = new System.Drawing.Size(1085, 337); this.tabMemory.TabIndex = 4; this.tabMemory.Text = "Memory Viewer"; this.tabMemory.UseVisualStyleBackColor = true; @@ -706,7 +683,7 @@ // splitContainer4.Panel2 // this.splitContainer4.Panel2.Controls.Add(this.groupBox2); - this.splitContainer4.Size = new System.Drawing.Size(1077, 299); + this.splitContainer4.Size = new System.Drawing.Size(1077, 327); this.splitContainer4.SplitterDistance = 566; this.splitContainer4.SplitterWidth = 6; this.splitContainer4.TabIndex = 7; @@ -723,7 +700,7 @@ this.txMemoryDump.Name = "txMemoryDump"; this.txMemoryDump.ReadOnly = true; this.txMemoryDump.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txMemoryDump.Size = new System.Drawing.Size(566, 299); + this.txMemoryDump.Size = new System.Drawing.Size(566, 327); this.txMemoryDump.TabIndex = 0; // // groupBox2 @@ -743,7 +720,7 @@ this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.groupBox2.Name = "groupBox2"; this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.groupBox2.Size = new System.Drawing.Size(505, 299); + this.groupBox2.Size = new System.Drawing.Size(505, 327); this.groupBox2.TabIndex = 8; this.groupBox2.TabStop = false; this.groupBox2.Text = "View or Dump Memory"; @@ -868,7 +845,7 @@ this.tabTweaks.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tabTweaks.Name = "tabTweaks"; this.tabTweaks.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabTweaks.Size = new System.Drawing.Size(1085, 309); + this.tabTweaks.Size = new System.Drawing.Size(1085, 337); this.tabTweaks.TabIndex = 5; this.tabTweaks.Text = "Memory Editor"; this.tabTweaks.UseVisualStyleBackColor = true; @@ -882,7 +859,7 @@ this.tabCEContainer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tabCEContainer.Name = "tabCEContainer"; this.tabCEContainer.SelectedIndex = 0; - this.tabCEContainer.Size = new System.Drawing.Size(1077, 299); + this.tabCEContainer.Size = new System.Drawing.Size(1077, 327); this.tabCEContainer.TabIndex = 5; // // tabSubData @@ -892,7 +869,7 @@ this.tabSubData.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tabSubData.Name = "tabSubData"; this.tabSubData.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabSubData.Size = new System.Drawing.Size(1069, 266); + this.tabSubData.Size = new System.Drawing.Size(1069, 294); this.tabSubData.TabIndex = 0; this.tabSubData.Text = "Edit Data"; this.tabSubData.UseVisualStyleBackColor = true; @@ -915,8 +892,8 @@ // splitContainer6.Panel2 // this.splitContainer6.Panel2.Controls.Add(this.lvCEMemory); - this.splitContainer6.Size = new System.Drawing.Size(1061, 256); - this.splitContainer6.SplitterDistance = 54; + this.splitContainer6.Size = new System.Drawing.Size(1061, 284); + this.splitContainer6.SplitterDistance = 59; this.splitContainer6.SplitterWidth = 6; this.splitContainer6.TabIndex = 2; // @@ -978,7 +955,7 @@ this.lvCEMemory.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.lvCEMemory.MultiSelect = false; this.lvCEMemory.Name = "lvCEMemory"; - this.lvCEMemory.Size = new System.Drawing.Size(1061, 196); + this.lvCEMemory.Size = new System.Drawing.Size(1061, 219); this.lvCEMemory.TabIndex = 1; this.lvCEMemory.UseCompatibleStateImageBehavior = false; this.lvCEMemory.View = System.Windows.Forms.View.Details; @@ -1010,7 +987,7 @@ this.tabSubAssembly.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tabSubAssembly.Name = "tabSubAssembly"; this.tabSubAssembly.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabSubAssembly.Size = new System.Drawing.Size(1069, 266); + this.tabSubAssembly.Size = new System.Drawing.Size(1069, 294); this.tabSubAssembly.TabIndex = 1; this.tabSubAssembly.Text = "Edit Assembly"; this.tabSubAssembly.UseVisualStyleBackColor = true; @@ -1061,7 +1038,7 @@ this.tabOutput.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tabOutput.Name = "tabOutput"; this.tabOutput.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabOutput.Size = new System.Drawing.Size(1085, 309); + this.tabOutput.Size = new System.Drawing.Size(1085, 337); this.tabOutput.TabIndex = 3; this.tabOutput.Text = "Debug Output"; this.tabOutput.UseVisualStyleBackColor = true; @@ -1084,7 +1061,7 @@ // splitContainer5.Panel2 // this.splitContainer5.Panel2.Controls.Add(this.lbDebug); - this.splitContainer5.Size = new System.Drawing.Size(1077, 299); + this.splitContainer5.Size = new System.Drawing.Size(1077, 327); this.splitContainer5.SplitterDistance = 26; this.splitContainer5.SplitterWidth = 6; this.splitContainer5.TabIndex = 6; @@ -1120,7 +1097,7 @@ this.lbDebug.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.lbDebug.Name = "lbDebug"; this.lbDebug.ScrollAlwaysVisible = true; - this.lbDebug.Size = new System.Drawing.Size(1077, 267); + this.lbDebug.Size = new System.Drawing.Size(1077, 295); this.lbDebug.TabIndex = 3; // // diagSaveMemory @@ -1145,7 +1122,7 @@ this.txDisassembly.Name = "txDisassembly"; this.txDisassembly.ReadOnly = true; this.txDisassembly.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical; - this.txDisassembly.Size = new System.Drawing.Size(1077, 259); + this.txDisassembly.Size = new System.Drawing.Size(1077, 287); this.txDisassembly.TabIndex = 1; this.txDisassembly.Text = ""; // @@ -1153,7 +1130,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.ClientSize = new System.Drawing.Size(1101, 509); + this.ClientSize = new System.Drawing.Size(1193, 559); this.ControlBox = false; this.Controls.Add(this.tableLayoutPanel3); this.Controls.Add(this.toolStrip1); @@ -1166,9 +1143,6 @@ this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); this.tableLayoutPanel3.ResumeLayout(false); - this.tableLayoutPanel3.PerformLayout(); - this.statusBar.ResumeLayout(false); - this.statusBar.PerformLayout(); this.tabContainer.ResumeLayout(false); this.tabSummary.ResumeLayout(false); this.tabSummary.PerformLayout(); @@ -1242,8 +1216,6 @@ private System.Windows.Forms.TextBox txAddress; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.TextBox tbFilter; - private System.Windows.Forms.StatusStrip statusBar; - private System.Windows.Forms.ToolStripStatusLabel lblStatus; private RicherTextBox txDisassembly; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; diff --git a/src/CxbxDebugger/CxbxDebuggerInstance.cs b/src/CxbxDebugger/CxbxDebuggerInstance.cs index 44e2c8888..e8499495a 100644 --- a/src/CxbxDebugger/CxbxDebuggerInstance.cs +++ b/src/CxbxDebugger/CxbxDebuggerInstance.cs @@ -37,6 +37,16 @@ namespace CxbxDebugger } } + DebugStateInfo StateInfo = new DebugStateInfo(); + + private void SetDebugState(DebugState State, string Detail = "") + { + DebugContainer.ReportStatus(this, State, Detail); + + StateInfo.State = State; + StateInfo.Detail = Detail; + } + List FileHandles = new List(); public CxbxDebuggerInstance(Form Owner, string[] args) @@ -57,7 +67,7 @@ namespace CxbxDebugger DebugEvents = new DebuggerFormEvents(this); - DebugContainer.ReportStatus(this, DebugState.Unknown); + SetDebugState(DebugState.Unknown); txDisassembly.InlineLinkClicked += OnDisassemblyNavigation; @@ -99,11 +109,13 @@ namespace CxbxDebugger DebuggerInst.RegisterEventInterfaces(DebugEvents); DebuggerInst.RegisterEventInterfaces(patchMan); - var ProcessName = Path.GetFileName(DebuggerInst.TargetPath); + var TargetXbeName = ValidateXbeTargetName(DebuggerInst.TargetPath); + var TargetXbeValid = true; - if (string.IsNullOrEmpty(ProcessName)) + if (string.IsNullOrEmpty(TargetXbeName)) { - ProcessName = ""; + TargetXbeName = ""; + TargetXbeValid = false; } if (InvokeRequired) @@ -111,21 +123,44 @@ namespace CxbxDebugger // Set form title based on this new process Invoke(new MethodInvoker(delegate () { - Text = ProcessName; + Text = TargetXbeName; })); } else { - Text = ProcessName; + Text = TargetXbeName; } - if (File.Exists(DebuggerInst.TargetPath)) + if (TargetXbeValid) { - DebugContainer.ReportStatus(this, DebugState.Idle); + SetDebugState(DebugState.Idle, $"{TargetXbeName} is waiting to start"); } } } + private string ValidateXbeTargetName(string XbePath) + { + var XbeName = Path.GetFileName(XbePath); + + if (File.Exists(XbePath)) + { + return XbeName; + } + + // Cxbx CLI will pass through the path as a list of parameters, "dir;name" + if (XbeName.StartsWith(";")) + { + var CleanedXbePath = XbePath.Remove(XbePath.Length - XbeName.Length, 1); + + if (File.Exists(CleanedXbePath)) + { + return XbeName.Substring(1); + } + } + + return null; + } + private void StartDebugging() { if (GetSessionState() == SessionState.Inactive) @@ -306,7 +341,7 @@ namespace CxbxDebugger { Invoke(new MethodInvoker(delegate () { - Suspend("file open"); + Suspend(DebugState.Breakpoint, "Hit file event"); })); } } @@ -353,7 +388,7 @@ namespace CxbxDebugger else { string module_name = Path.GetFileName(Module.Path); - Suspend(string.Format("Breakpoint hit in {0} at 0x{1:x}", module_name, Address)); + Suspend(DebugState.Breakpoint, string.Format("Breakpoint hit in {0} at 0x{1:x}", module_name, Address)); // Forces a refresh at the breakpoint address (not the callstack trace) DumpDisassembly(Address); @@ -368,17 +403,12 @@ namespace CxbxDebugger { Invoke(new MethodInvoker(delegate () { - DebugContainer.ReportStatus(this, Active ? DebugState.Running : DebugState.Terminated); - - //lblStatusText.Text = Active ? "Running" : "Terminated"; - + SetDebugState(Active ? DebugState.Running : DebugState.Terminated); })); } else { - DebugContainer.ReportStatus(this, Active ? DebugState.Running : DebugState.Terminated); - - //lblStatusText.Text = Active ? "Running" : "Terminated"; + SetDebugState(Active ? DebugState.Running : DebugState.Terminated); } } @@ -603,7 +633,7 @@ namespace CxbxDebugger } } - private void Suspend(string Reason) + private void Suspend(DebugState State, string Detail) { if (DebuggerInst != null) { @@ -619,7 +649,7 @@ namespace CxbxDebugger PopulateThreadList(cbThreads, null); } - DebugContainer.ReportStatus(this, DebugState.Suspended, Reason); + SetDebugState(State, Detail); cbThreads.Enabled = true; cbFrames.Enabled = true; @@ -640,7 +670,7 @@ namespace CxbxDebugger } } - DebugContainer.ReportStatus(this, DebugState.Running); + SetDebugState(DebugState.Running); cbThreads.Enabled = false; cbFrames.Enabled = false; @@ -1284,7 +1314,7 @@ namespace CxbxDebugger { if (GetSessionState() == SessionState.Running) { - Suspend("manually triggered"); + Suspend(DebugState.Suspended, "By user"); } } @@ -1308,9 +1338,9 @@ namespace CxbxDebugger tabContainer.SelectedTab = tabDisassembly; } - private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) + public DebugStateInfo GetDebugStateInfo() { - + return StateInfo; } } } diff --git a/src/CxbxDebugger/CxbxDebuggerInstance.resx b/src/CxbxDebugger/CxbxDebuggerInstance.resx index bd3ccd6e6..7fabf25c5 100644 --- a/src/CxbxDebugger/CxbxDebuggerInstance.resx +++ b/src/CxbxDebugger/CxbxDebuggerInstance.resx @@ -120,9 +120,6 @@ 534, 17 - - 17, 17 - 153, 17 diff --git a/src/CxbxDebugger/CxbxDebuggerMain.Designer.cs b/src/CxbxDebugger/CxbxDebuggerMain.Designer.cs index 6003267d9..419baad39 100644 --- a/src/CxbxDebugger/CxbxDebuggerMain.Designer.cs +++ b/src/CxbxDebugger/CxbxDebuggerMain.Designer.cs @@ -34,24 +34,21 @@ this.fileMenu = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.startDebuggingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.miStartDebugging = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); - this.suspendToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.resumeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.miSuspend = new System.Windows.Forms.ToolStripMenuItem(); + this.miResume = new System.Windows.Forms.ToolStripMenuItem(); this.windowsMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.cascadeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.tileVerticalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.tileHorizontalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.arrangeIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.statusStrip = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.lblStatus = new System.Windows.Forms.ToolStripStatusLabel(); this.menuStrip.SuspendLayout(); - this.statusStrip.SuspendLayout(); + this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // // menuStrip // + this.menuStrip.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2); this.menuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileMenu, @@ -60,8 +57,7 @@ this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.MdiWindowListItem = this.windowsMenu; this.menuStrip.Name = "menuStrip"; - this.menuStrip.Padding = new System.Windows.Forms.Padding(4, 1, 0, 1); - this.menuStrip.Size = new System.Drawing.Size(1281, 24); + this.menuStrip.Size = new System.Drawing.Size(1922, 36); this.menuStrip.TabIndex = 0; this.menuStrip.Text = "MenuStrip"; // @@ -71,132 +67,101 @@ this.exitToolStripMenuItem}); this.fileMenu.ImageTransparentColor = System.Drawing.SystemColors.ActiveBorder; this.fileMenu.Name = "fileMenu"; - this.fileMenu.Size = new System.Drawing.Size(37, 22); + this.fileMenu.Size = new System.Drawing.Size(54, 32); this.fileMenu.Text = "&File"; // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.ShortcutKeyDisplayString = "Alt+F4"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(135, 22); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(206, 34); this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.ExitToolsStripMenuItem_Click); // // debugToolStripMenuItem // this.debugToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.startDebuggingToolStripMenuItem, + this.miStartDebugging, this.toolStripMenuItem1, - this.suspendToolStripMenuItem, - this.resumeToolStripMenuItem}); + this.miSuspend, + this.miResume}); this.debugToolStripMenuItem.Name = "debugToolStripMenuItem"; - this.debugToolStripMenuItem.Size = new System.Drawing.Size(54, 22); + this.debugToolStripMenuItem.Size = new System.Drawing.Size(82, 32); this.debugToolStripMenuItem.Text = "Debug"; // - // startDebuggingToolStripMenuItem + // miStartDebugging // - this.startDebuggingToolStripMenuItem.Image = global::CxbxDebugger.Properties.Resources.run; - this.startDebuggingToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; - this.startDebuggingToolStripMenuItem.Name = "startDebuggingToolStripMenuItem"; - this.startDebuggingToolStripMenuItem.Size = new System.Drawing.Size(160, 22); - this.startDebuggingToolStripMenuItem.Text = "&Start Debugging"; - this.startDebuggingToolStripMenuItem.Click += new System.EventHandler(this.startDebuggingToolStripMenuItem_Click); + this.miStartDebugging.Image = global::CxbxDebugger.Properties.Resources.run; + this.miStartDebugging.ImageTransparentColor = System.Drawing.Color.Magenta; + this.miStartDebugging.Name = "miStartDebugging"; + this.miStartDebugging.ShortcutKeyDisplayString = "F5"; + this.miStartDebugging.Size = new System.Drawing.Size(181, 34); + this.miStartDebugging.Text = "&Start"; + this.miStartDebugging.Click += new System.EventHandler(this.startDebuggingToolStripMenuItem_Click); // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(157, 6); + this.toolStripMenuItem1.Size = new System.Drawing.Size(178, 6); // - // suspendToolStripMenuItem + // miSuspend // - this.suspendToolStripMenuItem.Image = global::CxbxDebugger.Properties.Resources.pause; - this.suspendToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; - this.suspendToolStripMenuItem.Name = "suspendToolStripMenuItem"; - this.suspendToolStripMenuItem.Size = new System.Drawing.Size(160, 22); - this.suspendToolStripMenuItem.Text = "&Suspend"; - this.suspendToolStripMenuItem.Click += new System.EventHandler(this.suspendToolStripMenuItem_Click); + this.miSuspend.Image = global::CxbxDebugger.Properties.Resources.pause; + this.miSuspend.ImageTransparentColor = System.Drawing.Color.Magenta; + this.miSuspend.Name = "miSuspend"; + this.miSuspend.Size = new System.Drawing.Size(181, 34); + this.miSuspend.Text = "&Break"; + this.miSuspend.Click += new System.EventHandler(this.suspendToolStripMenuItem_Click); // - // resumeToolStripMenuItem + // miResume // - this.resumeToolStripMenuItem.Image = global::CxbxDebugger.Properties.Resources.run; - this.resumeToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; - this.resumeToolStripMenuItem.Name = "resumeToolStripMenuItem"; - this.resumeToolStripMenuItem.Size = new System.Drawing.Size(160, 22); - this.resumeToolStripMenuItem.Text = "&Resume"; - this.resumeToolStripMenuItem.Click += new System.EventHandler(this.resumeToolStripMenuItem_Click); + this.miResume.Image = global::CxbxDebugger.Properties.Resources.run; + this.miResume.ImageTransparentColor = System.Drawing.Color.Magenta; + this.miResume.Name = "miResume"; + this.miResume.Size = new System.Drawing.Size(181, 34); + this.miResume.Text = "&Resume"; + this.miResume.Click += new System.EventHandler(this.resumeToolStripMenuItem_Click); // // windowsMenu // - this.windowsMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.cascadeToolStripMenuItem, - this.tileVerticalToolStripMenuItem, - this.tileHorizontalToolStripMenuItem, - this.arrangeIconsToolStripMenuItem}); this.windowsMenu.Name = "windowsMenu"; - this.windowsMenu.Size = new System.Drawing.Size(68, 22); + this.windowsMenu.Size = new System.Drawing.Size(102, 32); this.windowsMenu.Text = "&Windows"; // - // cascadeToolStripMenuItem + // statusStrip1 // - this.cascadeToolStripMenuItem.Name = "cascadeToolStripMenuItem"; - this.cascadeToolStripMenuItem.Size = new System.Drawing.Size(150, 22); - this.cascadeToolStripMenuItem.Text = "&Cascade"; - this.cascadeToolStripMenuItem.Click += new System.EventHandler(this.CascadeToolStripMenuItem_Click); + this.statusStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.lblStatus}); + this.statusStrip1.Location = new System.Drawing.Point(0, 818); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(1922, 32); + this.statusStrip1.TabIndex = 2; + this.statusStrip1.Text = "statusStrip1"; // - // tileVerticalToolStripMenuItem + // lblStatus // - this.tileVerticalToolStripMenuItem.Name = "tileVerticalToolStripMenuItem"; - this.tileVerticalToolStripMenuItem.Size = new System.Drawing.Size(150, 22); - this.tileVerticalToolStripMenuItem.Text = "Tile &Vertical"; - this.tileVerticalToolStripMenuItem.Click += new System.EventHandler(this.TileVerticalToolStripMenuItem_Click); - // - // tileHorizontalToolStripMenuItem - // - this.tileHorizontalToolStripMenuItem.Name = "tileHorizontalToolStripMenuItem"; - this.tileHorizontalToolStripMenuItem.Size = new System.Drawing.Size(150, 22); - this.tileHorizontalToolStripMenuItem.Text = "Tile &Horizontal"; - this.tileHorizontalToolStripMenuItem.Click += new System.EventHandler(this.TileHorizontalToolStripMenuItem_Click); - // - // arrangeIconsToolStripMenuItem - // - this.arrangeIconsToolStripMenuItem.Name = "arrangeIconsToolStripMenuItem"; - this.arrangeIconsToolStripMenuItem.Size = new System.Drawing.Size(150, 22); - this.arrangeIconsToolStripMenuItem.Text = "&Arrange Icons"; - this.arrangeIconsToolStripMenuItem.Click += new System.EventHandler(this.ArrangeIconsToolStripMenuItem_Click); - // - // statusStrip - // - this.statusStrip.ImageScalingSize = new System.Drawing.Size(24, 24); - this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabel}); - this.statusStrip.Location = new System.Drawing.Point(0, 545); - this.statusStrip.Name = "statusStrip"; - this.statusStrip.Size = new System.Drawing.Size(1281, 22); - this.statusStrip.TabIndex = 2; - this.statusStrip.Text = "StatusStrip"; - // - // toolStripStatusLabel - // - this.toolStripStatusLabel.Name = "toolStripStatusLabel"; - this.toolStripStatusLabel.Size = new System.Drawing.Size(39, 17); - this.toolStripStatusLabel.Text = "Status"; + this.lblStatus.Name = "lblStatus"; + this.lblStatus.Size = new System.Drawing.Size(60, 25); + this.lblStatus.Text = "Ready"; // // CxbxDebuggerMain // - this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.ClientSize = new System.Drawing.Size(1281, 567); - this.Controls.Add(this.statusStrip); + this.ClientSize = new System.Drawing.Size(1922, 850); + this.Controls.Add(this.statusStrip1); this.Controls.Add(this.menuStrip); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.IsMdiContainer = true; this.MainMenuStrip = this.menuStrip; + this.Margin = new System.Windows.Forms.Padding(4); this.Name = "CxbxDebuggerMain"; this.Text = "cxbx-debugger"; this.menuStrip.ResumeLayout(false); this.menuStrip.PerformLayout(); - this.statusStrip.ResumeLayout(false); - this.statusStrip.PerformLayout(); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -205,21 +170,17 @@ private System.Windows.Forms.MenuStrip menuStrip; - private System.Windows.Forms.StatusStrip statusStrip; - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel; - private System.Windows.Forms.ToolStripMenuItem tileHorizontalToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem fileMenu; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem windowsMenu; - private System.Windows.Forms.ToolStripMenuItem cascadeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem tileVerticalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem arrangeIconsToolStripMenuItem; private System.Windows.Forms.ToolTip toolTip; private System.Windows.Forms.ToolStripMenuItem debugToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem startDebuggingToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem miStartDebugging; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem suspendToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem resumeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem miSuspend; + private System.Windows.Forms.ToolStripMenuItem miResume; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel lblStatus; } } diff --git a/src/CxbxDebugger/CxbxDebuggerMain.cs b/src/CxbxDebugger/CxbxDebuggerMain.cs index c1b600afb..c88091a9c 100644 --- a/src/CxbxDebugger/CxbxDebuggerMain.cs +++ b/src/CxbxDebugger/CxbxDebuggerMain.cs @@ -1,4 +1,7 @@ -using System; +// Written by x1nixmzeng for the Cxbx-Reloaded project +// + +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -21,6 +24,10 @@ namespace CxbxDebugger // Setup session without initially running the game AddDebugSession(StartupArgs, false); + +#if FALSE + AddDebugSession(new string[] { }, false); +#endif } private void ExitToolsStripMenuItem_Click(object sender, EventArgs e) @@ -28,56 +35,27 @@ namespace CxbxDebugger Close(); } - private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) - { - LayoutMdi(MdiLayout.Cascade); - } - - private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e) - { - LayoutMdi(MdiLayout.TileVertical); - } - - private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) - { - LayoutMdi(MdiLayout.TileHorizontal); - } - - private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) - { - LayoutMdi(MdiLayout.ArrangeIcons); - } - private void startDebuggingToolStripMenuItem_Click(object sender, EventArgs e) { - foreach (Form childForm in MdiChildren) + if (ActiveMdiChild is IDebugWindow) { - if (childForm is IDebugWindow) - { - (childForm as IDebugWindow).StartSession(); - } + (ActiveMdiChild as IDebugWindow).StartSession(); } } private void suspendToolStripMenuItem_Click(object sender, EventArgs e) { - foreach (Form childForm in MdiChildren) + if (ActiveMdiChild is IDebugWindow) { - if (childForm is IDebugWindow) - { - (childForm as IDebugWindow).SuspendSession(); - } + (ActiveMdiChild as IDebugWindow).SuspendSession(); } } private void resumeToolStripMenuItem_Click(object sender, EventArgs e) { - foreach (Form childForm in MdiChildren) + if (ActiveMdiChild is IDebugWindow) { - if (childForm is IDebugWindow) - { - (childForm as IDebugWindow).ResumeSession(); - } + (ActiveMdiChild as IDebugWindow).ResumeSession(); } } @@ -98,12 +76,81 @@ namespace CxbxDebugger private IDebugWindow CreateNewSessionWindow(string[] Arguments) { - var childForm = new CxbxDebuggerInstance(Arguments); - childForm.MdiParent = this; + var childForm = new CxbxDebuggerInstance(this, Arguments); childForm.WindowState = FormWindowState.Maximized; + childForm.TextChanged += (sender, e) => { OnSessionWindowRenamed(sender as Form); }; + childForm.Activated += (sender, e) => { OnSessionWindowActivated(sender as IDebugWindow); }; childForm.Show(); - + return childForm; } + + private void OnSessionWindowActivated(IDebugWindow child) + { + var state = child.GetDebugStateInfo(); + RefreshStatusText(state); + } + + private void OnSessionWindowRenamed(Form form) + { + // https://stackoverflow.com/questions/1347734/mdi-window-list-not-updating-child-title-bar-texts + + ActivateMdiChild(null); + ActivateMdiChild(form); + } + + public void ReportStatus(IDebugWindow Window, DebugState State, string Detail) + { + if (Window == ActiveMdiChild) + { + RefreshStatusText(new DebugStateInfo() { State = State, Detail = Detail }); + } + } + + private void RefreshStatusText(DebugStateInfo stateInfo) + { + var stateString = ""; + var canSuspend = false; + var canResume = false; + var canRun = false; + + switch (stateInfo.State) + { + case DebugState.Unknown: + stateString = "No valid Xbe was loaded. Invalid session."; + break; + + case DebugState.Idle: + stateString = "Ready"; + canRun = true; + break; + + case DebugState.Suspended: + stateString = "Suspended"; + canResume = true; + break; + + case DebugState.Running: + stateString = "Running"; + canSuspend = true; + break; + + case DebugState.Terminated: + stateString = "Terminated"; + //canRun = true; // Uncomment to allow restarted sessions + break; + } + + if (!string.IsNullOrEmpty(stateInfo.Detail)) + { + stateString += $" - {stateInfo.Detail}"; + } + + miStartDebugging.Enabled = canRun; + miSuspend.Enabled = canSuspend; + miResume.Enabled = canResume; + lblStatus.Text = stateString; + } } } + diff --git a/src/CxbxDebugger/CxbxDebuggerMain.resx b/src/CxbxDebugger/CxbxDebuggerMain.resx index 79cbbc410..d2ddf11df 100644 --- a/src/CxbxDebugger/CxbxDebuggerMain.resx +++ b/src/CxbxDebugger/CxbxDebuggerMain.resx @@ -120,12 +120,12 @@ 17, 17 - - 295, 17 - 443, 17 + + 562, 17 + 51 diff --git a/src/CxbxDebugger/IDebugWindow.cs b/src/CxbxDebugger/IDebugWindow.cs index a2e23df12..370372a8e 100644 --- a/src/CxbxDebugger/IDebugWindow.cs +++ b/src/CxbxDebugger/IDebugWindow.cs @@ -10,6 +10,22 @@ namespace CxbxDebugger Ended, } + public enum DebugState + { + Unknown, + Idle, + Suspended, + Breakpoint, + Running, + Terminated, + } + + public struct DebugStateInfo + { + public DebugState State; + public string Detail; + } + public interface IDebugWindow { void StartSession(); @@ -19,6 +35,8 @@ namespace CxbxDebugger void ResumeSession(); SessionState GetSessionState(); + + DebugStateInfo GetDebugStateInfo(); } public interface IDebugContainerWindow @@ -26,6 +44,8 @@ namespace CxbxDebugger void AddDebugSession(string[] Arguments, bool StartAutomatically); void ReportGameTitle(string GameTitle); + + void ReportStatus(IDebugWindow Window, DebugState Status, string Detail); } }