PCE BG Viewer - implement Always on Top and Floating Window, and refactor

This commit is contained in:
adelikat 2014-01-31 23:42:06 +00:00
parent 5ecc74c435
commit 3497e28f96
7 changed files with 406 additions and 360 deletions

View File

@ -378,10 +378,8 @@ namespace BizHawk.Client.Common
public int SNESGraphicsUserBackdropColor = -1;
// PCE BG Viewer settings
public bool PCEBGViewerSaveWIndowPosition = true;
public ToolDialogSettings PceBgViewerSettings = new ToolDialogSettings();
public bool PCEBGViewerAutoload = false;
public int PCEBGViewerWndx = -1;
public int PCEBGViewerWndy = -1;
public int PCEBGViewerRefreshRate = 16;
#region Cheats Dialog

View File

@ -1254,7 +1254,7 @@ namespace BizHawk.Client.EmuHawk
private void PCEBGViewerMenuItem_Click(object sender, EventArgs e)
{
GlobalWin.Tools.Load<PCEBGViewer>();
GlobalWin.Tools.Load<PceBgViewer>();
}
private void PCEAlwaysPerformSpriteLimitMenuItem_Click(object sender, EventArgs e)

View File

@ -338,7 +338,7 @@ namespace BizHawk.Client.EmuHawk
if (Global.Config.PCEBGViewerAutoload && Global.Emulator is PCEngine)
{
GlobalWin.Tools.Load<PCEBGViewer>();
GlobalWin.Tools.Load<PceBgViewer>();
}
if (Global.Config.AutoLoadSNESGraphicsDebugger && Global.Emulator is LibsnesCore)

View File

