Annotation of hatari/src/gui-osx/SDLMain.m, revision 1.1.1.15

1.1.1.12  root        1: /*
                      2:     SDLMain.m - main entry point for our Cocoa-ized SDL app
1.1       root        3:        Initial Version: Darrell Walisser <[email protected]>
                      4:        Non-NIB-Code & other changes: Max Horn <[email protected]>
1.1.1.12  root        5:        Modifications for Hatari by Miguel Saro and Jerome Vernet
1.1       root        6: 
                      7:     Feel free to customize this file to suit your needs
1.1.1.11  root        8: */
1.1       root        9: 
1.1.1.11  root       10: /* Use this flag to determine whether we use SDLMain.nib or not */
                     11: #define                SDL_USE_NIB_FILE        1
1.1.1.6   root       12: 
1.1.1.11  root       13: /* Use this flag to determine whether we use CPS (docking) or not */
                     14: #define                SDL_USE_CPS                     1
1.1.1.6   root       15: 
1.1.1.11  root       16: #import "SDL.h"
                     17: #import "SDLMain.h"
                     18: #import <sys/param.h> // for MAXPATHLEN
                     19: #import <unistd.h>
1.1.1.6   root       20: 
1.1.1.11  root       21: // for Hatari
                     22: #import "dialog.h"
                     23: #import "floppy.h"
                     24: #import "reset.h"
                     25: #import "screenSnapShot.h"
                     26: #import "memorySnapShot.h"
                     27: #import "sound.h"
                     28: #import "screen.h"
                     29: #import "PrefsController.h"
                     30: #import "Shared.h"
                     31: #import "video.h"
                     32: #import "avi_record.h"
                     33: #import "debugui.h"
                     34: #import "clocks_timings.h"
                     35: #import "change.h"
1.1.1.6   root       36: 
1.1.1.14  root       37: extern void Main_RequestQuit(int exitval) ;
1.1.1.6   root       38: 
                     39: #ifdef SDL_USE_CPS
1.1.1.11  root       40: // Portions of CPS.h
1.1.1.6   root       41: typedef struct CPSProcessSerNum
                     42: {
                     43:        UInt32          lo;
                     44:        UInt32          hi;
                     45: } CPSProcessSerNum;
                     46: 
                     47: extern OSErr   CPSGetCurrentProcess( CPSProcessSerNum *psn);
                     48: extern OSErr   CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
                     49: extern OSErr   CPSSetFrontProcess( CPSProcessSerNum *psn);
                     50: 
1.1.1.11  root       51: #endif // SDL_USE_CPS
1.1       root       52: 
1.1.1.11  root       53: static int             gArgc;
                     54: static char            **gArgv;
                     55: static BOOL            gFinderLaunch = NO ;
                     56: static BOOL            gCalledAppMainline = NO ;
1.1.1.6   root       57: 
                     58: 
1.1.1.11  root       59: // The main class of the application, the application's delegate
                     60: //
                     61: @implementation HatariAppDelegate
