various dialog tweaks to the lua console window

This commit is contained in:
andres.delikat 2011-04-09 00:08:27 +00:00
parent ae8b4a3576
commit 50720e2a6d
4 changed files with 204 additions and 22 deletions

View File

@ -58,6 +58,12 @@
// Lua Console // Lua Console
public RecentFiles RecentLua = new RecentFiles(8); public RecentFiles RecentLua = new RecentFiles(8);
public bool AutoLoadLua = false;
public bool LuaConsoleSaveWindowPosition = true;
public int LuaConsoleWndx = -1; //Negative numbers will be ignored even with save window position set
public int LuaConsoleWndy = -1;
public int LuaConsoleWidth = -1;
public int LuaConsoleHeight = -1;
// RamWatch Settings // RamWatch Settings
public bool AutoLoadRamWatch = false; public bool AutoLoadRamWatch = false;
@ -65,7 +71,7 @@
public bool RamWatchSaveWindowPosition = true; public bool RamWatchSaveWindowPosition = true;
public int RamWatchWndx = -1; //Negative numbers will be ignored even with save window position set public int RamWatchWndx = -1; //Negative numbers will be ignored even with save window position set
public int RamWatchWndy = -1; public int RamWatchWndy = -1;
public int RamWatchWidth = -1; //Negative numbers will be ignored public int RamWatchWidth = -1;
public int RamWatchHeight = -1; public int RamWatchHeight = -1;
public bool RamWatchShowChangeColumn = true; public bool RamWatchShowChangeColumn = true;
public bool RamWatchShowPrevColumn = false; public bool RamWatchShowPrevColumn = false;

View File

