From a7f03d4c2cbd534e9e3738c85bc1f9420c938134 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 5 May 2016 09:01:01 -0500 Subject: [PATCH] make direct3d9 prereq check non-fatal and make d3d display method initialization fail non-fatal, falling back to gdi+ --- .../CustomControls/PrereqsAlert.cs | 4 ++- .../CustomControls/PrereqsAlert.resx | 2 +- BizHawk.Client.EmuHawk/Program.cs | 34 ++++++++++++++----- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/BizHawk.Client.EmuHawk/CustomControls/PrereqsAlert.cs b/BizHawk.Client.EmuHawk/CustomControls/PrereqsAlert.cs index 581ea98df5..14be3c735f 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/PrereqsAlert.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/PrereqsAlert.cs @@ -11,9 +11,11 @@ namespace BizHawk.Client.EmuHawk.CustomControls { public partial class PrereqsAlert : Form { - public PrereqsAlert() + public PrereqsAlert(bool warn_only) { InitializeComponent(); + if (warn_only) + button1.Text = "Continue"; } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) diff --git a/BizHawk.Client.EmuHawk/CustomControls/PrereqsAlert.resx b/BizHawk.Client.EmuHawk/CustomControls/PrereqsAlert.resx index 61d62150b1..6eeb0fa9ed 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/PrereqsAlert.resx +++ b/BizHawk.Client.EmuHawk/CustomControls/PrereqsAlert.resx @@ -121,6 +121,6 @@ We're not checking the version number of the VC 2010 runtime. Be sure you have the SP1 version installed. DirectX Web Update is reportedly failing for some people as part of our prereqs installer. Try installing it manually. The VC 2015 prerequisite has prerequisites of its own, so install it yourself manually at your own peril. - +You can proceed without Direct3d9 fully installed, but we're going to continue warning you, so you'll come help us figure out what's going wrong. \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/Program.cs b/BizHawk.Client.EmuHawk/Program.cs index 57a24012d3..f4124ae243 100644 --- a/BizHawk.Client.EmuHawk/Program.cs +++ b/BizHawk.Client.EmuHawk/Program.cs @@ -17,6 +17,10 @@ namespace BizHawk.Client.EmuHawk { static Program() { + //this needs to be done before the warnings/errors show up + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + //http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips #if WINDOWS //try loading libraries we know we'll need @@ -26,12 +30,12 @@ namespace BizHawk.Client.EmuHawk var vc2015 = Win32.LoadLibrary("vcruntime140.dll"); var vc2010 = Win32.LoadLibrary("msvcr100.dll"); //TODO - check version? var vc2010p = Win32.LoadLibrary("msvcp100.dll"); - bool fail = false; - fail |= d3dx9 == IntPtr.Zero; + bool fail = false, warn = false; + warn |= d3dx9 == IntPtr.Zero; fail |= vc2015 == IntPtr.Zero; fail |= vc2010 == IntPtr.Zero; fail |= vc2010p == IntPtr.Zero; - if (fail) + if (fail || warn) { var sw = new System.IO.StringWriter(); sw.WriteLine("[ OK ] .Net 4.0 (You couldn't even get here without it)"); @@ -39,10 +43,12 @@ namespace BizHawk.Client.EmuHawk sw.WriteLine("[{0}] Visual C++ 2010 SP1 Runtime", (vc2010 == IntPtr.Zero || vc2010p == IntPtr.Zero) ? "FAIL" : " OK "); sw.WriteLine("[{0}] Visual C++ 2015 Runtime", (vc2015 == IntPtr.Zero) ? "FAIL" : " OK "); var str = sw.ToString(); - var box = new BizHawk.Client.EmuHawk.CustomControls.PrereqsAlert(); + var box = new BizHawk.Client.EmuHawk.CustomControls.PrereqsAlert(!fail); box.textBox1.Text = str; box.ShowDialog(); - System.Diagnostics.Process.GetCurrentProcess().Kill(); + if (!fail) { } + else + System.Diagnostics.Process.GetCurrentProcess().Kill(); } Win32.FreeLibrary(d3dx9); @@ -102,8 +108,7 @@ namespace BizHawk.Client.EmuHawk } BizHawk.Common.TempFileCleaner.Start(); - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); + HawkFile.ArchiveHandlerFactory = new SevenZipSharpArchiveHandler(); @@ -136,7 +141,20 @@ namespace BizHawk.Client.EmuHawk if (Global.Config.DispMethod == Config.EDispMethod.GdiPlus) GlobalWin.GL = new Bizware.BizwareGL.Drivers.GdiPlus.IGL_GdiPlus(); else if (Global.Config.DispMethod == Config.EDispMethod.SlimDX9) - GlobalWin.GL = new Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9(); + { + try + { + GlobalWin.GL = new Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9(); + } + catch(Exception ex) + { + var e2 = new Exception("Initialization of Direct3d 9 Display Method failed; falling back to GDI+", ex); + new ExceptionBox(e2).ShowDialog(); + //fallback + Global.Config.DispMethod = Config.EDispMethod.GdiPlus; + goto REDO_DISPMETHOD; + } + } else { GlobalWin.GL = GlobalWin.IGL_GL;