|
|
1.1 root 1: /*
1.1.1.4 root 2: Hatari - AlertHooks.m
1.1 root 3:
1.1.1.3 root 4: This file is distributed under the GNU General Public License, version 2
5: or at your option any later version. Read the file gpl.txt for details.
1.1 root 6:
7: Hooked alerts, to be used instead of SDL alert windows
8:
9: June 2006, Sébastien Molines - Created
10: */
11:
12: #import <Cocoa/Cocoa.h>
13: #import "AlertHooks.h"
1.1.1.4 root 14: #import "Shared.h"
1.1 root 15:
16: #ifdef ALERT_HOOKS
17:
18: /*-----------------------------------------------------------------------*/
19: /*
20: Displays a Cocoa alert
21: */
22: int HookedAlertNotice(const char* szMessage)
23: {
1.1.1.4 root 24: NSString *message ;
25: NSRange cantTOS, firstPv, lastPv ;
26:
27: message = [NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding] ;
28: //NSLog(@"Notice: %@", message ) ;
29: cantTOS = [message rangeOfString:@"Can not load TOS file:"] ;
30: firstPv = [message rangeOfString:@"'"] ;
31: lastPv = [message rangeOfString:@"'" options:NSBackwardsSearch] ;
32:
1.1.1.5 ! root 33: if ((cantTOS.location == NSNotFound) || (firstPv.location==lastPv.location)) // traitement normal
! 34: return ([NSApp myAlerte:NSInformationalAlertStyle Txt:nil firstB:localize(@"Ok") alternateB:localize(@"Cancel")
! 35: otherB:nil informativeTxt:message ] == NSAlertDefaultReturn );
! 36: else // traitement can not load
! 37: return ([NSApp myAlerte:NSCriticalAlertStyle Txt:nil firstB:localize(@"Ok") alternateB:nil otherB:nil
! 38: informativeTxt:localize(@"Can not load TOS file:") ] == NSAlertDefaultReturn) ;
1.1 root 39: }
40:
41: /*-----------------------------------------------------------------------*/
42: /*
43: Displays a Cocoa alert with a choice (OK and Cancel buttons)
44: */
45: int HookedAlertQuery(const char* szMessage)
46: {
1.1.1.5 ! root 47: NSString *message ;
! 48:
! 49: message = localize([NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding]) ;
! 50: return [NSApp myAlerte:NSInformationalAlertStyle Txt:nil firstB:localize(@"Ok") alternateB:localize(@"Cancel")
! 51: otherB:nil informativeTxt:message ] ;
1.1 root 52: }
53:
54: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.