@ -1,6 +1,6 @@
namespace BizHawk.Client.EmuHawk
{
partial class PCEBGViewer
partial class PceBgViewer
{
/// <summary>
/// Required designer variable.
@ -28,290 +28,308 @@
/// </summary>
private void InitializeComponent()
{
this.menuStrip1 = new MenuStripEx();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.vDC1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.vCD2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.canvas = new BizHawk.Client.EmuHawk.PCEBGCanvas();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.RefreshRate = new System.Windows.Forms.TrackBar();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.PaletteLabel = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.PPUAddressLabel = new System.Windows.Forms.Label();
this.XYLabel = new System.Windows.Forms.Label();
this.TileIDLabel = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.menuStrip1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.RefreshRate)).BeginInit();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.ClickThrough = true;
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(676, 24);
this.menuStrip1.TabIndex = 2;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.vDC1ToolStripMenuItem,
this.vCD2ToolStripMenuItem,
this.PceBgViewerMenu = new MenuStripEx();
this.ViewerSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.VDC1MenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.VDC2MenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AutoloadMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.canvas = new BizHawk.Client.EmuHawk.PCEBGCanvas();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.RefreshRate = new System.Windows.Forms.TrackBar();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.PaletteLabel = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.PPUAddressLabel = new System.Windows.Forms.Label();
this.XYLabel = new System.Windows.Forms.Label();
this.TileIDLabel = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.PceBgViewerMenu.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.RefreshRate)).BeginInit();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// PceBgViewerMenu
//
this.PceBgViewerMenu.ClickThrough = true;
this.PceBgViewerMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ViewerSubMenu,
this.OptionsSubMenu});
this.PceBgViewerMenu.Location = new System.Drawing.Point(0, 0);
this.PceBgViewerMenu.Name = "PceBgViewerMenu";
this.PceBgViewerMenu.Size = new System.Drawing.Size(676, 24);
this.PceBgViewerMenu.TabIndex = 2;
this.PceBgViewerMenu.Text = "menuStrip1";
//
// ViewerSubMenu
//
this.ViewerSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.VDC1MenuItem,
this.VDC2MenuItem,
this.toolStripSeparator1,
this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
this.fileToolStripMenuItem.Text = "&Viewer";
this.fileToolStripMenuItem.DropDownOpened += new System.EventHandler(this.fileToolStripMenuItem_DropDownOpened);
//
// vDC1ToolStripMenuItem
//
this.vDC1ToolStripMenuItem.Name = "vDC1ToolStripMenuItem";
this.vDC1ToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
this.vDC1ToolStripMenuItem.Text = "VDC&1";
this.vDC1ToolStripMenuItem.Click += new System.EventHandler(this.vDC1ToolStripMenuItem_Click);
//
// vCD2ToolStripMenuItem
//
this.vCD2ToolStripMenuItem.Name = "vCD2ToolStripMenuItem";
this.vCD2ToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
this.vCD2ToolStripMenuItem.Text = "VCD&2";
this.vCD2ToolStripMenuItem.Click += new System.EventHandler(this.vCD2ToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(131, 6);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.ShortcutKeyDisplayString = "Alt+F4";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(134, 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.saveWindowPositionToolStripMenuItem});
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
this.optionsToolStripMenuItem.Text = "&Options";
this.optionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.optionsToolStripMenuItem_DropDownOpened);
//
// autoloadToolStripMenuItem
//
this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem";
this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
this.autoloadToolStripMenuItem.Text = "&Autoload";
this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click);
//
// saveWindowPositionToolStripMenuItem
//
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
this.saveWindowPositionToolStripMenuItem.Text = "&Save Window position";
this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.canvas);
this.groupBox1.Location = new System.Drawing.Point(12, 27);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(529, 536);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
//
// canvas
//
this.canvas.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.canvas.Location = new System.Drawing.Point(8, 15);
this.canvas.Name = "canvas";
this.canvas.Size = new System.Drawing.Size(512, 513);
this.canvas.TabIndex = 0;
this.canvas.MouseMove += new System.Windows.Forms.MouseEventHandler(this.canvas_MouseMove);
//
// groupBox5
//
this.groupBox5.Controls.Add(this.label7);
this.groupBox5.Controls.Add(this.label6);
this.groupBox5.Controls.Add(this.RefreshRate);
this.groupBox5.Location = new System.Drawing.Point(554, 122);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(108, 236);
this.groupBox5.TabIndex = 15;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Refresh";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(7, 186);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(31, 13);
this.label7.TabIndex = 2;
this.label7.Text = "More";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(7, 32);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(29, 13);
this.label6.TabIndex = 1;
this.label6.Text = "Less";
//
// RefreshRate
//
this.RefreshRate.LargeChange = 2;
this.RefreshRate.Location = new System.Drawing.Point(9, 47);
this.RefreshRate.Maximum = 16;
this.RefreshRate.Minimum = 1;
this.RefreshRate.Name = "RefreshRate";
this.RefreshRate.Orientation = System.Windows.Forms.Orientation.Vertical;
this.RefreshRate.Size = new System.Drawing.Size(45, 136);
this.RefreshRate.TabIndex = 0;
this.RefreshRate.TickFrequency = 4;
this.RefreshRate.Value = 16;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.PaletteLabel);
this.groupBox4.Controls.Add(this.label5);
this.groupBox4.Controls.Add(this.PPUAddressLabel);
this.groupBox4.Controls.Add(this.XYLabel);
this.groupBox4.Controls.Add(this.TileIDLabel);
this.groupBox4.Controls.Add(this.label2);
this.groupBox4.Controls.Add(this.label1);
this.groupBox4.Location = new System.Drawing.Point(554, 28);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(108, 87);
this.groupBox4.TabIndex = 16;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Properties";
//
// PaletteLabel
//
this.PaletteLabel.AutoSize = true;
this.PaletteLabel.Location = new System.Drawing.Point(64, 60);
this.PaletteLabel.Name = "PaletteLabel";
this.PaletteLabel.Size = new System.Drawing.Size(22, 13);
this.PaletteLabel.TabIndex = 9;
this.PaletteLabel.Text = " ";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(6, 60);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(43, 13);
this.label5.TabIndex = 8;
this.label5.Text = "Palette:";
//
// PPUAddressLabel
//
this.PPUAddressLabel.AutoSize = true;
this.PPUAddressLabel.Location = new System.Drawing.Point(64, 60);
this.PPUAddressLabel.Name = "PPUAddressLabel";
this.PPUAddressLabel.Size = new System.Drawing.Size(22, 13);
this.PPUAddressLabel.TabIndex = 5;
this.PPUAddressLabel.Text = " ";
//
// XYLabel
//
this.XYLabel.AutoSize = true;
this.XYLabel.Location = new System.Drawing.Point(64, 43);
this.XYLabel.Name = "XYLabel";
this.XYLabel.Size = new System.Drawing.Size(22, 13);
this.XYLabel.TabIndex = 4;
this.XYLabel.Text = " ";
//
// TileIDLabel
//
this.TileIDLabel.AutoSize = true;
this.TileIDLabel.Location = new System.Drawing.Point(64, 26);
this.TileIDLabel.Name = "TileIDLabel";
this.TileIDLabel.Size = new System.Drawing.Size(22, 13);
this.TileIDLabel.TabIndex = 3;
this.TileIDLabel.Text = " ";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 43);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(35, 13);
this.label2.TabIndex = 1;
this.label2.Text = "X / Y:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 26);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Tile ID:";
//
// PCEBGViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(676, 575);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "PCEBGViewer";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Background Viewer";
this.Load += new System.EventHandler(this.PCEBGViewer_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.RefreshRate)).EndInit();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
this.ExitMenuItem});
this.ViewerSubMenu.Name = "ViewerSubMenu";
this.ViewerSubMenu.Size = new System.Drawing.Size(54, 20);
this.ViewerSubMenu.Text = "&Viewer";
this.ViewerSubMenu.DropDownOpened += new System.EventHandler(this.FileSubMenu_DropDownOpened);
//
// VDC1MenuItem
//
this.VDC1MenuItem.Name = "VDC1MenuItem";
this.VDC1MenuItem.Size = new System.Drawing.Size(134, 22);
this.VDC1MenuItem.Text = "VDC&1";
this.VDC1MenuItem.Click += new System.EventHandler(this.VDC1MenuItem_Click);
//
// VDC2MenuItem
//
this.VDC2MenuItem.Name = "VDC2MenuItem";
this.VDC2MenuItem.Size = new System.Drawing.Size(134, 22);
this.VDC2MenuItem.Text = "VCD&2";
this.VDC2MenuItem.Click += new System.EventHandler(this.VDC2MenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(131, 6);
//
// ExitMenuItem
//
this.ExitMenuItem.Name = "ExitMenuItem";
this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
this.ExitMenuItem.Size = new System.Drawing.Size(134, 22);
this.ExitMenuItem.Text = "E&xit";
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
//
// OptionsSubMenu
//
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.AutoloadMenuItem,
this.SaveWindowPositionMenuItem,
this.AlwaysOnTopMenuItem,
this.FloatingWindowMenuItem});
this.OptionsSubMenu.Name = "OptionsSubMenu";
this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20);
this.OptionsSubMenu.Text = "&Options";
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
//
// AutoloadMenuItem
//
this.AutoloadMenuItem.Name = "AutoloadMenuItem";
this.AutoloadMenuItem.Size = new System.Drawing.Size(191, 22);
this.AutoloadMenuItem.Text = "&Autoload";
this.AutoloadMenuItem.Click += new System.EventHandler(this.AutoloadMenuItem_Click);
//
// SaveWindowPositionMenuItem
//
this.SaveWindowPositionMenuItem.Name = "SaveWindowPositionMenuItem";
this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(191, 22);
this.SaveWindowPositionMenuItem.Text = "&Save Window position";
this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.canvas);
this.groupBox1.Location = new System.Drawing.Point(12, 27);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(529, 536);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
//
// canvas
//
this.canvas.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.canvas.Location = new System.Drawing.Point(8, 15);
this.canvas.Name = "canvas";
this.canvas.Size = new System.Drawing.Size(512, 513);
this.canvas.TabIndex = 0;
this.canvas.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Canvas_MouseMove);
//
// groupBox5
//
this.groupBox5.Controls.Add(this.label7);
this.groupBox5.Controls.Add(this.label6);
this.groupBox5.Controls.Add(this.RefreshRate);
this.groupBox5.Location = new System.Drawing.Point(554, 122);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(108, 236);
this.groupBox5.TabIndex = 15;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Refresh";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(7, 186);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(31, 13);
this.label7.TabIndex = 2;
this.label7.Text = "More";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(7, 32);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(29, 13);
this.label6.TabIndex = 1;
this.label6.Text = "Less";
//
// RefreshRate
//
this.RefreshRate.LargeChange = 2;
this.RefreshRate.Location = new System.Drawing.Point(9, 47);
this.RefreshRate.Maximum = 16;
this.RefreshRate.Minimum = 1;
this.RefreshRate.Name = "RefreshRate";
this.RefreshRate.Orientation = System.Windows.Forms.Orientation.Vertical;
this.RefreshRate.Size = new System.Drawing.Size(45, 136);
this.RefreshRate.TabIndex = 0;
this.RefreshRate.TickFrequency = 4;
this.RefreshRate.Value = 16;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.PaletteLabel);
this.groupBox4.Controls.Add(this.label5);
this.groupBox4.Controls.Add(this.PPUAddressLabel);
this.groupBox4.Controls.Add(this.XYLabel);
this.groupBox4.Controls.Add(this.TileIDLabel);
this.groupBox4.Controls.Add(this.label2);
this.groupBox4.Controls.Add(this.label1);
this.groupBox4.Location = new System.Drawing.Point(554, 28);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(108, 87);
this.groupBox4.TabIndex = 16;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Properties";
//
// PaletteLabel
//
this.PaletteLabel.AutoSize = true;
this.PaletteLabel.Location = new System.Drawing.Point(64, 60);
this.PaletteLabel.Name = "PaletteLabel";
this.PaletteLabel.Size = new System.Drawing.Size(22, 13);
this.PaletteLabel.TabIndex = 9;
this.PaletteLabel.Text = " ";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(6, 60);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(43, 13);
this.label5.TabIndex = 8;
this.label5.Text = "Palette:";
//
// PPUAddressLabel
//
this.PPUAddressLabel.AutoSize = true;
this.PPUAddressLabel.Location = new System.Drawing.Point(64, 60);
this.PPUAddressLabel.Name = "PPUAddressLabel";
this.PPUAddressLabel.Size = new System.Drawing.Size(22, 13);
this.PPUAddressLabel.TabIndex = 5;
this.PPUAddressLabel.Text = " ";
//
// XYLabel
//
this.XYLabel.AutoSize = true;
this.XYLabel.Location = new System.Drawing.Point(64, 43);
this.XYLabel.Name = "XYLabel";
this.XYLabel.Size = new System.Drawing.Size(22, 13);
this.XYLabel.TabIndex = 4;
this.XYLabel.Text = " ";
//
// TileIDLabel
//
this.TileIDLabel.AutoSize = true;
this.TileIDLabel.Location = new System.Drawing.Point(64, 26);
this.TileIDLabel.Name = "TileIDLabel";
this.TileIDLabel.Size = new System.Drawing.Size(22, 13);
this.TileIDLabel.TabIndex = 3;
this.TileIDLabel.Text = " ";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 43);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(35, 13);
this.label2.TabIndex = 1;
this.label2.Text = "X / Y:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 26);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Tile ID:";
//
// AlwaysOnTopMenuItem
//
this.AlwaysOnTopMenuItem.Name = "AlwaysOnTopMenuItem";
this.AlwaysOnTopMenuItem.Size = new System.Drawing.Size(191, 22);
this.AlwaysOnTopMenuItem.Text = "Always On Top";
this.AlwaysOnTopMenuItem.Click += new System.EventHandler(this.AlwaysOnTopMenuItem_Click);
//
// FloatingWindowMenuItem
//
this.FloatingWindowMenuItem.Name = "FloatingWindowMenuItem";
this.FloatingWindowMenuItem.Size = new System.Drawing.Size(191, 22);
this.FloatingWindowMenuItem.Text = "Floating Window";
this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click);
//
// PceBgViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(676, 575);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.PceBgViewerMenu);
this.MainMenuStrip = this.PceBgViewerMenu;
this.Name = "PceBgViewer";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Background Viewer";
this.Load += new System.EventHandler(this.PceBgViewer_Load);
this.PceBgViewerMenu.ResumeLayout(false);
this.PceBgViewerMenu.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.RefreshRate)).EndInit();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PCEBGCanvas canvas;
private MenuStripEx menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem vDC1ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem vCD2ToolStripMenuItem;
private MenuStripEx PceBgViewerMenu;
private System.Windows.Forms.ToolStripMenuItem ViewerSubMenu;
private System.Windows.Forms.ToolStripMenuItem OptionsSubMenu;
private System.Windows.Forms.ToolStripMenuItem AutoloadMenuItem;
private System.Windows.Forms.ToolStripMenuItem SaveWindowPositionMenuItem;
private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
private System.Windows.Forms.ToolStripMenuItem VDC1MenuItem;
private System.Windows.Forms.ToolStripMenuItem VDC2MenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox5;
@ -326,5 +344,7 @@
private System.Windows.Forms.Label TileIDLabel;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem;
private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem;
}
}

