2011-03-13 19:11:43 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Globalization;
|
2011-09-15 00:49:25 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Drawing.Imaging;
|
2011-03-13 19:11:43 +00:00
|
|
|
|
|
|
|
|
|
namespace BizHawk.MultiClient
|
|
|
|
|
{
|
2011-06-10 08:10:16 +00:00
|
|
|
|
public class NameTableViewer : Control
|
|
|
|
|
{
|
|
|
|
|
Size pSize;
|
|
|
|
|
public Bitmap nametables;
|
2011-03-13 19:23:34 +00:00
|
|
|
|
|
2011-06-10 08:10:16 +00:00
|
|
|
|
public NameTableViewer()
|
|
|
|
|
{
|
|
|
|
|
pSize = new Size(512, 480);
|
|
|
|
|
nametables = new Bitmap(pSize.Width, pSize.Height);
|
|
|
|
|
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
|
|
|
|
SetStyle(ControlStyles.UserPaint, true);
|
|
|
|
|
SetStyle(ControlStyles.DoubleBuffer, true);
|
2011-08-29 01:09:16 +00:00
|
|
|
|
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
2012-08-12 02:13:06 +00:00
|
|
|
|
SetStyle(ControlStyles.Opaque, true);
|
2011-06-10 08:10:16 +00:00
|
|
|
|
this.Size = new Size(256, 224);
|
2011-08-29 01:09:16 +00:00
|
|
|
|
this.BackColor = Color.Transparent;
|
2011-06-10 08:10:16 +00:00
|
|
|
|
this.Paint += new System.Windows.Forms.PaintEventHandler(this.NameTableViewer_Paint);
|
|
|
|
|
}
|
2011-03-13 19:11:43 +00:00
|
|
|
|
|
2011-06-10 08:10:16 +00:00
|
|
|
|
public enum WhichNametable
|
|
|
|
|
{
|
2011-08-27 21:07:09 +00:00
|
|
|
|
NT_2000, NT_2400, NT_2800, NT_2C00, NT_ALL, TOPS, BOTTOMS
|
2011-06-10 08:10:16 +00:00
|
|
|
|
}
|
2011-03-13 19:11:43 +00:00
|
|
|
|
|
2011-06-10 08:10:16 +00:00
|
|
|
|
public WhichNametable Which = WhichNametable.NT_ALL;
|
|
|
|
|
|
|
|
|
|
private void Display(Graphics g)
|
|
|
|
|
{
|
|
|
|
|
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
|
|
|
|
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
|
|
|
|
|
switch (Which)
|
|
|
|
|
{
|
|
|
|
|
case WhichNametable.NT_ALL:
|
|
|
|
|
g.DrawImageUnscaled(nametables, 1, 1);
|
|
|
|
|
break;
|
|
|
|
|
case WhichNametable.NT_2000:
|
|
|
|
|
g.DrawImage(nametables, new Rectangle(0, 0, 512, 480), 0, 0, 256, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
|
|
|
|
case WhichNametable.NT_2400:
|
|
|
|
|
g.DrawImage(nametables, new Rectangle(0, 0, 512, 480), 256, 0, 256, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
|
|
|
|
case WhichNametable.NT_2800:
|
|
|
|
|
g.DrawImage(nametables, new Rectangle(0, 0, 512, 480), 0, 240, 256, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
|
|
|
|
case WhichNametable.NT_2C00:
|
|
|
|
|
g.DrawImage(nametables, new Rectangle(0, 0, 512, 480), 256, 240, 256, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
2011-08-27 21:07:09 +00:00
|
|
|
|
|
|
|
|
|
//adelikat: Meh, just in case we might want these, someone requested it but I can't remember the justification so I didn't do the UI part
|
|
|
|
|
case WhichNametable.TOPS:
|
|
|
|
|
g.DrawImage(nametables, new Rectangle(0, 0, 512, 240), 0, 0, 512, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
|
|
|
|
case WhichNametable.BOTTOMS:
|
|
|
|
|
g.DrawImage(nametables, new Rectangle(0, 240, 512, 240), 0, 240, 512, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
2011-06-10 08:10:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void NameTableViewer_Paint(object sender, PaintEventArgs e)
|
|
|
|
|
{
|
2011-08-29 01:09:16 +00:00
|
|
|
|
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
|
|
|
|
e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
|
|
|
|
|
switch (Which)
|
|
|
|
|
{
|
|
|
|
|
case WhichNametable.NT_ALL:
|
2012-03-25 08:52:52 +00:00
|
|
|
|
e.Graphics.DrawImageUnscaled(nametables, 0, 0);
|
2011-08-29 01:09:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case WhichNametable.NT_2000:
|
|
|
|
|
e.Graphics.DrawImage(nametables, new Rectangle(0, 0, 512, 480), 0, 0, 256, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
|
|
|
|
case WhichNametable.NT_2400:
|
|
|
|
|
e.Graphics.DrawImage(nametables, new Rectangle(0, 0, 512, 480), 256, 0, 256, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
|
|
|
|
case WhichNametable.NT_2800:
|
|
|
|
|
e.Graphics.DrawImage(nametables, new Rectangle(0, 0, 512, 480), 0, 240, 256, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
|
|
|
|
case WhichNametable.NT_2C00:
|
|
|
|
|
e.Graphics.DrawImage(nametables, new Rectangle(0, 0, 512, 480), 256, 240, 256, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//adelikat: Meh, just in case we might want these, someone requested it but I can't remember the justification so I didn't do the UI part
|
|
|
|
|
case WhichNametable.TOPS:
|
|
|
|
|
e.Graphics.DrawImage(nametables, new Rectangle(0, 0, 512, 240), 0, 0, 512, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
|
|
|
|
case WhichNametable.BOTTOMS:
|
|
|
|
|
e.Graphics.DrawImage(nametables, new Rectangle(0, 240, 512, 240), 0, 240, 512, 240, GraphicsUnit.Pixel);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-06-10 08:10:16 +00:00
|
|
|
|
}
|
2011-09-15 00:49:25 +00:00
|
|
|
|
|
|
|
|
|
public void Screenshot()
|
|
|
|
|
{
|
|
|
|
|
var sfd = new SaveFileDialog();
|
2012-03-25 08:52:52 +00:00
|
|
|
|
sfd.FileName = PathManager.FilesystemSafeName(Global.Game) + "-Nametables";
|
2011-09-15 00:49:25 +00:00
|
|
|
|
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathNESScreenshots, "NES");
|
|
|
|
|
sfd.Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*";
|
|
|
|
|
|
|
|
|
|
sfd.RestoreDirectory = true;
|
|
|
|
|
Global.Sound.StopSound();
|
|
|
|
|
var result = sfd.ShowDialog();
|
|
|
|
|
Global.Sound.StartSound();
|
|
|
|
|
if (result != DialogResult.OK)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var file = new FileInfo(sfd.FileName);
|
2012-03-25 08:52:52 +00:00
|
|
|
|
using (Bitmap b = new Bitmap(Width, Height))
|
2011-09-15 00:49:25 +00:00
|
|
|
|
{
|
2012-03-25 08:52:52 +00:00
|
|
|
|
Rectangle rect = new Rectangle(new Point(0, 0), Size);
|
|
|
|
|
DrawToBitmap(b, rect);
|
2011-09-15 00:49:25 +00:00
|
|
|
|
|
2012-03-25 08:52:52 +00:00
|
|
|
|
ImageFormat i;
|
|
|
|
|
string extension = file.Extension.ToUpper();
|
|
|
|
|
switch (extension)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case ".PNG":
|
|
|
|
|
i = ImageFormat.Png;
|
|
|
|
|
break;
|
|
|
|
|
case ".BMP":
|
|
|
|
|
i = ImageFormat.Bmp;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
b.Save(file.FullName, i);
|
|
|
|
|
}
|
2011-09-15 00:49:25 +00:00
|
|
|
|
}
|
2012-03-09 19:07:16 +00:00
|
|
|
|
|
|
|
|
|
public void ScreenshotToClipboard()
|
|
|
|
|
{
|
2012-03-25 08:52:52 +00:00
|
|
|
|
using(var b = new Bitmap(Width, Height))
|
2012-03-09 19:07:16 +00:00
|
|
|
|
{
|
2012-03-25 08:52:52 +00:00
|
|
|
|
Rectangle rect = new Rectangle(new Point(0, 0), Size);
|
|
|
|
|
DrawToBitmap(b, rect);
|
|
|
|
|
System.Windows.Forms.Clipboard.SetImage(b);
|
2012-03-09 19:07:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-10 08:10:16 +00:00
|
|
|
|
}
|
2011-03-13 19:11:43 +00:00
|
|
|
|
}
|