From 2f375388b550c57d06aacfd4aa2a8eabbdc78618 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 4 Dec 2016 09:20:22 -0600 Subject: [PATCH] Tastudio - refactor screenshot code to use a required dependency on VideoProvider instead of using Global.Emulator, also put it on the load event instead of the constructor --- .../tools/TAStudio/TAStudio.IToolForm.cs | 3 ++ .../tools/TAStudio/TAStudio.cs | 38 +++++++++---------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs index 9b848f5069..b476bccf5e 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs @@ -14,6 +14,9 @@ namespace BizHawk.Client.EmuHawk [RequiredService] public IStatable StatableEmulator { get; private set; } + [RequiredService] + public IVideoProvider VideoProvider { get; private set; } + [OptionalService] public ISaveRam SaveRamEmulator { get; private set; } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 1df219aa89..0ce48168e1 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -129,26 +129,6 @@ namespace BizHawk.Client.EmuHawk Settings = new TAStudioSettings(); InitializeComponent(); - if (Global.Emulator != null) - { - // Set the screenshot to "1x" resolution of the core - // cores like n64 and psx are going to still have sizes too big for the control, so cap them - int width = Global.Emulator.VideoProvider().BufferWidth; - int height = Global.Emulator.VideoProvider().BufferHeight; - if (width > 320) - { - double ratio = 320.0 / (double)width; - width = 320; - height = (int)((double)(height) * ratio); - } - ScreenshotControl.DrawingHeight = height; - ScreenshotControl.Size = new Size(width, ScreenshotControl.DrawingHeight + ScreenshotControl.UserPadding); - } - - ScreenshotControl.Visible = false; - Controls.Add(ScreenshotControl); - ScreenshotControl.BringToFront(); - // TODO: show this at all times or hide it when saving is done? this.SavingProgressBar.Visible = false; @@ -291,6 +271,24 @@ namespace BizHawk.Client.EmuHawk return; } + // Set the screenshot to "1x" resolution of the core + // cores like n64 and psx are going to still have sizes too big for the control, so cap them + int width = VideoProvider.BufferWidth; + int height = VideoProvider.BufferHeight; + if (width > 320) + { + double ratio = 320.0 / (double)width; + width = 320; + height = (int)((double)(height) * ratio); + } + ScreenshotControl.DrawingHeight = height; + ScreenshotControl.Size = new Size(width, ScreenshotControl.DrawingHeight + ScreenshotControl.UserPadding); + + + ScreenshotControl.Visible = false; + Controls.Add(ScreenshotControl); + ScreenshotControl.BringToFront(); + SetColumnsFromCurrentStickies(); if (VersionInfo.DeveloperBuild)