Lua - improve console.log() to print out lua tables. Useful for seeing the data coming from things like joypad.get()
This commit is contained in:
parent
c88ad00405
commit
5d23b2a406
|
@ -10,6 +10,7 @@ using System.Globalization;
|
|||
|
||||
using BizHawk.Emulation.Consoles.Nintendo;
|
||||
using BizHawk.MultiClient.tools;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
|
@ -624,7 +625,43 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
else
|
||||
{
|
||||
Global.MainForm.LuaConsole1.WriteToOutputWindow(lua_input.ToString());
|
||||
if (lua_input is LuaTable)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var lti = (lua_input as LuaTable);
|
||||
|
||||
List<string> Keys = new List<string>();
|
||||
List<string> Values = new List<string>();
|
||||
foreach (var key in lti.Keys) { Keys.Add(key.ToString()); }
|
||||
foreach (var value in lti.Values) { Values.Add(value.ToString()); }
|
||||
|
||||
List<KeyValuePair<string, string>> KVPs = new List<KeyValuePair<string, string>>();
|
||||
for (int i = 0; i < Keys.Count; i++)
|
||||
{
|
||||
if (i < Values.Count)
|
||||
{
|
||||
KeyValuePair<string, string> kvp = new KeyValuePair<string, string>(Keys[i], Values[i]);
|
||||
KVPs.Add(kvp);
|
||||
}
|
||||
}
|
||||
KVPs = KVPs.OrderBy(x => x.Key).ToList();
|
||||
foreach(var kvp in KVPs)
|
||||
{
|
||||
sb
|
||||
.Append("\"")
|
||||
.Append(kvp.Key)
|
||||
.Append("\": \"")
|
||||
.Append(kvp.Value)
|
||||
.Append("\"")
|
||||
.AppendLine();
|
||||
}
|
||||
|
||||
Global.MainForm.LuaConsole1.WriteToOutputWindow(sb.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.MainForm.LuaConsole1.WriteToOutputWindow(lua_input.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
this.tabPage2.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(486, 438);
|
||||
this.tabPage2.Size = new System.Drawing.Size(554, 467);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "Autofire Controls";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
|
@ -82,7 +82,7 @@
|
|||
//
|
||||
this.tabPage3.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage3.Name = "tabPage3";
|
||||
this.tabPage3.Size = new System.Drawing.Size(486, 438);
|
||||
this.tabPage3.Size = new System.Drawing.Size(554, 467);
|
||||
this.tabPage3.TabIndex = 2;
|
||||
this.tabPage3.Text = "Analog Controls";
|
||||
this.tabPage3.UseVisualStyleBackColor = true;
|
||||
|
@ -163,10 +163,8 @@
|
|||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.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.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBox1.Location = new System.Drawing.Point(571, 23);
|
||||
this.pictureBox1.Margin = new System.Windows.Forms.Padding(3, 23, 3, 3);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
|
|
|
@ -170,6 +170,23 @@ namespace BizHawk.MultiClient.config
|
|||
pictureBox1.Image = bmp;
|
||||
pictureBox1.Size = bmp.Size;
|
||||
tableLayoutPanel1.ColumnStyles[1].Width = bmp.Width;
|
||||
|
||||
//Uberhack
|
||||
if (ControlName == "Commodore 64 Controller")
|
||||
{
|
||||
PictureBox pictureBox2 = new PictureBox();
|
||||
pictureBox2.Image = Properties.Resources.C64Keyboard;
|
||||
pictureBox2.Size = Properties.Resources.C64Keyboard.Size;
|
||||
tableLayoutPanel1.ColumnStyles[1].Width = Properties.Resources.C64Keyboard.Width;
|
||||
pictureBox1.Height /= 2;
|
||||
pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
pictureBox1.Dock = DockStyle.Top;
|
||||
pictureBox2.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y + pictureBox1.Size.Height + 10);
|
||||
tableLayoutPanel1.Controls.Add(pictureBox2, 1, 0);
|
||||
|
||||
|
||||
pictureBox2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
|
||||
}
|
||||
}
|
||||
|
||||
// lazy methods, but they're not called often and actually
|
||||
|
|
Loading…
Reference in New Issue