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 |
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]); |
329 |
|
#endif |
330 |
|
} |
331 |
|
|
332 |
< |
// This is called when any of the screen/openGL/window, |
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 ) |
315 |
< |
newtype = DISPLAY_OPENGL; |
316 |
< |
else if ( cell == screen ) |
347 |
> |
if ( cell == screen ) |
348 |
|
newtype = DISPLAY_SCREEN; |
349 |
|
else if ( cell == window ) |
350 |
|
newtype = DISPLAY_WINDOW; |
404 |
|
else |
405 |
|
sprintf(str, "win/%hd/%hd", newx, newy); |
406 |
|
break; |
376 |
– |
case DISPLAY_OPENGL: |
377 |
– |
if ( newbpp ) |
378 |
– |
sprintf(str, "opengl/%hd/%hd/%hd", newx, newy, newbpp); |
379 |
– |
else |
380 |
– |
sprintf(str, "opengl/%hd/%hd", newx, newy); |
381 |
– |
break; |
407 |
|
case DISPLAY_SCREEN: |
408 |
|
if ( newbpp ) |
409 |
|
sprintf(str, "full/%hd/%hd/%hd", newx, newy, newbpp); |
634 |
|
[self RemoveVolumeEntry]; |
635 |
|
} |
636 |
|
|
637 |
< |
- (IBAction) ResetPrefs: (id)sender |
637 |
> |
- (void) loadPrefs: (int) argc |
638 |
> |
args: (char **) argv |
639 |
|
{ |
614 |
– |
int argc = 0; |
615 |
– |
char **argv = NULL; |
616 |
– |
|
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; |
688 |
– |
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]; |