|
|
1.1 root 1: /*
2: Hatari - PrefsController.m
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
6:
7: Preferences window controller implementation file
8:
9: Feb-Mar 2006, Sébastien Molines - Created
10: Jan 2006, Sébastien Molines - Updated for recent emulator updates
11: */
12:
13: // TODO: Set the default paths to MacOS-friendly values
14: // TODO: Move hardcoded string to localizable resources (e.g. string "Reset the emulator?")
15:
16:
17: #import "PrefsController.h"
18: #import "Shared.h"
19:
20: #include "main.h"
21: #include "configuration.h"
22: #include "change.h"
23: #include "dialog.h"
24: #include "file.h"
25: #include "screen.h"
26: #include "sdlgui.h"
27:
28: // Macros to transfer data between Cocoa controls and Hatari data structures
29: #define EXPORT_TEXTFIELD(nstextfield, target) GuiOsx_ExportPathString([nstextfield stringValue], target, sizeof((target)))
30: #define EXPORT_NTEXTFIELD(nstextfield, target) target = [nstextfield intValue]
31: #define EXPORT_SWITCH(nsbutton, target) target = ([(nsbutton) state] == NSOnState)
32: #define EXPORT_RADIO(nsmatrix, target) target = [[(nsmatrix) selectedCell] tag]
33: #define EXPORT_DROPDOWN(nspopupbutton, target) target = [[(nspopupbutton) selectedItem] tag]
34: #define EXPORT_SLIDER(nsslider, target) target = [(nsslider) intValue]
35:
36: #define IMPORT_TEXTFIELD(nstextfield, source) [(nstextfield) setStringValue:[[NSString stringWithCString:(source) encoding:NSASCIIStringEncoding] stringByAbbreviatingWithTildeInPath]]
37: #define IMPORT_NTEXTFIELD(nstextfield, source) [(nstextfield) setIntValue:(source)]
38: #define IMPORT_SWITCH(nsbutton, source) [(nsbutton) setState:((source))? NSOnState : NSOffState]
39: #define IMPORT_RADIO(nsmatrix, source) [(nsmatrix) selectCellWithTag:(source)]
40: #define IMPORT_DROPDOWN(nspopupbutton, source) [(nspopupbutton) selectItemAtIndex:[(nspopupbutton) indexOfItemWithTag:(source)]]
41: #define IMPORT_SLIDER(nsslider,source) [(nsslider) setIntValue:source]
42:
43:
44: // Back up of the current configuration parameters
45: CNF_PARAMS CurrentParams;
46:
47:
48: // Keys to be listed in the Joysticks dropdowns
1.1.1.4 root 49: SDL_Keycode Preferences_KeysForJoysticks[] =
1.1 root 50: {
51: SDLK_BACKSPACE,
52: SDLK_TAB,
53: SDLK_CLEAR,
54: SDLK_RETURN,
55: SDLK_PAUSE,
56: SDLK_ESCAPE,
57: SDLK_SPACE,
58: SDLK_EXCLAIM,
59: SDLK_QUOTEDBL,
60: SDLK_HASH,
61: SDLK_DOLLAR,
62: SDLK_AMPERSAND,
63: SDLK_QUOTE,
64: SDLK_LEFTPAREN,
65: SDLK_RIGHTPAREN,
66: SDLK_ASTERISK,
67: SDLK_PLUS,
68: SDLK_COMMA,
69: SDLK_MINUS,
70: SDLK_PERIOD,
71: SDLK_SLASH,
72: SDLK_0,
73: SDLK_1,
74: SDLK_2,
75: SDLK_3,
76: SDLK_4,
77: SDLK_5,
78: SDLK_6,
79: SDLK_7,
80: SDLK_8,
81: SDLK_9,
82: SDLK_COLON,
83: SDLK_SEMICOLON,
84: SDLK_LESS,
85: SDLK_EQUALS,
86: SDLK_GREATER,
87: SDLK_QUESTION,
88: SDLK_AT,
89: SDLK_LEFTBRACKET,
90: SDLK_BACKSLASH,
91: SDLK_RIGHTBRACKET,
92: SDLK_CARET,
93: SDLK_UNDERSCORE,
94: SDLK_BACKQUOTE,
95: SDLK_a,
96: SDLK_b,
97: SDLK_c,
98: SDLK_d,
99: SDLK_e,
100: SDLK_f,
101: SDLK_g,
102: SDLK_h,
103: SDLK_i,
104: SDLK_j,
105: SDLK_k,
106: SDLK_l,
107: SDLK_m,
108: SDLK_n,
109: SDLK_o,
110: SDLK_p,
111: SDLK_q,
112: SDLK_r,
113: SDLK_s,
114: SDLK_t,
115: SDLK_u,
116: SDLK_v,
117: SDLK_w,
118: SDLK_x,
119: SDLK_y,
120: SDLK_z,
121: SDLK_DELETE,
1.1.1.4 root 122: SDLK_KP_0,
123: SDLK_KP_1,
124: SDLK_KP_2,
125: SDLK_KP_3,
126: SDLK_KP_4,
127: SDLK_KP_5,
128: SDLK_KP_6,
129: SDLK_KP_7,
130: SDLK_KP_8,
131: SDLK_KP_9,
1.1 root 132: SDLK_KP_PERIOD,
133: SDLK_KP_DIVIDE,
134: SDLK_KP_MULTIPLY,
135: SDLK_KP_MINUS,
136: SDLK_KP_PLUS,
137: SDLK_KP_ENTER,
138: SDLK_KP_EQUALS,
139: SDLK_UP,
140: SDLK_DOWN,
141: SDLK_RIGHT,
142: SDLK_LEFT,
143: SDLK_INSERT,
144: SDLK_HOME,
145: SDLK_END,
146: SDLK_PAGEUP,
147: SDLK_PAGEDOWN,
148: SDLK_F1,
149: SDLK_F2,
150: SDLK_F3,
151: SDLK_F4,
152: SDLK_F5,
153: SDLK_F6,
154: SDLK_F7,
155: SDLK_F8,
156: SDLK_F9,
157: SDLK_F10,
158: SDLK_F11,
159: SDLK_F12,
160: SDLK_F13,
161: SDLK_F14,
162: SDLK_F15,
1.1.1.4 root 163: //SDLK_NUMLOCK,
1.1 root 164: SDLK_CAPSLOCK,
1.1.1.4 root 165: //SDLK_SCROLLOCK,
1.1 root 166: SDLK_RSHIFT,
167: SDLK_LSHIFT,
168: SDLK_RCTRL,
169: SDLK_LCTRL,
170: SDLK_RALT,
171: SDLK_LALT,
1.1.1.4 root 172: SDLK_RGUI,
173: SDLK_LGUI,
174: //SDLK_LSUPER,
175: //SDLK_RSUPER,
1.1 root 176: SDLK_MODE,
1.1.1.4 root 177: //SDLK_COMPOSE,
1.1 root 178: SDLK_HELP,
1.1.1.4 root 179: //SDLK_PRINT,
1.1 root 180: SDLK_SYSREQ,
1.1.1.4 root 181: //SDLK_BREAK,
1.1 root 182: SDLK_MENU,
183: SDLK_POWER,
1.1.1.4 root 184: //SDLK_EURO,
1.1 root 185: SDLK_UNDO
186: };
187:
188: size_t Preferences_cKeysForJoysticks = sizeof(Preferences_KeysForJoysticks) / sizeof(Preferences_KeysForJoysticks[0]);
189:
190: #define DLGSOUND_11KHZ 0
191: #define DLGSOUND_12KHZ 1
192: #define DLGSOUND_16KHZ 2
193: #define DLGSOUND_22KHZ 3
194: #define DLGSOUND_25KHZ 4
195: #define DLGSOUND_32KHZ 5
196: #define DLGSOUND_44KHZ 6
197: #define DLGSOUND_48KHZ 7
198: #define DLGSOUND_50KHZ 8
199:
200: @implementation PrefsController
201:
202:
203: /*-----------------------------------------------------------------------*/
204: /*
205: Helper method for Choose buttons
206: Returns: TRUE is the user selected a path, FALSE if he/she aborted
207: */
208: - (BOOL)choosePathForControl:(NSTextField*)textField chooseDirectories:(bool)chooseDirectories defaultInitialDir:(NSString*)defaultInitialDir
209: {
1.1.1.5 ! root 210: /*
1.1 root 211: // Create and configure an OpenPanel
212: NSOpenPanel *openPanel = [NSOpenPanel openPanel];
213: [openPanel setCanChooseDirectories: chooseDirectories];
214: [openPanel setCanChooseFiles: !chooseDirectories];
215:
216: NSString *directoryToOpen;
217: NSString *fileToPreselect;
218: NSString *oldPath = [textField stringValue];
219: if ((oldPath != nil) && ([oldPath length] > 0))
220: {
221: // There is existing path: we will open its directory with its file pre-selected.
222: directoryToOpen = [oldPath stringByDeletingLastPathComponent];
223: fileToPreselect = [oldPath lastPathComponent];
224: }
225: else
226: {
227: // Currently no path: we will open the user's directory with no file selected.
228: directoryToOpen = [defaultInitialDir stringByExpandingTildeInPath];
229: fileToPreselect = nil;
230: }
231:
232: // Run the OpenPanel, then check if the user clicked OK and selected at least one file
1.1.1.5 ! root 233: if ( (NSModalResponseOK == [openPanel runModalForDirectory:directoryToOpen file:fileToPreselect types:nil] )
! 234: && ([[openPanel URLs] count] > 0) )
1.1 root 235: {
236: // Get the path to the selected file
1.1.1.5 ! root 237: NSString *path = [[[openPanel URLs] objectAtIndex:0] path];
1.1 root 238:
239: // Set the control to it (abbreviated if possible)
240: [textField setStringValue:[path stringByAbbreviatingWithTildeInPath]];
241:
242: // Signal completion
243: return true;
244: }
245:
246: // Signal that the selection was aborted
1.1.1.5 ! root 247: */
1.1 root 248: return FALSE;
249: }
250:
251:
252: /*-----------------------------------------------------------------------*/
253: /*
254: Helper method to insert a floppy image
255: TODO: Add code to restrict to known file types
256: */
257: - (void)insertFloppyImageIntoDrive:(int)drive forTextField:(NSTextField*)floppyTextField
258: {
259: if ([self choosePathForControl:floppyTextField chooseDirectories:FALSE defaultInitialDir:[defaultImagesLocation stringValue]])
260: {
261: // Get the full path to the selected file
262: NSString *path = [[floppyTextField stringValue] stringByExpandingTildeInPath];
263:
264: // Make a non-const C string out of it
265: const char* constSzPath = [path cStringUsingEncoding:NSASCIIStringEncoding];
266: size_t cbPath = strlen(constSzPath) + 1;
267: char szPath[cbPath];
268: strncpy(szPath, constSzPath, cbPath);
269:
270: // Insert the floppy image at this path
271: // Floppy_SetDiskFileName(drive, szPath, NULL);
272: }
273: }
274:
275:
276: /*-----------------------------------------------------------------------*/
277: /*
278: Methods for all the "Choose" buttons
279: */
280: - (IBAction)chooseCartridgeImage:(id)sender;
281: {
282: [self choosePathForControl: cartridgeImage chooseDirectories:FALSE defaultInitialDir:@"~"];
283: }
284:
285: - (IBAction)chooseDefaultImagesLocation:(id)sender
286: {
287: [self choosePathForControl: defaultImagesLocation chooseDirectories:TRUE defaultInitialDir:@"~"];
288: }
289:
290: - (IBAction)chooseFloppyImageA:(id)sender
291: {
292: [self insertFloppyImageIntoDrive:0 forTextField: floppyImageA];
293: }
294:
295: - (IBAction)chooseFloppyImageB:(id)sender
296: {
297: [self insertFloppyImageIntoDrive:1 forTextField: floppyImageB];
298: }
299:
300: - (IBAction)chooseGemdosImage:(id)sender
301: {
302: [self choosePathForControl: gemdosImage chooseDirectories:TRUE defaultInitialDir:@"~"];
303: }
304:
305: - (IBAction)chooseHdImage:(id)sender
306: {
307: [self choosePathForControl: hdImage chooseDirectories:FALSE defaultInitialDir:@"~"];
308: }
309:
310: - (IBAction)chooseIdeMasterHdImage:(id)sender
311: {
312: [self choosePathForControl: ideMasterHdImage chooseDirectories:FALSE defaultInitialDir:@"~"];
313: }
314:
315: - (IBAction)chooseIdeSlaveHdImage:(id)sender
316: {
317: [self choosePathForControl: ideSlaveHdImage chooseDirectories:FALSE defaultInitialDir:@"~"];
318: }
319:
320: - (IBAction)chooseKeyboardMappingFile:(id)sender
321: {
322: [self choosePathForControl: keyboardMappingFile chooseDirectories:FALSE defaultInitialDir:@"~"];
323: }
324:
325: - (IBAction)chooseMidiOutputFile:(id)sender
326: {
327: [self choosePathForControl: writeMidiToFile chooseDirectories:FALSE defaultInitialDir:@"~"];
328: }
329:
330: - (IBAction)choosePrintToFile:(id)sender
331: {
332: [self choosePathForControl: printToFile chooseDirectories:FALSE defaultInitialDir:@"~"];
333: }
334:
335: - (IBAction)chooseRS232InputFile:(id)sender
336: {
337: [self choosePathForControl: readRS232FromFile chooseDirectories:FALSE defaultInitialDir:@"~"];
338: }
339:
340: - (IBAction)chooseRS232OutputFile:(id)sender
341: {
342: [self choosePathForControl: writeRS232ToFile chooseDirectories:FALSE defaultInitialDir:@"~"];
343: }
344:
345: - (IBAction)chooseTosImage:(id)sender;
346: {
347: [self choosePathForControl: tosImage chooseDirectories:FALSE defaultInitialDir:@"~"];
348: }
349:
350:
351: /*-----------------------------------------------------------------------*/
352: /*
353: Methods for the "Eject" buttons
354: */
355: - (IBAction)ejectFloppyA:(id)sender
356: {
357: // Floppy_SetDiskFileNameNone(0);
358:
359: // Refresh the control
360: [floppyImageA setStringValue:@""];
361: }
362:
363: - (IBAction)ejectFloppyB:(id)sender
364: {
365: // Floppy_SetDiskFileNameNone(1);
366:
367: // Refresh the control
368: [floppyImageB setStringValue:@""];
369: }
370:
371: - (IBAction)ejectGemdosImage:(id)sender
372: {
373: // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected
374: [gemdosImage setStringValue:@""];
375: }
376:
377: - (IBAction)ejectHdImage:(id)sender
378: {
379: // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected
380: [hdImage setStringValue:@""];
381: }
382:
383: - (IBAction)ejectIdeMasterHdImage:(id)sender
384: {
385: // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected
386: [ideMasterHdImage setStringValue:@""];
387: }
388:
389: - (IBAction)ejectIdeSlaveHdImage:(id)sender
390: {
391: // Clear the control. Later. saveAllControls will set the ConfigureParams accordingly to signal this is ejected
392: [ideSlaveHdImage setStringValue:@""];
393: }
394:
395: /*-----------------------------------------------------------------------*/
396: /**
397: * Methods for the "Load Config" button
398: */
399:
400: - (IBAction)loadConfigFrom:(id)sender
401: {
1.1.1.5 ! root 402: /*
1.1 root 403: NSString *ConfigFile = [NSString stringWithCString:(sConfigFileName) encoding:NSASCIIStringEncoding];
404: NSOpenPanel *openPanel = [ NSOpenPanel openPanel ];
405:
406: if ( [ openPanel runModalForDirectory:nil file:ConfigFile types:nil ] )
407: {
408: ConfigFile = [ [ openPanel filenames ] objectAtIndex:0 ];
409: }
410: else
411: {
412: ConfigFile = nil;
413: }
414:
415: if (ConfigFile != nil)
416: {
417: // Make a non-const C string out of it
418: const char* constSzPath = [ConfigFile cStringUsingEncoding:NSASCIIStringEncoding];
419: size_t cbPath = strlen(constSzPath) + 1;
420: char szPath[cbPath];
421: strncpy(szPath, constSzPath, cbPath);
422:
423: // Load the config into ConfigureParams
424: Configuration_Load(szPath);
425: strcpy(sConfigFileName,szPath);
426: // Refresh all the controls to match ConfigureParams
427: [self setAllControls];
428: }
1.1.1.5 ! root 429: */
1.1 root 430: }
431:
432: /**
433: * Methods for the "Load Config" button
434: */
435: - (IBAction)saveConfigAs:(id)sender
436: {
1.1.1.5 ! root 437: /*
1.1 root 438: char splitpath[FILENAME_MAX], splitname[FILENAME_MAX];
439:
440: // Update the ConfigureParams from the controls
441: [self saveAllControls];
442:
443: File_SplitPath(sConfigFileName, splitpath, splitname, NULL);
444:
445: NSSavePanel *savePanel = [ NSSavePanel savePanel ];
446:
447: NSString* defaultDir = [NSString stringWithCString:splitpath encoding:NSASCIIStringEncoding];
448: NSString *ConfigFile = [NSString stringWithCString:splitname encoding:NSASCIIStringEncoding];
449:
450: if ( ![ savePanel runModalForDirectory:defaultDir file:ConfigFile ] )
451: {
452: return;
453: }
454:
455: ConfigFile = [ savePanel filename ];
456:
457: if (ConfigFile != nil)
458: {
459: // Make a non-const C string out of it
460: const char* constSzPath = [ConfigFile cStringUsingEncoding:NSASCIIStringEncoding];
461: size_t cbPath = strlen(constSzPath) + 1;
462: char szPath[cbPath];
463: strncpy(szPath, constSzPath, cbPath);
464:
465: // Save the config from ConfigureParams
466: strcpy(sConfigFileName, szPath);
467: Configuration_Save();
468: }
1.1.1.5 ! root 469: */
1.1 root 470: }
471:
472:
473: /*-----------------------------------------------------------------------*/
474: /*
475: Commits and closes
476: */
477: - (IBAction)commitAndClose:(id)sender
478: {
1.1.1.5 ! root 479: /*
1.1 root 480: BOOL applyChanges = true;
481:
482: // The user clicked OK
483: [self saveAllControls];
484:
485: // If a reset is required, ask the user first
486: if (Change_DoNeedReset(&CurrentParams, &ConfigureParams))
487: {
488: applyChanges = ( 0 == NSRunAlertPanel (
489: NSLocalizedStringFromTable(@"Reset the emulator",@"Localizable",@"comment"),
490: NSLocalizedStringFromTable(@"Must be reset",@"Localizable",@"comment"),
491: NSLocalizedStringFromTable(@"Don't reset",@"Localizable",@"comment"),
492: NSLocalizedStringFromTable(@"Reset",@"Localizable",@"comment"), nil) );
493: }
494:
495: // Commit the new configuration
496: if (applyChanges)
497: {
498: Change_CopyChangedParamsToConfiguration(&CurrentParams, &ConfigureParams, false);
499: }
500: else
501: {
502: ConfigureParams = CurrentParams;
503: }
504:
505: // Close the window
506: [window close];
1.1.1.5 ! root 507: */
1.1 root 508: }
509:
510: - (void)initKeysDropDown:(NSPopUpButton*)dropDown
511: {
512: [dropDown removeAllItems];
1.1.1.2 root 513: unsigned int i;
1.1 root 514: for (i = 0; i < Preferences_cKeysForJoysticks; i++)
515: {
1.1.1.4 root 516: SDL_Keycode key = Preferences_KeysForJoysticks[i];
1.1 root 517: const char* szKeyName = SDL_GetKeyName(key);
518: [dropDown addItemWithTitle:[[NSString stringWithCString:szKeyName encoding:NSASCIIStringEncoding] capitalizedString]];
519: [[dropDown lastItem] setTag:key];
520: }
521: }
522:
523:
524: /*-----------------------------------------------------------------------*/
525: /*
526: Displays the Preferences dialog
527: */
528: - (IBAction)loadPrefs:(id)sender
529: {
530: if (!bInitialized)
531: {
532: // Note: These inits cannot be done in awakeFromNib as by this time SDL is not yet initialized.
533:
534: // Fill the keyboard dropdowns
535: [self initKeysDropDown:joystickUp];
536: [self initKeysDropDown:joystickRight];
537: [self initKeysDropDown:joystickDown];
538: [self initKeysDropDown:joystickLeft];
539: [self initKeysDropDown:joystickFire];
540:
541: // Get and store the number of real joysticks
542: cRealJoysticks = SDL_NumJoysticks();
543:
544: // Fill the real joysticks dropdown, if any are available
545: if (cRealJoysticks > 0)
546: {
547: [realJoystick removeAllItems];
548: int i;
549: for (i = 0; i < cRealJoysticks; i++)
550: {
1.1.1.5 ! root 551: const char* szJoystickName = SDL_JoystickNameForIndex(i);
1.1 root 552: [realJoystick addItemWithTitle:[[NSString stringWithCString:szJoystickName encoding:NSASCIIStringEncoding] capitalizedString]];
553: [[realJoystick lastItem] setTag:i];
554: }
555: }
556: else // No real joysticks: Disable the controls
557: {
558: [[joystickMode cellWithTag:1] setEnabled:FALSE];
559: [realJoystick setEnabled:FALSE];
560: }
561:
562: bInitialized = true;
563: }
564:
565:
566: // Backup of configuration settings to CurrentParams (which we will only
567: // commit back to the configuration settings if choosing OK)
568: CurrentParams = ConfigureParams;
569:
570: [self setAllControls];
571:
572: // Display the window
573: [[ModalWrapper alloc] runModal:window];
574: }
575:
576:
577: /*-----------------------------------------------------------------------*/
578: /*
579: Updates the controls following a change in the joystick selection
580: */
581: - (IBAction)changeViewedJoystick:(id)sender
582: {
583: // Save the pre-joystick controls, as we are about to change them
584: [self saveJoystickControls];
585:
586: // Refresh the per-joystick controls
587: [self setJoystickControls];
588:
589: // Update the controls' enabled states
590: [self updateEnabledStates:self];
591: }
592:
593:
594: /*-----------------------------------------------------------------------*/
595: /*
596: Initializes all controls
597: */
598: - (void)setAllControls
599: {
600: // Import all the preferences into their controls
1.1.1.5 ! root 601: IMPORT_SWITCH(realtime, ConfigureParams.System.bRealtime);
1.1 root 602: IMPORT_SWITCH(compatibleCpu, ConfigureParams.System.bCompatibleCpu);
603: IMPORT_RADIO(cpuClock, ConfigureParams.System.nCpuFreq);
604: IMPORT_RADIO(cpuType, ConfigureParams.System.nCpuLevel);
1.1.1.4 root 605: IMPORT_SWITCH(enablePrinter, ConfigureParams.Printer.bPrinterConnected);
1.1 root 606: IMPORT_SWITCH(enableSound, ConfigureParams.Sound.bEnableSound);
607: IMPORT_RADIO(keyboardMapping, ConfigureParams.Keyboard.nKeymapType);
608: IMPORT_TEXTFIELD(keyboardMappingFile, ConfigureParams.Keyboard.szMappingFileName);
609: IMPORT_RADIO(machineType, ConfigureParams.System.nMachineType);
610: IMPORT_RADIO(monitor, ConfigureParams.Screen.nMonitorType);
611: IMPORT_TEXTFIELD(printToFile, ConfigureParams.Printer.szPrintToFileName);
612: IMPORT_SWITCH(realTime, ConfigureParams.System.bRealTimeClock);
613: IMPORT_SWITCH(showStatusBar, ConfigureParams.Screen.bShowStatusbar);
614: IMPORT_DROPDOWN(enableDSP,ConfigureParams.System.nDSPType);
615: IMPORT_TEXTFIELD(configFile, sConfigFileName);
616:
617: // 12/04/2010
618: IMPORT_SWITCH(fullScreen, ConfigureParams.Screen.bFullScreen);
619: IMPORT_SWITCH(ledDisks, ConfigureParams.Screen.bShowDriveLed);
1.1.1.5 ! root 620:
1.1 root 621: [widthStepper setIntValue:[maxZoomedWidth intValue]];
622: [heightStepper setIntValue:[maxZoomedHeight intValue]];
623:
624:
625: int i;
626:
627: for (i = 0; i <= DLGSOUND_50KHZ-DLGSOUND_11KHZ; i++)
628: {
1.1.1.4 root 629: // if (ConfigureParams.Sound.nPlaybackFreq > nSoundFreqs[i]-500
630: // && ConfigureParams.Sound.nPlaybackFreq < nSoundFreqs[i]+500)
1.1 root 631: {
632: [playbackQuality selectCellWithTag:(i)];
633: break;
634: }
635: }
636:
637:
638: [resolution selectCellWithTag:(2)];
639:
640: // If the HD flag is set, load the HD path, otherwise make it blank
1.1.1.3 root 641: // if (ConfigureParams.HardDisk.bUseHardDiskImage)
642: // {
643: // IMPORT_TEXTFIELD(hdImage, ConfigureParams.HardDisk.szHardDiskImage);
644: // }
645: // else
646: // {
1.1 root 647: [hdImage setStringValue:@""];
1.1.1.3 root 648: // }
1.1 root 649:
650: // If the IDE HD flag is set, load the IDE HD path, otherwise make it blank
651: //Master
1.1.1.3 root 652: // if (ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage)
653: // {
654: // IMPORT_TEXTFIELD(ideMasterHdImage, ConfigureParams.HardDisk.szIdeMasterHardDiskImage);
655: // }
656: // else
657: // {
1.1 root 658: [ideMasterHdImage setStringValue:@""];
1.1.1.3 root 659: // }
1.1 root 660: //Slave
1.1.1.3 root 661: // if (ConfigureParams.HardDisk.bUseIdeSlaveHardDiskImage)
662: // {
663: // IMPORT_TEXTFIELD(ideSlaveHdImage, ConfigureParams.HardDisk.szIdeSlaveHardDiskImage);
664: // }
665: // else
666: // {
1.1 root 667: [ideSlaveHdImage setStringValue:@""];
1.1.1.3 root 668: // }
1.1 root 669:
670: // If the Gemdos flag is set, load the Gemdos path, otherwise make it blank
1.1.1.3 root 671: // if (ConfigureParams.HardDisk.bUseHardDiskDirectories)
672: // {
673: // IMPORT_TEXTFIELD(gemdosImage, ConfigureParams.HardDisk.szHardDiskDirectories[0]);
674: // }
675: // else
676: // {
1.1 root 677: [gemdosImage setStringValue:@""];
1.1.1.3 root 678: // }
1.1 root 679:
680: // Set the per-joystick controls
1.1.1.3 root 681: // [self setJoystickControls];
1.1 root 682:
683: // Update the controls' enabled states
684: [self updateEnabledStates:self];
685: }
686:
687:
688: /*-----------------------------------------------------------------------*/
689: /*
690: Updates the enabled states of controls who depend on other controls
691: */
692: - (IBAction)updateEnabledStates:(id)sender
693: {
694: // Joystick key controls are only enabled if "Use keyboard" is selected
695: int nJoystickMode;
696: EXPORT_RADIO(joystickMode, nJoystickMode);
1.1.1.3 root 697: // BOOL bUsingKeyboard = (nJoystickMode == JOYSTICK_KEYBOARD);
698: // [joystickUp setEnabled:bUsingKeyboard];
699: // [joystickRight setEnabled:bUsingKeyboard];
700: // [joystickDown setEnabled:bUsingKeyboard];
701: // [joystickLeft setEnabled:bUsingKeyboard];
702: // [joystickFire setEnabled:bUsingKeyboard];
1.1 root 703:
704: // Resolution and colour depth depend on Extended GEM VDI resolution
705: BOOL bUsingVDI;
706: EXPORT_SWITCH(useVDIResolution, bUsingVDI);
707: [resolution setEnabled:bUsingVDI];
708: [colorDepth setEnabled:bUsingVDI];
709:
710: // Playback quality depends on enable sound
711: BOOL bSoundEnabled;
712: EXPORT_SWITCH(enableSound, bSoundEnabled);
713: [playbackQuality setEnabled:bSoundEnabled];
714: }
715:
716:
717: /*-----------------------------------------------------------------------*/
718: /*
719: Updates the joystick controls to match the new joystick selection
720: */
721: - (void)setJoystickControls
722: {
723: // Get and persist the ID of the newly selected joystick
724: EXPORT_DROPDOWN(currentJoystick, nCurrentJoystick);
725:
726: // Data validation: If the JoyID is out of bounds, correct it and, if set to use real joystick, change to disabled
1.1.1.3 root 727: // if ( (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId < 0)
728: // || (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId >= cRealJoysticks) )
1.1 root 729: {
1.1.1.3 root 730: // ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId = 0;
731: // if (ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode == JOYSTICK_REALSTICK)
1.1 root 732: {
1.1.1.3 root 733: // ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode = JOYSTICK_DISABLED;
1.1 root 734: }
735: }
736:
737: // Don't change the realJoystick dropdown if none is available (to keep "(None available)" selected)
738: if (cRealJoysticks > 0)
739: {
1.1.1.3 root 740: // IMPORT_DROPDOWN(realJoystick, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId);
1.1 root 741: }
742:
1.1.1.3 root 743: // IMPORT_RADIO(joystickMode, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode);
744: // IMPORT_DROPDOWN(joystickUp, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeUp);
745: // IMPORT_DROPDOWN(joystickRight, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeRight);
746: // IMPORT_DROPDOWN(joystickDown, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeDown);
747: // IMPORT_DROPDOWN(joystickLeft, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeLeft);
748: // IMPORT_DROPDOWN(joystickFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeFire);
749: // IMPORT_SWITCH(enableAutoFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].bEnableAutoFire);
1.1 root 750: }
751:
752:
753: /*-----------------------------------------------------------------------*/
754: /*
755: Saves the setting for the joystick currently being viewed
756: */
757: - (void)saveJoystickControls
758: {
1.1.1.3 root 759: // EXPORT_RADIO(joystickMode, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoystickMode);
760: // EXPORT_DROPDOWN(realJoystick, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nJoyId);
761: // EXPORT_DROPDOWN(joystickUp, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeUp);
762: // EXPORT_DROPDOWN(joystickRight, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeRight);
763: // EXPORT_DROPDOWN(joystickDown, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeDown);
764: // EXPORT_DROPDOWN(joystickLeft, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeLeft);
765: // EXPORT_DROPDOWN(joystickFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].nKeyCodeFire);
766: // EXPORT_SWITCH(enableAutoFire, ConfigureParams.Joysticks.Joy[nCurrentJoystick].bEnableAutoFire);
1.1 root 767: }
768:
769:
770: /*-----------------------------------------------------------------------*/
771: /*
772: Saves the settings for all controls
773: */
774: - (void)saveAllControls
775: {
776: // Export the preference controls into their vars
1.1.1.5 ! root 777: EXPORT_SWITCH(realtime, ConfigureParams.System.bRealtime);
1.1 root 778: EXPORT_SWITCH(compatibleCpu, ConfigureParams.System.bCompatibleCpu);
779: EXPORT_RADIO(cpuClock, ConfigureParams.System.nCpuFreq);
780: EXPORT_RADIO(cpuType, ConfigureParams.System.nCpuLevel);
1.1.1.4 root 781: EXPORT_SWITCH(enablePrinter, ConfigureParams.Printer.bPrinterConnected);
1.1 root 782: EXPORT_SWITCH(enableSound, ConfigureParams.Sound.bEnableSound);
783: EXPORT_RADIO(keyboardMapping, ConfigureParams.Keyboard.nKeymapType);
784: EXPORT_TEXTFIELD(keyboardMappingFile, ConfigureParams.Keyboard.szMappingFileName);
785: EXPORT_RADIO(machineType, ConfigureParams.System.nMachineType);
786: EXPORT_RADIO(monitor, ConfigureParams.Screen.nMonitorType);
787: EXPORT_TEXTFIELD(printToFile, ConfigureParams.Printer.szPrintToFileName);
788: EXPORT_SWITCH(realTime, ConfigureParams.System.bRealTimeClock);
789: EXPORT_SWITCH(showStatusBar,ConfigureParams.Screen.bShowStatusbar);
790: EXPORT_DROPDOWN(enableDSP,ConfigureParams.System.nDSPType);
791:
792: EXPORT_SWITCH(fullScreen, ConfigureParams.Screen.bFullScreen);
793: IMPORT_SWITCH(ledDisks, ConfigureParams.Screen.bShowDriveLed);
1.1.1.5 ! root 794:
1.1 root 795: // Define the HD flag, and export the HD path if one is selected
796: if ([[hdImage stringValue] length] > 0)
797: {
1.1.1.3 root 798: // EXPORT_TEXTFIELD(hdImage, ConfigureParams.HardDisk.szHardDiskImage);
799: // ConfigureParams.HardDisk.bUseHardDiskImage = true;
1.1 root 800: }
801: else
802: {
1.1.1.3 root 803: // ConfigureParams.HardDisk.bUseHardDiskImage = false;
1.1 root 804: }
805:
806: // Define the IDE HD flag, and export the IDE HD path if one is selected
807: if ([[ideMasterHdImage stringValue] length] > 0)
808: {
1.1.1.3 root 809: // EXPORT_TEXTFIELD(ideMasterHdImage, ConfigureParams.HardDisk.szIdeMasterHardDiskImage);
810: // ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage = true;
1.1 root 811: }
812: else
813: {
1.1.1.3 root 814: // ConfigureParams.HardDisk.bUseIdeMasterHardDiskImage = false;
1.1 root 815: }
816:
817: // IDE Slave
818: if ([[ideSlaveHdImage stringValue] length] > 0)
819: {
1.1.1.3 root 820: // EXPORT_TEXTFIELD(ideSlaveHdImage, ConfigureParams.HardDisk.szIdeSlaveHardDiskImage);
821: // ConfigureParams.HardDisk.bUseIdeSlaveHardDiskImage = true;
1.1 root 822: }
823: else
824: {
1.1.1.3 root 825: // ConfigureParams.HardDisk.bUseIdeSlaveHardDiskImage = false;
1.1 root 826: }
827:
828: // Define the Gemdos flag, and export the Gemdos path if one is selected
829: if ([[gemdosImage stringValue] length] > 0)
830: {
1.1.1.3 root 831: // EXPORT_TEXTFIELD(gemdosImage, ConfigureParams.HardDisk.szHardDiskDirectories[0]);
832: // ConfigureParams.HardDisk.bUseHardDiskDirectories = true;
1.1 root 833: }
834: else
835: {
1.1.1.3 root 836: // ConfigureParams.HardDisk.bUseHardDiskDirectories = false;
1.1 root 837: }
838:
839: // Save the per-joystick controls
840: [self saveJoystickControls];
841: }
842:
843: // Max Zoomed Adjust
844:
845: - (IBAction) setWidth:(id)sender;
846: {
1.1.1.5 ! root 847: NSLog(@"Change Max Zoom width: %d", [sender intValue]);
1.1 root 848: [maxZoomedWidth setIntValue: [sender intValue]];
849: }
850:
851: - (IBAction) setHeight:(id)sender;
852: {
1.1.1.5 ! root 853: NSLog(@"Change Max Zoom height: %d", [sender intValue]);
1.1 root 854: [maxZoomedHeight setIntValue: [sender intValue]];
855: }
856:
857:
858: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.