gb gpu view: implement selectable sprite back color and continual mouseover update when the emulator is running. still some quirks and stuff to finish
This commit is contained in:
parent
e07919476c
commit
188e3b8770
|
@ -11,15 +11,22 @@ namespace BizHawk.MultiClient.GBtools
|
|||
{
|
||||
public partial class BmpView : Control
|
||||
{
|
||||
[Browsable(false)]
|
||||
public Bitmap bmp { get; private set; }
|
||||
[Browsable(true)]
|
||||
bool scaled;
|
||||
|
||||
/// <summary>
|
||||
/// if true, the backcolor will be drawn. otherwise, nothing (so HOM with transparent images)
|
||||
/// </summary>
|
||||
public bool DrawBackdrop { get; set; }
|
||||
|
||||
public BmpView()
|
||||
{
|
||||
if (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")
|
||||
{
|
||||
// in the designer
|
||||
this.BackColor = Color.Black;
|
||||
//this.BackColor = Color.Black;
|
||||
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
}
|
||||
else
|
||||
|
@ -43,6 +50,10 @@ namespace BizHawk.MultiClient.GBtools
|
|||
|
||||
void BmpView_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
if (DrawBackdrop)
|
||||
{
|
||||
e.Graphics.Clear(BackColor);
|
||||
}
|
||||
if (scaled)
|
||||
{
|
||||
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
|
@ -83,8 +94,8 @@ namespace BizHawk.MultiClient.GBtools
|
|||
}
|
||||
|
||||
// kill unused props
|
||||
[Browsable(false)]
|
||||
public override Color BackColor { get { return base.BackColor; } set { base.BackColor = Color.Black; } }
|
||||
//[Browsable(false)]
|
||||
//public override Color BackColor { get { return base.BackColor; } set { base.BackColor = Color.Blue; } }
|
||||
//[Browsable(false)]
|
||||
//public override string Text { get { return base.Text; } set { base.Text = value; } }
|
||||
}
|
||||
|
|
|
@ -52,6 +52,9 @@
|
|||
this.labelMemory = new System.Windows.Forms.Label();
|
||||
this.groupBox6 = new System.Windows.Forms.GroupBox();
|
||||
this.labelClipboard = new System.Windows.Forms.Label();
|
||||
this.groupBox7 = new System.Windows.Forms.GroupBox();
|
||||
this.checkBoxSavePos = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxAutoLoad = new System.Windows.Forms.CheckBox();
|
||||
this.bmpViewMemory = new BizHawk.MultiClient.GBtools.BmpView();
|
||||
this.bmpViewDetails = new BizHawk.MultiClient.GBtools.BmpView();
|
||||
this.bmpViewOAM = new BizHawk.MultiClient.GBtools.BmpView();
|
||||
|
@ -61,9 +64,10 @@
|
|||
this.bmpViewTiles2 = new BizHawk.MultiClient.GBtools.BmpView();
|
||||
this.bmpViewBG = new BizHawk.MultiClient.GBtools.BmpView();
|
||||
this.bmpViewWin = new BizHawk.MultiClient.GBtools.BmpView();
|
||||
this.groupBox7 = new System.Windows.Forms.GroupBox();
|
||||
this.checkBoxAutoLoad = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxSavePos = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox8 = new System.Windows.Forms.GroupBox();
|
||||
this.panelSpriteBackColor = new System.Windows.Forms.Panel();
|
||||
this.buttonChangeColor = new System.Windows.Forms.Button();
|
||||
this.labelSpriteBackColor = new System.Windows.Forms.Label();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
|
@ -73,6 +77,7 @@
|
|||
this.groupBoxMemory.SuspendLayout();
|
||||
this.groupBox6.SuspendLayout();
|
||||
this.groupBox7.SuspendLayout();
|
||||
this.groupBox8.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
|
@ -329,9 +334,43 @@
|
|||
this.labelClipboard.TabIndex = 0;
|
||||
this.labelClipboard.Text = "CTRL+C copies the pane under the mouse.";
|
||||
//
|
||||
// groupBox7
|
||||
//
|
||||
this.groupBox7.Controls.Add(this.checkBoxSavePos);
|
||||
this.groupBox7.Controls.Add(this.checkBoxAutoLoad);
|
||||
this.groupBox7.Location = new System.Drawing.Point(350, 312);
|
||||
this.groupBox7.Name = "groupBox7";
|
||||
this.groupBox7.Size = new System.Drawing.Size(192, 41);
|
||||
this.groupBox7.TabIndex = 24;
|
||||
this.groupBox7.TabStop = false;
|
||||
this.groupBox7.Text = "Config";
|
||||
//
|
||||
// checkBoxSavePos
|
||||
//
|
||||
this.checkBoxSavePos.AutoSize = true;
|
||||
this.checkBoxSavePos.Location = new System.Drawing.Point(87, 19);
|
||||
this.checkBoxSavePos.Name = "checkBoxSavePos";
|
||||
this.checkBoxSavePos.Size = new System.Drawing.Size(90, 17);
|
||||
this.checkBoxSavePos.TabIndex = 1;
|
||||
this.checkBoxSavePos.Text = "Save position";
|
||||
this.checkBoxSavePos.UseVisualStyleBackColor = true;
|
||||
this.checkBoxSavePos.CheckedChanged += new System.EventHandler(this.checkBoxSavePos_CheckedChanged);
|
||||
//
|
||||
// checkBoxAutoLoad
|
||||
//
|
||||
this.checkBoxAutoLoad.AutoSize = true;
|
||||
this.checkBoxAutoLoad.Location = new System.Drawing.Point(6, 19);
|
||||
this.checkBoxAutoLoad.Name = "checkBoxAutoLoad";
|
||||
this.checkBoxAutoLoad.Size = new System.Drawing.Size(75, 17);
|
||||
this.checkBoxAutoLoad.TabIndex = 0;
|
||||
this.checkBoxAutoLoad.Text = "Auto-Load";
|
||||
this.checkBoxAutoLoad.UseVisualStyleBackColor = true;
|
||||
this.checkBoxAutoLoad.CheckedChanged += new System.EventHandler(this.checkBoxAutoLoad_CheckedChanged);
|
||||
//
|
||||
// bmpViewMemory
|
||||
//
|
||||
this.bmpViewMemory.BackColor = System.Drawing.Color.Black;
|
||||
this.bmpViewMemory.DrawBackdrop = true;
|
||||
this.bmpViewMemory.Location = new System.Drawing.Point(6, 19);
|
||||
this.bmpViewMemory.Name = "bmpViewMemory";
|
||||
this.bmpViewMemory.Size = new System.Drawing.Size(64, 128);
|
||||
|
@ -341,6 +380,7 @@
|
|||
// bmpViewDetails
|
||||
//
|
||||
this.bmpViewDetails.BackColor = System.Drawing.Color.Black;
|
||||
this.bmpViewDetails.DrawBackdrop = true;
|
||||
this.bmpViewDetails.Location = new System.Drawing.Point(6, 19);
|
||||
this.bmpViewDetails.Name = "bmpViewDetails";
|
||||
this.bmpViewDetails.Size = new System.Drawing.Size(64, 128);
|
||||
|
@ -351,6 +391,7 @@
|
|||
// bmpViewOAM
|
||||
//
|
||||
this.bmpViewOAM.BackColor = System.Drawing.Color.Black;
|
||||
this.bmpViewOAM.DrawBackdrop = true;
|
||||
this.bmpViewOAM.Location = new System.Drawing.Point(6, 19);
|
||||
this.bmpViewOAM.Name = "bmpViewOAM";
|
||||
this.bmpViewOAM.Size = new System.Drawing.Size(320, 16);
|
||||
|
@ -364,6 +405,7 @@
|
|||
// bmpViewBGPal
|
||||
//
|
||||
this.bmpViewBGPal.BackColor = System.Drawing.Color.Black;
|
||||
this.bmpViewBGPal.DrawBackdrop = true;
|
||||
this.bmpViewBGPal.Location = new System.Drawing.Point(6, 32);
|
||||
this.bmpViewBGPal.Name = "bmpViewBGPal";
|
||||
this.bmpViewBGPal.Size = new System.Drawing.Size(128, 64);
|
||||
|
@ -377,6 +419,7 @@
|
|||
// bmpViewSPPal
|
||||
//
|
||||
this.bmpViewSPPal.BackColor = System.Drawing.Color.Black;
|
||||
this.bmpViewSPPal.DrawBackdrop = true;
|
||||
this.bmpViewSPPal.Location = new System.Drawing.Point(140, 32);
|
||||
this.bmpViewSPPal.Name = "bmpViewSPPal";
|
||||
this.bmpViewSPPal.Size = new System.Drawing.Size(128, 64);
|
||||
|
@ -390,6 +433,7 @@
|
|||
// bmpViewTiles1
|
||||
//
|
||||
this.bmpViewTiles1.BackColor = System.Drawing.Color.Black;
|
||||
this.bmpViewTiles1.DrawBackdrop = false;
|
||||
this.bmpViewTiles1.Location = new System.Drawing.Point(6, 32);
|
||||
this.bmpViewTiles1.Name = "bmpViewTiles1";
|
||||
this.bmpViewTiles1.Size = new System.Drawing.Size(128, 192);
|
||||
|
@ -403,6 +447,7 @@
|
|||
// bmpViewTiles2
|
||||
//
|
||||
this.bmpViewTiles2.BackColor = System.Drawing.Color.Black;
|
||||
this.bmpViewTiles2.DrawBackdrop = false;
|
||||
this.bmpViewTiles2.Location = new System.Drawing.Point(140, 32);
|
||||
this.bmpViewTiles2.Name = "bmpViewTiles2";
|
||||
this.bmpViewTiles2.Size = new System.Drawing.Size(128, 192);
|
||||
|
@ -416,6 +461,7 @@
|
|||
// bmpViewBG
|
||||
//
|
||||
this.bmpViewBG.BackColor = System.Drawing.Color.Black;
|
||||
this.bmpViewBG.DrawBackdrop = false;
|
||||
this.bmpViewBG.Location = new System.Drawing.Point(6, 32);
|
||||
this.bmpViewBG.Name = "bmpViewBG";
|
||||
this.bmpViewBG.Size = new System.Drawing.Size(256, 256);
|
||||
|
@ -429,6 +475,7 @@
|
|||
// bmpViewWin
|
||||
//
|
||||
this.bmpViewWin.BackColor = System.Drawing.Color.Black;
|
||||
this.bmpViewWin.DrawBackdrop = false;
|
||||
this.bmpViewWin.Location = new System.Drawing.Point(268, 32);
|
||||
this.bmpViewWin.Name = "bmpViewWin";
|
||||
this.bmpViewWin.Size = new System.Drawing.Size(256, 256);
|
||||
|
@ -439,44 +486,51 @@
|
|||
this.bmpViewWin.MouseLeave += new System.EventHandler(this.bmpViewWin_MouseLeave);
|
||||
this.bmpViewWin.MouseMove += new System.Windows.Forms.MouseEventHandler(this.bmpViewWin_MouseMove);
|
||||
//
|
||||
// groupBox7
|
||||
// groupBox8
|
||||
//
|
||||
this.groupBox7.Controls.Add(this.checkBoxSavePos);
|
||||
this.groupBox7.Controls.Add(this.checkBoxAutoLoad);
|
||||
this.groupBox7.Location = new System.Drawing.Point(350, 312);
|
||||
this.groupBox7.Name = "groupBox7";
|
||||
this.groupBox7.Size = new System.Drawing.Size(192, 41);
|
||||
this.groupBox7.TabIndex = 24;
|
||||
this.groupBox7.TabStop = false;
|
||||
this.groupBox7.Text = "Config";
|
||||
this.groupBox8.Controls.Add(this.labelSpriteBackColor);
|
||||
this.groupBox8.Controls.Add(this.buttonChangeColor);
|
||||
this.groupBox8.Controls.Add(this.panelSpriteBackColor);
|
||||
this.groupBox8.Location = new System.Drawing.Point(548, 518);
|
||||
this.groupBox8.Name = "groupBox8";
|
||||
this.groupBox8.Size = new System.Drawing.Size(274, 48);
|
||||
this.groupBox8.TabIndex = 25;
|
||||
this.groupBox8.TabStop = false;
|
||||
this.groupBox8.Text = "Sprite Backdrop";
|
||||
//
|
||||
// checkBoxAutoLoad
|
||||
// panelSpriteBackColor
|
||||
//
|
||||
this.checkBoxAutoLoad.AutoSize = true;
|
||||
this.checkBoxAutoLoad.Location = new System.Drawing.Point(6, 19);
|
||||
this.checkBoxAutoLoad.Name = "checkBoxAutoLoad";
|
||||
this.checkBoxAutoLoad.Size = new System.Drawing.Size(75, 17);
|
||||
this.checkBoxAutoLoad.TabIndex = 0;
|
||||
this.checkBoxAutoLoad.Text = "Auto-Load";
|
||||
this.checkBoxAutoLoad.UseVisualStyleBackColor = true;
|
||||
this.checkBoxAutoLoad.CheckedChanged += new System.EventHandler(this.checkBoxAutoLoad_CheckedChanged);
|
||||
this.panelSpriteBackColor.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.panelSpriteBackColor.Location = new System.Drawing.Point(6, 19);
|
||||
this.panelSpriteBackColor.Name = "panelSpriteBackColor";
|
||||
this.panelSpriteBackColor.Size = new System.Drawing.Size(55, 23);
|
||||
this.panelSpriteBackColor.TabIndex = 0;
|
||||
//
|
||||
// checkBoxSavePos
|
||||
// buttonChangeColor
|
||||
//
|
||||
this.checkBoxSavePos.AutoSize = true;
|
||||
this.checkBoxSavePos.Location = new System.Drawing.Point(87, 19);
|
||||
this.checkBoxSavePos.Name = "checkBoxSavePos";
|
||||
this.checkBoxSavePos.Size = new System.Drawing.Size(90, 17);
|
||||
this.checkBoxSavePos.TabIndex = 1;
|
||||
this.checkBoxSavePos.Text = "Save position";
|
||||
this.checkBoxSavePos.UseVisualStyleBackColor = true;
|
||||
this.checkBoxSavePos.CheckedChanged += new System.EventHandler(this.checkBoxSavePos_CheckedChanged);
|
||||
this.buttonChangeColor.Location = new System.Drawing.Point(164, 19);
|
||||
this.buttonChangeColor.Name = "buttonChangeColor";
|
||||
this.buttonChangeColor.Size = new System.Drawing.Size(104, 23);
|
||||
this.buttonChangeColor.TabIndex = 1;
|
||||
this.buttonChangeColor.Text = "Change Color...";
|
||||
this.buttonChangeColor.UseVisualStyleBackColor = true;
|
||||
this.buttonChangeColor.Click += new System.EventHandler(this.buttonChangeColor_Click);
|
||||
//
|
||||
// labelSpriteBackColor
|
||||
//
|
||||
this.labelSpriteBackColor.AutoSize = true;
|
||||
this.labelSpriteBackColor.Location = new System.Drawing.Point(67, 24);
|
||||
this.labelSpriteBackColor.Name = "labelSpriteBackColor";
|
||||
this.labelSpriteBackColor.Size = new System.Drawing.Size(35, 13);
|
||||
this.labelSpriteBackColor.TabIndex = 2;
|
||||
this.labelSpriteBackColor.Text = "label8";
|
||||
//
|
||||
// GBGPUView
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(834, 524);
|
||||
this.ClientSize = new System.Drawing.Size(834, 590);
|
||||
this.Controls.Add(this.groupBox8);
|
||||
this.Controls.Add(this.groupBox7);
|
||||
this.Controls.Add(this.groupBox6);
|
||||
this.Controls.Add(this.groupBoxMemory);
|
||||
|
@ -510,6 +564,8 @@
|
|||
this.groupBox6.PerformLayout();
|
||||
this.groupBox7.ResumeLayout(false);
|
||||
this.groupBox7.PerformLayout();
|
||||
this.groupBox8.ResumeLayout(false);
|
||||
this.groupBox8.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
@ -552,5 +608,9 @@
|
|||
private System.Windows.Forms.GroupBox groupBox7;
|
||||
private System.Windows.Forms.CheckBox checkBoxSavePos;
|
||||
private System.Windows.Forms.CheckBox checkBoxAutoLoad;
|
||||
private System.Windows.Forms.GroupBox groupBox8;
|
||||
private System.Windows.Forms.Panel panelSpriteBackColor;
|
||||
private System.Windows.Forms.Button buttonChangeColor;
|
||||
private System.Windows.Forms.Label labelSpriteBackColor;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ using System.Drawing;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace BizHawk.MultiClient.GBtools
|
||||
{
|
||||
|
@ -28,6 +29,29 @@ namespace BizHawk.MultiClient.GBtools
|
|||
|
||||
IntPtr tilespal; // current palette to use on tiles
|
||||
|
||||
Color _spriteback;
|
||||
Color spriteback
|
||||
{
|
||||
get { return _spriteback; }
|
||||
set
|
||||
{
|
||||
_spriteback = value;
|
||||
SetSpriteBack(_spriteback, this);
|
||||
panelSpriteBackColor.BackColor = _spriteback;
|
||||
labelSpriteBackColor.Text = string.Format("({0},{1},{2})", _spriteback.R, _spriteback.G, _spriteback.B);
|
||||
}
|
||||
}
|
||||
static void SetSpriteBack(Color color, Control control)
|
||||
{
|
||||
foreach (Control c in control.Controls)
|
||||
{
|
||||
if (c is BmpView && (c as BmpView).DrawBackdrop)
|
||||
c.BackColor = color;
|
||||
if (c.Controls.Count > 0)
|
||||
SetSpriteBack(color, c);
|
||||
}
|
||||
}
|
||||
|
||||
public GBGPUView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -52,6 +76,9 @@ namespace BizHawk.MultiClient.GBtools
|
|||
|
||||
checkBoxAutoLoad.Checked = Global.Config.AutoLoadGBGPUView;
|
||||
checkBoxSavePos.Checked = Global.Config.GBGPUViewSaveWindowPosition;
|
||||
|
||||
// TODO: from config
|
||||
spriteback = Color.Black;
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
|
@ -349,6 +376,10 @@ namespace BizHawk.MultiClient.GBtools
|
|||
p = (int*)sppal;
|
||||
for (int i = 0; i < 32; i++)
|
||||
p[i] |= unchecked((int)0xff000000);
|
||||
// transparent all sprite color 0s
|
||||
int c = spriteback.B | spriteback.G << 8 | spriteback.R << 16;
|
||||
for (int i = 0; i < 32; i += 4)
|
||||
p[i] = c;
|
||||
}
|
||||
|
||||
// bg maps
|
||||
|
@ -439,6 +470,11 @@ namespace BizHawk.MultiClient.GBtools
|
|||
}
|
||||
DrawOam(bmpViewOAM.bmp, oam, vram, sppal, lcdc.Bit(2), cgb);
|
||||
bmpViewOAM.Refresh();
|
||||
|
||||
// try to run the current mouseover, to refresh if the mouse is being held over a pane while the emulator runs
|
||||
// this doesn't really work well; the update rate seems to be throttled
|
||||
MouseEventArgs e = new MouseEventArgs(System.Windows.Forms.MouseButtons.None, 0, System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y, 0);
|
||||
this.OnMouseMove(e);
|
||||
}
|
||||
|
||||
private void GBGPUView_FormClosed(object sender, FormClosedEventArgs e)
|
||||
|
@ -878,7 +914,8 @@ namespace BizHawk.MultiClient.GBtools
|
|||
|
||||
if (found != null && found is BmpView)
|
||||
{
|
||||
Clipboard.SetImage((found as BmpView).bmp);
|
||||
var bv = found as BmpView;
|
||||
Clipboard.SetImage(bv.bmp);
|
||||
labelClipboard.Text = found.Text + " copied to clipboard.";
|
||||
messagetimer.Stop();
|
||||
messagetimer.Start();
|
||||
|
@ -911,5 +948,25 @@ namespace BizHawk.MultiClient.GBtools
|
|||
{
|
||||
Global.Config.GBGPUViewSaveWindowPosition = (sender as CheckBox).Checked;
|
||||
}
|
||||
|
||||
private void buttonChangeColor_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var dlg = new ColorDialog())
|
||||
{
|
||||
dlg.AllowFullOpen = true;
|
||||
dlg.AnyColor = true;
|
||||
dlg.FullOpen = true;
|
||||
dlg.Color = spriteback;
|
||||
|
||||
Global.Sound.StopSound();
|
||||
var result = dlg.ShowDialog();
|
||||
Global.Sound.StartSound();
|
||||
if (result == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
// force full opaque
|
||||
spriteback = Color.FromArgb(255, dlg.Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue