Annotation of hatari/src/gui-osx/AlertHooks.m, revision 1.1.1.4

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:        NSAlert  *lalerte ;
        !            27: 
        !            28:        message = [NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding] ;
        !            29:        //NSLog(@"Notice: %@", message ) ;
        !            30:        cantTOS = [message rangeOfString:@"Can not load TOS file:"] ;
        !            31:        firstPv = [message rangeOfString:@"'"] ;
        !            32:        lastPv = [message rangeOfString:@"'" options:NSBackwardsSearch] ;
        !            33: 
        !            34:        if ((cantTOS.location == NSNotFound) || (firstPv.location==lastPv.location))
        !            35:                return (NSAlertDefaultReturn == NSRunInformationalAlertPanel(@"Hatari", localize(message), localize(@"Ok"), nil, nil));
        !            36: 
        !            37:        firstPv.location++ ; firstPv.length = lastPv.location-firstPv.location ;
        !            38:        lalerte = [NSAlert alertWithMessageText:@"Hatari" defaultButton:localize(@"Ok") alternateButton:nil otherButton:nil
        !            39:                   informativeTextWithFormat:localize(@"Can not load TOS file:"), [NSApp pathUser:[message substringWithRange:firstPv]]] ;
        !            40: 
        !            41:        [lalerte runModal] ;
        !            42:        return YES ;
1.1       root       43: }
                     44: 
                     45: /*-----------------------------------------------------------------------*/
                     46: /*
                     47:   Displays a Cocoa alert with a choice (OK and Cancel buttons)
                     48: */
                     49: int HookedAlertQuery(const char* szMessage)
                     50: {
1.1.1.4 ! root       51: //     NSLog(@"Alerte: %@",  [NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding] ) ;
        !            52:        return (NSAlertDefaultReturn == NSRunAlertPanel(@"Hatari", localize([NSString stringWithCString:szMessage encoding:NSASCIIStringEncoding]),
        !            53:                                                                                                                        localize(@"Ok"), localize(@"Cancel"), nil));
1.1       root       54: }
                     55: 
                     56: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.