Another round of Lua Console

This commit is contained in:
andres.delikat 2011-05-07 00:07:27 +00:00
parent b95a5dfc17
commit 9cb852664d
5 changed files with 85 additions and 26 deletions

View File

@ -29,9 +29,9 @@
private void InitializeComponent()
{
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.Path = new System.Windows.Forms.ColumnHeader();
this.PathName = new System.Windows.Forms.ColumnHeader();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -58,29 +58,29 @@
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// listView1
// LuaListView
//
this.listView1.CheckBoxes = true;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.LuaListView.CheckBoxes = true;
this.LuaListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Script,
this.Path});
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(12, 51);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(293, 278);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
this.PathName});
this.LuaListView.GridLines = true;
this.LuaListView.Location = new System.Drawing.Point(12, 51);
this.LuaListView.Name = "LuaListView";
this.LuaListView.Size = new System.Drawing.Size(293, 278);
this.LuaListView.TabIndex = 0;
this.LuaListView.UseCompatibleStateImageBehavior = false;
this.LuaListView.View = System.Windows.Forms.View.Details;
//
// Script
//
this.Script.Text = "Script";
this.Script.Width = 92;
//
// Path
// PathName
//
this.Path.Text = "Path";
this.Path.Width = 195;
this.PathName.Text = "Path";
this.PathName.Width = 195;
//
// menuStrip1
//
@ -127,6 +127,7 @@
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.Text = "&Open";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
// saveToolStripMenuItem
//
@ -257,7 +258,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(598, 359);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.listView1);
this.Controls.Add(this.LuaListView);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
@ -274,8 +275,8 @@
#endregion
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader Path;
private VirtualListView LuaListView;
private System.Windows.Forms.ColumnHeader PathName;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;

View File

@ -6,15 +6,16 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace BizHawk.MultiClient
{
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 defaultHeight;
int defaultNameWidth;
int defaultAddressWidth;
List<LuaFiles> luaList = new List<LuaFiles>();
string lastLuaFile = "";
@ -32,6 +33,22 @@ namespace BizHawk.MultiClient
{
InitializeComponent();
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)
@ -78,5 +95,39 @@ namespace BizHawk.MultiClient
{
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();
}
}
}

View File

@ -10,6 +10,7 @@ namespace BizHawk.MultiClient
public string Name;
public string Path;
public bool Enabled;
public bool IsSeparator;
public LuaFiles(string path)
{
@ -23,6 +24,15 @@ namespace BizHawk.MultiClient
Name = name;
Path = path;
Enabled = enabled;
IsSeparator = false;
}
public LuaFiles(bool isSeparator)
{
IsSeparator = isSeparator;
Name = "";
Path = "";
Enabled = false;
}
public LuaFiles(LuaFiles l)
@ -30,6 +40,7 @@ namespace BizHawk.MultiClient
Name = l.Name;
Path = l.Path;
Enabled = l.Enabled;
IsSeparator = l.IsSeparator;
}
public void Toggle()

View File

@ -1256,7 +1256,6 @@ namespace BizHawk.MultiClient
if (result != DialogResult.OK)
return null;
var file = new FileInfo(sfd.FileName);
Global.Config.LastRomPath = file.DirectoryName;
return file;
}
@ -1450,8 +1449,7 @@ namespace BizHawk.MultiClient
if (result != DialogResult.OK)
return null;
var file = new FileInfo(ofd.FileName);
Global.Config.LastRomPath = file.DirectoryName;
return file;
return file;
}
private void includeMisalignedToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -596,7 +596,6 @@ namespace BizHawk.MultiClient
if (result != DialogResult.OK)
return null;
var file = new FileInfo(ofd.FileName);
Global.Config.LastRomPath = file.DirectoryName;
return file;
}
@ -654,7 +653,6 @@ namespace BizHawk.MultiClient
if (result != DialogResult.OK)
return null;
var file = new FileInfo(sfd.FileName);
Global.Config.LastRomPath = file.DirectoryName;
return file;
}