From 471a2f5cf07c24c9b0d01c6f11506c78e3d62bbd Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 13 Apr 2014 20:13:22 +0000 Subject: [PATCH] SMS - Vdp Viewer - save screenshot to file menu items --- BizHawk.Client.EmuHawk/config/GB/BmpView.cs | 50 +++++++++++++++++++ BizHawk.Client.EmuHawk/tools/PCE/PCECDL.cs | 12 +++++ .../tools/SMS/VDPViewer.Designer.cs | 44 ++++++++++++++-- BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs | 15 ++++++ 4 files changed, 118 insertions(+), 3 deletions(-) diff --git a/BizHawk.Client.EmuHawk/config/GB/BmpView.cs b/BizHawk.Client.EmuHawk/config/GB/BmpView.cs index cc4bad48c4..1099329aaf 100644 --- a/BizHawk.Client.EmuHawk/config/GB/BmpView.cs +++ b/BizHawk.Client.EmuHawk/config/GB/BmpView.cs @@ -2,11 +2,15 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +using System.Drawing.Imaging; +using System.IO; using System.Linq; using System.Text; using System.Drawing; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.Client.EmuHawk { public partial class BmpView : Control @@ -83,5 +87,51 @@ namespace BizHawk.Client.EmuHawk Refresh(); } + public void SaveFile() + { + string path = PathManager.MakeAbsolutePath( + Global.Config.PathEntries[Global.Emulator.SystemId, "Screenshots"].Path, + Global.Emulator.SystemId); + + DirectoryInfo di = new DirectoryInfo(path); + + if (!di.Exists) + { + di.Create(); + } + + var sfd = new SaveFileDialog + { + FileName = PathManager.FilesystemSafeName(Global.Game) + "-Palettes", + InitialDirectory = path, + Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*", + RestoreDirectory = true + }; + + var result = sfd.ShowHawkDialog(); + if (result != DialogResult.OK) + { + return; + } + + var file = new FileInfo(sfd.FileName); + var b = this.bmp; + + 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); + } } } diff --git a/BizHawk.Client.EmuHawk/tools/PCE/PCECDL.cs b/BizHawk.Client.EmuHawk/tools/PCE/PCECDL.cs index e1586609d9..fbffa4fbc4 100644 --- a/BizHawk.Client.EmuHawk/tools/PCE/PCECDL.cs +++ b/BizHawk.Client.EmuHawk/tools/PCE/PCECDL.cs @@ -30,6 +30,17 @@ namespace BizHawk.Client.EmuHawk Restart(); } + private void RefreshFloatingWindowControl() + { + Owner = Global.Config.SmsVdpSettings.FloatingWindow ? null : GlobalWin.MainForm; + } + + protected override void OnShown(EventArgs e) + { + RefreshFloatingWindowControl(); + base.OnShown(e); + } + public void UpdateValues() { UpdateDisplay(); @@ -322,6 +333,7 @@ namespace BizHawk.Client.EmuHawk private void FloatingWindowMenuItem_Click(object sender, EventArgs e) { Global.Config.PceCdlSettings.FloatingWindow ^= true; + RefreshFloatingWindowControl(); } private void RestoreDefaultSettingsMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.Designer.cs b/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.Designer.cs index 5dd807c836..7fc262a3ca 100644 --- a/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.Designer.cs @@ -38,12 +38,16 @@ this.label1 = new System.Windows.Forms.Label(); this.menuStrip1 = new MenuStripEx(); this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.saveTilesScreenshotToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.CloseMenuItem = 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.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.savePalettesScrenshotToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveBGScreenshotToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -129,16 +133,32 @@ // FileSubMenu // this.FileSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.saveTilesScreenshotToolStripMenuItem, + this.savePalettesScrenshotToolStripMenuItem, + this.saveBGScreenshotToolStripMenuItem, + this.toolStripSeparator1, this.CloseMenuItem}); this.FileSubMenu.Name = "FileSubMenu"; this.FileSubMenu.Size = new System.Drawing.Size(37, 20); this.FileSubMenu.Text = "&File"; // + // saveTilesScreenshotToolStripMenuItem + // + this.saveTilesScreenshotToolStripMenuItem.Name = "saveTilesScreenshotToolStripMenuItem"; + this.saveTilesScreenshotToolStripMenuItem.Size = new System.Drawing.Size(206, 22); + this.saveTilesScreenshotToolStripMenuItem.Text = "Save Tiles Screenshot..."; + this.saveTilesScreenshotToolStripMenuItem.Click += new System.EventHandler(this.saveTilesScreenshotToolStripMenuItem_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(203, 6); + // // CloseMenuItem // this.CloseMenuItem.Name = "CloseMenuItem"; this.CloseMenuItem.ShortcutKeyDisplayString = "Alt+F4"; - this.CloseMenuItem.Size = new System.Drawing.Size(145, 22); + this.CloseMenuItem.Size = new System.Drawing.Size(206, 22); this.CloseMenuItem.Text = "&Close"; this.CloseMenuItem.Click += new System.EventHandler(this.CloseMenuItem_Click); // @@ -182,7 +202,21 @@ this.FloatingWindowMenuItem.Text = "Floating Window"; this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click); // - // VDPViewer + // savePalettesScrenshotToolStripMenuItem + // + this.savePalettesScrenshotToolStripMenuItem.Name = "savePalettesScrenshotToolStripMenuItem"; + this.savePalettesScrenshotToolStripMenuItem.Size = new System.Drawing.Size(206, 22); + this.savePalettesScrenshotToolStripMenuItem.Text = "Save Palettes Screnshot..."; + this.savePalettesScrenshotToolStripMenuItem.Click += new System.EventHandler(this.savePalettesScrenshotToolStripMenuItem_Click); + // + // saveBGScreenshotToolStripMenuItem + // + this.saveBGScreenshotToolStripMenuItem.Name = "saveBGScreenshotToolStripMenuItem"; + this.saveBGScreenshotToolStripMenuItem.Size = new System.Drawing.Size(206, 22); + this.saveBGScreenshotToolStripMenuItem.Text = "Save BG Screenshot..."; + this.saveBGScreenshotToolStripMenuItem.Click += new System.EventHandler(this.saveBGScreenshotToolStripMenuItem_Click); + // + // SmsVDPViewer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -196,7 +230,7 @@ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.KeyPreview = true; this.MainMenuStrip = this.menuStrip1; - this.Name = "VDPViewer"; + this.Name = "SmsVDPViewer"; this.Text = "VDP Viewer"; this.Load += new System.EventHandler(this.VDPViewer_Load); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VDPViewer_KeyDown); @@ -227,5 +261,9 @@ private System.Windows.Forms.ToolStripMenuItem SaveWindowPositionMenuItem; private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem; private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveTilesScreenshotToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem savePalettesScrenshotToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveBGScreenshotToolStripMenuItem; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs b/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs index 3e76a69d9d..ae91c9e770 100644 --- a/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs @@ -260,5 +260,20 @@ namespace BizHawk.Client.EmuHawk { Global.Config.SmsVdpAutoLoad ^= true; } + + private void saveTilesScreenshotToolStripMenuItem_Click(object sender, EventArgs e) + { + bmpViewTiles.SaveFile(); + } + + private void savePalettesScrenshotToolStripMenuItem_Click(object sender, EventArgs e) + { + bmpViewPalette.SaveFile(); + } + + private void saveBGScreenshotToolStripMenuItem_Click(object sender, EventArgs e) + { + bmpViewBG.SaveFile(); + } } }