1.1       root       62: 
1.1.1.11  root       63: char szPath[FILENAME_MAX] ;                                                                                    // for general use
1.1       root       64: 
1.1.1.11  root       65: // Set the working directory to the .app's parent directory
1.1.1.6   root       66: - (void) setupWorkingDirectory:(BOOL)shouldChdir
                     67: {
1.1.1.12  root       68:        if (shouldChdir)
1.1.1.13  root       69:                chdir([[[NSBundle mainBundle].bundlePath stringByDeletingLastPathComponent] cStringUsingEncoding:NSASCIIStringEncoding]) ;
1.1.1.6   root       70: }
                     71: 
                     72: 
                     73: /*
                     74:  * Catch document open requests...this lets us notice files when the app
                     75:  *  was launched by double-clicking a document, or when a document was
                     76:  *  dragged/dropped on the app's icon. You need to have a
                     77:  *  CFBundleDocumentsType section in your Info.plist to get this message,
                     78:  *  apparently.
                     79:  *
                     80:  * Files are added to gArgv, so to the app, they'll look like command line
                     81:  *  arguments. Previously, apps launched from the finder had nothing but
                     82:  *  an argv[0].
                     83:  *
                     84:  * This message may be received multiple times to open several docs on launch.
                     85:  *
                     86:  * This message is ignored once the app's mainline has been called.
                     87:  */
                     88: - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
                     89: {
1.1.1.12  root       90:        const char *temparg;
                     91:        size_t arglen;
                     92:        char *arg;
                     93:        char **newargv;
                     94: 
                     95:        if (!gFinderLaunch)                     // MacOS is passing command line args.
                     96:                return FALSE;
                     97: 
                     98:        if (gCalledAppMainline)         // app has started, ignore this document.
                     99:                return FALSE;
                    100: 
1.1.1.13  root      101:        temparg = filename.UTF8String ;
1.1.1.12  root      102:        arglen = SDL_strlen(temparg) + 1 ;
                    103:        arg = (char *) SDL_malloc(arglen) ;
                    104:        if (arg == NULL)
                    105:                return FALSE;
                    106: 
                    107:        newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2)) ;
                    108:        if (newargv == NULL)
                    109:        {
                    110:                SDL_free(arg);
                    111:                return FALSE;
                    112:        }
                    113:        gArgv = newargv ;
                    114: 
                    115:        SDL_strlcpy(arg, temparg, arglen) ;
                    116:        gArgv[gArgc++] = arg ;
                    117:        gArgv[gArgc] = NULL ;
                    118:        return TRUE;
1.1.1.6   root      119: }
                    120: 
1.1.1.13  root      121: /*----------------------------------------------------------------------*/
1.1.1.11  root      122: // Called when the internal event loop has just started running
1.1.1.13  root      123: /*----------------------------------------------------------------------*/
1.1.1.6   root      124: - (void) applicationDidFinishLaunching: (NSNotification *) note
                    125: {
1.1.1.11  root      126:        int status;
1.1.1.6   root      127: 
1.1.1.11  root      128:        // Set the working directory to the .app's parent directory
                    129:        [self setupWorkingDirectory:gFinderLaunch];
1.1.1.6   root      130: 
1.1.1.11  root      131:        //setenv ("SDL_ENABLEAPPEVENTS", "1", 1) ;
1.1.1.6   root      132: 
1.1.1.11  root      133:        // Hand off to main application code
1.1.1.13  root      134:        emulationPaused=NO;
1.1.1.11  root      135:        gCalledAppMainline = TRUE;
                    136:        status = SDL_main (gArgc, gArgv) ;
                    137: 
                    138:        // We're done, thank you for playing 
                    139:        exit(status) ;
1.1.1.6   root      140: }
                    141: 
1.1.1.13  root      142: /*----------------------------------------------------------------------*/
1.1.1.6   root      143: // Hatari Stuff
1.1.1.13  root      144: /*----------------------------------------------------------------------*/
1.1       root      145: - (IBAction)prefsMenu:(id)sender
                    146: {
                    147:        static int in_propdialog =  0;
1.1.1.6   root      148: 
1.1       root      149:        if (in_propdialog)
1.1.1.11  root      150:                return ;
                    151:        ++in_propdialog ;
                    152:        Dialog_DoProperty() ;
1.1       root      153:        --in_propdialog;
                    154: }
                    155: 
1.1.1.11  root      156: /*- (IBAction) openPreferences:(id)sender
1.1.1.9   root      157: {
                    158:        [[PrefsController prefs] loadPrefs:sender];
1.1.1.11  root      159: }                                                                                                              // */
1.1.1.9   root      160: 
1.1.1.13  root      161: /*----------------------------------------------------------------------*/
1.1.1.6   root      162: - (IBAction)debugUI:(id)sender
                    163: {
1.1.1.8   root      164:        DebugUI(REASON_USER);
1.1.1.6   root      165: }
1.1.1.13  root      166: /*----------------------------------------------------------------------*/
1.1       root      167: - (IBAction)warmReset:(id)sender
                    168: {
1.1.1.12  root      169:        if ([NSApp myAlerte:NSInformationalAlertStyle Txt:localize(@"Warm reset!") firstB:localize(@"OK") alternateB:localize(@"Cancel")
1.1.1.13  root      170:                        otherB:nil informativeTxt:localize(@"Really reset the emulator?")] == NSAlertFirstButtonReturn )
1.1       root      171:                Reset_Warm();
1.1.1.10  root      172: } 
1.1.1.13  root      173: /*----------------------------------------------------------------------*/
1.1       root      174: - (IBAction)coldReset:(id)sender
                    175: {
1.1.1.12  root      176:        if ([NSApp myAlerte:NSInformationalAlertStyle Txt:localize(@"Cold reset") firstB:localize(@"OK") alternateB:localize(@"Cancel")
1.1.1.13  root      177:                        otherB:nil informativeTxt:localize(@"Really reset the emulator?")] == NSAlertFirstButtonReturn )
1.1       root      178:                Reset_Cold();
                    179: }