@ -36,18 +36,27 @@
this.IDT_OUTPUT = new System.Windows.Forms.TextBox(); this.IDT_OUTPUT = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// IDT_SCRIPTFILE // IDT_SCRIPTFILE
// //
this.IDT_SCRIPTFILE.Location = new System.Drawing.Point(12, 21); this.IDT_SCRIPTFILE.Location = new System.Drawing.Point(12, 45);
this.IDT_SCRIPTFILE.Name = "IDT_SCRIPTFILE"; this.IDT_SCRIPTFILE.Name = "IDT_SCRIPTFILE";
this.IDT_SCRIPTFILE.Size = new System.Drawing.Size(349, 20); this.IDT_SCRIPTFILE.Size = new System.Drawing.Size(349, 20);
this.IDT_SCRIPTFILE.TabIndex = 0; this.IDT_SCRIPTFILE.TabIndex = 0;
// //
// IDB_BROWSE // IDB_BROWSE
// //
this.IDB_BROWSE.Location = new System.Drawing.Point(12, 47); this.IDB_BROWSE.Location = new System.Drawing.Point(12, 71);
this.IDB_BROWSE.Name = "IDB_BROWSE"; this.IDB_BROWSE.Name = "IDB_BROWSE";
this.IDB_BROWSE.Size = new System.Drawing.Size(75, 23); this.IDB_BROWSE.Size = new System.Drawing.Size(75, 23);
this.IDB_BROWSE.TabIndex = 1; this.IDB_BROWSE.TabIndex = 1;
@ -57,16 +66,17 @@
// //
// IDB_EDIT // IDB_EDIT
// //
this.IDB_EDIT.Location = new System.Drawing.Point(93, 47); this.IDB_EDIT.Location = new System.Drawing.Point(93, 71);
this.IDB_EDIT.Name = "IDB_EDIT"; this.IDB_EDIT.Name = "IDB_EDIT";
this.IDB_EDIT.Size = new System.Drawing.Size(75, 23); this.IDB_EDIT.Size = new System.Drawing.Size(75, 23);
this.IDB_EDIT.TabIndex = 2; this.IDB_EDIT.TabIndex = 2;
this.IDB_EDIT.Text = "Edit"; this.IDB_EDIT.Text = "Edit";
this.IDB_EDIT.UseVisualStyleBackColor = true; this.IDB_EDIT.UseVisualStyleBackColor = true;
this.IDB_EDIT.Click += new System.EventHandler(this.IDB_EDIT_Click);
// //
// IDB_RUN // IDB_RUN
// //
this.IDB_RUN.Location = new System.Drawing.Point(286, 47); this.IDB_RUN.Location = new System.Drawing.Point(286, 71);
this.IDB_RUN.Name = "IDB_RUN"; this.IDB_RUN.Name = "IDB_RUN";
this.IDB_RUN.Size = new System.Drawing.Size(75, 23); this.IDB_RUN.Size = new System.Drawing.Size(75, 23);
this.IDB_RUN.TabIndex = 4; this.IDB_RUN.TabIndex = 4;
@ -76,27 +86,31 @@
// //
// IDB_STOP // IDB_STOP
// //
this.IDB_STOP.Location = new System.Drawing.Point(205, 47); this.IDB_STOP.Location = new System.Drawing.Point(205, 71);
this.IDB_STOP.Name = "IDB_STOP"; this.IDB_STOP.Name = "IDB_STOP";
this.IDB_STOP.Size = new System.Drawing.Size(75, 23); this.IDB_STOP.Size = new System.Drawing.Size(75, 23);
this.IDB_STOP.TabIndex = 3; this.IDB_STOP.TabIndex = 3;
this.IDB_STOP.Text = "Stop"; this.IDB_STOP.Text = "Stop";
this.IDB_STOP.UseVisualStyleBackColor = true; this.IDB_STOP.UseVisualStyleBackColor = true;
this.IDB_STOP.Click += new System.EventHandler(this.IDB_STOP_Click);
// //
// IDT_OUTPUT // IDT_OUTPUT
// //
this.IDT_OUTPUT.Location = new System.Drawing.Point(12, 91); this.IDT_OUTPUT.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.IDT_OUTPUT.Location = new System.Drawing.Point(12, 115);
this.IDT_OUTPUT.Multiline = true; this.IDT_OUTPUT.Multiline = true;
this.IDT_OUTPUT.Name = "IDT_OUTPUT"; this.IDT_OUTPUT.Name = "IDT_OUTPUT";
this.IDT_OUTPUT.ReadOnly = true; this.IDT_OUTPUT.ReadOnly = true;
this.IDT_OUTPUT.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.IDT_OUTPUT.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.IDT_OUTPUT.Size = new System.Drawing.Size(349, 151); this.IDT_OUTPUT.Size = new System.Drawing.Size(353, 151);
this.IDT_OUTPUT.TabIndex = 5; this.IDT_OUTPUT.TabIndex = 5;
// //
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 75); this.label1.Location = new System.Drawing.Point(12, 99);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(83, 13); this.label1.Size = new System.Drawing.Size(83, 13);
this.label1.TabIndex = 6; this.label1.TabIndex = 6;
@ -105,17 +119,83 @@
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 5); this.label2.Location = new System.Drawing.Point(12, 29);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 13); this.label2.Size = new System.Drawing.Size(53, 13);
this.label2.TabIndex = 7; this.label2.TabIndex = 7;
this.label2.Text = "Script File"; this.label2.Text = "Script File";
// //
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.optionsToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(369, 24);
this.menuStrip1.TabIndex = 8;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.openToolStripMenuItem,
this.toolStripSeparator1,
this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20);
this.fileToolStripMenuItem.Text = "&File";
//
// optionsToolStripMenuItem
//
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.saveWindowPositionToolStripMenuItem,
this.restoreWindowSizeToolStripMenuItem});
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
this.optionsToolStripMenuItem.Text = "&Options";
this.optionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.optionsToolStripMenuItem_DropDownOpened);
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.openToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.openToolStripMenuItem.Text = "&Open...";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(160, 6);
//
// 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(163, 22);
this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// saveWindowPositionToolStripMenuItem
//
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(190, 22);
this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position";
this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click);
//
// restoreWindowSizeToolStripMenuItem
//
this.restoreWindowSizeToolStripMenuItem.Name = "restoreWindowSizeToolStripMenuItem";
this.restoreWindowSizeToolStripMenuItem.Size = new System.Drawing.Size(190, 22);
this.restoreWindowSizeToolStripMenuItem.Text = "Restore Window Size";
this.restoreWindowSizeToolStripMenuItem.Click += new System.EventHandler(this.restoreWindowSizeToolStripMenuItem_Click);
//
// LuaWindow // LuaWindow
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(365, 251); this.ClientSize = new System.Drawing.Size(369, 281);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.IDT_OUTPUT); this.Controls.Add(this.IDT_OUTPUT);
@ -124,9 +204,13 @@
this.Controls.Add(this.IDB_EDIT); this.Controls.Add(this.IDB_EDIT);
this.Controls.Add(this.IDB_BROWSE); this.Controls.Add(this.IDB_BROWSE);
this.Controls.Add(this.IDT_SCRIPTFILE); this.Controls.Add(this.IDT_SCRIPTFILE);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "LuaWindow"; this.Name = "LuaWindow";
this.Text = "Lua Script"; this.Text = "Lua Script";
this.Load += new System.EventHandler(this.LuaWindow_Load); this.Load += new System.EventHandler(this.LuaWindow_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -142,5 +226,13 @@
private System.Windows.Forms.TextBox IDT_OUTPUT; private System.Windows.Forms.TextBox IDT_OUTPUT;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem restoreWindowSizeToolStripMenuItem;
} }
} }

