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
+3 -5
View File
@@ -32,11 +32,9 @@ public:
*/ */
virtual RString GetMachineId() const { return RString(); } virtual RString GetMachineId() const { return RString(); }
/* /* If this is a second instance, return true.
* If this is a second instance, return true. Optionally, give focus to the existing * Optionally, give focus to the existing window. */
* window. virtual bool CheckForMultipleInstances(int argc, char* argv[]) { return false; }
*/
virtual bool CheckForMultipleInstances() { return false; }
virtual void SetTime( tm newtime ) { } virtual void SetTime( tm newtime ) { }
+16 -1
View File
@@ -92,7 +92,7 @@ RString ArchHooks_Win32::GetMachineId() const
return RString(); return RString();
} }
bool ArchHooks_Win32::CheckForMultipleInstances() bool ArchHooks_Win32::CheckForMultipleInstances(int argc, char* argv[])
{ {
if( !g_bIsMultipleInstance ) if( !g_bIsMultipleInstance )
return false; return false;
@@ -117,6 +117,21 @@ bool ArchHooks_Win32::CheckForMultipleInstances()
SetForegroundWindow( data.hResult ); SetForegroundWindow( data.hResult );
else else
SetForegroundWindow( hWnd ); SetForegroundWindow( hWnd );
// Send the command line to the existing window.
vector<RString> vsArgs;
for( int i=0; i<argc; i++ )
vsArgs.push_back( argv[i] );
RString sAllArgs = join("|", vsArgs);
COPYDATASTRUCT cds;
cds.dwData = 0;
cds.cbData = sAllArgs.size();
cds.lpData = (void*)sAllArgs.data();
SendMessage(
(HWND)hWnd, // HWND hWnd = handle of destination window
WM_COPYDATA,
(WPARAM)NULL, // HANDLE OF SENDING WINDOW
(LPARAM)&cds ); // 2nd msg parameter = pointer to COPYDATASTRUCT
} }
return true; return true;
+1 -1
View File
@@ -13,7 +13,7 @@ public:
void DumpDebugInfo(); void DumpDebugInfo();
void RestartProgram(); void RestartProgram();
RString GetMachineId() const; RString GetMachineId() const;
bool CheckForMultipleInstances(); bool CheckForMultipleInstances(int argc, char* argv[]);
void SetTime( tm newtime ); void SetTime( tm newtime );
+70 -2
View File
@@ -6,12 +6,56 @@
#endif #endif
#include "RageUtil.h" #include "RageUtil.h"
#include "RageLog.h" #include "RageLog.h"
#include "arch/arch.h"
#include "RageThreads.h" #include "RageThreads.h"
#if !defined(SMPACKAGE) #if !defined(SMPACKAGE)
static Preference<RString> g_sIgnoredDialogs( "IgnoredDialogs", "" ); static Preference<RString> g_sIgnoredDialogs( "IgnoredDialogs", "" );
#endif #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 *g_pImpl = NULL;
static DialogDriver_Null g_NullDriver; 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.
@@ -28,7 +72,7 @@ void Dialog::Init()
g_pImpl = DialogDriver::Create(); g_pImpl = DialogDriver::Create();
/* DialogDriver_Null should have worked, at least. */ // DialogDriver_Null should have worked, at least.
ASSERT( g_pImpl != NULL ); ASSERT( g_pImpl != NULL );
} }
@@ -52,7 +96,7 @@ static bool MessageIsIgnored( RString sID )
void Dialog::IgnoreMessage( 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 !defined(SMPACKAGE)
if( PREFSMAN == NULL ) if( PREFSMAN == NULL )
{ {
@@ -118,6 +162,30 @@ void Dialog::OK( RString sMessage, RString sID )
RageThread::SetIsShowingDialog( false ); 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::Result Dialog::AbortRetryIgnore( RString sMessage, RString sID )
{ {
Dialog::Init(); Dialog::Init();
+1
View File
@@ -13,6 +13,7 @@ namespace Dialog
enum Result { abort, retry, ignore }; enum Result { abort, retry, ignore };
void Error( RString sError, RString sID = "" ); void Error( RString sError, RString sID = "" );
void OK( RString sMessage, RString sID = "" ); void OK( RString sMessage, RString sID = "" );
Result OKCancel( RString sMessage, RString sID = "" );
Result AbortRetryIgnore( RString sMessage, RString sID = "" ); Result AbortRetryIgnore( RString sMessage, RString sID = "" );
Result AbortRetry( RString sMessage, RString sID = "" ); Result AbortRetry( RString sMessage, RString sID = "" );
+2 -1
View File
@@ -11,6 +11,7 @@ public:
virtual void Error( RString sMessage, RString sID ) { printf("Error: %s\n", sMessage.c_str()); } virtual void Error( RString sMessage, RString sID ) { printf("Error: %s\n", sMessage.c_str()); }
virtual void OK( RString sMessage, RString sID ) {} virtual void OK( RString sMessage, RString sID ) {}
virtual Dialog::Result OKCancel( RString sMessage, RString sID ) { return Dialog::ok; }
virtual Dialog::Result AbortRetryIgnore( RString sMessage, RString sID ) { return Dialog::ignore; } virtual Dialog::Result AbortRetryIgnore( RString sMessage, RString sID ) { return Dialog::ignore; }
virtual Dialog::Result AbortRetry( RString sMessage, RString sID ) { return Dialog::abort; } virtual Dialog::Result AbortRetry( RString sMessage, RString sID ) { return Dialog::abort; }
@@ -18,6 +19,7 @@ public:
virtual ~DialogDriver() { } virtual ~DialogDriver() { }
}; };
class DialogDriver_Null : public DialogDriver { }; class DialogDriver_Null : public DialogDriver { };
#define USE_DIALOG_DRIVER_NULL
typedef DialogDriver *(*CreateDialogDriverFn)(); typedef DialogDriver *(*CreateDialogDriverFn)();
struct RegisterDialogDriver struct RegisterDialogDriver
@@ -28,7 +30,6 @@ struct RegisterDialogDriver
#define REGISTER_DIALOG_DRIVER_CLASS( name ) \ #define REGISTER_DIALOG_DRIVER_CLASS( name ) \
static RegisterDialogDriver register_##name( #name, CreateClass<DialogDriver_##name, DialogDriver> ) static RegisterDialogDriver register_##name( #name, CreateClass<DialogDriver_##name, DialogDriver> )
#endif #endif
/* /*
+1
View File
@@ -11,6 +11,7 @@ public:
Dialog::Result AbortRetryIgnore( RString sMessage, RString sID ); Dialog::Result AbortRetryIgnore( RString sMessage, RString sID );
Dialog::Result AbortRetry( RString sMessage, RString sID ); Dialog::Result AbortRetry( RString sMessage, RString sID );
}; };
#define USE_DIALOG_DRIVER_COCOA
#endif #endif
+26 -2
View File
@@ -72,7 +72,7 @@ static BOOL CALLBACK OKWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
{ {
case IDOK: case IDOK:
g_bHush = !!IsDlgButtonChecked( hWnd, IDC_HUSH ); g_bHush = !!IsDlgButtonChecked( hWnd, IDC_HUSH );
/* fall through */ // fall through
case IDCANCEL: case IDCANCEL:
EndDialog( hWnd, 0 ); EndDialog( hWnd, 0 );
break; break;
@@ -112,6 +112,30 @@ void DialogDriver_Win32::OK( RString sMessage, RString sID )
Dialog::IgnoreMessage( sID ); Dialog::IgnoreMessage( sID );
} }
Dialog::Result DialogDriver_Win32::OKCancel( RString sMessage, RString sID )
{
g_bAllowHush = sID != "";
g_sMessage = sMessage;
AppInstance handle;
#if !defined(SMPACKAGE)
//DialogBox( handle.Get(), MAKEINTRESOURCE(IDD_OK), ::GetHwnd(), OKWndProc );
int result = ::MessageBox( NULL, sMessage, GetWindowTitle(), MB_OKCANCEL );
#else
int result = ::AfxMessageBox( ConvertUTF8ToACP(sMessage).c_str(), MB_OKCANCEL, 0 );
#endif
if( g_bAllowHush && g_bHush )
Dialog::IgnoreMessage( sID );
switch( result )
{
case IDOK:
return Dialog::ok;
default:
return Dialog::cancel;
}
}
#if !defined(SMPACKAGE) #if !defined(SMPACKAGE)
static RString g_sErrorString; static RString g_sErrorString;
@@ -159,7 +183,7 @@ static BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
break; break;
case IDC_BUTTON_RESTART: case IDC_BUTTON_RESTART:
Win32RestartProgram(); Win32RestartProgram();
/* not reached */ // not reached
ASSERT( 0 ); ASSERT( 0 );
EndDialog( hWnd, 0 ); EndDialog( hWnd, 0 );
break; break;
+1
View File
@@ -8,6 +8,7 @@ class DialogDriver_Win32: public DialogDriver
public: public:
void Error( RString sMessage, RString sID ); void Error( RString sMessage, RString sID );
void OK( RString sMessage, RString sID ); void OK( RString sMessage, RString sID );
Dialog::Result OKCancel( RString sMessage, RString sID );
Dialog::Result AbortRetryIgnore( RString sMessage, RString sID ); Dialog::Result AbortRetryIgnore( RString sMessage, RString sID );
Dialog::Result AbortRetry( RString sMessage, RString sID ); Dialog::Result AbortRetry( RString sMessage, RString sID );
}; };
+1 -2
View File
@@ -11,7 +11,7 @@ LoadingWindow *LoadingWindow::Create()
#if defined(UNIX) && !defined(HAVE_GTK) #if defined(UNIX) && !defined(HAVE_GTK)
return new LoadingWindow_Null; return new LoadingWindow_Null;
#endif #endif
/* Don't load NULL by default. */ // Don't load NULL by default.
const RString drivers = "xbox,win32,macosx,gtk"; const RString drivers = "xbox,win32,macosx,gtk";
vector<RString> DriversToTry; vector<RString> DriversToTry;
split( drivers, ",", DriversToTry, true ); split( drivers, ",", DriversToTry, true );
@@ -39,7 +39,6 @@ LoadingWindow *LoadingWindow::Create()
#endif #endif
if( !DriversToTry[i].CompareNoCase("Null") ) ret = new LoadingWindow_Null; if( !DriversToTry[i].CompareNoCase("Null") ) ret = new LoadingWindow_Null;
if( ret == NULL ) if( ret == NULL )
continue; continue;
@@ -7,7 +7,7 @@
#import "arch/ArchHooks/ArchHooks.h" #import "arch/ArchHooks/ArchHooks.h"
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import <OpenGl/OpenGl.h> #import <OpenGL/OpenGL.h>
#import <OpenGL/gl.h> #import <OpenGL/gl.h>
#import <mach-o/dyld.h> #import <mach-o/dyld.h>
+25
View File
@@ -1,6 +1,8 @@
#include "global.h" #include "global.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "RageThreads.h" #include "RageThreads.h"
#include "RageLog.h"
#include "CommandLineActions.h"
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include "ProductInfo.h" #include "ProductInfo.h"
@@ -69,11 +71,34 @@
exit( SM_main(m_iArgc, m_pArgv) ); exit( SM_main(m_iArgc, m_pArgv) );
} }
/* From here:
* http://www.cocoadev.com/index.pl?HowToRegisterURLHandler */
- (void) getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
const char *url = [[[event paramDescriptorForKeyword:keyDirectObject] stringValue] UTF8String];
LOG->Info("Parsing URL: %s", url);
// I'm not sure this handles everything it needs to. - Colby
CommandLineActions::CommandLineArgs args;
args.argv.push_back(url);
CommandLineActions::ToProcess.push_back(args);
}
// Called when the internal event loop has just started running. // Called when the internal event loop has just started running.
- (void) applicationDidFinishLaunching:(NSNotification *)note - (void) applicationDidFinishLaunching:(NSNotification *)note
{ {
m_bApplicationLaunched = YES; m_bApplicationLaunched = YES;
[NSThread detachNewThreadSelector:@selector(startGame:) toTarget:self withObject:nil]; [NSThread detachNewThreadSelector:@selector(startGame:) toTarget:self withObject:nil];
// Register ourselves as a URL handler.
[
[NSAppleEventManager sharedAppleEventManager] setEventHandler:self
andSelector:@selector(getUrl:withReplyEvent:)
forEventClass:kInternetEventClass
andEventID:kAEGetURL
];
} }
- (BOOL) application:(NSApplication *)app openFile:(NSString *)file - (BOOL) application:(NSApplication *)app openFile:(NSString *)file
-1
View File
@@ -81,7 +81,6 @@ void DialogUtil::LocalizeDialogAndContents( HWND hdlg )
} }
} }
/* /*
* (c) 2002-2004 Chris Danford * (c) 2002-2004 Chris Danford
* All rights reserved. * All rights reserved.
+11 -1
View File
@@ -11,6 +11,7 @@
#include "archutils/Win32/ErrorStrings.h" #include "archutils/Win32/ErrorStrings.h"
#include "archutils/Win32/WindowIcon.h" #include "archutils/Win32/WindowIcon.h"
#include "archutils/Win32/GetFileInformation.h" #include "archutils/Win32/GetFileInformation.h"
#include "CommandLineActions.h"
#include <set> #include <set>
@@ -25,7 +26,7 @@ static HICON g_hIcon = NULL;
static bool m_bWideWindowClass; static bool m_bWideWindowClass;
static bool g_bD3D = false; static bool g_bD3D = false;
/* If we're fullscreen, this is the mode we set. */ // If we're fullscreen, this is the mode we set.
static DEVMODE g_FullScreenDevMode; static DEVMODE g_FullScreenDevMode;
static bool g_bRecreatingVideoMode = false; static bool g_bRecreatingVideoMode = false;
@@ -160,6 +161,15 @@ static LRESULT CALLBACK GraphicsWindow_WndProc( HWND hWnd, UINT msg, WPARAM wPar
} }
break; break;
} }
case WM_COPYDATA:
{
PCOPYDATASTRUCT pMyCDS = (PCOPYDATASTRUCT) lParam;
RString sCommandLine( (char*)pMyCDS->lpData, pMyCDS->cbData );
CommandLineActions::CommandLineArgs args;
split( sCommandLine, "|", args.argv, false );
CommandLineActions::ToProcess.push_back( args );
break;
}
} }
CHECKPOINT_M( ssprintf("%p, %u, %08x, %08x", hWnd, msg, wParam, lParam) ); CHECKPOINT_M( ssprintf("%p, %u, %08x, %08x", hWnd, msg, wParam, lParam) );