View File

@ -1,43 +1,74 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.PCEngine;
namespace BizHawk.Client.EmuHawk
{
public partial class PCEBGViewer : Form, IToolForm
public partial class PceBgViewer : Form, IToolForm
{
private PCEngine _pce;
private int VDCtype;
private int _vdcType;
public PceBgViewer()
{
InitializeComponent();
TopMost = Global.Config.PceBgViewerSettings.TopMost;
Activated += (o, e) => Generate();
Closing += (o, e) =>
{
Global.Config.PceBgViewerSettings.Wndx = Location.X;
Global.Config.PceBgViewerSettings.Wndy = Location.Y;
Global.Config.PCEBGViewerRefreshRate = RefreshRate.Value;
};
}
private void PceBgViewer_Load(object sender, EventArgs e)
{
_pce = Global.Emulator as PCEngine;
if (Global.Config.PceBgViewerSettings.UseWindowPosition)
{
Location = Global.Config.PceBgViewerSettings.WindowPosition;
}
if (Global.Config.PCEBGViewerRefreshRate >= RefreshRate.Minimum && Global.Config.PCEBGViewerRefreshRate <= RefreshRate.Maximum)
{
RefreshRate.Value = Global.Config.PCEBGViewerRefreshRate;
}
else
{
RefreshRate.Value = RefreshRate.Maximum;
}
}
private void RefreshFloatingWindowControl()
{
Owner = Global.Config.PceBgViewerSettings.FloatingWindow ? null : GlobalWin.MainForm;
}
#region Public API
public bool AskSave() { return true; }
public bool UpdateBefore { get { return true; } }
public PCEBGViewer()
{
InitializeComponent();
Activated += (o, e) => Generate();
Closing += (o, e) => SaveConfigSettings();
}
public unsafe void Generate()
{
if (Global.Emulator.Frame % RefreshRate.Value != 0) return;
if (Global.Emulator.Frame % RefreshRate.Value != 0)
{
return;
}
VDC vdc = VDCtype == 0 ? _pce.VDC1 : _pce.VDC2;
var vdc = _vdcType == 0 ? _pce.VDC1 : _pce.VDC2;
int width = 8 * vdc.BatWidth;
int height = 8 * vdc.BatHeight;
BitmapData buf = canvas.Bat.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, canvas.Bat.PixelFormat);
int pitch = buf.Stride / 4;
int* begin = (int*)buf.Scan0.ToPointer();
// TODO: this does not clear background, why?
//for (int i = 0; i < pitch * buf.Height; ++i, ++p)
// *p = canvas.BackColor.ToArgb();
var width = 8 * vdc.BatWidth;
var height = 8 * vdc.BatHeight;
var buf = canvas.Bat.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, canvas.Bat.PixelFormat);
var pitch = buf.Stride / 4;
var begin = (int*)buf.Scan0.ToPointer();
int* p = begin;
for (int y = 0; y < height; ++y)
@ -54,12 +85,15 @@ namespace BizHawk.Client.EmuHawk
byte c = vdc.PatternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs];
if (c == 0)
{
*p = _pce.VCE.Palette[0];
}
else
{
*p = _pce.VCE.Palette[paletteBase + c];
}
}
p += pitch - width;
}
@ -91,95 +125,89 @@ namespace BizHawk.Client.EmuHawk
}
}
private void SaveConfigSettings()
#endregion
#region Events
#region Menu
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
{
Global.Config.PCEBGViewerWndx = Location.X;
Global.Config.PCEBGViewerWndy = Location.Y;
Global.Config.PCEBGViewerRefreshRate = RefreshRate.Value;
VDC2MenuItem.Enabled = _pce.SystemId == "SGX";
VDC1MenuItem.Checked = _vdcType == 0;
VDC2MenuItem.Checked = _vdcType == 1;
}
private void LoadConfigSettings()
private void VDC1MenuItem_Click(object sender, EventArgs e)
{
if (Global.Config.PCEBGViewerSaveWIndowPosition && Global.Config.PCEBGViewerWndx >= 0 && Global.Config.PCEBGViewerWndy >= 0)
Location = new Point(Global.Config.PCEBGViewerWndx, Global.Config.PCEBGViewerWndy);
_vdcType = 0;
}
private void PCEBGViewer_Load(object sender, EventArgs e)
private void VDC2MenuItem_Click(object sender, EventArgs e)
{
_pce = Global.Emulator as PCEngine;
LoadConfigSettings();
if (Global.Config.PCEBGViewerRefreshRate >= RefreshRate.Minimum && Global.Config.PCEBGViewerRefreshRate <= RefreshRate.Maximum)
{
RefreshRate.Value = Global.Config.PCEBGViewerRefreshRate;
}
else
{
RefreshRate.Value = RefreshRate.Maximum;
}
_vdcType = 1;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
private void ExitMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{
Global.Config.PCEBGViewerSaveWIndowPosition ^= true;
SaveWindowPositionMenuItem.Checked = Global.Config.PceBgViewerSettings.SaveWindowPosition;
AutoloadMenuItem.Checked = Global.Config.PCEBGViewerAutoload;
AlwaysOnTopMenuItem.Checked = Global.Config.PceBgViewerSettings.TopMost;
FloatingWindowMenuItem.Checked = Global.Config.PceBgViewerSettings.FloatingWindow;
}
private void autoloadToolStripMenuItem_Click(object sender, EventArgs e)
private void AutoloadMenuItem_Click(object sender, EventArgs e)
{
Global.Config.PCEBGViewerAutoload ^= true;
}
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{
saveWindowPositionToolStripMenuItem.Checked = Global.Config.PCEBGViewerSaveWIndowPosition;
autoloadToolStripMenuItem.Checked = Global.Config.PCEBGViewerAutoload;
Global.Config.PceBgViewerSettings.SaveWindowPosition ^= true;
}
private void vDC1ToolStripMenuItem_Click(object sender, EventArgs e)
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
{
VDCtype = 0;
Global.Config.PceBgViewerSettings.TopMost ^= true;
TopMost = Global.Config.PceBgViewerSettings.TopMost;
}
private void vCD2ToolStripMenuItem_Click(object sender, EventArgs e)
private void FloatingWindowMenuItem_Click(object sender, EventArgs e)
{
VDCtype = 1;
Global.Config.PceBgViewerSettings.FloatingWindow ^= true;
RefreshFloatingWindowControl();
}
private void fileToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
if (_pce.SystemId == "SGX")
vCD2ToolStripMenuItem.Enabled = true;
else
vCD2ToolStripMenuItem.Enabled = false;
switch (VDCtype)
{
default:
case 0:
vDC1ToolStripMenuItem.Checked = true;
vCD2ToolStripMenuItem.Checked = false;
break;
case 1:
vDC1ToolStripMenuItem.Checked = false;
vCD2ToolStripMenuItem.Checked = true;
break;
}
}
#endregion
private void canvas_MouseMove(object sender, MouseEventArgs e)
#region Dialog and Controls
private void Canvas_MouseMove(object sender, MouseEventArgs e)
{
VDC vdc = VDCtype == 0 ? _pce.VDC1 : _pce.VDC2;
var vdc = _vdcType == 0 ? _pce.VDC1 : _pce.VDC2;
int xTile = e.X / 8;
int yTile = e.Y / 8;
int tileNo = vdc.VRAM[(ushort)(((yTile * vdc.BatWidth) + xTile))] & 0x07FF;
int paletteNo = vdc.VRAM[(ushort)(((yTile * vdc.BatWidth) + xTile))] >> 12;
int tileNo = vdc.VRAM[(ushort)((yTile * vdc.BatWidth) + xTile)] & 0x07FF;
int paletteNo = vdc.VRAM[(ushort)((yTile * vdc.BatWidth) + xTile)] >> 12;
TileIDLabel.Text = tileNo.ToString();
XYLabel.Text = xTile.ToString() + ":" + yTile.ToString();
XYLabel.Text = xTile + ":" + yTile;
PaletteLabel.Text = paletteNo.ToString();
}
protected override void OnShown(EventArgs e)
{
RefreshFloatingWindowControl();
base.OnShown(e);
}
#endregion
#endregion
}
}

View File

@ -117,7 +117,7 @@
<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">
<metadata name="PceBgViewerMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -200,7 +200,7 @@ namespace BizHawk.Client.EmuHawk
private void PceBgViewerToolbarItem_Click(object sender, EventArgs e)
{
GlobalWin.Tools.Load<PCEBGViewer>();
GlobalWin.Tools.Load<PceBgViewer>();
}
private void GbaGpuViewerToolBarItem_Click(object sender, EventArgs e)