| 3474 | | |
|---|
| 3475 | | /* |
|---|
| 3476 | | * We ignore the validity check, because we trust the FInder, and we only |
|---|
| 3477 | | * allow one savefile to be opened, so we ignore the depth of the list. |
|---|
| 3478 | | */ |
|---|
| 3479 | | err = AEGetNthPtr( |
|---|
| 3480 | | &docList, 1L, typeFSS, &keywd, &returnedType, |
|---|
| 3481 | | (Ptr) &myFSS, sizeof(myFSS), &actualSize); |
|---|
| | 3457 | |
|---|
| | 3458 | err = AECountItems(&docList, &filecount); |
|---|
| 3484 | | /* Only needed to check savefile type below */ |
|---|
| 3485 | | err = FSpGetFInfo(&myFSS, &myFileInfo); |
|---|
| 3486 | | if (err) |
|---|
| 3487 | | { |
|---|
| 3488 | | strnfmt(msg, sizeof(msg), "Argh! FSpGetFInfo failed with code %d", err); |
|---|
| 3489 | | mac_warning(msg); |
|---|
| 3490 | | return err; |
|---|
| 3491 | | } |
|---|
| 3492 | | |
|---|
| 3493 | | /* Ignore non 'SAVE' files */ |
|---|
| 3494 | | if (myFileInfo.fdType != 'SAVE') return noErr; |
|---|
| 3495 | | |
|---|
| 3496 | | /* Extract a file name */ |
|---|
| 3497 | | (void)spec_to_path(&myFSS, savefile, sizeof(savefile)); |
|---|
| 3498 | | |
|---|
| 3499 | | /* Delay actual open */ |
|---|
| 3500 | | open_when_ready = TRUE; |
|---|
| | 3461 | /* Only open one file, but check for the first valid file in the list */ |
|---|
| | 3462 | for (fileindex = 1; fileindex <= filecount; fileindex++) |
|---|
| | 3463 | { |
|---|
| | 3464 | err = AEGetNthPtr(&docList, fileindex, typeFSS, NULL, NULL, &myFSS, sizeof(myFSS), NULL); |
|---|
| | 3465 | if (err) continue; |
|---|
| | 3466 | |
|---|
| | 3467 | err = FSpGetFInfo(&myFSS, &myFileInfo); |
|---|
| | 3468 | if (err) continue; |
|---|
| | 3469 | |
|---|
| | 3470 | if (myFileInfo.fdType == 'SAVE') |
|---|
| | 3471 | { |
|---|
| | 3472 | |
|---|
| | 3473 | /* Extract the filename and delay the open */ |
|---|
| | 3474 | (void)spec_to_path(&myFSS, savefile, sizeof(savefile)); |
|---|
| | 3475 | cmd.command = CMD_LOADFILE; |
|---|
| | 3476 | |
|---|
| | 3477 | break; |
|---|
| | 3478 | } |
|---|
| | 3479 | } |
|---|
| 3507 | | } |
|---|
| 3508 | | |
|---|
| 3509 | | /* |
|---|
| 3510 | | * Apple Event Handler -- Re-open Application |
|---|
| 3511 | | * |
|---|
| 3512 | | * If no windows are currently open, show the Angband window. |
|---|
| 3513 | | * This required AppleEvent was introduced by System 8 -- pelpel |
|---|
| 3514 | | */ |
|---|
| 3515 | | static OSErr AEH_Reopen(const AppleEvent *theAppleEvent, |
|---|
| 3516 | | AppleEvent* reply, long handlerRefCon) |
|---|
| 3517 | | { |
|---|
| 3518 | | #pragma unused(theAppleEvent, reply, handlerRefCon) |
|---|
| 3519 | | |
|---|
| 3520 | | term_data *td = NULL; |
|---|
| 3521 | | |
|---|
| 3522 | | /* No open windows */ |
|---|
| 3523 | | if (NULL == FrontWindow()) |
|---|
| 3524 | | { |
|---|
| 3525 | | /* Obtain the Angband window */ |
|---|
| 3526 | | td = &data[0]; |
|---|
| 3527 | | |
|---|
| 3528 | | /* Mapped */ |
|---|
| 3529 | | td->mapped = TRUE; |
|---|
| 3530 | | |
|---|
| 3531 | | /* Link */ |
|---|
| 3532 | | term_data_link(0); |
|---|
| 3533 | | |
|---|
| 3534 | | /* Mapped (?) */ |
|---|
| 3535 | | td->t->mapped_flag = TRUE; |
|---|
| 3536 | | |
|---|
| 3537 | | /* Show the window */ |
|---|
| 3538 | | ShowWindow(td->w); |
|---|
| 3539 | | |
|---|
| 3540 | | /* Bring to the front */ |
|---|
| 3541 | | SelectWindow(td->w); |
|---|
| 3542 | | |
|---|
| 3543 | | /* Make it active */ |
|---|
| 3544 | | activate(td->w); |
|---|
| 3545 | | } |
|---|
| 3546 | | /* Event handled */ |
|---|
| 3547 | | return (noErr); |
|---|