4 |
|
* |
5 |
|
* $Id$ |
6 |
|
* |
7 |
< |
* Basilisk II (C) 1997-2001 Christian Bauer |
7 |
> |
* Basilisk II (C) 1997-2003 Christian Bauer |
8 |
|
* |
9 |
|
* This program is free software; you can redistribute it and/or modify |
10 |
|
* it under the terms of the GNU General Public License as published by |
30 |
|
self = [super init]; |
31 |
|
|
32 |
|
numItems = 0; |
33 |
< |
col1 = [[NSMutableArray alloc] init]; |
34 |
< |
col2 = [[NSMutableArray alloc] init]; |
33 |
> |
col1 = [NSMutableArray new]; |
34 |
> |
col2 = [NSMutableArray new]; |
35 |
|
|
36 |
|
return self; |
37 |
|
} |
109 |
|
|
110 |
|
#import <AppKit/NSImage.h> // For [NSBundle pathForImageResource:] proto |
111 |
|
|
112 |
+ |
#include <string> |
113 |
+ |
using std::string; |
114 |
+ |
extern string UserPrefsPath; // from prefs_unix.cpp |
115 |
+ |
|
116 |
|
#import "sysdeps.h" // Types used in Basilisk C++ code |
117 |
|
#import "video_macosx.h" // some items that we edit here |
118 |
|
#import "misc_macosx.h" // WarningSheet() prototype |
130 |
|
|
131 |
|
devs = @"/dev"; |
132 |
|
home = NSHomeDirectory(); |
133 |
< |
volsDS = [[TableDS alloc] init]; |
134 |
< |
SCSIds = [[TableDS alloc] init]; |
133 |
> |
volsDS = [TableDS new]; |
134 |
> |
SCSIds = [TableDS new]; |
135 |
|
|
136 |
< |
lockCell = [[NSImageCell alloc] init]; |
136 |
> |
lockCell = [NSImageCell new]; |
137 |
|
if ( lockCell == nil ) |
138 |
|
NSLog (@"%s - Can't create NSImageCell?", __PRETTY_FUNCTION__); |
139 |
|
|
140 |
< |
blank = [[NSImage alloc] init]; |
140 |
> |
blank = [NSImage new]; |
141 |
|
locked = [NSImage alloc]; |
142 |
|
if ( [locked initWithContentsOfFile: |
143 |
|
[[NSBundle mainBundle] |
222 |
|
} |
223 |
|
} |
224 |
|
|
225 |
+ |
- (IBAction) BrowsePrefs: (id)sender |
226 |
+ |
{ |
227 |
+ |
NSOpenPanel *oP = [NSOpenPanel openPanel]; |
228 |
+ |
|
229 |
+ |
[oP setCanChooseFiles: YES]; |
230 |
+ |
[oP setTitle: @"Select a Preferences file"]; |
231 |
+ |
D(NSLog(@"%s - home = %@", __PRETTY_FUNCTION__, home)); |
232 |
+ |
if ( [oP runModalForDirectory: ([prefsFile stringValue] ? [prefsFile stringValue] : home) |
233 |
+ |
file:nil |
234 |
+ |
types:nil] == NSOKButton ) |
235 |
+ |
{ |
236 |
+ |
[prefsFile setStringValue: [oP filename] ]; |
237 |
+ |
UserPrefsPath = [[oP filename] cString]; |
238 |
+ |
} |
239 |
+ |
} |
240 |
+ |
|
241 |
|
- (IBAction) BrowseROM: (id)sender |
242 |
|
{ |
243 |
|
NSOpenPanel *oP = [NSOpenPanel openPanel]; |
295 |
|
edited = YES; |
296 |
|
} |
297 |
|
|
298 |
+ |
- (IBAction) ChangeKeyboard: (NSPopUpButton *)sender |
299 |
+ |
{ |
300 |
+ |
// Deselest current item |
301 |
+ |
int val = PrefsFindInt32("keyboardtype"); |
302 |
+ |
int current = [keyboard indexOfItemWithTag: val]; |
303 |
+ |
|
304 |
+ |
if ( current ) |
305 |
+ |
[[keyboard itemAtIndex: current] setState: FALSE]; |
306 |
+ |
|
307 |
+ |
PrefsReplaceInt32("keyboardtype", [[sender selectedItem] tag]); |
308 |
+ |
edited = YES; |
309 |
+ |
} |
310 |
+ |
|
311 |
|
- (IBAction) ChangeModel: (NSMatrix *)sender |
312 |
|
{ |
313 |
|
PrefsReplaceInt32("modelid", [[sender selectedCell] tag]); |
314 |
|
edited = YES; |
315 |
|
} |
316 |
|
|
317 |
< |
// This is called when any of the screen/openGL/window, |
317 |
> |
|
318 |
> |
// If we are not using the CGIMAGEREF drawing strategy, |
319 |
> |
// then source bitmaps must be 32bits deep. |
320 |
> |
|
321 |
> |
- (short) testWinDepth: (int) newbpp |
322 |
> |
{ |
323 |
> |
#ifdef CGIMAGEREF |
324 |
> |
return newbpp; |
325 |
> |
#else |
326 |
> |
if ( newbpp != 32 ) |
327 |
> |
WarningSheet(@"Sorry - In windowed mode, depth must be 32", panel); |
328 |
> |
return 32 |
329 |
> |
#endif |
330 |
> |
} |
331 |
> |
|
332 |
> |
// This is called when the screen/window, |
333 |
|
// width, height or depth is clicked. |
334 |
|
// |
335 |
|
// Note that sender may not actually be an NSMatrix. |
344 |
|
short newtype; |
345 |
|
char str[20]; |
346 |
|
|
347 |
< |
if ( cell == openGL ) |
300 |
< |
newtype = DISPLAY_OPENGL; |
301 |
< |
else if ( cell == screen ) |
347 |
> |
if ( cell == screen ) |
348 |
|
newtype = DISPLAY_SCREEN; |
349 |
|
else if ( cell == window ) |
350 |
|
newtype = DISPLAY_WINDOW; |
360 |
|
} |
361 |
|
|
362 |
|
// If we are changing type, supply some sensible defaults |
363 |
+ |
|
364 |
+ |
short screenx = CGDisplayPixelsWide(kCGDirectMainDisplay), |
365 |
+ |
screeny = CGDisplayPixelsHigh(kCGDirectMainDisplay), |
366 |
+ |
screenb = CGDisplayBitsPerPixel(kCGDirectMainDisplay); |
367 |
+ |
|
368 |
|
if ( newtype != display_type ) |
369 |
|
{ |
370 |
|
D(NSLog(@"Changing display type in ChangeScreen")); |
320 |
– |
if ( newtype == DISPLAY_SCREEN ) // If changing to full screen |
321 |
– |
{ |
322 |
– |
// supply main screen dimensions as a default |
323 |
– |
newx = CGDisplayPixelsWide (kCGDirectMainDisplay); |
324 |
– |
newy = CGDisplayPixelsHigh (kCGDirectMainDisplay); |
325 |
– |
newbpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay); |
326 |
– |
} |
371 |
|
|
372 |
< |
if ( display_type == DISPLAY_SCREEN ) // If changing from full screen |
372 |
> |
// If changing to full screen, supply main screen dimensions as a default |
373 |
> |
if ( newtype == DISPLAY_SCREEN ) |
374 |
> |
newx = screenx, newy = screeny, newbpp = screenb; |
375 |
> |
|
376 |
> |
// If changing from full screen, use minimum screen resolutions |
377 |
> |
if ( display_type == DISPLAY_SCREEN ) |
378 |
> |
{ |
379 |
|
newx = MIN_WIDTH, newy = MIN_HEIGHT; |
380 |
< |
|
381 |
< |
[width setIntValue: newx]; |
332 |
< |
[height setIntValue: newy]; |
333 |
< |
[depth setIntValue: newbpp]; |
380 |
> |
newbpp = [self testWinDepth: newbpp]; |
381 |
> |
} |
382 |
|
} |
383 |
|
else |
384 |
|
{ |
385 |
+ |
newbpp = [self testWinDepth: newbpp]; |
386 |
+ |
|
387 |
|
// Check size is within ranges of MIN_WIDTH ... MAX_WIDTH |
388 |
|
// and MIN_HEIGHT ... MAX_HEIGHT |
389 |
|
// ??? |
390 |
|
} |
391 |
|
|
392 |
+ |
[width setIntValue: newx]; |
393 |
+ |
[height setIntValue: newy]; |
394 |
+ |
[depth setIntValue: newbpp]; |
395 |
+ |
|
396 |
|
|
397 |
|
// Store new prefs |
398 |
|
*str = '\0'; |
404 |
|
else |
405 |
|
sprintf(str, "win/%hd/%hd", newx, newy); |
406 |
|
break; |
353 |
– |
case DISPLAY_OPENGL: |
354 |
– |
if ( newbpp ) |
355 |
– |
sprintf(str, "opengl/%hd/%hd/%hd", newx, newy, newbpp); |
356 |
– |
else |
357 |
– |
sprintf(str, "opengl/%hd/%hd", newx, newy); |
358 |
– |
break; |
407 |
|
case DISPLAY_SCREEN: |
408 |
|
if ( newbpp ) |
409 |
|
sprintf(str, "full/%hd/%hd/%hd", newx, newy, newbpp); |
459 |
|
} |
460 |
|
} |
461 |
|
|
462 |
+ |
- (BOOL) fileManager: (NSFileManager *) manager |
463 |
+ |
shouldProceedAfterError: (NSDictionary *) errorDict |
464 |
+ |
{ |
465 |
+ |
NSRunAlertPanel(@"File operation error", |
466 |
+ |
@"%@ %@, toPath %@", |
467 |
+ |
@"Bugger!", nil, nil, |
468 |
+ |
[errorDict objectForKey:@"Error"], |
469 |
+ |
[errorDict objectForKey:@"Path"], |
470 |
+ |
[errorDict objectForKey:@"ToPath"]); |
471 |
+ |
return NO; |
472 |
+ |
} |
473 |
+ |
|
474 |
|
- (IBAction) DeleteVolume: (id)sender |
475 |
|
{ |
476 |
< |
const char *path = [self RemoveVolumeEntry]; |
477 |
< |
if ( unlink(path) == -1 ) |
476 |
> |
// const char *path = [self RemoveVolumeEntry]; |
477 |
> |
// if ( unlink(path) == -1 ) |
478 |
> |
NSString *Path = [self RemoveVolumeEntry]; |
479 |
> |
|
480 |
> |
if ( ! [[NSFileManager defaultManager] removeFileAtPath: Path |
481 |
> |
handler: self] ) |
482 |
|
{ |
483 |
< |
NSLog(@"%s unlink(%s) failed", __PRETTY_FUNCTION__, path, strerror(errno)); |
483 |
> |
WarningSheet(@"Unable to delete volume", panel); |
484 |
> |
// NSLog(@"%s unlink(%s) failed - %s", __PRETTY_FUNCTION__, path, strerror(errno)); |
485 |
|
} |
486 |
|
} |
487 |
|
|
584 |
|
PrefsRemoveItem(pref,0); |
585 |
|
} |
586 |
|
|
587 |
< |
- (const char *) RemoveVolumeEntry |
587 |
> |
//- (const char *) RemoveVolumeEntry |
588 |
> |
- (NSString *) RemoveVolumeEntry |
589 |
|
{ |
590 |
|
int row = [diskImages selectedRow]; |
591 |
|
|
592 |
|
if ( row != -1 ) |
593 |
|
{ |
594 |
< |
const char *path = [[volsDS pathAtRow: row] cString], |
594 |
> |
NSString *Path = [volsDS pathAtRow: row]; |
595 |
> |
const char *path = [Path cString], |
596 |
|
*str; |
597 |
|
int tmp = 0; |
598 |
|
|
619 |
|
if ( ! [volsDS deleteRow: row] ) |
620 |
|
NSLog (@"%s - RemoveVolume %d failed", __PRETTY_FUNCTION__, tmp); |
621 |
|
[diskImages reloadData]; |
622 |
< |
return path; |
622 |
> |
// return path; |
623 |
> |
return Path; |
624 |
|
} |
625 |
|
else |
626 |
|
{ |
634 |
|
[self RemoveVolumeEntry]; |
635 |
|
} |
636 |
|
|
637 |
< |
- (IBAction) ResetPrefs: (id)sender |
637 |
> |
- (void) loadPrefs: (int) argc |
638 |
> |
args: (char **) argv |
639 |
|
{ |
571 |
– |
int argc = 0; |
572 |
– |
char **argv = NULL; |
573 |
– |
|
640 |
|
[panel close]; // Temporarily hide preferences panel |
641 |
|
|
642 |
|
PrefsExit(); // Purge all the old pref values |
652 |
|
edited = NO; |
653 |
|
} |
654 |
|
|
655 |
+ |
- (IBAction) LoadPrefs: (id)sender |
656 |
+ |
{ |
657 |
+ |
int argc = 2; |
658 |
+ |
char *argv[2]; |
659 |
+ |
|
660 |
+ |
argv[0] = "--prefs", |
661 |
+ |
argv[1] = (char *) [[prefsFile stringValue] cString]; |
662 |
+ |
|
663 |
+ |
[self loadPrefs: argc |
664 |
+ |
args: argv]; |
665 |
+ |
} |
666 |
+ |
|
667 |
+ |
- (IBAction) ResetPrefs: (id)sender |
668 |
+ |
{ |
669 |
+ |
[self loadPrefs: 0 |
670 |
+ |
args: NULL]; |
671 |
+ |
} |
672 |
+ |
|
673 |
|
- (void) setStringOf: (NSTextField *) field |
674 |
|
fromPref: (const char *) prefName |
675 |
|
{ |
689 |
|
{ |
690 |
|
NSTableColumn *locks; |
691 |
|
const char *str; |
692 |
< |
int cpu, tmp; |
692 |
> |
int cpu, tmp, val; |
693 |
|
|
694 |
|
|
695 |
|
// Set simple single field items |
696 |
|
|
697 |
< |
tmp = PrefsFindInt32("frameskip"); |
698 |
< |
[delay setIntValue: tmp]; |
699 |
< |
if ( tmp ) |
700 |
< |
[frequency setFloatValue: 60.0 / tmp]; |
697 |
> |
val = PrefsFindInt32("frameskip"); |
698 |
> |
[delay setIntValue: val]; |
699 |
> |
if ( val ) |
700 |
> |
[frequency setFloatValue: 60.0 / val]; |
701 |
|
else |
702 |
|
[frequency setFloatValue: 60.0]; |
703 |
|
|
704 |
< |
tmp = PrefsFindInt32("ramsize"); |
705 |
< |
[bytes setIntValue: tmp]; |
706 |
< |
[MB setFloatValue: tmp / (1024.0 * 1024.0)]; |
704 |
> |
val = PrefsFindInt32("ramsize"); |
705 |
> |
[bytes setIntValue: val]; |
706 |
> |
[MB setFloatValue: val / (1024.0 * 1024.0)]; |
707 |
|
|
708 |
|
[disableCD setState: PrefsFindBool("nocdrom")]; |
709 |
|
[disableSound setState: PrefsFindBool("nosound")]; |
715 |
|
[self setStringOf: printer fromPref: "serialb"]; |
716 |
|
[self setStringOf: ROMfile fromPref: "rom" ]; |
717 |
|
|
718 |
+ |
[prefsFile setStringValue: [NSString stringWithCString: UserPrefsPath.c_str()] ]; |
719 |
+ |
|
720 |
|
|
721 |
|
parse_screen_prefs(PrefsFindString("screen")); |
722 |
|
|
724 |
|
[height setIntValue: init_height]; |
725 |
|
[depth setIntValue: init_depth]; |
726 |
|
|
727 |
< |
[window setState: NO]; |
727 |
> |
[screen setState: NO]; |
728 |
|
switch ( display_type ) |
729 |
|
{ |
730 |
|
case DISPLAY_WINDOW: [window setState: YES]; break; |
645 |
– |
case DISPLAY_OPENGL: [openGL setState: YES]; break; |
731 |
|
case DISPLAY_SCREEN: [screen setState: YES]; break; |
732 |
|
} |
733 |
|
|
735 |
|
|
736 |
|
// Radio button groups: |
737 |
|
|
738 |
< |
tmp = PrefsFindInt32("bootdriver"); |
739 |
< |
[bootFromAny setState: tmp != CDROMRefNum]; |
740 |
< |
[bootFromCD setState: tmp == CDROMRefNum]; |
738 |
> |
val = PrefsFindInt32("bootdriver"); |
739 |
> |
[bootFromAny setState: val != CDROMRefNum]; |
740 |
> |
[bootFromCD setState: val == CDROMRefNum]; |
741 |
|
|
742 |
|
cpu = PrefsFindInt32("cpu"); |
743 |
< |
tmp = PrefsFindInt32("modelid"); |
743 |
> |
val = PrefsFindInt32("modelid"); |
744 |
|
|
745 |
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
746 |
|
puts("Current memory model does not support 24bit addressing"); |
747 |
< |
if ( tmp == [classic tag] ) |
747 |
> |
if ( val == [classic tag] ) |
748 |
|
{ |
749 |
|
// Window already created by NIB file, just display |
750 |
|
[panel makeKeyAndOrderFront:self]; |
752 |
|
@"Disabling Mac Classic emulation", nil, panel); |
753 |
|
cpu = [CPU68030 tag]; |
754 |
|
PrefsReplaceInt32("cpu", cpu); |
755 |
< |
tmp = [IIci tag]; |
756 |
< |
PrefsReplaceInt32("modelid", tmp); |
755 |
> |
val = [IIci tag]; |
756 |
> |
PrefsReplaceInt32("modelid", val); |
757 |
|
} |
758 |
|
|
759 |
|
puts("Disabling 68000 & Mac Classic buttons"); |
766 |
|
[CPU68030 setState: [CPU68030 tag] == cpu]; |
767 |
|
[CPU68040 setState: [CPU68040 tag] == cpu]; |
768 |
|
|
769 |
< |
[classic setState: [classic tag] == tmp]; |
770 |
< |
[IIci setState: [IIci tag] == tmp]; |
771 |
< |
[quadra900 setState: [quadra900 tag] == tmp]; |
769 |
> |
[classic setState: [classic tag] == val]; |
770 |
> |
[IIci setState: [IIci tag] == val]; |
771 |
> |
[quadra900 setState: [quadra900 tag] == val]; |
772 |
|
|
773 |
|
|
774 |
|
// Lists of thingies: |
775 |
|
|
776 |
+ |
val = PrefsFindInt32("keyboardtype"); |
777 |
+ |
[keyboard selectItemAtIndex: [keyboard indexOfItemWithTag: val]]; |
778 |
+ |
for ( tmp = 0; tmp < [keyboard numberOfItems]; ++tmp ) |
779 |
+ |
{ |
780 |
+ |
NSMenuItem *type = [keyboard itemAtIndex: tmp]; |
781 |
+ |
[type setState: [type tag] == val]; |
782 |
+ |
} |
783 |
+ |
|
784 |
+ |
|
785 |
|
for ( tmp = 0; tmp < 7; ++tmp) |
786 |
|
{ |
787 |
|
char pref[6]; |