win32: add dx9 error dialog with download link

This commit is contained in:
OV2 2018-08-14 21:28:58 +02:00
parent a117e9505c
commit 67effe4b42
3 changed files with 89 additions and 9 deletions

View File

@ -196,6 +196,7 @@
#include "wsnes9x.h"
#include <process.h>
#include "dxerr.h"
#include "commctrl.h"
/* CXAudio2
Implements audio output through XAudio2.
@ -224,6 +225,64 @@ CXAudio2::~CXAudio2(void)
DeInitXAudio2();
}
INT_PTR CALLBACK DlgXAudio2InitError(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
{
// display warning icon and set text of sys control (too long for resource)
HICON aIcn = LoadIcon(NULL, IDI_WARNING);
SendDlgItemMessage(hDlg, IDC_STATIC_ICON, STM_SETICON, (WPARAM)aIcn, 0);
SetDlgItemText(hDlg, IDC_SYSLINK_DX, TEXT("Unable to initialize XAudio2.\
You will not be able to hear any sound effects or music while playing.\n\n\
This is usually caused by not having a recent DirectX9 runtime installed.\n\
You can download the most recent DirectX9 runtime here:\n\n\
<a href=\"https://www.microsoft.com/en-us/download/details.aspx?id=35\">https://www.microsoft.com/en-us/download/details.aspx?id=35</a>"));
// center dialog on parent
HWND parent = GetParent(hDlg);
RECT rcParent, rcSelf;
GetWindowRect(parent, &rcParent);
GetWindowRect(hDlg, &rcSelf);
SetWindowPos(hDlg,
HWND_TOP,
rcParent.left + ((rcParent.right - rcParent.left) - (rcSelf.right - rcSelf.left)) / 2,
rcParent.top + ((rcParent.bottom - rcParent.top) - (rcSelf.bottom - rcSelf.top)) / 2,
0, 0,
SWP_NOSIZE);
}
return true;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
if (HIWORD(wParam) == BN_CLICKED) {
EndDialog(hDlg, IDOK);
return TRUE;
}
}
break;
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code)
{
case NM_CLICK: // Fall through to the next case.
case NM_RETURN:
{
PNMLINK pNMLink = (PNMLINK)lParam;
LITEM item = pNMLink->item;
// open link with registered application
ShellExecute(NULL, L"open", item.szUrl, NULL, NULL, SW_SHOW);
break;
}
}
}
return FALSE;
}
/* CXAudio2::InitXAudio2
initializes the XAudio2 object
-----
@ -237,12 +296,7 @@ bool CXAudio2::InitXAudio2(void)
HRESULT hr;
if ( FAILED(hr = XAudio2Create( &pXAudio2, 0 , XAUDIO2_DEFAULT_PROCESSOR ) ) ) {
DXTRACE_ERR_MSGBOX(TEXT("Unable to create XAudio2 object."),hr);
MessageBox (GUI.hWnd, TEXT("\
Unable to initialize XAudio2. You will not be able to hear any\n\
sound effects or music while playing.\n\n\
This is usually caused by not having a recent DirectX release installed."),
TEXT("Snes9X - Unable to Initialize XAudio2"),
MB_OK | MB_ICONWARNING);
DialogBox(GUI.hInstance, MAKEINTRESOURCE(IDD_DIALOG_XAUDIO2_INIT_ERROR), GUI.hWnd, DlgXAudio2InitError);
return false;
}
initDone = true;

View File

@ -40,6 +40,7 @@
#define IDB_HIDDENFOLDER 149
#define IDD_MULTICART 150
#define IDD_DIALOG_SHADER_PARAMS 155
#define IDD_DIALOG_XAUDIO2_INIT_ERROR 159
#define IDC_DRIVER 1001
#define IDC_BUFLEN 1002
#define IDC_RATE 1003
@ -387,7 +388,9 @@
#define IDC_STATIC_INTERLEAVE_MODE 3024
#define IDC_STATIC_VIDEO_SYSTEM 3025
#define IDC_STATIC_HEADER 3026
#define IDC_ROM_SPLITTER 3027
#define IDC_ROM_SPLITTER 3027
#define IDC_SYSLINK_DX 3028
#define IDC_STATIC_ICON 3029
#define ID_FILE_EXIT 40001
#define ID_WINDOW_HIDEMENUBAR 40004
#define ID_FILE_AVI_RECORDING 40005
@ -535,9 +538,9 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 159
#define _APS_NEXT_RESOURCE_VALUE 161
#define _APS_NEXT_COMMAND_VALUE 40178
#define _APS_NEXT_CONTROL_VALUE 3028
#define _APS_NEXT_CONTROL_VALUE 3030
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -552,6 +552,16 @@ BEGIN
LTEXT "Changing these parameters will create a new ""custom_shader_params.glslp"" file in the snes9x directory that contains the parameters and references to your currently loaded shader. This will then be used as your current OpenGL shader.",IDC_STATIC,7,7,295,28
END
IDD_DIALOG_XAUDIO2_INIT_ERROR DIALOGEX 0, 0, 277, 92
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Snes9x - Unable to Initialize XAudio2"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,220,71,50,14
CONTROL "Dummy",IDC_SYSLINK_DX,"SysLink",WS_TABSTOP,33,7,236,62
ICON "",IDC_STATIC_ICON,7,7,21,20,SS_CENTERIMAGE | SS_REALSIZEIMAGE | WS_GROUP
END
/////////////////////////////////////////////////////////////////////////////
//
@ -694,6 +704,14 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 198
END
IDD_DIALOG_XAUDIO2_INIT_ERROR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 270
TOPMARGIN, 7
BOTTOMMARGIN, 85
END
END
#endif // APSTUDIO_INVOKED
@ -733,6 +751,11 @@ BEGIN
0
END
IDD_DIALOG_XAUDIO2_INIT_ERROR AFX_DIALOG_LAYOUT
BEGIN
0
END
/////////////////////////////////////////////////////////////////////////////
//