ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/PrefsEditor.mm
(Generate patch)

Comparing BasiliskII/src/MacOSX/PrefsEditor.mm (file contents):
Revision 1.8 by nigel, 2003-03-21T12:04:34Z vs.
Revision 1.13 by cebix, 2004-01-12T15:29:24Z

# Line 4 | Line 4
4   *
5   *      $Id$
6   *
7 < *  Basilisk II (C) 1997-2003 Christian Bauer
7 > *  Basilisk II (C) 1997-2004 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
# Line 109 | Line 109
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
# Line 218 | Line 222
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];
# Line 275 | Line 295
295          edited = YES;
296   }
297  
298 + - (IBAction) ChangeKeyboard: (NSPopUpButton *)sender
299 + {
300 +        // Deselest current item
301 +        int  current = [keyboard indexOfItemWithTag: PrefsFindInt32("keyboardtype")];
302 +        if ( current != -1 )
303 +                [[keyboard itemAtIndex: current] setState: FALSE];
304 +
305 +        PrefsReplaceInt32("keyboardtype", [[sender selectedItem] tag]);
306 +        edited = YES;
307 + }
308 +
309   - (IBAction) ChangeModel: (NSMatrix *)sender
310   {
311          PrefsReplaceInt32("modelid", [[sender selectedCell] tag]);
# Line 601 | Line 632 | shouldProceedAfterError: (NSDictionary *
632          [self RemoveVolumeEntry];
633   }
634  
635 < - (IBAction) ResetPrefs: (id)sender
635 > - (void) loadPrefs: (int) argc
636 >                          args: (char **) argv
637   {
606        int             argc = 0;
607        char    **argv = NULL;
608
638          [panel close];                          // Temporarily hide preferences panel
639  
640          PrefsExit();                            // Purge all the old pref values
# Line 621 | Line 650 | shouldProceedAfterError: (NSDictionary *
650          edited = NO;
651   }
652  
653 + - (IBAction) LoadPrefs: (id)sender
654 + {
655 +        int             argc = 2;
656 +        char    *argv[2];
657 +
658 +        argv[0] = "--prefs",
659 +        argv[1] = (char *) [[prefsFile stringValue] cString];
660 +
661 +        [self loadPrefs: argc
662 +                           args: argv];
663 + }
664 +
665 + - (IBAction) ResetPrefs: (id)sender
666 + {
667 +        [self loadPrefs: 0
668 +                           args: NULL];
669 + }
670 +
671   - (void) setStringOf: (NSTextField *) field
672                          fromPref: (const char *)  prefName
673   {
# Line 640 | Line 687 | shouldProceedAfterError: (NSDictionary *
687   {
688          NSTableColumn   *locks;
689          const char              *str;
690 <        int                             cpu, tmp;
690 >        int                             cpu, tmp, val;
691  
692  
693          // Set simple single field items
694  
695 <        tmp = PrefsFindInt32("frameskip");
696 <        [delay setIntValue: tmp];
697 <        if ( tmp )
698 <                [frequency      setFloatValue:  60.0 / tmp];
695 >        val = PrefsFindInt32("frameskip");
696 >        [delay setIntValue: val];
697 >        if ( val )
698 >                [frequency      setFloatValue:  60.0 / val];
699          else
700                  [frequency      setFloatValue:  60.0];
701  
702 <        tmp = PrefsFindInt32("ramsize");
703 <        [bytes  setIntValue:   tmp];
704 <        [MB             setFloatValue: tmp / (1024.0 * 1024.0)];
702 >        val = PrefsFindInt32("ramsize");
703 >        [bytes  setIntValue:   val];
704 >        [MB             setFloatValue: val / (1024.0 * 1024.0)];
705  
706          [disableCD              setState:       PrefsFindBool("nocdrom")];
707          [disableSound   setState:       PrefsFindBool("nosound")];
# Line 666 | Line 713 | shouldProceedAfterError: (NSDictionary *
713          [self setStringOf: printer       fromPref: "serialb"];
714      [self setStringOf: ROMfile   fromPref: "rom"        ];
715  
716 +        [prefsFile setStringValue: [NSString stringWithCString: UserPrefsPath.c_str()] ];
717 +
718  
719          parse_screen_prefs(PrefsFindString("screen"));
720  
# Line 673 | Line 722 | shouldProceedAfterError: (NSDictionary *
722          [height setIntValue: init_height];
723          [depth  setIntValue: init_depth];
724  
725 <        [window setState: NO];
725 >        [screen setState: NO];
726          switch ( display_type )
727          {
728                  case DISPLAY_WINDOW: [window setState: YES]; break;
# Line 684 | Line 733 | shouldProceedAfterError: (NSDictionary *
733  
734          // Radio button groups:
735  
736 <        tmp = PrefsFindInt32("bootdriver");
737 <        [bootFromAny setState: tmp != CDROMRefNum];
738 <        [bootFromCD  setState: tmp == CDROMRefNum];
736 >        val = PrefsFindInt32("bootdriver");
737 >        [bootFromAny setState: val != CDROMRefNum];
738 >        [bootFromCD  setState: val == CDROMRefNum];
739  
740          cpu = PrefsFindInt32("cpu");
741 <        tmp = PrefsFindInt32("modelid");
741 >        val = PrefsFindInt32("modelid");
742  
743   #if REAL_ADDRESSING || DIRECT_ADDRESSING
744          puts("Current memory model does not support 24bit addressing");
745 <        if ( tmp == [classic tag] )
745 >        if ( val == [classic tag] )
746          {
747                  // Window already created by NIB file, just display
748                  [panel makeKeyAndOrderFront:self];
# Line 701 | Line 750 | shouldProceedAfterError: (NSDictionary *
750                                                  @"Disabling Mac Classic emulation", nil, panel);
751                  cpu = [CPU68030 tag];
752                  PrefsReplaceInt32("cpu", cpu);
753 <                tmp = [IIci tag];
754 <                PrefsReplaceInt32("modelid", tmp);
753 >                val = [IIci tag];
754 >                PrefsReplaceInt32("modelid", val);
755          }
756  
757          puts("Disabling 68000 & Mac Classic buttons");
# Line 715 | Line 764 | shouldProceedAfterError: (NSDictionary *
764          [CPU68030   setState: [CPU68030  tag] == cpu];
765          [CPU68040   setState: [CPU68040  tag] == cpu];
766  
767 <        [classic        setState: [classic       tag] == tmp];
768 <        [IIci           setState: [IIci          tag] == tmp];
769 <        [quadra900      setState: [quadra900 tag] == tmp];
767 >        [classic        setState: [classic       tag] == val];
768 >        [IIci           setState: [IIci          tag] == val];
769 >        [quadra900      setState: [quadra900 tag] == val];
770  
771  
772          // Lists of thingies:
773  
774 +        val = PrefsFindInt32("keyboardtype");
775 +        tmp = [keyboard indexOfItemWithTag: val];
776 +        if ( tmp != -1 )
777 +                [keyboard selectItemAtIndex: tmp];
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];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines