smsvn -> ssc-hg glue: rearrange directory structure

This commit is contained in:
Devin J. Pohly
2013-06-10 15:38:43 -04:00
parent 51576d5942
commit 80057f53cd
3362 changed files with 0 additions and 0 deletions
+192
View File
@@ -0,0 +1,192 @@
#include "global.h"
#include "Dialog.h"
#include "DialogDriver.h"
#if !defined(SMPACKAGE)
#include "PrefsManager.h"
#endif
#include "RageUtil.h"
#include "RageLog.h"
#include "RageThreads.h"
#if !defined(SMPACKAGE)
static Preference<RString> g_sIgnoredDialogs( "IgnoredDialogs", "" );
#endif
static DialogDriver *g_pImpl = NULL;
static DialogDriver_Null g_NullDriver;
static bool g_bWindowed = true; // Start out true so that we'll show errors before DISPLAY is init'd.
static bool DialogsEnabled()
{
return g_bWindowed;
}
void Dialog::Init()
{
if( g_pImpl != NULL )
return;
g_pImpl = DialogDriver::Create();
/* DialogDriver_Null should have worked, at least. */
ASSERT( g_pImpl != NULL );
}
void Dialog::Shutdown()
{
delete g_pImpl;
g_pImpl = NULL;
}
static bool MessageIsIgnored( RString sID )
{
#if !defined(SMPACKAGE)
vector<RString> asList;
split( g_sIgnoredDialogs, ",", asList );
for( unsigned i = 0; i < asList.size(); ++i )
if( !sID.CompareNoCase(asList[i]) )
return true;
#endif
return false;
}
void Dialog::IgnoreMessage( RString sID )
{
/* We can't ignore messages before PREFSMAN is around. */
#if !defined(SMPACKAGE)
if( PREFSMAN == NULL )
{
if( sID != "" && LOG )
LOG->Warn( "Dialog: message \"%s\" set ID too early for ignorable messages", sID.c_str() );
return;
}
if( sID == "" )
return;
if( MessageIsIgnored(sID) )
return;
vector<RString> asList;
split( g_sIgnoredDialogs, ",", asList );
asList.push_back( sID );
g_sIgnoredDialogs.Set( join(",",asList) );
PREFSMAN->SavePrefsToDisk();
#endif
}
void Dialog::Error( RString sMessage, RString sID )
{
Dialog::Init();
if( LOG )
LOG->Trace( "Dialog: \"%s\" [%s]", sMessage.c_str(), sID.c_str() );
if( sID != "" && MessageIsIgnored(sID) )
return;
RageThread::SetIsShowingDialog( true );
g_pImpl->Error( sMessage, sID );
RageThread::SetIsShowingDialog( false );
}
void Dialog::SetWindowed( bool bWindowed )
{
g_bWindowed = bWindowed;
}
void Dialog::OK( RString sMessage, RString sID )
{
Dialog::Init();
if( LOG )
LOG->Trace( "Dialog: \"%s\" [%s]", sMessage.c_str(), sID.c_str() );
if( sID != "" && MessageIsIgnored(sID) )
return;
RageThread::SetIsShowingDialog( true );
// only show Dialog if windowed
if( DialogsEnabled() )
g_pImpl->OK( sMessage, sID ); // call derived version
else
g_NullDriver.OK( sMessage, sID );
RageThread::SetIsShowingDialog( false );
}
Dialog::Result Dialog::AbortRetryIgnore( RString sMessage, RString sID )
{
Dialog::Init();
if( LOG )
LOG->Trace( "Dialog: \"%s\" [%s]", sMessage.c_str(), sID.c_str() );
if( sID != "" && MessageIsIgnored(sID) )
return g_NullDriver.AbortRetryIgnore( sMessage, sID );
RageThread::SetIsShowingDialog( true );
// only show Dialog if windowed
Dialog::Result ret;
if( DialogsEnabled() )
ret = g_pImpl->AbortRetryIgnore( sMessage, sID ); // call derived version
else
ret = g_NullDriver.AbortRetryIgnore( sMessage, sID );
RageThread::SetIsShowingDialog( false );
return ret;
}
Dialog::Result Dialog::AbortRetry( RString sMessage, RString sID )
{
Dialog::Init();
if( LOG )
LOG->Trace( "Dialog: \"%s\" [%s]", sMessage.c_str(), sID.c_str() );
if( sID != "" && MessageIsIgnored(sID) )
return g_NullDriver.AbortRetry( sMessage, sID );
RageThread::SetIsShowingDialog( true );
// only show Dialog if windowed
Dialog::Result ret;
if( DialogsEnabled() )
ret = g_pImpl->AbortRetry( sMessage, sID ); // call derived version
else
ret = g_NullDriver.AbortRetry( sMessage, sID );
RageThread::SetIsShowingDialog( false );
return ret;
}
/*
* (c) 2003-2004 Glenn Maynard, Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+48
View File
@@ -0,0 +1,48 @@
#ifndef DIALOG_BOX_H
#define DIALOG_BOX_H
namespace Dialog
{
/* ID can be used to identify a class of messages, for "don't display this
* dialog"-type prompts. */
void Init();
void Shutdown();
void SetWindowed( bool bWindowed );
enum Result { abort, retry, ignore };
void Error( RString sError, RString sID = "" );
void OK( RString sMessage, RString sID = "" );
Result AbortRetryIgnore( RString sMessage, RString sID = "" );
Result AbortRetry( RString sMessage, RString sID = "" );
/* for DialogDrivers */
void IgnoreMessage( RString sID );
}
#endif
/*
* (c) 2003-2004 Glenn Maynard, Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+70
View File
@@ -0,0 +1,70 @@
#include "global.h"
#include "DialogDriver.h"
#include "Foreach.h"
#include "RageLog.h"
map<istring, CreateDialogDriverFn> *RegisterDialogDriver::g_pRegistrees;
RegisterDialogDriver::RegisterDialogDriver( const istring &sName, CreateDialogDriverFn pfn )
{
if( g_pRegistrees == NULL )
g_pRegistrees = new map<istring, CreateDialogDriverFn>;
ASSERT( g_pRegistrees->find(sName) == g_pRegistrees->end() );
(*g_pRegistrees)[sName] = pfn;
}
REGISTER_DIALOG_DRIVER_CLASS( Null );
DialogDriver *DialogDriver::Create()
{
RString sDrivers = "win32,macosx,null";
vector<RString> asDriversToTry;
split( sDrivers, ",", asDriversToTry, true );
ASSERT( asDriversToTry.size() != 0 );
FOREACH_CONST( RString, asDriversToTry, Driver )
{
map<istring, CreateDialogDriverFn>::const_iterator iter = RegisterDialogDriver::g_pRegistrees->find( istring(*Driver) );
if( iter == RegisterDialogDriver::g_pRegistrees->end() )
continue;
DialogDriver *pRet = (iter->second)();
DEBUG_ASSERT( pRet );
const RString sError = pRet->Init();
if( sError.empty() )
return pRet;
if( LOG )
LOG->Info( "Couldn't load driver %s: %s", Driver->c_str(), sError.c_str() );
SAFE_DELETE( pRet );
}
return NULL;
}
/*
* (c) 2002-2006 Glenn Maynard, Steve Checkoway
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+57
View File
@@ -0,0 +1,57 @@
#ifndef DIALOG_BOX_DRIVER_H
#define DIALOG_BOX_DRIVER_H
#include "Dialog.h"
#include "RageUtil.h"
class DialogDriver
{
public:
static DialogDriver *Create();
virtual void Error( RString sMessage, RString sID ) { printf("Error: %s\n", sMessage.c_str()); }
virtual void OK( RString sMessage, RString sID ) {}
virtual Dialog::Result AbortRetryIgnore( RString sMessage, RString sID ) { return Dialog::ignore; }
virtual Dialog::Result AbortRetry( RString sMessage, RString sID ) { return Dialog::abort; }
virtual RString Init() { return RString(); }
virtual ~DialogDriver() { }
};
class DialogDriver_Null : public DialogDriver { };
typedef DialogDriver *(*CreateDialogDriverFn)();
struct RegisterDialogDriver
{
static map<istring, CreateDialogDriverFn> *g_pRegistrees;
RegisterDialogDriver( const istring &sName, CreateDialogDriverFn pfn );
};
#define REGISTER_DIALOG_DRIVER_CLASS( name ) \
static RegisterDialogDriver register_##name( #name, CreateClass<DialogDriver_##name, DialogDriver> )
#endif
/*
* (c) 2003-2004 Glenn Maynard, Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+127
View File
@@ -0,0 +1,127 @@
#include "global.h"
#include "RageUtil.h"
#include "DialogDriver_MacOSX.h"
#include "RageThreads.h"
#include "ProductInfo.h"
#include "InputFilter.h"
#include <CoreFoundation/CoreFoundation.h>
REGISTER_DIALOG_DRIVER_CLASS( MacOSX );
static CFOptionFlags ShowAlert( CFOptionFlags flags, const RString& sMessage, CFStringRef OK,
CFStringRef alt = NULL, CFStringRef other = NULL)
{
CFOptionFlags result;
CFStringRef text = CFStringCreateWithCString( NULL, sMessage, kCFStringEncodingUTF8 );
if( text == NULL )
{
RString error = ssprintf( "CFString for dialog string \"%s\" could not be created.", sMessage.c_str() );
WARN( error );
DEBUG_ASSERT_M( false, error );
return kCFUserNotificationDefaultResponse; // Is this better than displaying an "unknown error" message?
}
CFUserNotificationDisplayAlert( 0.0, flags, NULL, NULL, NULL, CFSTR(PRODUCT_FAMILY),
text, OK, alt, other, &result );
CFRelease( text );
// Flush all input that's accumulated while the dialog box was up.
if( INPUTFILTER )
{
vector<InputEvent> dummy;
INPUTFILTER->Reset();
INPUTFILTER->GetInputEvents( dummy );
}
return result;
}
#define LSTRING(b,x) CFBundleCopyLocalizedString( (b), CFSTR(x), NULL, CFSTR("Localizable") )
void DialogDriver_MacOSX::OK( RString sMessage, RString sID )
{
CFBundleRef bundle = CFBundleGetMainBundle();
CFStringRef sDSA = LSTRING( bundle, "Don't show again" );
CFOptionFlags result = ShowAlert( kCFUserNotificationNoteAlertLevel, sMessage, CFSTR("OK"), sDSA );
CFRelease( sDSA );
if( result == kCFUserNotificationAlternateResponse )
Dialog::IgnoreMessage( sID );
}
void DialogDriver_MacOSX::Error( RString sError, RString sID )
{
ShowAlert( kCFUserNotificationStopAlertLevel, sError, CFSTR("OK") );
}
Dialog::Result DialogDriver_MacOSX::AbortRetryIgnore( RString sMessage, RString sID )
{
CFBundleRef bundle = CFBundleGetMainBundle();
CFStringRef sIgnore = LSTRING( bundle, "Ignore" );
CFStringRef sRetry = LSTRING( bundle, "Retry" );
CFStringRef sAbort = LSTRING( bundle, "Abort" );
CFOptionFlags result = ShowAlert( kCFUserNotificationNoteAlertLevel, sMessage, sIgnore, sRetry, sAbort );
CFRelease( sIgnore );
CFRelease( sRetry );
CFRelease( sAbort );
switch( result )
{
case kCFUserNotificationDefaultResponse:
Dialog::IgnoreMessage( sID );
return Dialog::ignore;
case kCFUserNotificationAlternateResponse:
return Dialog::retry;
case kCFUserNotificationOtherResponse:
case kCFUserNotificationCancelResponse:
return Dialog::abort;
default:
FAIL_M( ssprintf("Invalid response: %d.", int(result)) );
}
}
Dialog::Result DialogDriver_MacOSX::AbortRetry( RString sMessage, RString sID )
{
CFBundleRef bundle = CFBundleGetMainBundle();
CFStringRef sRetry = LSTRING( bundle, "Retry" );
CFStringRef sAbort = LSTRING( bundle, "Abort" );
CFOptionFlags result = ShowAlert( kCFUserNotificationNoteAlertLevel, sMessage, sRetry, sAbort );
CFRelease( sRetry );
CFRelease( sAbort );
switch( result )
{
case kCFUserNotificationDefaultResponse:
case kCFUserNotificationCancelResponse:
return Dialog::abort;
case kCFUserNotificationAlternateResponse:
return Dialog::retry;
default:
FAIL_M( ssprintf("Invalid response: %d.", int(result)) );
}
}
/*
* (c) 2003-2006 Steve Checkoway
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+40
View File
@@ -0,0 +1,40 @@
#ifndef DIALOG_BOX_DRIVER_MACOSX_H
#define DIALOG_BOX_DRIVER_MACOSX_H
#include "DialogDriver.h"
class DialogDriver_MacOSX: public DialogDriver
{
public:
void Error( RString sError, RString sID );
void OK( RString sMessage, RString sID );
Dialog::Result AbortRetryIgnore( RString sMessage, RString sID );
Dialog::Result AbortRetry( RString sMessage, RString sID );
};
#endif
/*
* (c) 2003-2004 Steve Checkoway
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+265
View File
@@ -0,0 +1,265 @@
#include "global.h"
#include "DialogDriver_Win32.h"
#include "RageUtil.h"
#if !defined(SMPACKAGE)
#include "LocalizedString.h"
#endif
#include "ThemeManager.h"
#include "ProductInfo.h"
#include "archutils/win32/AppInstance.h"
#include "archutils/win32/ErrorStrings.h"
#include "archutils/win32/GotoURL.h"
#include "archutils/win32/RestartProgram.h"
#include "archutils/Win32/SpecialDirs.h"
#if !defined(SMPACKAGE)
#include "archutils/win32/WindowsResources.h"
#include "archutils/win32/GraphicsWindow.h"
#endif
#include "archutils/win32/DialogUtil.h"
#if defined(SMPACKAGE)
int __stdcall AfxMessageBox(LPCTSTR lpszText, UINT nType, UINT nIDHelp);
#endif
REGISTER_DIALOG_DRIVER_CLASS( Win32 );
static bool g_bHush;
static RString g_sMessage;
static bool g_bAllowHush;
#if !defined(SMPACKAGE)
static BOOL CALLBACK OKWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_INITDIALOG:
{
// Disable the parent window, like a modal MessageBox does.
EnableWindow( GetParent(hWnd), FALSE );
DialogUtil::LocalizeDialogAndContents( hWnd );
// Hide or display "Don't show this message."
g_bHush = false;
HWND hHushButton = GetDlgItem( hWnd, IDC_HUSH );
int iStyle = GetWindowLong( hHushButton, GWL_STYLE );
if( g_bAllowHush )
iStyle |= WS_VISIBLE;
else
iStyle &= ~WS_VISIBLE;
SetWindowLong( hHushButton, GWL_STYLE, iStyle );
// Set static text.
RString sMessage = g_sMessage;
sMessage.Replace( "\n", "\r\n" );
SetWindowText( GetDlgItem(hWnd, IDC_MESSAGE), sMessage );
// Focus is on any of the controls in the dialog by default.
// I'm not sure why. Set focus to the button manually. -Chris
SetFocus( GetDlgItem(hWnd, IDOK) );
}
break;
case WM_DESTROY:
// Re-enable the parent window.
EnableWindow( GetParent(hWnd), TRUE );
break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDOK:
g_bHush = !!IsDlgButtonChecked( hWnd, IDC_HUSH );
/* fall through */
case IDCANCEL:
EndDialog( hWnd, 0 );
break;
}
}
return FALSE;
}
#endif
#if !defined(SMPACKAGE)
static HWND GetHwnd()
{
return GraphicsWindow::GetHwnd();
}
#endif
#if !defined(SMPACKAGE)
static LocalizedString ERROR_WINDOW_TITLE("Dialog-Prompt", "Error");
static RString GetWindowTitle()
{
RString s = ERROR_WINDOW_TITLE.GetValue();
return s;
}
#endif
void DialogDriver_Win32::OK( RString sMessage, RString sID )
{
g_bAllowHush = sID != "";
g_sMessage = sMessage;
AppInstance handle;
#if !defined(SMPACKAGE)
DialogBox( handle.Get(), MAKEINTRESOURCE(IDD_OK), ::GetHwnd(), OKWndProc );
#else
::AfxMessageBox( ConvertUTF8ToACP(sMessage).c_str(), MB_OK, 0 );
#endif
if( g_bAllowHush && g_bHush )
Dialog::IgnoreMessage( sID );
}
#if !defined(SMPACKAGE)
static RString g_sErrorString;
static BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_INITDIALOG:
{
DialogUtil::SetHeaderFont( hWnd, IDC_STATIC_HEADER_TEXT );
// Set static text
RString sMessage = g_sErrorString;
sMessage.Replace( "\n", "\r\n" );
SetWindowText( GetDlgItem(hWnd, IDC_EDIT_ERROR), sMessage );
}
break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDC_BUTTON_VIEW_LOG:
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
ZeroMemory( &si, sizeof(si) );
RString sAppDataDir = SpecialDirs::GetAppDataDir();
RString sCommand = "notepad \"" + sAppDataDir + PRODUCT_ID + "/Logs/log.txt\"";
CreateProcess(
NULL, // pointer to name of executable module
sCommand.GetBuffer(), // pointer to command line string
NULL, // process security attributes
NULL, // thread security attributes
false, // handle inheritance flag
0, // creation flags
NULL, // pointer to new environment block
NULL, // pointer to current directory name
&si, // pointer to STARTUPINFO
&pi // pointer to PROCESS_INFORMATION
);
}
break;
case IDC_BUTTON_REPORT:
GotoURL( REPORT_BUG_URL );
break;
case IDC_BUTTON_RESTART:
Win32RestartProgram();
/* not reached */
ASSERT( 0 );
EndDialog( hWnd, 0 );
break;
case IDOK:
EndDialog( hWnd, 0 );
break;
}
break;
case WM_CTLCOLORSTATIC:
{
HDC hdc = (HDC)wParam;
HWND hwndStatic = (HWND)lParam;
HBRUSH hbr = NULL;
// TODO: Change any attributes of the DC here
switch( GetDlgCtrlID(hwndStatic) )
{
case IDC_STATIC_HEADER_TEXT:
case IDC_STATIC_ICON:
hbr = (HBRUSH)::GetStockObject(WHITE_BRUSH);
SetBkMode( hdc, OPAQUE );
SetBkColor( hdc, RGB(255,255,255) );
break;
}
// TODO: Return a different brush if the default is not desired
return (BOOL)hbr;
}
}
return FALSE;
}
#endif
void DialogDriver_Win32::Error( RString sError, RString sID )
{
#if !defined(SMPACKAGE)
g_sErrorString = sError;
// throw up a pretty error dialog
AppInstance handle;
DialogBox( handle.Get(), MAKEINTRESOURCE(IDD_ERROR_DIALOG), NULL, ErrorWndProc );
#else
::AfxMessageBox( ConvertUTF8ToACP(sError).c_str(), MB_OK, 0 );
#endif
}
Dialog::Result DialogDriver_Win32::AbortRetryIgnore( RString sMessage, RString ID )
{
int iRet = 0;
#if !defined(SMPACKAGE)
iRet = ::MessageBox(::GetHwnd(), ConvertUTF8ToACP(sMessage).c_str(), ConvertUTF8ToACP(::GetWindowTitle()).c_str(), MB_ABORTRETRYIGNORE|MB_DEFBUTTON3 );
#else
iRet = ::AfxMessageBox( ConvertUTF8ToACP(sMessage).c_str(), MB_ABORTRETRYIGNORE|MB_DEFBUTTON3, 0 );
#endif
switch( iRet )
{
case IDABORT: return Dialog::abort;
case IDRETRY: return Dialog::retry;
default: ASSERT(0);
case IDIGNORE: return Dialog::ignore;
}
}
Dialog::Result DialogDriver_Win32::AbortRetry( RString sMessage, RString sID )
{
int iRet = 0;
#if !defined(SMPACKAGE)
iRet = ::MessageBox(::GetHwnd(), ConvertUTF8ToACP(sMessage).c_str(), ConvertUTF8ToACP(::GetWindowTitle()).c_str(), MB_RETRYCANCEL);
#else
iRet = ::AfxMessageBox( ConvertUTF8ToACP(sMessage).c_str(), MB_RETRYCANCEL, 0 );
#endif
switch( iRet )
{
case IDRETRY: return Dialog::retry;
default: ASSERT(0);
case IDCANCEL: return Dialog::abort;
}
}
/*
* (c) 2003-2004 Glenn Maynard, Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+40
View File
@@ -0,0 +1,40 @@
#ifndef DIALOG_BOX_DRIVER_WIN32_H
#define DIALOG_BOX_DRIVER_WIN32_H
#include "DialogDriver.h"
class DialogDriver_Win32: public DialogDriver
{
public:
void Error( RString sMessage, RString sID );
void OK( RString sMessage, RString sID );
Dialog::Result AbortRetryIgnore( RString sMessage, RString sID );
Dialog::Result AbortRetry( RString sMessage, RString sID );
};
#endif
/*
* (c) 2003-2004 Glenn Maynard, Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/