various arch modifications, mainly for file download support

This commit is contained in:
AJ Kelly
2010-12-15 19:15:53 -06:00
parent 6d70de3199
commit a4fe858757
15 changed files with 258 additions and 116 deletions
+71 -3
View File
@@ -6,15 +6,59 @@
#endif
#include "RageUtil.h"
#include "RageLog.h"
#include "arch/arch.h"
#include "RageThreads.h"
#if !defined(SMPACKAGE)
static Preference<RString> g_sIgnoredDialogs( "IgnoredDialogs", "" );
#endif
#include "Selector_Dialog.h"
DialogDriver *MakeDialogDriver()
{
RString sDrivers = "win32,cocoa,null";
vector<RString> asDriversToTry;
split( sDrivers, ",", asDriversToTry, true );
ASSERT( asDriversToTry.size() != 0 );
RString sDriver;
DialogDriver *pRet = NULL;
for( unsigned i = 0; pRet == NULL && i < asDriversToTry.size(); ++i )
{
sDriver = asDriversToTry[i];
#ifdef USE_DIALOG_DRIVER_COCOA
if( !asDriversToTry[i].CompareNoCase("Cocoa") ) pRet = new DialogDriver_Cocoa;
#endif
#ifdef USE_DIALOG_DRIVER_WIN32
if( !asDriversToTry[i].CompareNoCase("Win32") ) pRet = new DialogDriver_Win32;
#endif
#ifdef USE_DIALOG_DRIVER_NULL
if( !asDriversToTry[i].CompareNoCase("Null") ) pRet = new DialogDriver_Null;
#endif
if( pRet == NULL )
{
continue;
}
RString sError = pRet->Init();
if( sError != "" )
{
if( LOG )
LOG->Info( "Couldn't load driver %s: %s", asDriversToTry[i].c_str(), sError.c_str() );
SAFE_DELETE( pRet );
}
}
return pRet;
}
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 g_bWindowed = true; // Start out true so that we'll show errors before DISPLAY is init'd.
static bool DialogsEnabled()
{
@@ -28,7 +72,7 @@ void Dialog::Init()
g_pImpl = DialogDriver::Create();
/* DialogDriver_Null should have worked, at least. */
// DialogDriver_Null should have worked, at least.
ASSERT( g_pImpl != NULL );
}
@@ -52,7 +96,7 @@ static bool MessageIsIgnored( RString sID )
void Dialog::IgnoreMessage( RString sID )
{
/* We can't ignore messages before PREFSMAN is around. */
// We can't ignore messages before PREFSMAN is around.
#if !defined(SMPACKAGE)
if( PREFSMAN == NULL )
{
@@ -118,6 +162,30 @@ void Dialog::OK( RString sMessage, RString sID )
RageThread::SetIsShowingDialog( false );
}
Dialog::Result Dialog::OKCancel( 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.OKCancel( sMessage, sID );
RageThread::SetIsShowingDialog( true );
// only show Dialog if windowed
Dialog::Result ret;
if( DialogsEnabled() )
ret = g_pImpl->OKCancel( sMessage, sID ); // call derived version
else
ret = g_NullDriver.OKCancel( sMessage, sID );
RageThread::SetIsShowingDialog( false );
return ret;
}
Dialog::Result Dialog::AbortRetryIgnore( RString sMessage, RString sID )
{
Dialog::Init();