Another round of Lua Console
This commit is contained in:
parent
b95a5dfc17
commit
9cb852664d
|
@ -29,9 +29,9 @@
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LuaConsole));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LuaConsole));
|
||||||
this.listView1 = new System.Windows.Forms.ListView();
|
this.LuaListView = new VirtualListView();
|
||||||
this.Script = new System.Windows.Forms.ColumnHeader();
|
this.Script = new System.Windows.Forms.ColumnHeader();
|
||||||
this.Path = new System.Windows.Forms.ColumnHeader();
|
this.PathName = new System.Windows.Forms.ColumnHeader();
|
||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
@ -58,29 +58,29 @@
|
||||||
this.groupBox1.SuspendLayout();
|
this.groupBox1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// listView1
|
// LuaListView
|
||||||
//
|
//
|
||||||
this.listView1.CheckBoxes = true;
|
this.LuaListView.CheckBoxes = true;
|
||||||
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
this.LuaListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||||
this.Script,
|
this.Script,
|
||||||
this.Path});
|
this.PathName});
|
||||||
this.listView1.GridLines = true;
|
this.LuaListView.GridLines = true;
|
||||||
this.listView1.Location = new System.Drawing.Point(12, 51);
|
this.LuaListView.Location = new System.Drawing.Point(12, 51);
|
||||||
this.listView1.Name = "listView1";
|
this.LuaListView.Name = "LuaListView";
|
||||||
this.listView1.Size = new System.Drawing.Size(293, 278);
|
this.LuaListView.Size = new System.Drawing.Size(293, 278);
|
||||||
this.listView1.TabIndex = 0;
|
this.LuaListView.TabIndex = 0;
|
||||||
this.listView1.UseCompatibleStateImageBehavior = false;
|
this.LuaListView.UseCompatibleStateImageBehavior = false;
|
||||||
this.listView1.View = System.Windows.Forms.View.Details;
|
this.LuaListView.View = System.Windows.Forms.View.Details;
|
||||||
//
|
//
|
||||||
// Script
|
// Script
|
||||||
//
|
//
|
||||||
this.Script.Text = "Script";
|
this.Script.Text = "Script";
|
||||||
this.Script.Width = 92;
|
this.Script.Width = 92;
|
||||||
//
|
//
|
||||||
// Path
|
// PathName
|
||||||
//
|
//
|
||||||
this.Path.Text = "Path";
|
this.PathName.Text = "Path";
|
||||||
this.Path.Width = 195;
|
this.PathName.Width = 195;
|
||||||
//
|
//
|
||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
|
@ -127,6 +127,7 @@
|
||||||
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
|
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
|
||||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
|
this.openToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
|
||||||
this.openToolStripMenuItem.Text = "&Open";
|
this.openToolStripMenuItem.Text = "&Open";
|
||||||
|
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// saveToolStripMenuItem
|
// saveToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
@ -257,7 +258,7 @@
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(598, 359);
|
this.ClientSize = new System.Drawing.Size(598, 359);
|
||||||
this.Controls.Add(this.groupBox1);
|
this.Controls.Add(this.groupBox1);
|
||||||
this.Controls.Add(this.listView1);
|
this.Controls.Add(this.LuaListView);
|
||||||
this.Controls.Add(this.menuStrip1);
|
this.Controls.Add(this.menuStrip1);
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.MainMenuStrip = this.menuStrip1;
|
this.MainMenuStrip = this.menuStrip1;
|
||||||
|
@ -274,8 +275,8 @@
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.ListView listView1;
|
private VirtualListView LuaListView;
|
||||||
private System.Windows.Forms.ColumnHeader Path;
|
private System.Windows.Forms.ColumnHeader PathName;
|
||||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
|
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
|
||||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||||
|
|
|
@ -6,15 +6,16 @@ using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace BizHawk.MultiClient
|
namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
public partial class LuaConsole : Form
|
public partial class LuaConsole : Form
|
||||||
{
|
{
|
||||||
|
//TODO: remember column widths
|
||||||
|
|
||||||
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
|
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
|
||||||
int defaultHeight;
|
int defaultHeight;
|
||||||
int defaultNameWidth;
|
|
||||||
int defaultAddressWidth;
|
|
||||||
|
|
||||||
List<LuaFiles> luaList = new List<LuaFiles>();
|
List<LuaFiles> luaList = new List<LuaFiles>();
|
||||||
string lastLuaFile = "";
|
string lastLuaFile = "";
|
||||||
|
@ -32,6 +33,22 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Closing += (o, e) => SaveConfigSettings();
|
Closing += (o, e) => SaveConfigSettings();
|
||||||
|
LuaListView.QueryItemText += new QueryItemTextHandler(LuaListView_QueryItemText);
|
||||||
|
LuaListView.QueryItemBkColor += new QueryItemBkColorHandler(LuaListView_QueryItemBkColor);
|
||||||
|
LuaListView.VirtualMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LuaListView_QueryItemBkColor(int index, int column, ref Color color)
|
||||||
|
{
|
||||||
|
if (luaList[index].IsSeparator)
|
||||||
|
color = Color.DarkGray;
|
||||||
|
else if (!luaList[index].Enabled)
|
||||||
|
color = this.BackColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LuaListView_QueryItemText(int index, int column, out string text)
|
||||||
|
{
|
||||||
|
text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LuaConsole_Load(object sender, EventArgs e)
|
private void LuaConsole_Load(object sender, EventArgs e)
|
||||||
|
@ -78,5 +95,39 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
|
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private FileInfo GetFileFromUser()
|
||||||
|
{
|
||||||
|
var ofd = new OpenFileDialog();
|
||||||
|
if (lastLuaFile.Length > 0)
|
||||||
|
ofd.FileName = Path.GetFileNameWithoutExtension(lastLuaFile);
|
||||||
|
ofd.InitialDirectory = Global.Config.LuaPath;
|
||||||
|
ofd.Filter = "Lua Scripts (*.lua)|*.lua|All Files|*.*";
|
||||||
|
ofd.RestoreDirectory = true;
|
||||||
|
|
||||||
|
Global.Sound.StopSound();
|
||||||
|
var result = ofd.ShowDialog();
|
||||||
|
Global.Sound.StartSound();
|
||||||
|
if (result != DialogResult.OK)
|
||||||
|
return null;
|
||||||
|
var file = new FileInfo(ofd.FileName);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void OpenLuaFile()
|
||||||
|
{
|
||||||
|
var file = GetFileFromUser();
|
||||||
|
if (file != null)
|
||||||
|
{
|
||||||
|
//LoadLuaFile(file.FullName, false);
|
||||||
|
//DisplayLuaList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenLuaFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace BizHawk.MultiClient
|
||||||
public string Name;
|
public string Name;
|
||||||
public string Path;
|
public string Path;
|
||||||
public bool Enabled;
|
public bool Enabled;
|
||||||
|
public bool IsSeparator;
|
||||||
|
|
||||||
public LuaFiles(string path)
|
public LuaFiles(string path)
|
||||||
{
|
{
|
||||||
|
@ -23,6 +24,15 @@ namespace BizHawk.MultiClient
|
||||||
Name = name;
|
Name = name;
|
||||||
Path = path;
|
Path = path;
|
||||||
Enabled = enabled;
|
Enabled = enabled;
|
||||||
|
IsSeparator = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LuaFiles(bool isSeparator)
|
||||||
|
{
|
||||||
|
IsSeparator = isSeparator;
|
||||||
|
Name = "";
|
||||||
|
Path = "";
|
||||||
|
Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LuaFiles(LuaFiles l)
|
public LuaFiles(LuaFiles l)
|
||||||
|
@ -30,6 +40,7 @@ namespace BizHawk.MultiClient
|
||||||
Name = l.Name;
|
Name = l.Name;
|
||||||
Path = l.Path;
|
Path = l.Path;
|
||||||
Enabled = l.Enabled;
|
Enabled = l.Enabled;
|
||||||
|
IsSeparator = l.IsSeparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Toggle()
|
public void Toggle()
|
||||||
|
|
|
@ -1256,7 +1256,6 @@ namespace BizHawk.MultiClient
|
||||||
if (result != DialogResult.OK)
|
if (result != DialogResult.OK)
|
||||||
return null;
|
return null;
|
||||||
var file = new FileInfo(sfd.FileName);
|
var file = new FileInfo(sfd.FileName);
|
||||||
Global.Config.LastRomPath = file.DirectoryName;
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1450,8 +1449,7 @@ namespace BizHawk.MultiClient
|
||||||
if (result != DialogResult.OK)
|
if (result != DialogResult.OK)
|
||||||
return null;
|
return null;
|
||||||
var file = new FileInfo(ofd.FileName);
|
var file = new FileInfo(ofd.FileName);
|
||||||
Global.Config.LastRomPath = file.DirectoryName;
|
return file;
|
||||||
return file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void includeMisalignedToolStripMenuItem_Click(object sender, EventArgs e)
|
private void includeMisalignedToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
|
|
@ -596,7 +596,6 @@ namespace BizHawk.MultiClient
|
||||||
if (result != DialogResult.OK)
|
if (result != DialogResult.OK)
|
||||||
return null;
|
return null;
|
||||||
var file = new FileInfo(ofd.FileName);
|
var file = new FileInfo(ofd.FileName);
|
||||||
Global.Config.LastRomPath = file.DirectoryName;
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +653,6 @@ namespace BizHawk.MultiClient
|
||||||
if (result != DialogResult.OK)
|
if (result != DialogResult.OK)
|
||||||
return null;
|
return null;
|
||||||
var file = new FileInfo(sfd.FileName);
|
var file = new FileInfo(sfd.FileName);
|
||||||
Global.Config.LastRomPath = file.DirectoryName;
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue