Cleanup disabling of DirectX options when it isn't installed
This commit is contained in:
parent
c112f0b036
commit
2ec0c7d733
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
using BizHawk.Common;
|
||||||
|
|
||||||
|
namespace BizHawk.Client.Common
|
||||||
|
{
|
||||||
|
public static class HostCapabilityDetector
|
||||||
|
{
|
||||||
|
private static bool? _hasDirectX = null;
|
||||||
|
|
||||||
|
public static bool HasDirectX => _hasDirectX ??= DetectDirectX();
|
||||||
|
|
||||||
|
private static bool DetectDirectX()
|
||||||
|
{
|
||||||
|
if (OSTailoredCode.IsUnixHost) return false;
|
||||||
|
var p = OSTailoredCode.LinkedLibManager.LoadOrZero("d3dx9_43.dll");
|
||||||
|
if (p == IntPtr.Zero) return false;
|
||||||
|
OSTailoredCode.LinkedLibManager.FreeByPtr(p);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -211,16 +211,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public int DispPrescale { get; set; } = 1;
|
public int DispPrescale { get; set; } = 1;
|
||||||
|
|
||||||
private static bool DetectDirectX()
|
public EDispMethod DispMethod { get; set; } = HostCapabilityDetector.HasDirectX ? EDispMethod.SlimDX9 : EDispMethod.OpenGL;
|
||||||
{
|
|
||||||
if (OSTailoredCode.IsUnixHost) return false;
|
|
||||||
var p = OSTailoredCode.LinkedLibManager.LoadOrZero("d3dx9_43.dll");
|
|
||||||
if (p == IntPtr.Zero) return false;
|
|
||||||
OSTailoredCode.LinkedLibManager.FreeByPtr(p);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EDispMethod DispMethod { get; set; } = DetectDirectX() ? EDispMethod.SlimDX9 : EDispMethod.OpenGL;
|
|
||||||
|
|
||||||
public int DispChromeFrameWindowed { get; set; } = 2;
|
public int DispChromeFrameWindowed { get; set; } = 2;
|
||||||
public bool DispChromeStatusBarWindowed { get; set; } = true;
|
public bool DispChromeStatusBarWindowed { get; set; } = true;
|
||||||
|
@ -248,7 +239,7 @@ namespace BizHawk.Client.Common
|
||||||
public int DispCropBottom { get; set; } = 0;
|
public int DispCropBottom { get; set; } = 0;
|
||||||
|
|
||||||
// Sound options
|
// Sound options
|
||||||
public ESoundOutputMethod SoundOutputMethod { get; set; } = DetectDirectX() ? ESoundOutputMethod.DirectSound : ESoundOutputMethod.OpenAL;
|
public ESoundOutputMethod SoundOutputMethod { get; set; } = HostCapabilityDetector.HasDirectX ? ESoundOutputMethod.DirectSound : ESoundOutputMethod.OpenAL;
|
||||||
public bool SoundEnabled { get; set; } = true;
|
public bool SoundEnabled { get; set; } = true;
|
||||||
public bool SoundEnabledNormal { get; set; } = true;
|
public bool SoundEnabledNormal { get; set; } = true;
|
||||||
public bool SoundEnabledRWFF { get; set; } = true;
|
public bool SoundEnabledRWFF { get; set; } = true;
|
||||||
|
@ -345,7 +336,7 @@ namespace BizHawk.Client.Common
|
||||||
// ReSharper disable once UnusedMember.Global
|
// ReSharper disable once UnusedMember.Global
|
||||||
public string LastWrittenFromDetailed { get; set; } = VersionInfo.GetEmuVersion();
|
public string LastWrittenFromDetailed { get; set; } = VersionInfo.GetEmuVersion();
|
||||||
|
|
||||||
public EHostInputMethod HostInputMethod { get; set; } = OSTailoredCode.IsUnixHost ? EHostInputMethod.OpenTK : EHostInputMethod.DirectInput;
|
public EHostInputMethod HostInputMethod { get; set; } = HostCapabilityDetector.HasDirectX ? EHostInputMethod.DirectInput : EHostInputMethod.OpenTK;
|
||||||
|
|
||||||
public bool UseStaticWindowTitles { get; set; }
|
public bool UseStaticWindowTitles { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,9 +94,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
RefreshAspectRatioOptions();
|
RefreshAspectRatioOptions();
|
||||||
|
|
||||||
if (OSTailoredCode.IsUnixHost)
|
if (!HostCapabilityDetector.HasDirectX)
|
||||||
{
|
{
|
||||||
// Disable SlimDX on Unix
|
|
||||||
rbD3D9.Enabled = false;
|
rbD3D9.Enabled = false;
|
||||||
rbD3D9.AutoCheck = false;
|
rbD3D9.AutoCheck = false;
|
||||||
cbAlternateVsync.Enabled = false;
|
cbAlternateVsync.Enabled = false;
|
||||||
|
|
|
@ -61,6 +61,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void GuiOptions_Load(object sender, EventArgs e)
|
private void GuiOptions_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
rbInputMethodDirectInput.Enabled = HostCapabilityDetector.HasDirectX;
|
||||||
|
|
||||||
StartFullScreenCheckbox.Checked = _config.StartFullscreen;
|
StartFullScreenCheckbox.Checked = _config.StartFullscreen;
|
||||||
StartPausedCheckbox.Checked = _config.StartPaused;
|
StartPausedCheckbox.Checked = _config.StartPaused;
|
||||||
PauseWhenMenuActivatedCheckbox.Checked = _config.PauseWhenMenuActivated;
|
PauseWhenMenuActivatedCheckbox.Checked = _config.PauseWhenMenuActivated;
|
||||||
|
|
|
@ -36,12 +36,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
cbEnableRWFF.Checked = _config.SoundEnabledRWFF;
|
cbEnableRWFF.Checked = _config.SoundEnabledRWFF;
|
||||||
cbMuteFrameAdvance.Checked = _config.MuteFrameAdvance;
|
cbMuteFrameAdvance.Checked = _config.MuteFrameAdvance;
|
||||||
|
|
||||||
if (OSTailoredCode.IsUnixHost)
|
rbOutputMethodDirectSound.Enabled = rbOutputMethodXAudio2.Enabled = HostCapabilityDetector.HasDirectX;
|
||||||
{
|
|
||||||
// Disable DirectSound and XAudio2 on Mono
|
|
||||||
rbOutputMethodDirectSound.Enabled = false;
|
|
||||||
rbOutputMethodXAudio2.Enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
rbOutputMethodDirectSound.Checked = _config.SoundOutputMethod == ESoundOutputMethod.DirectSound;
|
rbOutputMethodDirectSound.Checked = _config.SoundOutputMethod == ESoundOutputMethod.DirectSound;
|
||||||
rbOutputMethodXAudio2.Checked = _config.SoundOutputMethod == ESoundOutputMethod.XAudio2;
|
rbOutputMethodXAudio2.Checked = _config.SoundOutputMethod == ESoundOutputMethod.XAudio2;
|
||||||
|
|
Loading…
Reference in New Issue