Support display preferences

This commit is contained in:
x1nixmzeng 2018-04-13 23:40:55 +01:00
parent 0308b5cea3
commit 3b16f2672d
4 changed files with 142 additions and 113 deletions

View File

@ -31,6 +31,7 @@ namespace CxbxDebugger
{
public string ID;
public string Description;
public bool ShowAsHex;
public State LastState;
public uint Color;
public Variable VariableType;

View File

@ -206,6 +206,10 @@ namespace CxbxDebugger
Entry.Description = xnode.InnerText.Trim(new char[]{ '\"' });
break;
case "ShowAsHex":
Entry.ShowAsHex = (GetNumber(xnode.InnerText) != 0);
break;
case "Options":
// stub
// attributes: moHideChildren (bool)

View File

@ -84,24 +84,25 @@
this.label3 = new System.Windows.Forms.Label();
this.lbDebug = new System.Windows.Forms.ListBox();
this.tabTweaks = new System.Windows.Forms.TabPage();
this.listView2 = new System.Windows.Forms.ListView();
this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader11 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.button3 = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabSubData = new System.Windows.Forms.TabPage();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.button2 = new System.Windows.Forms.Button();
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tabSubAssembly = new System.Windows.Forms.TabPage();
this.listView2 = new System.Windows.Forms.ListView();
this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader11 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.diagSaveMemory = new System.Windows.Forms.SaveFileDialog();
this.diagBrowseCT = new System.Windows.Forms.OpenFileDialog();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabSubData = new System.Windows.Forms.TabPage();
this.tabSubAssembly = new System.Windows.Forms.TabPage();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.txDisassembly = new CxbxDebugger.RicherTextBox();
this.toolStrip1.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
@ -135,10 +136,10 @@
this.splitContainer5.Panel2.SuspendLayout();
this.splitContainer5.SuspendLayout();
this.tabTweaks.SuspendLayout();
this.groupBox3.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabSubData.SuspendLayout();
this.tabSubAssembly.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// lbConsole
@ -733,29 +734,80 @@
this.tabTweaks.Text = "Cheat Engine";
this.tabTweaks.UseVisualStyleBackColor = true;
//
// listView2
// groupBox3
//
this.listView2.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader10,
this.columnHeader11});
this.listView2.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView2.FullRowSelect = true;
this.listView2.Location = new System.Drawing.Point(3, 3);
this.listView2.Name = "listView2";
this.listView2.Size = new System.Drawing.Size(584, 152);
this.listView2.TabIndex = 4;
this.listView2.UseCompatibleStateImageBehavior = false;
this.listView2.View = System.Windows.Forms.View.Details;
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox3.Controls.Add(this.button3);
this.groupBox3.Controls.Add(this.label7);
this.groupBox3.Controls.Add(this.textBox1);
this.groupBox3.Controls.Add(this.button2);
this.groupBox3.Location = new System.Drawing.Point(5, 6);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(135, 184);
this.groupBox3.TabIndex = 6;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Controls";
//
// columnHeader10
// button3
//
this.columnHeader10.Text = "Address";
this.columnHeader10.Width = 200;
this.button3.Location = new System.Drawing.Point(6, 117);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(123, 23);
this.button3.TabIndex = 4;
this.button3.Text = "Apply";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click_1);
//
// columnHeader11
// label7
//
this.columnHeader11.Text = "Name";
this.columnHeader11.Width = 200;
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(6, 75);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(37, 13);
this.label7.TabIndex = 3;
this.label7.Text = "Value:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(6, 91);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(123, 20);
this.textBox1.TabIndex = 2;
//
// button2
//
this.button2.Location = new System.Drawing.Point(6, 19);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(123, 23);
this.button2.TabIndex = 0;
this.button2.Text = "Load .CT";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click_1);
//
// tabControl1
//
this.tabControl1.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.tabControl1.Controls.Add(this.tabSubData);
this.tabControl1.Controls.Add(this.tabSubAssembly);
this.tabControl1.Location = new System.Drawing.Point(144, 6);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(598, 184);
this.tabControl1.TabIndex = 5;
//
// tabSubData
//
this.tabSubData.Controls.Add(this.listView1);
this.tabSubData.Location = new System.Drawing.Point(4, 22);
this.tabSubData.Name = "tabSubData";
this.tabSubData.Padding = new System.Windows.Forms.Padding(3);
this.tabSubData.Size = new System.Drawing.Size(590, 158);
this.tabSubData.TabIndex = 0;
this.tabSubData.Text = "Memory";
this.tabSubData.UseVisualStyleBackColor = true;
//
// listView1
//
@ -763,7 +815,8 @@
this.columnHeader8,
this.columnHeader4,
this.columnHeader7,
this.columnHeader6});
this.columnHeader6,
this.columnHeader5});
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(3, 3);
@ -794,47 +847,10 @@
this.columnHeader6.Text = "Type";
this.columnHeader6.Width = 80;
//
// button2
// columnHeader5
//
this.button2.Location = new System.Drawing.Point(6, 19);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(123, 23);
this.button2.TabIndex = 0;
this.button2.Text = "Load .CT";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click_1);
//
// diagSaveMemory
//
this.diagSaveMemory.Filter = "Any Type|*.*";
//
// diagBrowseCT
//
this.diagBrowseCT.FileName = "openFileDialog1";
//
// tabControl1
//
this.tabControl1.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.tabControl1.Controls.Add(this.tabSubData);
this.tabControl1.Controls.Add(this.tabSubAssembly);
this.tabControl1.Location = new System.Drawing.Point(144, 6);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(598, 184);
this.tabControl1.TabIndex = 5;
//
// tabSubData
//
this.tabSubData.Controls.Add(this.listView1);
this.tabSubData.Location = new System.Drawing.Point(4, 22);
this.tabSubData.Name = "tabSubData";
this.tabSubData.Padding = new System.Windows.Forms.Padding(3);
this.tabSubData.Size = new System.Drawing.Size(590, 158);
this.tabSubData.TabIndex = 0;
this.tabSubData.Text = "Memory";
this.tabSubData.UseVisualStyleBackColor = true;
this.columnHeader5.Text = "Value";
this.columnHeader5.Width = 150;
//
// tabSubAssembly
//
@ -847,46 +863,39 @@
this.tabSubAssembly.Text = "Assembly";
this.tabSubAssembly.UseVisualStyleBackColor = true;
//
// groupBox3
// listView2
//
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox3.Controls.Add(this.button3);
this.groupBox3.Controls.Add(this.label7);
this.groupBox3.Controls.Add(this.textBox1);
this.groupBox3.Controls.Add(this.button2);
this.groupBox3.Location = new System.Drawing.Point(5, 6);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(135, 184);
this.groupBox3.TabIndex = 6;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Controls";
this.listView2.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader10,
this.columnHeader11});
this.listView2.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView2.FullRowSelect = true;
this.listView2.Location = new System.Drawing.Point(3, 3);
this.listView2.Name = "listView2";
this.listView2.Size = new System.Drawing.Size(584, 152);
this.listView2.TabIndex = 4;
this.listView2.UseCompatibleStateImageBehavior = false;
this.listView2.View = System.Windows.Forms.View.Details;
//
// textBox1
// columnHeader10
//
this.textBox1.Location = new System.Drawing.Point(6, 91);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(123, 20);
this.textBox1.TabIndex = 2;
this.columnHeader10.Text = "Address";
this.columnHeader10.Width = 200;
//
// label7
// columnHeader11
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(6, 75);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(37, 13);
this.label7.TabIndex = 3;
this.label7.Text = "Value:";
this.columnHeader11.Text = "Name";
this.columnHeader11.Width = 200;
//
// button3
// diagSaveMemory
//
this.button3.Location = new System.Drawing.Point(6, 117);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(123, 23);
this.button3.TabIndex = 4;
this.button3.Text = "Apply";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click_1);
this.diagSaveMemory.Filter = "Any Type|*.*";
//
// diagBrowseCT
//
this.diagBrowseCT.FileName = "openFileDialog1";
this.diagBrowseCT.Filter = "Cheat Engine Tables (*.CT)|*.ct";
this.diagBrowseCT.Title = "Load cheat table";
//
// txDisassembly
//
@ -954,11 +963,11 @@
((System.ComponentModel.ISupportInitialize)(this.splitContainer5)).EndInit();
this.splitContainer5.ResumeLayout(false);
this.tabTweaks.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.tabControl1.ResumeLayout(false);
this.tabSubData.ResumeLayout(false);
this.tabSubAssembly.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -1039,6 +1048,7 @@
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ColumnHeader columnHeader5;
}
}

View File

@ -1046,6 +1046,7 @@ namespace CxbxDebugger
li.SubItems.Add(code.Description);
li.SubItems.Add(string.Format("{0:x8}", code.Address));
li.SubItems.Add(code.VariableType.ToString());
li.SubItems.Add("??"); // todo: read live memory
li.Checked = code.LastState.Activated;
li.ForeColor = MakeColor(code.Color);
@ -1053,6 +1054,8 @@ namespace CxbxDebugger
listView1.EndUpdate();
// Code entries are not supported at the moment
listView2.BeginUpdate();
listView2.Items.Clear();
@ -1069,6 +1072,9 @@ namespace CxbxDebugger
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DebugThreads.Count == 0)
return;
if(listView1.SelectedIndices.Count == 1 )
{
int selected = listView1.SelectedIndices[0];
@ -1081,6 +1087,8 @@ namespace CxbxDebugger
return;
}
string printed_value = "<failed to read>";
switch (entry.VariableType)
{
case Variable.Byte:
@ -1089,16 +1097,21 @@ namespace CxbxDebugger
if (data != null)
{
textBox1.Text = string.Format("{0}", data[0]);
if( entry.ShowAsHex )
{
printed_value = string.Format("0x{0:x}", data[0]);
}
else
{
printed_value = string.Format("{0}", data[0]);
}
}
else
{
textBox1.Text = "<failed to read>";
}
break;
}
}
textBox1.Text = printed_value;
}
}
@ -1122,7 +1135,8 @@ namespace CxbxDebugger
{
case Variable.Byte:
{
uint byte_val = uint.Parse(src);
uint byte_val = 0;
ReadAddress(src, ref byte_val);
byte val = (byte)(byte_val & 0xFF);
DebugThreads[0].OwningProcess.WriteMemory(new IntPtr(addr), val);