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; public int SNESGraphicsUserBackdropColor = -1;
// PCE BG Viewer settings // PCE BG Viewer settings
public bool PCEBGViewerSaveWIndowPosition = true; public ToolDialogSettings PceBgViewerSettings = new ToolDialogSettings();
public bool PCEBGViewerAutoload = false; public bool PCEBGViewerAutoload = false;
public int PCEBGViewerWndx = -1;
public int PCEBGViewerWndy = -1;
public int PCEBGViewerRefreshRate = 16; public int PCEBGViewerRefreshRate = 16;
#region Cheats Dialog #region Cheats Dialog

View File

@ -1254,7 +1254,7 @@ namespace BizHawk.Client.EmuHawk
private void PCEBGViewerMenuItem_Click(object sender, EventArgs e) private void PCEBGViewerMenuItem_Click(object sender, EventArgs e)
{ {
GlobalWin.Tools.Load<PCEBGViewer>(); GlobalWin.Tools.Load<PceBgViewer>();
} }
private void PCEAlwaysPerformSpriteLimitMenuItem_Click(object sender, EventArgs e) 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) if (Global.Config.PCEBGViewerAutoload && Global.Emulator is PCEngine)
{ {
GlobalWin.Tools.Load<PCEBGViewer>(); GlobalWin.Tools.Load<PceBgViewer>();
} }
if (Global.Config.AutoLoadSNESGraphicsDebugger && Global.Emulator is LibsnesCore) if (Global.Config.AutoLoadSNESGraphicsDebugger && Global.Emulator is LibsnesCore)

View File

@ -1,6 +1,6 @@
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
partial class PCEBGViewer partial class PceBgViewer
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -28,290 +28,308 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.menuStrip1 = new MenuStripEx(); this.PceBgViewerMenu = new MenuStripEx();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ViewerSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.vDC1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.VDC1MenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.vCD2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.VDC2MenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AutoloadMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.canvas = new BizHawk.Client.EmuHawk.PCEBGCanvas(); this.canvas = new BizHawk.Client.EmuHawk.PCEBGCanvas();
this.groupBox5 = new System.Windows.Forms.GroupBox(); this.groupBox5 = new System.Windows.Forms.GroupBox();
this.label7 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label();
this.RefreshRate = new System.Windows.Forms.TrackBar(); this.RefreshRate = new System.Windows.Forms.TrackBar();
this.groupBox4 = new System.Windows.Forms.GroupBox(); this.groupBox4 = new System.Windows.Forms.GroupBox();
this.PaletteLabel = new System.Windows.Forms.Label(); this.PaletteLabel = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label();
this.PPUAddressLabel = new System.Windows.Forms.Label(); this.PPUAddressLabel = new System.Windows.Forms.Label();
this.XYLabel = new System.Windows.Forms.Label(); this.XYLabel = new System.Windows.Forms.Label();
this.TileIDLabel = new System.Windows.Forms.Label(); this.TileIDLabel = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.menuStrip1.SuspendLayout(); this.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox1.SuspendLayout(); this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox5.SuspendLayout(); this.PceBgViewerMenu.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.RefreshRate)).BeginInit(); this.groupBox1.SuspendLayout();
this.groupBox4.SuspendLayout(); this.groupBox5.SuspendLayout();
this.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.RefreshRate)).BeginInit();
// this.groupBox4.SuspendLayout();
// menuStrip1 this.SuspendLayout();
// //
this.menuStrip1.ClickThrough = true; // PceBgViewerMenu
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { //
this.fileToolStripMenuItem, this.PceBgViewerMenu.ClickThrough = true;
this.optionsToolStripMenuItem}); this.PceBgViewerMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.ViewerSubMenu,
this.menuStrip1.Name = "menuStrip1"; this.OptionsSubMenu});
this.menuStrip1.Size = new System.Drawing.Size(676, 24); this.PceBgViewerMenu.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.TabIndex = 2; this.PceBgViewerMenu.Name = "PceBgViewerMenu";
this.menuStrip1.Text = "menuStrip1"; this.PceBgViewerMenu.Size = new System.Drawing.Size(676, 24);
// this.PceBgViewerMenu.TabIndex = 2;
// fileToolStripMenuItem this.PceBgViewerMenu.Text = "menuStrip1";
// //
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { // ViewerSubMenu
this.vDC1ToolStripMenuItem, //
this.vCD2ToolStripMenuItem, this.ViewerSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.VDC1MenuItem,
this.VDC2MenuItem,
this.toolStripSeparator1, this.toolStripSeparator1,
this.exitToolStripMenuItem}); this.ExitMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.ViewerSubMenu.Name = "ViewerSubMenu";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 20); this.ViewerSubMenu.Size = new System.Drawing.Size(54, 20);
this.fileToolStripMenuItem.Text = "&Viewer"; this.ViewerSubMenu.Text = "&Viewer";
this.fileToolStripMenuItem.DropDownOpened += new System.EventHandler(this.fileToolStripMenuItem_DropDownOpened); this.ViewerSubMenu.DropDownOpened += new System.EventHandler(this.FileSubMenu_DropDownOpened);
// //
// vDC1ToolStripMenuItem // VDC1MenuItem
// //
this.vDC1ToolStripMenuItem.Name = "vDC1ToolStripMenuItem"; this.VDC1MenuItem.Name = "VDC1MenuItem";
this.vDC1ToolStripMenuItem.Size = new System.Drawing.Size(134, 22); this.VDC1MenuItem.Size = new System.Drawing.Size(134, 22);
this.vDC1ToolStripMenuItem.Text = "VDC&1"; this.VDC1MenuItem.Text = "VDC&1";
this.vDC1ToolStripMenuItem.Click += new System.EventHandler(this.vDC1ToolStripMenuItem_Click); this.VDC1MenuItem.Click += new System.EventHandler(this.VDC1MenuItem_Click);
// //
// vCD2ToolStripMenuItem // VDC2MenuItem
// //
this.vCD2ToolStripMenuItem.Name = "vCD2ToolStripMenuItem"; this.VDC2MenuItem.Name = "VDC2MenuItem";
this.vCD2ToolStripMenuItem.Size = new System.Drawing.Size(134, 22); this.VDC2MenuItem.Size = new System.Drawing.Size(134, 22);
this.vCD2ToolStripMenuItem.Text = "VCD&2"; this.VDC2MenuItem.Text = "VCD&2";
this.vCD2ToolStripMenuItem.Click += new System.EventHandler(this.vCD2ToolStripMenuItem_Click); this.VDC2MenuItem.Click += new System.EventHandler(this.VDC2MenuItem_Click);
// //
// toolStripSeparator1 // toolStripSeparator1
// //
this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(131, 6); this.toolStripSeparator1.Size = new System.Drawing.Size(131, 6);
// //
// exitToolStripMenuItem // ExitMenuItem
// //
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.ExitMenuItem.Name = "ExitMenuItem";
this.exitToolStripMenuItem.ShortcutKeyDisplayString = "Alt+F4"; this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(134, 22); this.ExitMenuItem.Size = new System.Drawing.Size(134, 22);
this.exitToolStripMenuItem.Text = "E&xit"; this.ExitMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
// //
// optionsToolStripMenuItem // OptionsSubMenu
// //
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.autoloadToolStripMenuItem, this.AutoloadMenuItem,
this.saveWindowPositionToolStripMenuItem}); this.SaveWindowPositionMenuItem,
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; this.AlwaysOnTopMenuItem,
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); this.FloatingWindowMenuItem});
this.optionsToolStripMenuItem.Text = "&Options"; this.OptionsSubMenu.Name = "OptionsSubMenu";
this.optionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.optionsToolStripMenuItem_DropDownOpened); this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20);
// this.OptionsSubMenu.Text = "&Options";
// autoloadToolStripMenuItem this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
// //
this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem"; // AutoloadMenuItem
this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(191, 22); //
this.autoloadToolStripMenuItem.Text = "&Autoload"; this.AutoloadMenuItem.Name = "AutoloadMenuItem";
this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click); this.AutoloadMenuItem.Size = new System.Drawing.Size(191, 22);
// this.AutoloadMenuItem.Text = "&Autoload";
// saveWindowPositionToolStripMenuItem this.AutoloadMenuItem.Click += new System.EventHandler(this.AutoloadMenuItem_Click);
// //
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem"; // SaveWindowPositionMenuItem
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(191, 22); //
this.saveWindowPositionToolStripMenuItem.Text = "&Save Window position"; this.SaveWindowPositionMenuItem.Name = "SaveWindowPositionMenuItem";
this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click); this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(191, 22);
// this.SaveWindowPositionMenuItem.Text = "&Save Window position";
// groupBox1 this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click);
// //
this.groupBox1.Controls.Add(this.canvas); // groupBox1
this.groupBox1.Location = new System.Drawing.Point(12, 27); //
this.groupBox1.Name = "groupBox1"; this.groupBox1.Controls.Add(this.canvas);
this.groupBox1.Size = new System.Drawing.Size(529, 536); this.groupBox1.Location = new System.Drawing.Point(12, 27);
this.groupBox1.TabIndex = 3; this.groupBox1.Name = "groupBox1";
this.groupBox1.TabStop = false; this.groupBox1.Size = new System.Drawing.Size(529, 536);
// this.groupBox1.TabIndex = 3;
// canvas this.groupBox1.TabStop = false;
// //
this.canvas.BackColor = System.Drawing.SystemColors.ControlLightLight; // canvas
this.canvas.Location = new System.Drawing.Point(8, 15); //
this.canvas.Name = "canvas"; this.canvas.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.canvas.Size = new System.Drawing.Size(512, 513); this.canvas.Location = new System.Drawing.Point(8, 15);
this.canvas.TabIndex = 0; this.canvas.Name = "canvas";
this.canvas.MouseMove += new System.Windows.Forms.MouseEventHandler(this.canvas_MouseMove); this.canvas.Size = new System.Drawing.Size(512, 513);
// this.canvas.TabIndex = 0;
// groupBox5 this.canvas.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Canvas_MouseMove);
// //
this.groupBox5.Controls.Add(this.label7); // groupBox5
this.groupBox5.Controls.Add(this.label6); //
this.groupBox5.Controls.Add(this.RefreshRate); this.groupBox5.Controls.Add(this.label7);
this.groupBox5.Location = new System.Drawing.Point(554, 122); this.groupBox5.Controls.Add(this.label6);
this.groupBox5.Name = "groupBox5"; this.groupBox5.Controls.Add(this.RefreshRate);
this.groupBox5.Size = new System.Drawing.Size(108, 236); this.groupBox5.Location = new System.Drawing.Point(554, 122);
this.groupBox5.TabIndex = 15; this.groupBox5.Name = "groupBox5";
this.groupBox5.TabStop = false; this.groupBox5.Size = new System.Drawing.Size(108, 236);
this.groupBox5.Text = "Refresh"; this.groupBox5.TabIndex = 15;
// this.groupBox5.TabStop = false;
// label7 this.groupBox5.Text = "Refresh";
// //
this.label7.AutoSize = true; // label7
this.label7.Location = new System.Drawing.Point(7, 186); //
this.label7.Name = "label7"; this.label7.AutoSize = true;
this.label7.Size = new System.Drawing.Size(31, 13); this.label7.Location = new System.Drawing.Point(7, 186);
this.label7.TabIndex = 2; this.label7.Name = "label7";
this.label7.Text = "More"; this.label7.Size = new System.Drawing.Size(31, 13);
// this.label7.TabIndex = 2;
// label6 this.label7.Text = "More";
// //
this.label6.AutoSize = true; // label6
this.label6.Location = new System.Drawing.Point(7, 32); //
this.label6.Name = "label6"; this.label6.AutoSize = true;
this.label6.Size = new System.Drawing.Size(29, 13); this.label6.Location = new System.Drawing.Point(7, 32);
this.label6.TabIndex = 1; this.label6.Name = "label6";
this.label6.Text = "Less"; this.label6.Size = new System.Drawing.Size(29, 13);
// this.label6.TabIndex = 1;
// RefreshRate this.label6.Text = "Less";
// //
this.RefreshRate.LargeChange = 2; // RefreshRate
this.RefreshRate.Location = new System.Drawing.Point(9, 47); //
this.RefreshRate.Maximum = 16; this.RefreshRate.LargeChange = 2;
this.RefreshRate.Minimum = 1; this.RefreshRate.Location = new System.Drawing.Point(9, 47);
this.RefreshRate.Name = "RefreshRate"; this.RefreshRate.Maximum = 16;
this.RefreshRate.Orientation = System.Windows.Forms.Orientation.Vertical; this.RefreshRate.Minimum = 1;
this.RefreshRate.Size = new System.Drawing.Size(45, 136); this.RefreshRate.Name = "RefreshRate";
this.RefreshRate.TabIndex = 0; this.RefreshRate.Orientation = System.Windows.Forms.Orientation.Vertical;
this.RefreshRate.TickFrequency = 4; this.RefreshRate.Size = new System.Drawing.Size(45, 136);
this.RefreshRate.Value = 16; this.RefreshRate.TabIndex = 0;
// this.RefreshRate.TickFrequency = 4;
// groupBox4 this.RefreshRate.Value = 16;
// //
this.groupBox4.Controls.Add(this.PaletteLabel); // groupBox4
this.groupBox4.Controls.Add(this.label5); //
this.groupBox4.Controls.Add(this.PPUAddressLabel); this.groupBox4.Controls.Add(this.PaletteLabel);
this.groupBox4.Controls.Add(this.XYLabel); this.groupBox4.Controls.Add(this.label5);
this.groupBox4.Controls.Add(this.TileIDLabel); this.groupBox4.Controls.Add(this.PPUAddressLabel);
this.groupBox4.Controls.Add(this.label2); this.groupBox4.Controls.Add(this.XYLabel);
this.groupBox4.Controls.Add(this.label1); this.groupBox4.Controls.Add(this.TileIDLabel);
this.groupBox4.Location = new System.Drawing.Point(554, 28); this.groupBox4.Controls.Add(this.label2);
this.groupBox4.Name = "groupBox4"; this.groupBox4.Controls.Add(this.label1);
this.groupBox4.Size = new System.Drawing.Size(108, 87); this.groupBox4.Location = new System.Drawing.Point(554, 28);
this.groupBox4.TabIndex = 16; this.groupBox4.Name = "groupBox4";
this.groupBox4.TabStop = false; this.groupBox4.Size = new System.Drawing.Size(108, 87);
this.groupBox4.Text = "Properties"; this.groupBox4.TabIndex = 16;
// this.groupBox4.TabStop = false;
// PaletteLabel this.groupBox4.Text = "Properties";
// //
this.PaletteLabel.AutoSize = true; // PaletteLabel
this.PaletteLabel.Location = new System.Drawing.Point(64, 60); //
this.PaletteLabel.Name = "PaletteLabel"; this.PaletteLabel.AutoSize = true;
this.PaletteLabel.Size = new System.Drawing.Size(22, 13); this.PaletteLabel.Location = new System.Drawing.Point(64, 60);
this.PaletteLabel.TabIndex = 9; this.PaletteLabel.Name = "PaletteLabel";
this.PaletteLabel.Text = " "; this.PaletteLabel.Size = new System.Drawing.Size(22, 13);
// this.PaletteLabel.TabIndex = 9;
// label5 this.PaletteLabel.Text = " ";
// //
this.label5.AutoSize = true; // label5
this.label5.Location = new System.Drawing.Point(6, 60); //
this.label5.Name = "label5"; this.label5.AutoSize = true;
this.label5.Size = new System.Drawing.Size(43, 13); this.label5.Location = new System.Drawing.Point(6, 60);
this.label5.TabIndex = 8; this.label5.Name = "label5";
this.label5.Text = "Palette:"; this.label5.Size = new System.Drawing.Size(43, 13);
// this.label5.TabIndex = 8;
// PPUAddressLabel this.label5.Text = "Palette:";
// //
this.PPUAddressLabel.AutoSize = true; // PPUAddressLabel
this.PPUAddressLabel.Location = new System.Drawing.Point(64, 60); //
this.PPUAddressLabel.Name = "PPUAddressLabel"; this.PPUAddressLabel.AutoSize = true;
this.PPUAddressLabel.Size = new System.Drawing.Size(22, 13); this.PPUAddressLabel.Location = new System.Drawing.Point(64, 60);
this.PPUAddressLabel.TabIndex = 5; this.PPUAddressLabel.Name = "PPUAddressLabel";
this.PPUAddressLabel.Text = " "; this.PPUAddressLabel.Size = new System.Drawing.Size(22, 13);
// this.PPUAddressLabel.TabIndex = 5;
// XYLabel this.PPUAddressLabel.Text = " ";
// //
this.XYLabel.AutoSize = true; // XYLabel
this.XYLabel.Location = new System.Drawing.Point(64, 43); //
this.XYLabel.Name = "XYLabel"; this.XYLabel.AutoSize = true;
this.XYLabel.Size = new System.Drawing.Size(22, 13); this.XYLabel.Location = new System.Drawing.Point(64, 43);
this.XYLabel.TabIndex = 4; this.XYLabel.Name = "XYLabel";
this.XYLabel.Text = " "; this.XYLabel.Size = new System.Drawing.Size(22, 13);
// this.XYLabel.TabIndex = 4;
// TileIDLabel this.XYLabel.Text = " ";
// //
this.TileIDLabel.AutoSize = true; // TileIDLabel
this.TileIDLabel.Location = new System.Drawing.Point(64, 26); //
this.TileIDLabel.Name = "TileIDLabel"; this.TileIDLabel.AutoSize = true;
this.TileIDLabel.Size = new System.Drawing.Size(22, 13); this.TileIDLabel.Location = new System.Drawing.Point(64, 26);
this.TileIDLabel.TabIndex = 3; this.TileIDLabel.Name = "TileIDLabel";
this.TileIDLabel.Text = " "; this.TileIDLabel.Size = new System.Drawing.Size(22, 13);
// this.TileIDLabel.TabIndex = 3;
// label2 this.TileIDLabel.Text = " ";
// //
this.label2.AutoSize = true; // label2
this.label2.Location = new System.Drawing.Point(6, 43); //
this.label2.Name = "label2"; this.label2.AutoSize = true;
this.label2.Size = new System.Drawing.Size(35, 13); this.label2.Location = new System.Drawing.Point(6, 43);
this.label2.TabIndex = 1; this.label2.Name = "label2";
this.label2.Text = "X / Y:"; this.label2.Size = new System.Drawing.Size(35, 13);
// this.label2.TabIndex = 1;
// label1 this.label2.Text = "X / Y:";
// //
this.label1.AutoSize = true; // label1
this.label1.Location = new System.Drawing.Point(6, 26); //
this.label1.Name = "label1"; this.label1.AutoSize = true;
this.label1.Size = new System.Drawing.Size(41, 13); this.label1.Location = new System.Drawing.Point(6, 26);
this.label1.TabIndex = 0; this.label1.Name = "label1";
this.label1.Text = "Tile ID:"; this.label1.Size = new System.Drawing.Size(41, 13);
// this.label1.TabIndex = 0;
// PCEBGViewer this.label1.Text = "Tile ID:";
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); // AlwaysOnTopMenuItem
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; //
this.ClientSize = new System.Drawing.Size(676, 575); this.AlwaysOnTopMenuItem.Name = "AlwaysOnTopMenuItem";
this.Controls.Add(this.groupBox4); this.AlwaysOnTopMenuItem.Size = new System.Drawing.Size(191, 22);
this.Controls.Add(this.groupBox5); this.AlwaysOnTopMenuItem.Text = "Always On Top";
this.Controls.Add(this.groupBox1); this.AlwaysOnTopMenuItem.Click += new System.EventHandler(this.AlwaysOnTopMenuItem_Click);
this.Controls.Add(this.menuStrip1); //
this.MainMenuStrip = this.menuStrip1; // FloatingWindowMenuItem
this.Name = "PCEBGViewer"; //
this.ShowIcon = false; this.FloatingWindowMenuItem.Name = "FloatingWindowMenuItem";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.FloatingWindowMenuItem.Size = new System.Drawing.Size(191, 22);
this.Text = "Background Viewer"; this.FloatingWindowMenuItem.Text = "Floating Window";
this.Load += new System.EventHandler(this.PCEBGViewer_Load); this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click);
this.menuStrip1.ResumeLayout(false); //
this.menuStrip1.PerformLayout(); // PceBgViewer
this.groupBox1.ResumeLayout(false); //
this.groupBox5.ResumeLayout(false); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.groupBox5.PerformLayout(); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
((System.ComponentModel.ISupportInitialize)(this.RefreshRate)).EndInit(); this.ClientSize = new System.Drawing.Size(676, 575);
this.groupBox4.ResumeLayout(false); this.Controls.Add(this.groupBox4);
this.groupBox4.PerformLayout(); this.Controls.Add(this.groupBox5);
this.ResumeLayout(false); this.Controls.Add(this.groupBox1);
this.PerformLayout(); 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 #endregion
private PCEBGCanvas canvas; private PCEBGCanvas canvas;
private MenuStripEx menuStrip1; private MenuStripEx PceBgViewerMenu;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem ViewerSubMenu;
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem OptionsSubMenu;
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem AutoloadMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem SaveWindowPositionMenuItem;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
private System.Windows.Forms.ToolStripMenuItem vDC1ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem VDC1MenuItem;
private System.Windows.Forms.ToolStripMenuItem vCD2ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem VDC2MenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox5; private System.Windows.Forms.GroupBox groupBox5;
@ -326,5 +344,7 @@
private System.Windows.Forms.Label TileIDLabel; private System.Windows.Forms.Label TileIDLabel;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1; 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;
using System.Drawing; using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.PCEngine; using BizHawk.Emulation.Cores.PCEngine;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class PCEBGViewer : Form, IToolForm public partial class PceBgViewer : Form, IToolForm
{ {
private PCEngine _pce; 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 AskSave() { return true; }
public bool UpdateBefore { get { return true; } } public bool UpdateBefore { get { return true; } }
public PCEBGViewer()
{
InitializeComponent();
Activated += (o, e) => Generate();
Closing += (o, e) => SaveConfigSettings();
}
public unsafe void Generate() 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; var width = 8 * vdc.BatWidth;
int height = 8 * vdc.BatHeight; var height = 8 * vdc.BatHeight;
BitmapData buf = canvas.Bat.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, canvas.Bat.PixelFormat); var buf = canvas.Bat.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, canvas.Bat.PixelFormat);
int pitch = buf.Stride / 4; var pitch = buf.Stride / 4;
int* begin = (int*)buf.Scan0.ToPointer(); var 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();
int* p = begin; int* p = begin;
for (int y = 0; y < height; ++y) for (int y = 0; y < height; ++y)
@ -54,12 +85,15 @@ namespace BizHawk.Client.EmuHawk
byte c = vdc.PatternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs]; byte c = vdc.PatternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs];
if (c == 0) if (c == 0)
{
*p = _pce.VCE.Palette[0]; *p = _pce.VCE.Palette[0];
}
else else
{ {
*p = _pce.VCE.Palette[paletteBase + c]; *p = _pce.VCE.Palette[paletteBase + c];
} }
} }
p += pitch - width; 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; VDC2MenuItem.Enabled = _pce.SystemId == "SGX";
Global.Config.PCEBGViewerWndy = Location.Y;
Global.Config.PCEBGViewerRefreshRate = RefreshRate.Value; 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) _vdcType = 0;
Location = new Point(Global.Config.PCEBGViewerWndx, Global.Config.PCEBGViewerWndy);
} }
private void PCEBGViewer_Load(object sender, EventArgs e) private void VDC2MenuItem_Click(object sender, EventArgs e)
{ {
_pce = Global.Emulator as PCEngine; _vdcType = 1;
LoadConfigSettings();
if (Global.Config.PCEBGViewerRefreshRate >= RefreshRate.Minimum && Global.Config.PCEBGViewerRefreshRate <= RefreshRate.Maximum)
{
RefreshRate.Value = Global.Config.PCEBGViewerRefreshRate;
}
else
{
RefreshRate.Value = RefreshRate.Maximum;
}
} }
private void exitToolStripMenuItem_Click(object sender, EventArgs e) private void ExitMenuItem_Click(object sender, EventArgs e)
{ {
Close(); 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; 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; Global.Config.PceBgViewerSettings.SaveWindowPosition ^= true;
autoloadToolStripMenuItem.Checked = Global.Config.PCEBGViewerAutoload;
} }
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) #endregion
{
if (_pce.SystemId == "SGX")
vCD2ToolStripMenuItem.Enabled = true;
else
vCD2ToolStripMenuItem.Enabled = false;
switch (VDCtype) #region Dialog and Controls
{
default:
case 0:
vDC1ToolStripMenuItem.Checked = true;
vCD2ToolStripMenuItem.Checked = false;
break;
case 1:
vDC1ToolStripMenuItem.Checked = false;
vCD2ToolStripMenuItem.Checked = true;
break;
}
}
private void canvas_MouseMove(object sender, MouseEventArgs e) 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 xTile = e.X / 8;
int yTile = e.Y / 8; int yTile = e.Y / 8;
int tileNo = vdc.VRAM[(ushort)(((yTile * vdc.BatWidth) + xTile))] & 0x07FF; int tileNo = vdc.VRAM[(ushort)((yTile * vdc.BatWidth) + xTile)] & 0x07FF;
int paletteNo = vdc.VRAM[(ushort)(((yTile * vdc.BatWidth) + xTile))] >> 12; int paletteNo = vdc.VRAM[(ushort)((yTile * vdc.BatWidth) + xTile)] >> 12;
TileIDLabel.Text = tileNo.ToString(); TileIDLabel.Text = tileNo.ToString();
XYLabel.Text = xTile.ToString() + ":" + yTile.ToString(); XYLabel.Text = xTile + ":" + yTile;
PaletteLabel.Text = paletteNo.ToString(); 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"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </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> <value>17, 17</value>
</metadata> </metadata>
</root> </root>

View File

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