PCE BG Viewer - implemented auto-load and save window position options

This commit is contained in:
adelikat 2012-03-13 02:41:10 +00:00
parent f53088c7be
commit e0e95ee8ea
4 changed files with 135 additions and 88 deletions

View File

@ -304,6 +304,12 @@ namespace BizHawk.MultiClient
public bool PCEDispBG2 = true; public bool PCEDispBG2 = true;
public bool PCEDispOBJ2= true; public bool PCEDispOBJ2= true;
// PCE BG Viewer settings
public bool PCEBGViewerSaveWIndowPosition = true;
public bool PCEBGViewerAutoload = false;
public int PCEBGViewerWndx = -1;
public int PCEBGViewerWndy = -1;
// SMS Graphics settings // SMS Graphics settings
public bool SMSDispBG = true; public bool SMSDispBG = true;
public bool SMSDispOBJ = true; public bool SMSDispOBJ = true;

View File

@ -234,6 +234,8 @@ namespace BizHawk.MultiClient
LoadTAStudio(); LoadTAStudio();
if (Global.Config.AutoLoadLuaConsole) if (Global.Config.AutoLoadLuaConsole)
OpenLuaConsole(); OpenLuaConsole();
if (Global.Config.PCEBGViewerAutoload && Global.Emulator is PCEngine)
LoadPCEBGViewer();
if (Global.Config.MainWndx >= 0 && Global.Config.MainWndy >= 0 && Global.Config.SaveWindowPosition) if (Global.Config.MainWndx >= 0 && Global.Config.MainWndy >= 0 && Global.Config.SaveWindowPosition)
this.Location = new Point(Global.Config.MainWndx, Global.Config.MainWndy); this.Location = new Point(Global.Config.MainWndx, Global.Config.MainWndy);

View File

@ -28,99 +28,102 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.vdcComboBox = new System.Windows.Forms.ComboBox(); this.vdcComboBox = new System.Windows.Forms.ComboBox();
this.canvas = new BizHawk.MultiClient.PCEBGCanvas(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.canvas = new BizHawk.MultiClient.PCEBGCanvas();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// vdcComboBox // vdcComboBox
// //
this.vdcComboBox.FormattingEnabled = true; this.vdcComboBox.FormattingEnabled = true;
this.vdcComboBox.Location = new System.Drawing.Point(12, 27); this.vdcComboBox.Location = new System.Drawing.Point(12, 27);
this.vdcComboBox.Name = "vdcComboBox"; this.vdcComboBox.Name = "vdcComboBox";
this.vdcComboBox.Size = new System.Drawing.Size(121, 21); this.vdcComboBox.Size = new System.Drawing.Size(121, 21);
this.vdcComboBox.TabIndex = 1; this.vdcComboBox.TabIndex = 1;
this.vdcComboBox.SelectedIndexChanged += new System.EventHandler(this.vdcComboBox_SelectedIndexChanged); this.vdcComboBox.SelectedIndexChanged += new System.EventHandler(this.vdcComboBox_SelectedIndexChanged);
// //
// canvas // menuStrip1
// //
this.canvas.Location = new System.Drawing.Point(12, 65); this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.canvas.Name = "canvas";
this.canvas.Size = new System.Drawing.Size(1024, 543);
this.canvas.TabIndex = 0;
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem, this.fileToolStripMenuItem,
this.optionsToolStripMenuItem}); this.optionsToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1056, 24); this.menuStrip1.Size = new System.Drawing.Size(1056, 24);
this.menuStrip1.TabIndex = 2; this.menuStrip1.TabIndex = 2;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
// fileToolStripMenuItem // fileToolStripMenuItem
// //
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exitToolStripMenuItem}); this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 20); this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
this.fileToolStripMenuItem.Text = "&Viewer"; this.fileToolStripMenuItem.Text = "&Viewer";
// //
// optionsToolStripMenuItem // exitToolStripMenuItem
// //
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.ShortcutKeyDisplayString = "Alt+F4";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// optionsToolStripMenuItem
//
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.autoloadToolStripMenuItem, this.autoloadToolStripMenuItem,
this.saveWindowPositionToolStripMenuItem}); this.saveWindowPositionToolStripMenuItem});
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
this.optionsToolStripMenuItem.Text = "&Options"; this.optionsToolStripMenuItem.Text = "&Options";
// this.optionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.optionsToolStripMenuItem_DropDownOpened);
// autoloadToolStripMenuItem //
// // autoloadToolStripMenuItem
this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem"; //
this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem";
this.autoloadToolStripMenuItem.Text = "&Auto-load"; this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
// this.autoloadToolStripMenuItem.Text = "&Auto-load";
// saveWindowPositionToolStripMenuItem this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click);
// //
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem"; // saveWindowPositionToolStripMenuItem
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(191, 22); //
this.saveWindowPositionToolStripMenuItem.Text = "&Save Window position"; this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
// this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
// exitToolStripMenuItem this.saveWindowPositionToolStripMenuItem.Text = "&Save Window position";
// this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click);
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; //
this.exitToolStripMenuItem.ShortcutKeyDisplayString = "Alt+F4"; // canvas
this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22); //
this.exitToolStripMenuItem.Text = "E&xit"; this.canvas.Location = new System.Drawing.Point(12, 65);
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); this.canvas.Name = "canvas";
// this.canvas.Size = new System.Drawing.Size(1024, 543);
// PCEBGViewer this.canvas.TabIndex = 0;
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); // PCEBGViewer
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; //
this.ClientSize = new System.Drawing.Size(1056, 649); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.Controls.Add(this.vdcComboBox); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.canvas); this.ClientSize = new System.Drawing.Size(1056, 649);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.vdcComboBox);
this.MainMenuStrip = this.menuStrip1; this.Controls.Add(this.canvas);
this.Name = "PCEBGViewer"; this.Controls.Add(this.menuStrip1);
this.ShowIcon = false; this.MainMenuStrip = this.menuStrip1;
this.Text = "PCE BG Viewer (interim)"; this.Name = "PCEBGViewer";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.PCEBGViewer_FormClosed); this.ShowIcon = false;
this.Load += new System.EventHandler(this.PCEBGViewer_Load); this.Text = "PCE BG Viewer (interim)";
this.menuStrip1.ResumeLayout(false); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.PCEBGViewer_FormClosed);
this.menuStrip1.PerformLayout(); this.Load += new System.EventHandler(this.PCEBGViewer_Load);
this.ResumeLayout(false); this.menuStrip1.ResumeLayout(false);
this.PerformLayout(); this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
} }