View File

@ -6,34 +6,61 @@ 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;
using LuaInterface; using LuaInterface;
namespace BizHawk.MultiClient.tools namespace BizHawk.MultiClient.tools
{ {
public partial class LuaWindow : Form public partial class LuaWindow : Form
{ {
//TODO: main form should run save config settings, however, multiple lua consoles should be able to be opened at once, think about the logic of this
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight;
LuaImplementation LuaImp; LuaImplementation LuaImp;
public LuaWindow() public LuaWindow()
{ {
InitializeComponent(); InitializeComponent();
LuaImp = new LuaImplementation(this); LuaImp = new LuaImplementation(this);
Closing += (o, e) => SaveConfigSettings();
} }
public LuaWindow get() public LuaWindow get()
{ {
return this; return this;
} }
private FileInfo GetFileFromUser()
{
var ofd = new OpenFileDialog();
if (IDT_SCRIPTFILE.Text.Length > 0)
ofd.FileName = Path.GetFileNameWithoutExtension(IDT_SCRIPTFILE.Text);
ofd.InitialDirectory = Global.Config.LastRomPath;
ofd.Filter = "Watch Files (*.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);
Global.Config.LastRomPath = file.DirectoryName;
return file;
}
private void OpenLuaScript()
{
var file = GetFileFromUser();
if (file != null)
{
IDT_SCRIPTFILE.Text = file.FullName;
}
}
private void IDB_BROWSE_Click(object sender, EventArgs e) private void IDB_BROWSE_Click(object sender, EventArgs e)
{ {
OpenFileDialog fdlg = new OpenFileDialog(); OpenLuaScript();
fdlg.Title = "Open Lua Script";
fdlg.InitialDirectory = @".\"; //Switch this to a better default directory
fdlg.Filter = "Lua files (*.lua)|*.lua|All files (*.*)|*.*";
fdlg.FilterIndex = 1;
fdlg.RestoreDirectory = true;
if (fdlg.ShowDialog(this) == DialogResult.OK)
{
IDT_SCRIPTFILE.Text = fdlg.FileName;
}
} }
public void AddText(string s) public void AddText(string s)
{ {
@ -47,8 +74,62 @@ namespace BizHawk.MultiClient.tools
private void LuaWindow_Load(object sender, EventArgs e) private void LuaWindow_Load(object sender, EventArgs e)
{ {
LoadConfigSettings();
} }
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenLuaScript();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.LuaConsoleSaveWindowPosition ^= true;
}
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
saveWindowPositionToolStripMenuItem.Checked = Global.Config.LuaConsoleSaveWindowPosition;
}
private void LoadConfigSettings()
{
defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
defaultHeight = Size.Height;
if (Global.Config.LuaConsoleSaveWindowPosition && Global.Config.LuaConsoleWndx >= 0 && Global.Config.LuaConsoleWndy >= 0)
Location = new Point(Global.Config.LuaConsoleWndx, Global.Config.LuaConsoleWndy);
if (Global.Config.LuaConsoleWidth >= 0 && Global.Config.LuaConsoleHeight >= 0)
Size = new System.Drawing.Size(Global.Config.LuaConsoleWidth, Global.Config.LuaConsoleHeight);
}
public void SaveConfigSettings()
{
Global.Config.LuaConsoleWndx = this.Location.X;
Global.Config.LuaConsoleWndy = this.Location.Y;
Global.Config.LuaConsoleWidth = this.Right - this.Left;
Global.Config.LuaConsoleHeight = this.Bottom - this.Top;
}
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
}
private void IDB_EDIT_Click(object sender, EventArgs e)
{
}
private void IDB_STOP_Click(object sender, EventArgs e)
{
}
} }
} }

View File

@ -117,4 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root> </root>