1.1.1.13  root      180: /*----------------------------------------------------------------------*/
1.1       root      181: - (IBAction)insertDiskA:(id)sender
                    182: {
1.1.1.11  root      183:        [self insertDisk:0] ;
1.1       root      184: }
1.1.1.13  root      185: /*----------------------------------------------------------------------*/
1.1       root      186: - (IBAction)insertDiskB:(id)sender
                    187: {
1.1.1.11  root      188:        [self insertDisk:1] ;
                    189: }
1.1.1.13  root      190: /*----------------------------------------------------------------------*/
1.1.1.11  root      191: - (void)insertDisk:(int)disque 
                    192: {
                    193:        NSString        *aDisk ;
1.1.1.6   root      194: 
1.1.1.13  root      195:        aDisk = [NSApp hopenfile:NO defoDir:nil defoFile:@"" types:@[allF]] ;
                    196:        if (aDisk.length == 0) return ;                                 // user canceled
1.1.1.6   root      197: 
1.1.1.11  root      198:        [aDisk getCString:szPath maxLength:FILENAME_MAX-1 encoding:NSASCIIStringEncoding] ;
                    199:        Floppy_SetDiskFileName(disque, szPath, NULL) ;
                    200:        Floppy_InsertDiskIntoDrive(disque) ;
1.1       root      201: }
1.1.1.13  root      202: /*----------------------------------------------------------------------*/
                    203: - (IBAction)quit:(id)sender
                    204: {
                    205:        Main_RequestQuit(0) ;
                    206: }
1.1       root      207: 
1.1.1.13  root      208: /*----------------------------------------------------------------------*/
                    209: /*Controls the enabled state of the menu items                                                 */
                    210: /*----------------------------------------------------------------------*/
1.1       root      211: - (BOOL)validateMenuItem:(NSMenuItem*)item
                    212: {
                    213:        if (item == beginCaptureAnim)
                    214:        {
1.1.1.11  root      215:                return !Avi_AreWeRecording() ;
1.1       root      216:        }
                    217:        if (item == endCaptureAnim)
                    218:        {
1.1.1.11  root      219:                return Avi_AreWeRecording() ;
1.1       root      220:        }
                    221:        if (item == beginCaptureSound)
                    222:        {
1.1.1.11  root      223:                return !Sound_AreWeRecording() ;
1.1       root      224:        }
                    225:        if (item == endCaptureSound)
                    226:        {
1.1.1.11  root      227:                return Sound_AreWeRecording() ;
1.1       root      228:        }
                    229: 
                    230:        return YES;
                    231: }
                    232: 
1.1.1.13  root      233: /*----------------------------------------------------------------------*/
                    234: 
1.1.1.7   root      235: - (NSString*)displayFileSelection:(const char*)pathInParams preferredFileName:(NSString*)preferredFileName allowedExtensions:(NSArray*)allowedExtensions
1.1       root      236: {
1.1.1.11  root      237:        // BOOL test ;
                    238:        NSString *directoryToOpen;
                    239:        NSString *fileToPreselect;
                    240:        NSString *preferredPath;
                    241:        NSString *extensionText;
                    242:        NSString *selectFile;
1.1.1.12  root      243: 
1.1       root      244:        // Get the path from the user settings
1.1.1.11  root      245:        preferredPath = [[NSString stringWithCString:pathInParams encoding:NSASCIIStringEncoding] stringByAbbreviatingWithTildeInPath];
                    246: 
1.1.1.13  root      247:        if ((preferredPath != nil) && (preferredPath.length > 0))                                       // Determine the directory and filename
1.1.1.11  root      248:         {
1.1.1.13  root      249:                directoryToOpen = preferredPath.stringByDeletingLastPathComponent ;             // Existing path: we use it
                    250:                fileToPreselect = preferredPath.lastPathComponent;
1.1.1.11  root      251:         }
1.1       root      252:        else
1.1.1.11  root      253:         {
                    254:                directoryToOpen = [@"~" stringByExpandingTildeInPath];                                  // No path: we use the user's directory
1.1.1.7   root      255:                fileToPreselect = preferredFileName;
1.1.1.11  root      256:         }      ;
1.1.1.12  root      257: 
1.1.1.11  root      258:        if(bInFullScreen)
                    259:                Screen_ReturnFromFullScreen();
                    260:        //  SavePanel for choosing what file to write
                    261:        extensionText = [NSString stringWithFormat:localize(@"Please specify a .%@ file"), [allowedExtensions componentsJoinedByString:localize(@" or a .")] ];
1.1.1.12  root      262: 
1.1.1.11  root      263:        selectFile = [NSApp hsavefile:YES defoDir:directoryToOpen defoFile:fileToPreselect types:allowedExtensions titre:extensionText ] ;
1.1.1.13  root      264:        if (selectFile.length != 0 )
1.1.1.11  root      265:                return selectFile ;
1.1.1.12  root      266: 
1.1.1.7   root      267:        return nil;
                    268: }
1.1.1.13  root      269: /*----------------------------------------------------------------------*/
1.1.1.7   root      270: - (IBAction)captureScreen:(id)sender
                    271: {
1.1.1.13  root      272:        GuiOsx_Pause(false);
1.1.1.7   root      273:        ScreenSnapShot_SaveScreen();
                    274:        GuiOsx_Resume();
                    275: }
1.1.1.13  root      276: /*----------------------------------------------------------------------*/
1.1.1.7   root      277: - (IBAction)captureAnimation:(id)sender
                    278: {
1.1.1.13  root      279:        GuiOsx_Pause(false);
1.1.1.7   root      280:        if(!Avi_AreWeRecording()) {
1.1.1.12  root      281:                NSString* path = [self displayFileSelection:ConfigureParams.Video.AviRecordFile preferredFileName:@"hatari.avi"
1.1.1.13  root      282:                                                                         allowedExtensions:@[@"avi"]];
1.1.1.12  root      283: 
1.1.1.7   root      284:                if(path) {
                    285:                        GuiOsx_ExportPathString(path, ConfigureParams.Video.AviRecordFile, sizeof(ConfigureParams.Video.AviRecordFile));
                    286:                        Avi_StartRecording ( ConfigureParams.Video.AviRecordFile , ConfigureParams.Screen.bCrop ,
                    287:                                        ConfigureParams.Video.AviRecordFps == 0 ?
                    288:                                        ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , nScreenRefreshRate ) :
                    289:                                        (Uint32)ConfigureParams.Video.AviRecordFps << CLOCKS_TIMINGS_SHIFT_VBL ,
                    290:                                1 << CLOCKS_TIMINGS_SHIFT_VBL ,
                    291:                                ConfigureParams.Video.AviRecordVcodec );
                    292:                }
                    293:        } else {
                    294:                Avi_StopRecording();
1.1.1.6   root      295:        }
1.1.1.7   root      296:        GuiOsx_Resume();
                    297: }
1.1.1.13  root      298: /*----------------------------------------------------------------------*/
1.1.1.7   root      299: - (IBAction)endCaptureAnimation:(id)sender
                    300: {
1.1.1.13  root      301:        GuiOsx_Pause(false);
1.1.1.11  root      302:        Avi_StopRecording();
                    303:        GuiOsx_Resume();
1.1.1.7   root      304: }
1.1.1.13  root      305: /*----------------------------------------------------------------------*/
1.1.1.7   root      306: - (IBAction)captureSound:(id)sender
                    307: {
1.1.1.13  root      308:        GuiOsx_Pause(true);
1.1.1.12  root      309:        NSString* path = [self displayFileSelection:ConfigureParams.Sound.szYMCaptureFileName preferredFileName:@"hatari.wav"
1.1.1.13  root      310:                                                                 allowedExtensions:@[@"ym", @"wav"]];
1.1.1.7   root      311:        if(path) {
                    312:                GuiOsx_ExportPathString(path, ConfigureParams.Sound.szYMCaptureFileName, sizeof(ConfigureParams.Sound.szYMCaptureFileName));
                    313:                Sound_BeginRecording(ConfigureParams.Sound.szYMCaptureFileName);
                    314:        }
1.1.1.5   root      315:        GuiOsx_Resume();
1.1       root      316: }
1.1.1.13  root      317: /*----------------------------------------------------------------------*/
1.1       root      318: - (IBAction)endCaptureSound:(id)sender
                    319: {
1.1.1.13  root      320:        GuiOsx_Pause(false);
1.1       root      321:        Sound_EndRecording();
1.1.1.5   root      322:        GuiOsx_Resume();
1.1       root      323: }
1.1.1.13  root      324: /*----------------------------------------------------------------------*/
1.1       root      325: - (IBAction)saveMemorySnap:(id)sender
                    326: {
1.1.1.13  root      327:        GuiOsx_Pause(true);
1.1       root      328: 
1.1.1.12  root      329:        NSString* path = [self displayFileSelection:ConfigureParams.Memory.szMemoryCaptureFileName preferredFileName:@"hatari.sav"
1.1.1.13  root      330:         allowedExtensions:@[@"sav"]];
1.1.1.7   root      331:        if(path) {
1.1       root      332:                GuiOsx_ExportPathString(path, ConfigureParams.Memory.szMemoryCaptureFileName, sizeof(ConfigureParams.Memory.szMemoryCaptureFileName));
1.1.1.2   root      333:                MemorySnapShot_Capture(ConfigureParams.Memory.szMemoryCaptureFileName, TRUE);
1.1.1.6   root      334:        }
1.1.1.12  root      335: 
1.1.1.5   root      336:        GuiOsx_Resume();
1.1       root      337: }
1.1.1.13  root      338: /*----------------------------------------------------------------------*/
1.1       root      339: - (IBAction)restoreMemorySnap:(id)sender
                    340: {
1.1.1.12  root      341:        NSString *directoryToOpen;
                    342:        NSString *fileToPreselect;
                    343:        NSString *oldPath ;
                    344:        NSString *newPath ;
1.1       root      345: 
1.1.1.13  root      346:        GuiOsx_Pause(true);
1.1       root      347: 
                    348:        // Get the path from the user settings
1.1.1.11  root      349:        oldPath = [NSString stringWithCString:(ConfigureParams.Memory.szMemoryCaptureFileName) encoding:NSASCIIStringEncoding];
1.1.1.12  root      350: 
1.1.1.13  root      351:        if ((oldPath != nil) && (oldPath.length > 0))                                           // Determine directory and filename
                    352:         {      directoryToOpen = oldPath.stringByDeletingLastPathComponent ;   // existing path: we use it.
                    353:                fileToPreselect = oldPath.lastPathComponent ; }
1.1       root      354:        else
1.1.1.13  root      355:         {      directoryToOpen = @"~".stringByExpandingTildeInPath ;                   // Currently no path: we use user's directory
1.1.1.11  root      356:                fileToPreselect = nil; } ;
1.1.1.6   root      357: 
1.1.1.13  root      358:        newPath = [NSApp hopenfile:NO defoDir:directoryToOpen defoFile:fileToPreselect types:@[@"sav"] ] ;
                    359:        if (newPath.length != 0)                                                                                        // Perform the memory snapshot load
1.1.1.11  root      360:                MemorySnapShot_Restore([newPath cStringUsingEncoding:NSASCIIStringEncoding], TRUE);
1.1.1.6   root      361: 
1.1.1.5   root      362:        GuiOsx_Resume();
1.1       root      363: }
1.1.1.13  root      364: /*----------------------------------------------------------------------*/
1.1       root      365: - (IBAction)doFullScreen:(id)sender
                    366: {
1.1.1.12  root      367:        // A call to Screen_EnterFullScreen() would be required, but this causes a crash when using
1.1.1.11  root      368:        // SDL runtime 1.2.11, probably due to conflicts between Cocoa and SDL.
1.1       root      369:        // Therefore we simulate the fullscreen key press instead
1.1.1.12  root      370: 
1.1       root      371:        SDL_KeyboardEvent event;
1.1.1.12  root      372:        memset(&event, 0, sizeof(event));
1.1.1.6   root      373:        event.type = SDL_KEYDOWN;
                    374:        event.state = SDL_PRESSED;
                    375:        event.keysym.sym = SDLK_F11;
                    376:        SDL_PushEvent((SDL_Event*)&event);      // Send the F11 key press
                    377:        event.type = SDL_KEYUP;
                    378:        event.state = SDL_RELEASED;
                    379:        SDL_PushEvent((SDL_Event*)&event);      // Send the F11 key release
1.1       root      380: }
                    381: 
1.1.1.13  root      382: /*----------------------------------------------------------------------*/
1.1       root      383: - (IBAction)help:(id)sender
                    384: {
1.1.1.11  root      385:        NSString *the_help;
1.1.1.12  root      386: 
1.1.1.11  root      387:        the_help = [[NSBundle mainBundle] pathForResource:@"manual" ofType:@"html" inDirectory:@"HatariHelp"];
1.1.1.12  root      388: 
1.1.1.13  root      389:        [[NSWorkspace sharedWorkspace] openFile:the_help];
1.1       root      390: }
1.1.1.13  root      391: /*----------------------------------------------------------------------*/
1.1.1.10  root      392: - (IBAction)compat:(id)sender
                    393: {
1.1.1.13  root      394:        NSString *the_help ;
1.1.1.12  root      395: 
1.1.1.13  root      396:        the_help = [[NSBundle mainBundle] pathForResource:@"compatibility" ofType:@"html" inDirectory:@"HatariHelp"] ;
1.1.1.12  root      397: 
1.1.1.13  root      398:        [[NSWorkspace sharedWorkspace] openFile:the_help];
1.1.1.10  root      399: }
1.1.1.13  root      400: /*----------------------------------------------------------------------*/
                    401: - (IBAction)PauseMenu:(id)sender {
                    402:        if(!emulationPaused)
                    403:        {
                    404:                GuiOsx_Pause(true);
                    405:                emulationPaused=YES;
                    406:                [pauseMenuItem setState:NSOnState];
                    407:        }
                    408:        else
                    409:        {
                    410:                GuiOsx_Resume();
                    411:                emulationPaused=NO;
                    412:                [pauseMenuItem setState:NSOffState];
                    413:        }
                    414: }
                    415: /*----------------------------------------------------------------------*/
1.1.1.12  root      416: - (IBAction)openConfig:(id)sender
1.1.1.9   root      417: {
1.1.1.12  root      418:        BOOL            applyChanges ;
                    419:        NSString        *ConfigFile, *newCfg ;
                    420:        CNF_PARAMS      CurrentParams;
1.1.1.11  root      421: 
                    422:        applyChanges = true ;
1.1.1.12  root      423:        ConfigFile = [NSString stringWithCString:(sConfigFileName) encoding:NSASCIIStringEncoding];
                    424: 
1.1.1.9   root      425:        // Backup of configuration settings to CurrentParams (which we will only
                    426:        // commit back to the configuration settings if choosing user confirm)
                    427:        CurrentParams = ConfigureParams;
1.1.1.12  root      428: 
1.1.1.13  root      429:        GuiOsx_Pause(true);
1.1.1.12  root      430: 
1.1.1.13  root      431:        newCfg = [NSApp hopenfile:NO defoDir:nil defoFile:ConfigFile types:@[@"cfg"] ] ;
1.1.1.12  root      432: 
1.1.1.13  root      433:        if (newCfg.length != 0)
1.1.1.12  root      434:        {
1.1.1.11  root      435:                [newCfg getCString:szPath maxLength:FILENAME_MAX-1 encoding:NSASCIIStringEncoding] ;    // get Cstring  szPath
                    436:                Configuration_Load(szPath) ;                                                                                                                    // Load the config into ConfigureParams
                    437:                strcpy(sConfigFileName,szPath) ;
                    438: 
1.1.1.12  root      439:                // Refresh all the controls to match ConfigureParams
1.1.1.9   root      440:                if (Change_DoNeedReset(&CurrentParams, &ConfigureParams))
1.1.1.12  root      441:                        applyChanges = [NSApp myAlerte:NSInformationalAlertStyle Txt:localize(@"Reset the emulator") firstB:localize(@"Don't reset")
1.1.1.15! root      442:                                alternateB:localize(@"Reset") otherB:nil informativeTxt:@"" ] == NSAlertSecondButtonReturn ;
1.1.1.9   root      443:                if (applyChanges)
1.1.1.13  root      444:                        Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, true);        // Ok with Reset
1.1.1.12  root      445:                else
1.1.1.11  root      446:                        ConfigureParams = CurrentParams;   //Restore previous Params.
1.1.1.12  root      447:        } ;
                    448: 
1.1.1.9   root      449:        GuiOsx_Resume();
1.1       root      450: }
                    451: 
1.1.1.13  root      452: /*----------------------------------------------------------------------*/
1.1.1.6   root      453: - (IBAction)saveConfig:(id)sender {
1.1       root      454: }
                    455: 
                    456: @end
1.1.1.13  root      457: /*----------------------------------------------------------------------*/
1.1.1.12  root      458: static int IsRootCwd()
                    459: {
                    460:        char buf[MAXPATHLEN];
                    461:        char *cwd = getcwd(buf, sizeof (buf));
                    462:        return (cwd && (strcmp(cwd, "/") == 0));
                    463: }
1.1.1.13  root      464: /*----------------------------------------------------------------------*/
1.1.1.12  root      465: static int IsTenPointNineOrLater()
                    466: {
1.1.1.13  root      467:        // OK for 10.9, but before ??
                    468:        NSOperatingSystemVersion systemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];  
                    469:        int r=(systemVersion.majorVersion==10) && (systemVersion.minorVersion>=9);
1.1.1.12  root      470: 
1.1.1.13  root      471:        return r;
                    472: }
                    473: /*----------------------------------------------------------------------*/
1.1.1.12  root      474: static int IsFinderLaunch(const int argc, char **argv)
                    475: {
                    476:        /* -psn_XXX is passed if we are launched from Finder in 10.8 and earlier */
                    477:        if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) {
                    478:                return 1;
                    479:        }
                    480:        if (IsTenPointNineOrLater() && argc == 1 && IsRootCwd()) {
                    481:                /* we might still be launched from the Finder; on 10.9+, you might not
                    482:                get the -psn command line anymore. Check version, if there's no
                    483:                command line, and if our current working directory is "/". */
                    484:                return 1;
                    485:        }
1.1.1.13  root      486:        return 0;                                       /* not a Finder launch. */
1.1.1.12  root      487: }
                    488: 
1.1       root      489: #ifdef main
                    490: #  undef main
                    491: #endif
1.1.1.13  root      492: /*----------------------------------------------------------------------*/
1.1.1.12  root      493: // Main entry point to executable - should *not* be SDL_main!
1.1.1.13  root      494: /*----------------------------------------------------------------------*/
1.1       root      495: int main (int argc, char **argv)
                    496: {
1.1.1.12  root      497:        // Copy the arguments into a global variable
                    498:        if (IsFinderLaunch(argc, argv)) {
                    499:                gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
                    500:                gArgv[0] = argv[0];
                    501:                gArgv[1] = NULL;
                    502:                gArgc = 1;
                    503:                gFinderLaunch = YES;
                    504:        } else {
                    505:                int i;
                    506:                gArgc = argc;
                    507:                gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
                    508:                for (i = 0; i <= argc; i++)
                    509:                        gArgv[i] = argv[i];
                    510:                gFinderLaunch = NO;
                    511:        }
1.1       root      512: 
1.1.1.6   root      513: #if SDL_USE_NIB_FILE
1.1.1.12  root      514:        NSApplicationMain (argc, (const char**)argv);
1.1.1.6   root      515: #else
1.1.1.12  root      516:        CustomApplicationMain (argc, argv);
1.1.1.6   root      517: #endif
1.1.1.12  root      518:        return 0;
                    519: }

unix.superglobalmegacorp.com

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