View File

@ -15,6 +15,9 @@ namespace BizHawk.MultiClient
{ {
PCEngine pce; PCEngine pce;
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight;
public PCEBGViewer() public PCEBGViewer()
{ {
InitializeComponent(); InitializeComponent();
@ -23,6 +26,7 @@ namespace BizHawk.MultiClient
vdcComboBox.DropDownStyle = ComboBoxStyle.DropDownList; vdcComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
vdcComboBox.SelectedIndex = 0; vdcComboBox.SelectedIndex = 0;
Activated += (o, e) => Generate(); Activated += (o, e) => Generate();
Closing += (o, e) => SaveConfigSettings();
} }
public unsafe void Generate() public unsafe void Generate()
@ -94,11 +98,27 @@ namespace BizHawk.MultiClient
} }
private void SaveConfigSettings()
{
Global.Config.PCEBGViewerWndx = this.Location.X;
Global.Config.PCEBGViewerWndy = this.Location.Y;
}
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.PCEBGViewerSaveWIndowPosition && Global.Config.PCEBGViewerWndx >= 0 && Global.Config.PCEBGViewerWndy >= 0)
Location = new Point(Global.Config.PCEBGViewerWndx, Global.Config.PCEBGViewerWndy);
}
private void PCEBGViewer_Load(object sender, EventArgs e) private void PCEBGViewer_Load(object sender, EventArgs e)
{ {
pce = Global.Emulator as PCEngine; pce = Global.Emulator as PCEngine;
vdcComboBox.SelectedIndex = 0; vdcComboBox.SelectedIndex = 0;
vdcComboBox.Enabled = pce.SystemId == "SGX"; vdcComboBox.Enabled = pce.SystemId == "SGX";
LoadConfigSettings();
} }
private void PCEBGViewer_FormClosed(object sender, FormClosedEventArgs e) private void PCEBGViewer_FormClosed(object sender, FormClosedEventArgs e)
@ -115,5 +135,21 @@ namespace BizHawk.MultiClient
{ {
this.Close(); this.Close();
} }
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.PCEBGViewerSaveWIndowPosition ^= true;
}
private void autoloadToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.PCEBGViewerAutoload ^= true;
}
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
saveWindowPositionToolStripMenuItem.Checked = Global.Config.PCEBGViewerSaveWIndowPosition;
autoloadToolStripMenuItem.Checked = Global.Config.PCEBGViewerAutoload;
}
} }
} }