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

This commit is contained in:
adelikat 2016-12-04 09:20:22 -06:00
parent 45a96920b3
commit 2f375388b5
2 changed files with 21 additions and 20 deletions

View File

@ -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; }

View File

@ -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)