Consolidate core accuracy warning dialog.
This commit is contained in:
parent
1aadff8ca1
commit
1df41efc0d
|
@ -649,6 +649,7 @@
|
|||
<Compile Include="DisplayManager\RenderTargetFrugalizer.cs" />
|
||||
<Compile Include="DisplayManager\SwappableDisplaySurfaceSet.cs" />
|
||||
<Compile Include="DisplayManager\TextureFrugalizer.cs" />
|
||||
<Compile Include="EmuHawkUtil.cs" />
|
||||
<Compile Include="Extensions\ControlExtensions.cs" />
|
||||
<Compile Include="Extensions\CoreExtensions.cs" />
|
||||
<Compile Include="Extensions\ToolExtensions.cs" />
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Client.EmuHawk.CustomControls;
|
||||
using BizHawk.Emulation.Common;
|
||||
using Cores = BizHawk.Emulation.Cores;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public static class EmuHawkUtil
|
||||
{
|
||||
public static bool EnsureCoreIsAccurate(IEmulator emulator)
|
||||
{
|
||||
bool PromptToSwitchCore(string currentCore, string recommendedCore, Action disableCurrentCore)
|
||||
{
|
||||
var box = new MsgBox(
|
||||
$"While the {currentCore} core is faster, it is not nearly as accurate as {recommendedCore}.{Environment.NewLine}It is recommended that you switch to the {recommendedCore} core for movie recording. {Environment.NewLine}Switch to {recommendedCore}?",
|
||||
"Accuracy Warning",
|
||||
MessageBoxIcon.Warning);
|
||||
|
||||
box.SetButtons(
|
||||
new[] { "Switch", "Continue" },
|
||||
new[] { DialogResult.Yes, DialogResult.Cancel });
|
||||
|
||||
box.MaximumSize = UIHelper.Scale(new Size(575, 175));
|
||||
box.SetMessageToAutoSize();
|
||||
|
||||
var result = box.ShowDialog();
|
||||
box.Dispose();
|
||||
|
||||
if (result != DialogResult.Yes)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
disableCurrentCore();
|
||||
GlobalWin.MainForm.RebootCore();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (emulator is Cores.Nintendo.SNES9X.Snes9x)
|
||||
{
|
||||
return PromptToSwitchCore("Snes9x", "bsnes", () => Global.Config.SNES_InSnes9x = false);
|
||||
}
|
||||
if (emulator is Cores.Consoles.Nintendo.QuickNES.QuickNES)
|
||||
{
|
||||
return PromptToSwitchCore("QuickNes", "NesHawk", () => Global.Config.NES_InQuickNES = false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -478,55 +478,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (Emulator is Snes9x)
|
||||
|
||||
if (!EmuHawkUtil.EnsureCoreIsAccurate(Emulator))
|
||||
{
|
||||
var box = new MsgBox(
|
||||
"While the Snes9x core is faster, it is not nearly as accurate as bsnes. \nIt is recommended that you switch to the bsnes core for movie recording\nSwitch to bsnes?",
|
||||
"Accuracy Warning",
|
||||
MessageBoxIcon.Warning);
|
||||
|
||||
box.SetButtons(
|
||||
new[] { "Switch", "Continue" },
|
||||
new[] { DialogResult.Yes, DialogResult.Cancel });
|
||||
|
||||
box.MaximumSize = UIHelper.Scale(new Size(475, 350));
|
||||
box.SetMessageToAutoSize();
|
||||
var result = box.ShowDialog();
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Global.Config.SNES_InSnes9x = false;
|
||||
RebootCore();
|
||||
}
|
||||
else if (result == DialogResult.Cancel)
|
||||
{
|
||||
// Do nothing and allow the user to continue to record the movie
|
||||
}
|
||||
}
|
||||
else if (Emulator is QuickNES) // This is unsustainable :( But mixing the logic together is even worse, this needs to be rethought
|
||||
{
|
||||
var box = new MsgBox(
|
||||
"While the QuickNes core is faster, it is not nearly as accurate as NesHawk. \nIt is recommended that you switch to the NesHawk core for movie recording\nSwitch to NesHawk?",
|
||||
"Accuracy Warning",
|
||||
MessageBoxIcon.Warning);
|
||||
|
||||
box.SetButtons(
|
||||
new[] { "Switch", "Continue" },
|
||||
new[] { DialogResult.Yes, DialogResult.Cancel });
|
||||
|
||||
box.MaximumSize = UIHelper.Scale(new Size(475, 350));
|
||||
box.SetMessageToAutoSize();
|
||||
var result = box.ShowDialog();
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Global.Config.NES_InQuickNES = false;
|
||||
RebootCore();
|
||||
}
|
||||
else if (result == DialogResult.Cancel)
|
||||
{
|
||||
// Do nothing and allow the user to continue to record the movie
|
||||
}
|
||||
// Inaccurate core but allow the user to continue anyway
|
||||
}
|
||||
|
||||
new RecordMovie(Emulator).ShowDialog();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
@ -8,14 +7,12 @@ using System.ComponentModel;
|
|||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES9X;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Client.Common.MovieConversionExtensions;
|
||||
|
||||
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
||||
using BizHawk.Client.EmuHawk.ToolExtensions;
|
||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -320,56 +317,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
Mainform.PauseOnFrame = null;
|
||||
Mainform.PauseEmulator();
|
||||
|
||||
// Start Scenario 0: snes9x needs a nag (copied from RecordMovieMenuItem_Click())
|
||||
if (Emulator is Snes9x)
|
||||
// Start Scenario 0: core needs a nag
|
||||
if (!EmuHawkUtil.EnsureCoreIsAccurate(Emulator))
|
||||
{
|
||||
var box = new CustomControls.MsgBox(
|
||||
"While the Snes9x core is faster, it is not nearly as accurate as bsnes. \nIt is recommended that you switch to the bsnes core for movie recording\nSwitch to bsnes?",
|
||||
"Accuracy Warning",
|
||||
MessageBoxIcon.Warning);
|
||||
|
||||
box.SetButtons(
|
||||
new[] { "Switch", "Continue" },
|
||||
new[] { DialogResult.Yes, DialogResult.Cancel });
|
||||
|
||||
box.MaximumSize = UIHelper.Scale(new Size(475, 350));
|
||||
box.SetMessageToAutoSize();
|
||||
var result = box.ShowDialog();
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Global.Config.SNES_InSnes9x = false;
|
||||
Mainform.RebootCore();
|
||||
}
|
||||
else if (result == DialogResult.Cancel)
|
||||
{
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
else if (Emulator is QuickNES) // Copy pasta of unsustainable logic, even better
|
||||
{
|
||||
var box = new CustomControls.MsgBox(
|
||||
"While the QuickNes core is faster, it is not nearly as accurate as NesHawk. \nIt is recommended that you switch to the NesHawk core for movie recording\nSwitch to NesHawk?",
|
||||
"Accuracy Warning",
|
||||
MessageBoxIcon.Warning);
|
||||
|
||||
box.SetButtons(
|
||||
new[] { "Switch", "Continue" },
|
||||
new[] { DialogResult.Yes, DialogResult.Cancel });
|
||||
|
||||
box.MaximumSize = UIHelper.Scale(new Size(475, 350));
|
||||
box.SetMessageToAutoSize();
|
||||
var result = box.ShowDialog();
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Global.Config.NES_InQuickNES = false;
|
||||
Mainform.RebootCore();
|
||||
}
|
||||
else if (result == DialogResult.Cancel)
|
||||
{
|
||||
//return false;
|
||||
}
|
||||
// Inaccurate core but allow the user to continue anyway
|
||||
}
|
||||
|
||||
// Start Scenario 1: A regular movie is active
|
||||
|
|
Loading…
Reference in New Issue