Lua Window - various dialog fix ups like toggle, storing recent files, drag & drop
This commit is contained in:
parent
d6a57e08c1
commit
3e2e657dcf
|
@ -171,7 +171,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void recentToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
//Clear out recent Roms list
|
||||
//Clear out recent Cheats list
|
||||
//repopulate it with an up to date list
|
||||
recentToolStripMenuItem.DropDownItems.Clear();
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
this.Script = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.PathName = ((System.Windows.Forms.ColumnHeader)(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();
|
||||
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -84,6 +83,7 @@
|
|||
this.LuaListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.Script,
|
||||
this.PathName});
|
||||
this.LuaListView.ContextMenuStrip = this.contextMenuStrip1;
|
||||
this.LuaListView.FullRowSelect = true;
|
||||
this.LuaListView.GridLines = true;
|
||||
this.LuaListView.HideSelection = false;
|
||||
|
@ -97,6 +97,7 @@
|
|||
this.LuaListView.View = System.Windows.Forms.View.Details;
|
||||
this.LuaListView.SelectedIndexChanged += new System.EventHandler(this.LuaListView_SelectedIndexChanged);
|
||||
this.LuaListView.DoubleClick += new System.EventHandler(this.LuaListView_DoubleClick);
|
||||
this.LuaListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.LuaListView_KeyDown);
|
||||
//
|
||||
// Script
|
||||
//
|
||||
|
@ -111,7 +112,6 @@
|
|||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItem1,
|
||||
this.fileToolStripMenuItem,
|
||||
this.scriptToolStripMenuItem,
|
||||
this.viewToolStripMenuItem,
|
||||
|
@ -122,11 +122,6 @@
|
|||
this.menuStrip1.TabIndex = 1;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(12, 20);
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
|
@ -187,22 +182,23 @@
|
|||
this.recentToolStripMenuItem.Name = "recentToolStripMenuItem";
|
||||
this.recentToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
|
||||
this.recentToolStripMenuItem.Text = "Recent";
|
||||
this.recentToolStripMenuItem.DropDownOpened += new System.EventHandler(this.recentToolStripMenuItem_DropDownOpened);
|
||||
//
|
||||
// noneToolStripMenuItem
|
||||
//
|
||||
this.noneToolStripMenuItem.Name = "noneToolStripMenuItem";
|
||||
this.noneToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
|
||||
this.noneToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.noneToolStripMenuItem.Text = "None";
|
||||
//
|
||||
// toolStripSeparator3
|
||||
//
|
||||
this.toolStripSeparator3.Name = "toolStripSeparator3";
|
||||
this.toolStripSeparator3.Size = new System.Drawing.Size(107, 6);
|
||||
this.toolStripSeparator3.Size = new System.Drawing.Size(149, 6);
|
||||
//
|
||||
// clearToolStripMenuItem
|
||||
//
|
||||
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
|
||||
this.clearToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
|
||||
this.clearToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.clearToolStripMenuItem.Text = "Clear";
|
||||
//
|
||||
// toolStripSeparator1
|
||||
|
@ -213,6 +209,7 @@
|
|||
// exitToolStripMenuItem
|
||||
//
|
||||
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||
this.exitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4)));
|
||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
|
||||
this.exitToolStripMenuItem.Text = "E&xit";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
|
@ -241,6 +238,7 @@
|
|||
this.toggleToolStripMenuItem.Name = "toggleToolStripMenuItem";
|
||||
this.toggleToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
|
||||
this.toggleToolStripMenuItem.Text = "Toggle";
|
||||
this.toggleToolStripMenuItem.Click += new System.EventHandler(this.toggleToolStripMenuItem_Click);
|
||||
//
|
||||
// insertSeparatorToolStripMenuItem
|
||||
//
|
||||
|
@ -415,6 +413,7 @@
|
|||
//
|
||||
// LuaConsole
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(584, 342);
|
||||
|
@ -424,10 +423,12 @@
|
|||
this.Controls.Add(this.menuStrip1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.MinimumSize = new System.Drawing.Size(356, 115);
|
||||
this.MinimumSize = new System.Drawing.Size(356, 132);
|
||||
this.Name = "LuaConsole";
|
||||
this.Text = "Lua Console";
|
||||
this.Load += new System.EventHandler(this.LuaConsole_Load);
|
||||
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.LuaConsole_DragDrop);
|
||||
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.LuaConsole_DragEnter);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
|
@ -441,8 +442,7 @@
|
|||
|
||||
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.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
|
||||
|
|
|
@ -14,11 +14,11 @@ namespace BizHawk.MultiClient
|
|||
public partial class LuaConsole : Form
|
||||
{
|
||||
//TODO: remember column widths
|
||||
//TODO: recent menu
|
||||
//TODO: load from recent menu
|
||||
//TODO: drag & drop for .lua files
|
||||
|
||||
|
||||
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;
|
||||
|
||||
List<LuaFiles> luaList = new List<LuaFiles>();
|
||||
|
@ -151,7 +151,7 @@ namespace BizHawk.MultiClient
|
|||
luaList.Add(l);
|
||||
LuaListView.ItemCount = luaList.Count;
|
||||
LuaListView.Refresh();
|
||||
|
||||
Global.Config.RecentLua.Add(path);
|
||||
LuaImp.DoLuaFile(path);
|
||||
}
|
||||
|
||||
|
@ -194,13 +194,10 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
for (int x = 0; x < indexes.Count; x++)
|
||||
{
|
||||
if (luaList[indexes[x]].Enabled)
|
||||
luaList[indexes[x]].Enabled = false;
|
||||
else
|
||||
luaList[indexes[x]].Enabled = true;
|
||||
luaList[indexes[x]].Toggle();
|
||||
}
|
||||
LuaListView.Refresh();
|
||||
}
|
||||
LuaListView.Refresh();
|
||||
UpdateNumberOfScripts();
|
||||
}
|
||||
|
||||
|
@ -389,5 +386,79 @@ namespace BizHawk.MultiClient
|
|||
|
||||
DisplayLuaList();
|
||||
}
|
||||
|
||||
private void toggleToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Toggle();
|
||||
}
|
||||
|
||||
private void recentToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
//Clear out recent Cheats list
|
||||
//repopulate it with an up to date list
|
||||
recentToolStripMenuItem.DropDownItems.Clear();
|
||||
|
||||
if (Global.Config.RecentLua.IsEmpty())
|
||||
{
|
||||
var none = new ToolStripMenuItem();
|
||||
none.Enabled = false;
|
||||
none.Text = "None";
|
||||
recentToolStripMenuItem.DropDownItems.Add(none);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int x = 0; x < Global.Config.RecentLua.Length(); x++)
|
||||
{
|
||||
string path = Global.Config.RecentLua.GetRecentFileByPosition(x);
|
||||
var item = new ToolStripMenuItem();
|
||||
item.Text = path;
|
||||
item.Click += (o, ev) => LoadLuaFromRecent(path);
|
||||
recentToolStripMenuItem.DropDownItems.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
recentToolStripMenuItem.DropDownItems.Add("-");
|
||||
|
||||
var clearitem = new ToolStripMenuItem();
|
||||
clearitem.Text = "&Clear";
|
||||
clearitem.Click += (o, ev) => Global.Config.RecentLua.Clear();
|
||||
recentToolStripMenuItem.DropDownItems.Add(clearitem);
|
||||
}
|
||||
|
||||
private void LoadLuaFromRecent(string path)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void LuaConsole_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
if (Path.GetExtension(filePaths[0]) == (".lua"))
|
||||
{
|
||||
LoadLuaFile(filePaths[0]);
|
||||
DisplayLuaList();
|
||||
UpdateNumberOfScripts();
|
||||
}
|
||||
}
|
||||
|
||||
private void LuaConsole_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
}
|
||||
|
||||
private void LuaListView_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Delete && !e.Control && !e.Alt && !e.Shift)
|
||||
{
|
||||
RemoveScript();
|
||||
}
|
||||
else if (e.KeyCode == Keys.A && e.Control && !e.Alt && !e.Shift) //Select All
|
||||
{
|
||||
for (int x = 0; x < luaList.Count; x++)
|
||||
{
|
||||
LuaListView.SelectItem(x, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,12 +117,12 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>126, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
|
|
@ -5,47 +5,47 @@ using System.Text;
|
|||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
class LuaFiles
|
||||
{
|
||||
public string Name;
|
||||
public string Path;
|
||||
public bool Enabled;
|
||||
public bool IsSeparator;
|
||||
class LuaFiles
|
||||
{
|
||||
public string Name;
|
||||
public string Path;
|
||||
public bool Enabled;
|
||||
public bool IsSeparator;
|
||||
|
||||
public LuaFiles(string path)
|
||||
{
|
||||
Name = "";
|
||||
Path = path;
|
||||
Enabled = true;
|
||||
}
|
||||
public LuaFiles(string path)
|
||||
{
|
||||
Name = "";
|
||||
Path = path;
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
public LuaFiles(string name, string path, bool enabled)
|
||||
{
|
||||
Name = name;
|
||||
Path = path;
|
||||
Enabled = enabled;
|
||||
IsSeparator = false;
|
||||
}
|
||||
public LuaFiles(string name, string path, bool enabled)
|
||||
{
|
||||
Name = name;
|
||||
Path = path;
|
||||
Enabled = enabled;
|
||||
IsSeparator = false;
|
||||
}
|
||||
|
||||
public LuaFiles(bool isSeparator)
|
||||
{
|
||||
IsSeparator = isSeparator;
|
||||
Name = "";
|
||||
Path = "";
|
||||
Enabled = false;
|
||||
}
|
||||
public LuaFiles(bool isSeparator)
|
||||
{
|
||||
IsSeparator = isSeparator;
|
||||
Name = "";
|
||||
Path = "";
|
||||
Enabled = false;
|
||||
}
|
||||
|
||||
public LuaFiles(LuaFiles l)
|
||||
{
|
||||
Name = l.Name;
|
||||
Path = l.Path;
|
||||
Enabled = l.Enabled;
|
||||
IsSeparator = l.IsSeparator;
|
||||
}
|
||||
public LuaFiles(LuaFiles l)
|
||||
{
|
||||
Name = l.Name;
|
||||
Path = l.Path;
|
||||
Enabled = l.Enabled;
|
||||
IsSeparator = l.IsSeparator;
|
||||
}
|
||||
|
||||
public void Toggle()
|
||||
{
|
||||
Enabled ^= true;
|
||||
}
|
||||
}
|
||||
public void Toggle()
|
||||
{
|
||||
Enabled ^= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue