mirror of https://github.com/OpenTTD/OpenTTD
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
parent
b542f784f9
commit
10a2787fd5
|
@ -8,11 +8,33 @@
|
||||||
* To insure that the crosscompiler still works, let him try any changes before they are committed
|
* To insure that the crosscompiler still works, let him try any changes before they are committed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WITH_SDL
|
||||||
|
|
||||||
void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel )
|
void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel )
|
||||||
{
|
{
|
||||||
NSRunAlertPanel([NSString stringWithCString: title], [NSString stringWithCString: message], [NSString stringWithCString: buttonLabel], nil, nil);
|
NSRunAlertPanel([NSString stringWithCString: title], [NSString stringWithCString: message], [NSString stringWithCString: buttonLabel], nil, nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined WITH_COCOA
|
||||||
|
|
||||||
|
void CocoaDialog ( const char *title, const char *message, const char *buttonLabel );
|
||||||
|
|
||||||
|
void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel )
|
||||||
|
{
|
||||||
|
CocoaDialog(title, message, buttonLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: %s\n", title, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void ShowMacAssertDialog ( const char *function, const char *file, const int line, const char *expression )
|
void ShowMacAssertDialog ( const char *function, const char *file, const int line, const char *expression )
|
||||||
{
|
{
|
||||||
const char *buffer =
|
const char *buffer =
|
||||||
|
|
|
@ -175,7 +175,8 @@ static struct CocoaVideoData {
|
||||||
uint32 palette32[256];
|
uint32 palette32[256];
|
||||||
} _cocoa_video_data;
|
} _cocoa_video_data;
|
||||||
|
|
||||||
|
static bool _cocoa_video_started = false;
|
||||||
|
static bool _cocoa_video_dialog = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1872,7 +1873,7 @@ void QZ_HideMouse (void) {
|
||||||
/* 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
|
||||||
{
|
{
|
||||||
/* Hand off to main application code */
|
/* Hand off to main application code */
|
||||||
QZ_GameLoop();
|
QZ_GameLoop();
|
||||||
|
|
||||||
/* We're done, thank you for playing */
|
/* We're done, thank you for playing */
|
||||||
|
@ -2007,10 +2008,15 @@ static void CocoaVideoStop(void)
|
||||||
{
|
{
|
||||||
DEBUG(driver, 1)("cocoa_v: CocoaVideoStop");
|
DEBUG(driver, 1)("cocoa_v: CocoaVideoStop");
|
||||||
|
|
||||||
|
if(!_cocoa_video_started)
|
||||||
|
return;
|
||||||
|
|
||||||
if(_cocoa_video_data.isset)
|
if(_cocoa_video_data.isset)
|
||||||
QZ_UnsetVideoMode();
|
QZ_UnsetVideoMode();
|
||||||
|
|
||||||
[_ottd_main release];
|
[_ottd_main release];
|
||||||
|
|
||||||
|
_cocoa_video_started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *CocoaVideoStart(const char * const *parm)
|
static const char *CocoaVideoStart(const char * const *parm)
|
||||||
|
@ -2019,8 +2025,18 @@ static const char *CocoaVideoStart(const char * const *parm)
|
||||||
|
|
||||||
DEBUG(driver, 1)("cocoa_v: CocoaVideoStart");
|
DEBUG(driver, 1)("cocoa_v: CocoaVideoStart");
|
||||||
|
|
||||||
|
if(_cocoa_video_started)
|
||||||
|
return "Already started";
|
||||||
|
_cocoa_video_started = true;
|
||||||
|
|
||||||
|
memset(&_cocoa_video_data, 0, sizeof(_cocoa_video_data));
|
||||||
|
|
||||||
setupApplication();
|
setupApplication();
|
||||||
|
|
||||||
|
/* Don't create a window or enter fullscreen if we're just going to show a dialog. */
|
||||||
|
if(_cocoa_video_dialog)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
QZ_VideoInit();
|
QZ_VideoInit();
|
||||||
|
|
||||||
ret = QZ_SetVideoMode(_cur_resolution[0], _cur_resolution[1], _fullscreen);
|
ret = QZ_SetVideoMode(_cur_resolution[0], _cur_resolution[1], _fullscreen);
|
||||||
|
@ -2086,6 +2102,31 @@ const HalVideoDriver _cocoa_video_driver = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* This is needed since sometimes assert is called before the videodriver is initialized */
|
||||||
|
void CocoaDialog ( const char *title, const char *message, const char *buttonLabel )
|
||||||
|
{
|
||||||
|
bool wasstarted;
|
||||||
|
|
||||||
|
_cocoa_video_dialog = true;
|
||||||
|
|
||||||
|
wasstarted = _cocoa_video_started;
|
||||||
|
if(!_cocoa_video_started && CocoaVideoStart(NULL) != NULL) {
|
||||||
|
fprintf(stderr, "%s: %s\n", title, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NSRunAlertPanel([NSString stringWithCString: title], [NSString stringWithCString: message], [NSString stringWithCString: buttonLabel], nil, nil);
|
||||||
|
|
||||||
|
if(!wasstarted)
|
||||||
|
CocoaVideoStop();
|
||||||
|
|
||||||
|
_cocoa_video_dialog = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This is needed since OS X applications are started with the working dir set to / when double-clicked */
|
/* This is needed since OS X applications are started with the working dir set to / when double-clicked */
|
||||||
void cocoaSetWorkingDirectory(void)
|
void cocoaSetWorkingDirectory(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue