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.7 by nigel, 2003-03-21T06:44:14Z 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 296 | Line 327
327   #endif
328   }
329  
330 < // This is called when any of the screen/openGL/window,
330 > // This is called when the screen/window,
331   // width, height or depth is clicked.
332   //
333   // Note that sender may not actually be an NSMatrix.
# Line 311 | Line 342
342          short newtype;
343          char  str[20];
344  
345 <        if ( cell == openGL )
315 <                newtype = DISPLAY_OPENGL;
316 <        else if ( cell == screen )
345 >        if ( cell == screen )
346                  newtype = DISPLAY_SCREEN;
347          else if ( cell == window )
348                  newtype = DISPLAY_WINDOW;
# Line 373 | Line 402
402                          else
403                                  sprintf(str, "win/%hd/%hd",  newx, newy);
404                          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;
405                  case DISPLAY_SCREEN:
406                          if ( newbpp )
407                                  sprintf(str, "full/%hd/%hd/%hd", newx, newy, newbpp);
# Line 609 | Line 632 | shouldProceedAfterError: (NSDictionary *
632          [self RemoveVolumeEntry];
633   }
634  
635 < - (IBAction) ResetPrefs: (id)sender
635 > - (void) loadPrefs: (int) argc
636 >                          args: (char **) argv
637   {
614        int             argc = 0;
615        char    **argv = NULL;
616
638          [panel close];                          // Temporarily hide preferences panel
639  
640          PrefsExit();                            // Purge all the old pref values
# Line 629 | 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 648 | 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 674 | 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 681 | 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;
688                case DISPLAY_OPENGL: [openGL setState: YES]; break;
729                  case DISPLAY_SCREEN: [screen setState: YES]; break;
730          }
731  
# Line 693 | 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 710 | 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 724 | 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