ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/PrefsEditor.mm
Revision: 1.11
Committed: 2003-08-16T02:51:46Z (21 years, 1 month ago) by nigel
Branch: MAIN
Changes since 1.10: +41 -19 lines
Log Message:
Extra code for keyboardtype popup menu, renamed a variable

File Contents

# User Rev Content
1 nigel 1.1 /*
2     * PrefsEditor.m - GUI stuff for Basilisk II preferences
3     * (which is a text file in the user's home directory)
4     *
5 nigel 1.11 * $Id: PrefsEditor.mm,v 1.10 2003/04/02 02:19:53 nigel Exp $
6 nigel 1.1 *
7 nigel 1.7 * Basilisk II (C) 1997-2003 Christian Bauer
8 nigel 1.1 *
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
11     * the Free Software Foundation; either version 2 of the License, or
12     * (at your option) any later version.
13     *
14     * This program is distributed in the hope that it will be useful,
15     * but WITHOUT ANY WARRANTY; without even the implied warranty of
16     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     * GNU General Public License for more details.
18     *
19     * You should have received a copy of the GNU General Public License
20     * along with this program; if not, write to the Free Software
21     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22     */
23    
24     #import "PrefsEditor.h"
25    
26     @implementation TableDS
27    
28     - (TableDS *) init
29     {
30     self = [super init];
31    
32     numItems = 0;
33 nigel 1.5 col1 = [NSMutableArray new];
34     col2 = [NSMutableArray new];
35 nigel 1.1
36     return self;
37     }
38    
39     - (void) dealloc
40     {
41     [col1 dealloc];
42     [col2 dealloc];
43     [super dealloc];
44     }
45    
46     - (void) addInt: (int)target
47     withPath: (NSString *)path
48     {
49     [col1 addObject: [NSNumber numberWithInt: target]];
50     [col2 addObject: path];
51     ++numItems;
52     }
53    
54     - (void) addObject: (NSObject *)obj
55     withPath: (NSString *)path
56     {
57     [col1 addObject: obj];
58     [col2 addObject: path];
59     ++numItems;
60     }
61    
62     - (void) deleteAll
63     {
64     numItems = 0;
65     [col1 removeAllObjects];
66     [col2 removeAllObjects];
67     }
68    
69     - (BOOL) deleteRow: (int)row
70     {
71     if ( row > numItems )
72     return NO;
73    
74     [col1 removeObjectAtIndex: row];
75     [col2 removeObjectAtIndex: row];
76     -- numItems;
77    
78     return YES;
79     }
80    
81     - (int)intAtRow: (int)row
82     {
83     return [[col1 objectAtIndex: row] intValue];
84     }
85    
86     - (int) numberOfRowsInTableView: (NSTableView *)tView
87     {
88     return numItems;
89     }
90    
91     - (NSString *)pathAtRow: (int)row
92     {
93     return (NSString *) [col2 objectAtIndex: row];
94     }
95    
96     - (id) tableView: (NSTableView *)tView
97     objectValueForTableColumn: (NSTableColumn *)tColumn
98     row: (int)row
99     {
100     if ( [[tColumn identifier] isEqualToString:@"path"] )
101     return [col2 objectAtIndex: row];
102     else
103     return [col1 objectAtIndex: row];
104     }
105    
106     @end
107    
108     @implementation PrefsEditor
109    
110     #import <AppKit/NSImage.h> // For [NSBundle pathForImageResource:] proto
111    
112 nigel 1.10 #include <string>
113     using std::string;
114     extern string UserPrefsPath; // from prefs_unix.cpp
115    
116 nigel 1.1 #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
119    
120     #import <prefs.h>
121    
122 nigel 1.3 #define DEBUG 0
123 nigel 1.1 #import <debug.h>
124    
125     - (PrefsEditor *) init
126     {
127     self = [super init];
128    
129     edited = NO;
130    
131     devs = @"/dev";
132     home = NSHomeDirectory();
133 nigel 1.5 volsDS = [TableDS new];
134     SCSIds = [TableDS new];
135 nigel 1.1
136 nigel 1.5 lockCell = [NSImageCell new];
137 nigel 1.1 if ( lockCell == nil )
138     NSLog (@"%s - Can't create NSImageCell?", __PRETTY_FUNCTION__);
139    
140 nigel 1.5 blank = [NSImage new];
141 nigel 1.1 locked = [NSImage alloc];
142     if ( [locked initWithContentsOfFile:
143     [[NSBundle mainBundle]
144     pathForImageResource: @"nowrite.icns"]] == nil )
145     NSLog(@"%s - Couldn't open write protection image", __PRETTY_FUNCTION__);
146    
147     return self;
148     }
149    
150     - (void) dealloc
151     {
152     [volsDS dealloc];
153     [SCSIds dealloc];
154     [lockCell dealloc];
155     [locked dealloc];
156     [blank dealloc];
157     [super dealloc];
158     }
159    
160     - (void) awakeFromNib
161     {
162     emuFreq = [theEmulator speed];
163     #if DEBUG
164     [self ShowPrefs: self]; // For testing
165     #endif
166     }
167    
168     - (BOOL) hasEdited
169     {
170     return edited;
171     }
172    
173     - (NSWindow *) window
174     {
175     return panel;
176     }
177    
178     - (IBAction) AddSCSI: (id)sender
179     {
180     NSOpenPanel *oP = [NSOpenPanel openPanel];
181    
182     if ( [oP runModalForDirectory:home file:nil types:nil] == NSOKButton )
183     {
184     [SCSIds addInt: -1
185     withPath: [oP filename] ];
186     [SCSIdisks reloadData];
187     edited = YES;
188     }
189     }
190    
191     - (IBAction) AddVolume: (id)sender
192     {
193     NSOpenPanel *oP = [NSOpenPanel openPanel];
194    
195     if ( [oP runModalForDirectory:home file:nil types:nil] == NSOKButton )
196     {
197     [volsDS addObject: (NSObject *) locked
198     withPath: [oP filename] ];
199     PrefsAddString("disk", [[oP filename] cString]);
200     [diskImages reloadData];
201     edited = YES;
202     }
203     }
204    
205     - (IBAction) BrowseExtFS: (id)sender
206     {
207     NSOpenPanel *oP = [NSOpenPanel openPanel];
208    
209     [oP setCanChooseDirectories: YES];
210     [oP setCanChooseFiles: NO];
211     [oP setPrompt: @"Select"];
212     [oP setTitle: @"Select a directory to mount"];
213     D(NSLog(@"%s - home = %@, [extFS stringValue] = %@",
214     __PRETTY_FUNCTION__, home, [extFS stringValue]));
215     if ( [oP runModalForDirectory: ([extFS stringValue] ? [extFS stringValue] : home)
216     file:nil
217     types:nil] == NSOKButton )
218     {
219     [extFS setStringValue: [oP directory] ];
220     PrefsReplaceString("extfs", [[oP directory] cString]);
221     edited = YES;
222     }
223     }
224    
225 nigel 1.10 - (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 nigel 1.1 - (IBAction) BrowseROM: (id)sender
242     {
243     NSOpenPanel *oP = [NSOpenPanel openPanel];
244    
245     [oP setCanChooseFiles: YES];
246     [oP setTitle: @"Open a ROM file"];
247     D(NSLog(@"%s - home = %@", __PRETTY_FUNCTION__, home));
248     if ( [oP runModalForDirectory: ([ROMfile stringValue] ? [ROMfile stringValue] : home)
249     file:nil
250     types:nil] == NSOKButton )
251     {
252     [ROMfile setStringValue: [oP filename] ];
253     PrefsReplaceString("rom", [[oP filename] cString]);
254     edited = YES;
255     }
256     }
257    
258     #include <cdrom.h> // for CDROMRefNum
259    
260     - (IBAction) ChangeBootFrom: (NSMatrix *)sender
261     {
262     if ( [sender selectedCell] == bootFromCD )
263     PrefsReplaceInt32("bootdriver", CDROMRefNum);
264     else
265     PrefsReplaceInt32("bootdriver", 0);
266     edited = YES;
267     }
268    
269     - (IBAction) ChangeCPU: (NSMatrix *)sender
270     {
271     PrefsReplaceInt32("cpu", [[sender selectedCell] tag]);
272     edited = YES;
273     }
274    
275     - (IBAction) ChangeDisableCD: (NSButton *)sender
276     {
277     PrefsReplaceBool("nocdrom", [disableCD state]);
278     edited = YES;
279     }
280    
281     - (IBAction) ChangeDisableSound: (NSButton *)sender
282     {
283 nigel 1.2 BOOL noSound = [disableSound state];
284    
285     if ( ! noSound )
286     WarningSheet(@"Sound is currently unimplemented", panel);
287    
288     PrefsReplaceBool("nosound", noSound);
289 nigel 1.1 edited = YES;
290     }
291    
292     - (IBAction) ChangeFPU: (NSButton *)sender
293     {
294     PrefsReplaceBool("fpu", [FPU state]);
295     edited = YES;
296     }
297    
298 nigel 1.11 - (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 nigel 1.1 - (IBAction) ChangeModel: (NSMatrix *)sender
312     {
313     PrefsReplaceInt32("modelid", [[sender selectedCell] tag]);
314     edited = YES;
315     }
316    
317 nigel 1.7
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 nigel 1.8 // This is called when the screen/window,
333 nigel 1.3 // width, height or depth is clicked.
334     //
335     // Note that sender may not actually be an NSMatrix.
336 nigel 1.1
337 nigel 1.3 - (IBAction) ChangeScreen: (NSMatrix *)sender
338     {
339     NSButton *cell = [sender selectedCell];
340 nigel 1.1
341     short newx = [width intValue];
342     short newy = [height intValue];
343     short newbpp = [depth intValue];
344 nigel 1.2 short newtype;
345 nigel 1.1 char str[20];
346    
347 nigel 1.8 if ( cell == screen )
348 nigel 1.1 newtype = DISPLAY_SCREEN;
349 nigel 1.3 else if ( cell == window )
350 nigel 1.2 newtype = DISPLAY_WINDOW;
351     else
352     newtype = display_type;
353 nigel 1.1
354     // Check that a field actually changed
355     if ( newbpp == init_depth && newx == init_width &&
356     newy == init_height && newtype == display_type )
357 nigel 1.2 {
358 nigel 1.4 D(NSLog(@"No changed GUI items in ChangeScreen"));
359 nigel 1.1 return;
360 nigel 1.2 }
361 nigel 1.1
362     // If we are changing type, supply some sensible defaults
363 nigel 1.7
364     short screenx = CGDisplayPixelsWide(kCGDirectMainDisplay),
365     screeny = CGDisplayPixelsHigh(kCGDirectMainDisplay),
366     screenb = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
367    
368 nigel 1.1 if ( newtype != display_type )
369     {
370 nigel 1.4 D(NSLog(@"Changing display type in ChangeScreen"));
371 nigel 1.1
372 nigel 1.7 // 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 nigel 1.6 {
379 nigel 1.1 newx = MIN_WIDTH, newy = MIN_HEIGHT;
380 nigel 1.7 newbpp = [self testWinDepth: newbpp];
381 nigel 1.6 }
382 nigel 1.1 }
383     else
384     {
385 nigel 1.7 newbpp = [self testWinDepth: newbpp];
386 nigel 1.6
387 nigel 1.1 // Check size is within ranges of MIN_WIDTH ... MAX_WIDTH
388     // and MIN_HEIGHT ... MAX_HEIGHT
389     // ???
390     }
391 nigel 1.7
392     [width setIntValue: newx];
393     [height setIntValue: newy];
394     [depth setIntValue: newbpp];
395 nigel 1.1
396    
397     // Store new prefs
398     *str = '\0';
399     switch ( newtype )
400     {
401     case DISPLAY_WINDOW:
402     if ( newbpp )
403     sprintf(str, "win/%hd/%hd/%hd", newx, newy, newbpp);
404     else
405     sprintf(str, "win/%hd/%hd", newx, newy);
406     break;
407     case DISPLAY_SCREEN:
408     if ( newbpp )
409     sprintf(str, "full/%hd/%hd/%hd", newx, newy, newbpp);
410     else
411     sprintf(str, "full/%hd/%hd", newx, newy);
412     break;
413     };
414     PrefsReplaceString("screen", str);
415    
416     parse_screen_prefs(str);
417    
418     edited = YES;
419    
420     if ( display_type != DISPLAY_SCREEN )
421 nigel 1.2 {
422 nigel 1.4 D(NSLog(@"Display type is not SCREEN (%d), resizing window",
423     display_type));
424 nigel 1.1 resizeWinTo(newx, newy);
425 nigel 1.2 }
426 nigel 1.1 }
427    
428     - (IBAction) CreateVolume: (id)sender
429     {
430     NSSavePanel *sP = [NSSavePanel savePanel];
431    
432     [sP setAccessoryView: newVolumeView];
433     [sP setPrompt: @"Create"];
434     [sP setTitle: @"Create new volume as"];
435    
436     if ( [sP runModalForDirectory:NSHomeDirectory() file:@"basilisk-II.vol"] == NSOKButton )
437     {
438     char cmd[1024];
439     const char *filename = [[sP filename] cString];
440     int retVal,
441     size = [newVolumeSize intValue];
442    
443     sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", filename, size);
444     retVal = system(cmd);
445     if (retVal != 0)
446     {
447     NSString *details = [NSString stringWithFormat:
448     @"The dd command failed.\nReturn status %d (%s)",
449     retVal, strerror(errno)];
450 nigel 1.2 WarningSheet(@"Unable to create volume", details, nil, panel);
451 nigel 1.1 }
452     else
453     {
454     [volsDS addObject: (NSObject *) blank
455     withPath: [sP filename] ];
456     PrefsAddString("disk", filename);
457     [diskImages reloadData];
458     }
459     }
460     }
461    
462 nigel 1.5 - (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 nigel 1.1 - (IBAction) DeleteVolume: (id)sender
475     {
476 nigel 1.5 // 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 nigel 1.1 {
483 nigel 1.5 WarningSheet(@"Unable to delete volume", panel);
484     // NSLog(@"%s unlink(%s) failed - %s", __PRETTY_FUNCTION__, path, strerror(errno));
485 nigel 1.1 }
486     }
487    
488     - (IBAction) EditDelay: (NSTextField *)sender
489     {
490     int ticks = [delay intValue];
491     float freq;
492    
493     if ( ticks )
494     freq = 60.0 / ticks;
495     else
496     freq = 60.0;
497    
498     [frequency setFloatValue: freq];
499     [emuFreq setFloatValue: freq];
500     PrefsReplaceInt32("frameskip", ticks);
501     edited = YES;
502     }
503    
504     - (IBAction) EditBytes: (NSTextField *)sender
505     {
506     int B = (int) [bytes floatValue];
507     float M = B / 1024 / 1024;
508    
509 nigel 1.2 D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B));
510 nigel 1.1 PrefsReplaceInt32("ramsize", B);
511     [MB setFloatValue: M];
512     edited = YES;
513     }
514    
515     - (IBAction) EditEtherNetDevice: (NSTextField *)sender
516     {
517     NSString *path = [etherNet stringValue];
518    
519     PrefsReplaceString("ether", [path cString]);
520     edited = YES;
521     }
522    
523     - (IBAction) EditExtFS: (NSTextField *)sender
524     {
525     NSString *path = [extFS stringValue];
526    
527     PrefsReplaceString("extfs", [path cString]);
528     edited = YES;
529     }
530    
531     - (IBAction) EditFrequency: (NSTextField *)sender
532     {
533     float freq = [frequency floatValue];
534    
535     [delay setIntValue: frequencyToTickDelay(freq)];
536     [emuFreq setFloatValue: freq];
537     edited = YES;
538     }
539    
540     - (IBAction) EditModemDevice: (NSTextField *)sender
541     {
542     NSString *path = [modem stringValue];
543    
544     PrefsReplaceString("seriala", [path cString]);
545     edited = YES;
546     }
547    
548     - (IBAction) EditMB: (NSTextField *)sender
549     {
550     float M = [MB floatValue];
551     int B = (int) (M * 1024 * 1024);
552    
553 nigel 1.2 D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B));
554 nigel 1.1 PrefsReplaceInt32("ramsize", B);
555     [bytes setIntValue: B];
556     edited = YES;
557     }
558    
559     - (IBAction) EditPrinterDevice: (NSTextField *)sender
560     {
561     NSString *path = [printer stringValue];
562    
563     PrefsReplaceString("serialb", [path cString]);
564     edited = YES;
565     }
566    
567     - (IBAction) EditROMpath: (NSTextField *)sender
568     {
569     NSString *path = [ROMfile stringValue];
570    
571     PrefsReplaceString("rom", [path cString]);
572     }
573    
574     - (IBAction) RemoveSCSI: (id)sender
575     {
576     char pref[6];
577     int row = [SCSIdisks selectedRow],
578     SCSIid = [SCSIds intAtRow: row];
579    
580     if ( ! [SCSIds deleteRow: row] )
581     NSLog (@"%s - [SCSIds deleteRow: %d] failed", __PRETTY_FUNCTION__, row);
582     [SCSIdisks reloadData];
583     sprintf(pref, "scsi%d", SCSIid);
584     PrefsRemoveItem(pref,0);
585     }
586    
587 nigel 1.5 //- (const char *) RemoveVolumeEntry
588     - (NSString *) RemoveVolumeEntry
589 nigel 1.1 {
590     int row = [diskImages selectedRow];
591    
592     if ( row != -1 )
593     {
594 nigel 1.5 NSString *Path = [volsDS pathAtRow: row];
595     const char *path = [Path cString],
596 nigel 1.1 *str;
597     int tmp = 0;
598    
599     while ( (str = PrefsFindString("disk", tmp) ) != NULL )
600     {
601     if ( strcmp(str, path) == 0 )
602     {
603     PrefsRemoveItem("disk", tmp);
604 nigel 1.4 D(NSLog(@"%s - Deleted prefs entry \"disk\", %d",
605     __PRETTY_FUNCTION__, tmp));
606 nigel 1.1 edited = YES;
607     break;
608     }
609     ++tmp;
610     }
611    
612     if ( str == NULL )
613     {
614 nigel 1.4 NSLog(@"%s - Couldn't find any disk preference to match %s",
615     __PRETTY_FUNCTION__, path);
616 nigel 1.1 return NULL;
617     }
618    
619     if ( ! [volsDS deleteRow: row] )
620     NSLog (@"%s - RemoveVolume %d failed", __PRETTY_FUNCTION__, tmp);
621     [diskImages reloadData];
622 nigel 1.5 // return path;
623     return Path;
624 nigel 1.1 }
625     else
626     {
627 nigel 1.2 WarningSheet(@"Please select a volume first", panel);
628 nigel 1.1 return NULL;
629     }
630     }
631    
632     - (IBAction) RemoveVolume: (id)sender
633     {
634     [self RemoveVolumeEntry];
635     }
636    
637 nigel 1.10 - (void) loadPrefs: (int) argc
638     args: (char **) argv
639 nigel 1.1 {
640     [panel close]; // Temporarily hide preferences panel
641    
642     PrefsExit(); // Purge all the old pref values
643    
644     PrefsInit(argc, argv);
645     AddPrefsDefaults();
646     AddPlatformPrefsDefaults(); // and only create basic ones
647    
648     [SCSIds deleteAll]; // Clear out datasources for the tables
649     [volsDS deleteAll];
650    
651     [self ShowPrefs: self]; // Reset items in panel, and redisplay
652     edited = NO;
653     }
654    
655 nigel 1.10 - (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 nigel 1.1 - (void) setStringOf: (NSTextField *) field
674     fromPref: (const char *) prefName
675     {
676     const char *value = PrefsFindString(prefName, 0);
677    
678     if ( value )
679     [field setStringValue: [NSString stringWithCString: value] ];
680     }
681    
682     - (IBAction) SavePrefs: (id)sender
683     {
684     SavePrefs();
685     edited = NO;
686     }
687    
688     - (IBAction) ShowPrefs: (id)sender
689     {
690     NSTableColumn *locks;
691     const char *str;
692 nigel 1.11 int cpu, tmp, val;
693 nigel 1.1
694    
695     // Set simple single field items
696    
697 nigel 1.11 val = PrefsFindInt32("frameskip");
698     [delay setIntValue: val];
699     if ( val )
700     [frequency setFloatValue: 60.0 / val];
701 nigel 1.1 else
702     [frequency setFloatValue: 60.0];
703    
704 nigel 1.11 val = PrefsFindInt32("ramsize");
705     [bytes setIntValue: val];
706     [MB setFloatValue: val / (1024.0 * 1024.0)];
707 nigel 1.1
708     [disableCD setState: PrefsFindBool("nocdrom")];
709     [disableSound setState: PrefsFindBool("nosound")];
710     [FPU setState: PrefsFindBool("fpu") ];
711    
712     [self setStringOf: etherNet fromPref: "ether" ];
713     [self setStringOf: extFS fromPref: "extfs" ];
714     [self setStringOf: modem fromPref: "seriala"];
715     [self setStringOf: printer fromPref: "serialb"];
716     [self setStringOf: ROMfile fromPref: "rom" ];
717 nigel 1.10
718     [prefsFile setStringValue: [NSString stringWithCString: UserPrefsPath.c_str()] ];
719 nigel 1.1
720    
721     parse_screen_prefs(PrefsFindString("screen"));
722    
723     [width setIntValue: init_width];
724     [height setIntValue: init_height];
725     [depth setIntValue: init_depth];
726    
727 nigel 1.9 [screen setState: NO];
728 nigel 1.1 switch ( display_type )
729     {
730     case DISPLAY_WINDOW: [window setState: YES]; break;
731     case DISPLAY_SCREEN: [screen setState: YES]; break;
732     }
733    
734     [newVolumeSize setIntValue: 10];
735    
736     // Radio button groups:
737    
738 nigel 1.11 val = PrefsFindInt32("bootdriver");
739     [bootFromAny setState: val != CDROMRefNum];
740     [bootFromCD setState: val == CDROMRefNum];
741 nigel 1.1
742     cpu = PrefsFindInt32("cpu");
743 nigel 1.11 val = PrefsFindInt32("modelid");
744 nigel 1.1
745     #if REAL_ADDRESSING || DIRECT_ADDRESSING
746     puts("Current memory model does not support 24bit addressing");
747 nigel 1.11 if ( val == [classic tag] )
748 nigel 1.1 {
749     // Window already created by NIB file, just display
750     [panel makeKeyAndOrderFront:self];
751     WarningSheet(@"Compiled-in memory model does not support 24bit",
752 nigel 1.2 @"Disabling Mac Classic emulation", nil, panel);
753 nigel 1.1 cpu = [CPU68030 tag];
754     PrefsReplaceInt32("cpu", cpu);
755 nigel 1.11 val = [IIci tag];
756     PrefsReplaceInt32("modelid", val);
757 nigel 1.1 }
758    
759     puts("Disabling 68000 & Mac Classic buttons");
760     [CPU68000 setEnabled:FALSE];
761     [classic setEnabled:FALSE];
762     #endif
763    
764     [CPU68000 setState: [CPU68000 tag] == cpu];
765     [CPU68020 setState: [CPU68020 tag] == cpu];
766     [CPU68030 setState: [CPU68030 tag] == cpu];
767     [CPU68040 setState: [CPU68040 tag] == cpu];
768    
769 nigel 1.11 [classic setState: [classic tag] == val];
770     [IIci setState: [IIci tag] == val];
771     [quadra900 setState: [quadra900 tag] == val];
772 nigel 1.1
773    
774     // Lists of thingies:
775 nigel 1.11
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 nigel 1.1
785     for ( tmp = 0; tmp < 7; ++tmp)
786     {
787     char pref[6];
788    
789     pref[0] = '\0';
790    
791     sprintf (pref, "scsi%d", tmp);
792     if ( (str = PrefsFindString(pref, 0) ) )
793     [SCSIds addInt: tmp
794     withPath: [NSString stringWithCString: str] ];
795     }
796    
797     [SCSIdisks setDataSource: SCSIds];
798    
799     locks = [diskImages tableColumnWithIdentifier: @"locked"];
800     if ( locks == nil )
801     NSLog (@"%s - Can't find column for lock images", __PRETTY_FUNCTION__);
802     [locks setDataCell: lockCell];
803    
804     tmp = 0;
805     while ( (str = PrefsFindString("disk", tmp++) ) != NULL )
806     {
807     if ( *str == '*' )
808     [volsDS addObject: (NSObject *) locked
809     withPath: [NSString stringWithCString: str+1]];
810     else
811     [volsDS addObject: (NSObject *) blank
812     withPath: [NSString stringWithCString: str]];
813     }
814    
815     [diskImages setDataSource: volsDS];
816    
817    
818     [panel makeKeyAndOrderFront:self]; // Window already created by NIB file, just display
819     }
820    
821     @end