--- hatari/src/gui-osx/AlertHooks.m 2019/04/09 08:54:08 1.1.1.4 +++ hatari/src/gui-osx/AlertHooks.m 2019/04/09 08:56:36 1.1.1.6 @@ -23,7 +23,6 @@ int HookedAlertNotice(const char* szMess { NSString *message ; NSRange cantTOS, firstPv, lastPv ; - NSAlert *lalerte ; message = [NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding] ; //NSLog(@"Notice: %@", message ) ; @@ -31,26 +30,32 @@ int HookedAlertNotice(const char* szMess firstPv = [message rangeOfString:@"'"] ; lastPv = [message rangeOfString:@"'" options:NSBackwardsSearch] ; - if ((cantTOS.location == NSNotFound) || (firstPv.location==lastPv.location)) - return (NSAlertDefaultReturn == NSRunInformationalAlertPanel(@"Hatari", localize(message), localize(@"Ok"), nil, nil)); - - firstPv.location++ ; firstPv.length = lastPv.location-firstPv.location ; - lalerte = [NSAlert alertWithMessageText:@"Hatari" defaultButton:localize(@"Ok") alternateButton:nil otherButton:nil - informativeTextWithFormat:localize(@"Can not load TOS file:"), [NSApp pathUser:[message substringWithRange:firstPv]]] ; - - [lalerte runModal] ; - return YES ; + if ((cantTOS.location == NSNotFound) || (firstPv.location==lastPv.location)) // TOS can be found + return ([NSApp myAlerte:NSInformationalAlertStyle Txt:nil firstB:localize(@"Ok") alternateB:localize(@"Cancel") + otherB:nil informativeTxt:message ] == NSAlertFirstButtonReturn + //NSAlertDefaultReturn + ); + else // TOS can be found + return ([NSApp myAlerte:NSCriticalAlertStyle Txt:nil firstB:localize(@"Ok") alternateB:nil otherB:nil + informativeTxt:localize(@"Can not load TOS file:") ] == NSAlertFirstButtonReturn) ; } -/*-----------------------------------------------------------------------*/ -/* - Displays a Cocoa alert with a choice (OK and Cancel buttons) -*/ +/*----------------------------------------------------------------------*/ +/* Displays a Cocoa alert with a choice (OK and Cancel buttons) */ +/*----------------------------------------------------------------------*/ + int HookedAlertQuery(const char* szMessage) { -// NSLog(@"Alerte: %@", [NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding] ) ; - return (NSAlertDefaultReturn == NSRunAlertPanel(@"Hatari", localize([NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding]), - localize(@"Ok"), localize(@"Cancel"), nil)); + NSString *message ; + int ret; + + message = localize([NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding]) ; + ret= [NSApp myAlerte:NSInformationalAlertStyle Txt:nil firstB:localize(@"Ok") alternateB:localize(@"Cancel") + otherB:nil informativeTxt:message ] ; + if(ret==NSAlertFirstButtonReturn) + return true; //OK + else + return false; // otherwise false } #endif