implement IgnoredMessageWindows for ArchHooks::MessageBoxOK
This commit is contained in:
@@ -28,10 +28,12 @@ public:
|
||||
* and we can safely log and throw. */
|
||||
virtual void DumpDebugInfo() { }
|
||||
|
||||
/* Message box stuff. Not supported on all archs. */
|
||||
/* Message box stuff. Not supported on all archs. The ID can be used
|
||||
* to identify a class of messages, for "don't display this dialog"-type
|
||||
* prompts. */
|
||||
enum MessageBoxResult { abort, retry, ignore };
|
||||
virtual void MessageBoxOK( CString sMessage ) {}
|
||||
virtual MessageBoxResult MessageBoxAbortRetryIgnore( CString sMessage ) { return ignore; }
|
||||
virtual void MessageBoxOK( CString sMessage, CString ID = "" ) {}
|
||||
virtual MessageBoxResult MessageBoxAbortRetryIgnore( CString sMessage, CString ID = "" ) { return ignore; }
|
||||
|
||||
virtual ~ArchHooks() { }
|
||||
};
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#include "global.h"
|
||||
#include "ArchHooks_Win32.h"
|
||||
#include "RageUtil.h"
|
||||
#include "PrefsManager.h"
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "archutils/win32/AppInstance.h"
|
||||
#include "archutils/win32/tls.h"
|
||||
#include "archutils/win32/crash.h"
|
||||
#include "archutils/win32/DebugInfoHunt.h"
|
||||
@@ -34,12 +39,88 @@ void ArchHooks_Win32::DumpDebugInfo()
|
||||
SearchForDebugInfo();
|
||||
}
|
||||
|
||||
void ArchHooks_Win32::MessageBoxOK( CString sMessage )
|
||||
bool ArchHooks_Win32::MessageIsIgnored( CString ID )
|
||||
{
|
||||
MessageBox(NULL, sMessage, "StepMania", MB_OK );
|
||||
vector<CString> list;
|
||||
split( PREFSMAN->m_sIgnoredMessageWindows, ",", list );
|
||||
for( unsigned i = 0; i < list.size(); ++i )
|
||||
if( !ID.CompareNoCase(list[i]) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
ArchHooks::MessageBoxResult ArchHooks_Win32::MessageBoxAbortRetryIgnore( CString sMessage )
|
||||
void ArchHooks_Win32::IgnoreMessage( CString ID )
|
||||
{
|
||||
if( MessageIsIgnored(ID) )
|
||||
return;
|
||||
vector<CString> list;
|
||||
split( PREFSMAN->m_sIgnoredMessageWindows, ",", list );
|
||||
list.push_back( ID );
|
||||
PREFSMAN->m_sIgnoredMessageWindows = join( ",", list );
|
||||
PREFSMAN->SaveGlobalPrefsToDisk();
|
||||
}
|
||||
|
||||
static CString g_sMessage;
|
||||
static bool g_AllowHush;
|
||||
static bool g_Hush;
|
||||
static BOOL CALLBACK OKWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
switch( msg )
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
g_Hush = false;
|
||||
CString sMessage = g_sMessage;
|
||||
|
||||
sMessage.Replace( "\n", "\r\n" );
|
||||
HWND hush = GetDlgItem( hWnd, IDC_HUSH );
|
||||
int style = GetWindowLong(hush, GWL_STYLE);
|
||||
|
||||
if( g_AllowHush )
|
||||
style |= WS_VISIBLE;
|
||||
else
|
||||
style &= ~WS_VISIBLE;
|
||||
SetWindowLong( hush, GWL_STYLE, style );
|
||||
|
||||
SendDlgItemMessage(
|
||||
hWnd,
|
||||
IDC_MESSAGE,
|
||||
WM_SETTEXT,
|
||||
0,
|
||||
(LPARAM)(LPCTSTR)sMessage
|
||||
);
|
||||
}
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
g_Hush = !!IsDlgButtonChecked(hWnd, IDC_HUSH);
|
||||
/* fall through */
|
||||
case IDCANCEL:
|
||||
EndDialog( hWnd, 0 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ArchHooks_Win32::MessageBoxOK( CString sMessage, CString ID )
|
||||
{
|
||||
g_AllowHush = ID != "";
|
||||
if( g_AllowHush && MessageIsIgnored( ID ) )
|
||||
return;
|
||||
g_sMessage = sMessage;
|
||||
AppInstance handle;
|
||||
DialogBox(handle.Get(), MAKEINTRESOURCE(IDD_OK), NULL, OKWndProc);
|
||||
if( g_AllowHush && g_Hush )
|
||||
IgnoreMessage( ID );
|
||||
}
|
||||
|
||||
ArchHooks::MessageBoxResult ArchHooks_Win32::MessageBoxAbortRetryIgnore( CString sMessage, CString ID )
|
||||
{
|
||||
switch( MessageBox(NULL, sMessage, "StepMania", MB_ABORTRETRYIGNORE ) )
|
||||
{
|
||||
|
||||
@@ -4,13 +4,16 @@
|
||||
#include "ArchHooks.h"
|
||||
class ArchHooks_Win32: public ArchHooks
|
||||
{
|
||||
bool MessageIsIgnored( CString ID );
|
||||
void IgnoreMessage( CString ID );
|
||||
|
||||
public:
|
||||
ArchHooks_Win32();
|
||||
void Log(CString str, bool important);
|
||||
void DumpDebugInfo();
|
||||
void AdditionalLog(CString str);
|
||||
void MessageBoxOK( CString sMessage );
|
||||
MessageBoxResult MessageBoxAbortRetryIgnore( CString sMessage );
|
||||
void MessageBoxOK( CString sMessage, CString ID );
|
||||
MessageBoxResult MessageBoxAbortRetryIgnore( CString sMessage, CString ID );
|
||||
};
|
||||
|
||||
#undef ARCH_HOOKS
|
||||
|
||||
Reference in New Issue
Block a user