|
|
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.6 ! root 33: if ((cantTOS.location == NSNotFound) || (firstPv.location==lastPv.location)) // TOS can be found
1.1.1.5 root 34: return ([NSApp myAlerte:NSInformationalAlertStyle Txt:nil firstB:localize(@"Ok") alternateB:localize(@"Cancel")
1.1.1.6 ! root 35: otherB:nil informativeTxt:message ] == NSAlertFirstButtonReturn
! 36: //NSAlertDefaultReturn
! 37: );
! 38: else // TOS can be found
1.1.1.5 root 39: return ([NSApp myAlerte:NSCriticalAlertStyle Txt:nil firstB:localize(@"Ok") alternateB:nil otherB:nil
1.1.1.6 ! root 40: informativeTxt:localize(@"Can not load TOS file:") ] == NSAlertFirstButtonReturn) ;
1.1 root 41: }
42:
1.1.1.6 ! root 43: /*----------------------------------------------------------------------*/
! 44: /* Displays a Cocoa alert with a choice (OK and Cancel buttons) */
! 45: /*----------------------------------------------------------------------*/
! 46:
1.1 root 47: int HookedAlertQuery(const char* szMessage)
48: {
1.1.1.5 root 49: NSString *message ;
1.1.1.6 ! root 50: int ret;
1.1.1.5 root 51:
52: message = localize([NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding]) ;
1.1.1.6 ! root 53: ret= [NSApp myAlerte:NSInformationalAlertStyle Txt:nil firstB:localize(@"Ok") alternateB:localize(@"Cancel")
! 54: otherB:nil informativeTxt:message ] ;
! 55: if(ret==NSAlertFirstButtonReturn)
! 56: return true; //OK
! 57: else
! 58: return false; // otherwise false
1.1 root 59: }
60:
61: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.