25 |
|
|
26 |
|
const int CDROMRefNum = -62; // RefNum of driver |
27 |
|
|
28 |
+ |
#ifdef STANDALONE_PREFS |
29 |
|
void prefs_init() |
30 |
|
{ |
31 |
|
} |
33 |
|
void prefs_exit() |
34 |
|
{ |
35 |
|
} |
36 |
+ |
#endif |
37 |
|
|
38 |
|
@implementation VMSettingsController |
39 |
|
|
40 |
|
+ (id) sharedInstance |
41 |
|
{ |
42 |
< |
static VMSettingsController *_sharedInstance = nil; |
43 |
< |
if (!_sharedInstance) { |
44 |
< |
_sharedInstance = [[VMSettingsController allocWithZone:[self zone]] init]; |
45 |
< |
} |
46 |
< |
return _sharedInstance; |
42 |
> |
static VMSettingsController *_sharedInstance = nil; |
43 |
> |
if (!_sharedInstance) { |
44 |
> |
_sharedInstance = [[VMSettingsController allocWithZone:[self zone]] init]; |
45 |
> |
} |
46 |
> |
return _sharedInstance; |
47 |
|
} |
48 |
|
|
49 |
|
- (id) init |
50 |
|
{ |
51 |
|
self = [super initWithWindowNibName:@"VMSettingsWindow"]; |
52 |
|
|
53 |
< |
cancelWasClicked = NO; |
53 |
> |
cancelWasClicked = NO; |
54 |
|
|
55 |
< |
return self; |
55 |
> |
return self; |
56 |
|
} |
57 |
|
|
58 |
|
- (int) numberOfRowsInTableView: (NSTableView *) table |
137 |
|
[useRawKeyCodes setIntValue: PrefsFindBool("keycodes") ]; |
138 |
|
[rawKeyCodes setStringValue: getStringFromPrefs("keycodefile") ]; |
139 |
|
[rawKeyCodes setEnabled:[useRawKeyCodes intValue]]; |
140 |
+ |
[browseRawKeyCodesButton setEnabled:[useRawKeyCodes intValue]]; |
141 |
|
|
142 |
|
int wheelmode = PrefsFindInt32("mousewheelmode"), wheel = 0; |
143 |
|
switch (wheelmode) { |
162 |
|
|
163 |
|
- (void) editSettingsFor: (NSString *) vmdir sender: (id) sender |
164 |
|
{ |
165 |
< |
chdir([vmdir fileSystemRepresentation]); |
165 |
> |
chdir([vmdir fileSystemRepresentation]); |
166 |
> |
AddPrefsDefaults(); |
167 |
> |
AddPlatformPrefsDefaults(); |
168 |
> |
LoadPrefs([vmdir fileSystemRepresentation]); |
169 |
> |
NSWindow *window = [self window]; |
170 |
> |
[self setupGUI]; |
171 |
> |
[NSApp runModalForWindow:window]; |
172 |
> |
} |
173 |
> |
|
174 |
> |
- (void) editSettingsForNewVM: (NSString *) vmdir sender: (id) sender |
175 |
> |
{ |
176 |
> |
chdir([vmdir fileSystemRepresentation]); |
177 |
|
AddPrefsDefaults(); |
178 |
|
AddPlatformPrefsDefaults(); |
179 |
|
LoadPrefs([vmdir fileSystemRepresentation]); |
180 |
< |
NSWindow *window = [self window]; |
181 |
< |
[self setupGUI]; |
182 |
< |
[NSApp runModalForWindow:window]; |
180 |
> |
PrefsReplaceString("screen", "win/800/600"); |
181 |
> |
PrefsReplaceString("extfs", ""); |
182 |
> |
PrefsReplaceString("ether", "slirp"); |
183 |
> |
PrefsReplaceInt32("ramsize", 64 << 20); |
184 |
> |
PrefsReplaceInt32("frameskip", 2); |
185 |
> |
PrefsReplaceBool("jit", true); |
186 |
> |
NSWindow *window = [self window]; |
187 |
> |
[self setupGUI]; |
188 |
> |
[NSApp runModalForWindow:window]; |
189 |
|
} |
190 |
|
|
191 |
|
static NSString *makeRelativeIfNecessary(NSString *path) |
192 |
|
{ |
193 |
< |
char cwd[1024], filename[1024]; |
194 |
< |
int cwdlen; |
195 |
< |
strlcpy(filename, [path fileSystemRepresentation], sizeof(filename)); |
196 |
< |
getcwd(cwd, sizeof(cwd)); |
197 |
< |
cwdlen = strlen(cwd); |
198 |
< |
if (!strncmp(cwd, filename, cwdlen)) { |
199 |
< |
if (cwdlen >= 0 && cwd[cwdlen-1] != '/') |
200 |
< |
cwdlen++; |
201 |
< |
return [NSString stringWithCString: filename + cwdlen]; |
202 |
< |
} |
203 |
< |
return path; |
193 |
> |
char cwd[1024], filename[1024]; |
194 |
> |
int cwdlen; |
195 |
> |
strlcpy(filename, [path fileSystemRepresentation], sizeof(filename)); |
196 |
> |
getcwd(cwd, sizeof(cwd)); |
197 |
> |
cwdlen = strlen(cwd); |
198 |
> |
if (!strncmp(cwd, filename, cwdlen)) { |
199 |
> |
if (cwdlen >= 0 && cwd[cwdlen-1] != '/') |
200 |
> |
cwdlen++; |
201 |
> |
return [NSString stringWithCString: filename + cwdlen]; |
202 |
> |
} |
203 |
> |
return path; |
204 |
|
} |
205 |
|
|
206 |
|
- (IBAction) addDisk: (id) sender |
220 |
|
- (void) _addDiskEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo |
221 |
|
{ |
222 |
|
if (theReturnCode == NSOKButton) { |
223 |
< |
[diskArray addObject: makeRelativeIfNecessary([open filename])]; |
223 |
> |
[diskArray addObject: makeRelativeIfNecessary([open filename])]; |
224 |
|
[disks reloadData]; |
225 |
|
} |
226 |
|
} |
256 |
|
snprintf(cmd, sizeof(cmd), "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", [[save filename] UTF8String], [diskSaveSizeField intValue]); |
257 |
|
int ret = system(cmd); |
258 |
|
if (ret == 0) { |
259 |
< |
[diskArray addObject: makeRelativeIfNecessary([save filename])]; |
259 |
> |
[diskArray addObject: makeRelativeIfNecessary([save filename])]; |
260 |
|
[disks reloadData]; |
261 |
|
} |
262 |
|
} |
267 |
|
- (IBAction) useRawKeyCodesClicked: (id) sender |
268 |
|
{ |
269 |
|
[rawKeyCodes setEnabled:[useRawKeyCodes intValue]]; |
270 |
+ |
[browseRawKeyCodesButton setEnabled:[useRawKeyCodes intValue]]; |
271 |
|
} |
272 |
|
|
273 |
|
- (IBAction) browseForROMFileClicked: (id) sender |
287 |
|
- (void) _browseForROMFileEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo |
288 |
|
{ |
289 |
|
if (theReturnCode == NSOKButton) { |
290 |
< |
[romFile setStringValue: makeRelativeIfNecessary([open filename])]; |
291 |
< |
} |
290 |
> |
[romFile setStringValue: makeRelativeIfNecessary([open filename])]; |
291 |
> |
} |
292 |
|
} |
293 |
|
|
294 |
|
- (IBAction) browseForUnixRootClicked: (id) sender |
308 |
|
- (void) _browseForUnixRootEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo |
309 |
|
{ |
310 |
|
if (theReturnCode == NSOKButton) { |
311 |
< |
[unixRoot setStringValue: makeRelativeIfNecessary([open filename])]; |
311 |
> |
[unixRoot setStringValue: makeRelativeIfNecessary([open filename])]; |
312 |
> |
} |
313 |
> |
} |
314 |
> |
|
315 |
> |
- (IBAction) browseForKeyCodesFileClicked: (id) sender |
316 |
> |
{ |
317 |
> |
NSOpenPanel *open = [NSOpenPanel openPanel]; |
318 |
> |
[open setCanChooseDirectories:NO]; |
319 |
> |
[open setAllowsMultipleSelection:NO]; |
320 |
> |
[open setTreatsFilePackagesAsDirectories:YES]; |
321 |
> |
[open beginSheetForDirectory: @"" |
322 |
> |
file: [unixRoot stringValue] |
323 |
> |
modalForWindow: [self window] |
324 |
> |
modalDelegate: self |
325 |
> |
didEndSelector: @selector(_browseForKeyCodesFileEnd: returnCode: contextInfo:) |
326 |
> |
contextInfo: nil]; |
327 |
> |
} |
328 |
> |
|
329 |
> |
- (void) _browseForKeyCodesFileEnd: (NSOpenPanel *) open returnCode: (int) theReturnCode contextInfo: (void *) theContextInfo |
330 |
> |
{ |
331 |
> |
if (theReturnCode == NSOKButton) { |
332 |
> |
[rawKeyCodes setStringValue: makeRelativeIfNecessary([open filename])]; |
333 |
|
} |
334 |
|
} |
335 |
|
|
336 |
|
- (void) cancelEdit: (id) sender |
337 |
|
{ |
338 |
+ |
#ifdef STANDALONE_PREFS |
339 |
|
PrefsExit(); |
340 |
< |
[[self window] close]; |
341 |
< |
[NSApp stopModal]; |
342 |
< |
cancelWasClicked = YES; |
340 |
> |
#endif |
341 |
> |
[[self window] close]; |
342 |
> |
[NSApp stopModal]; |
343 |
> |
cancelWasClicked = YES; |
344 |
|
} |
345 |
|
|
346 |
|
- (void) saveChanges: (id) sender |
394 |
|
PrefsReplaceString("serialb", [[printerPort stringValue] UTF8String]); |
395 |
|
PrefsReplaceString("ether", [[ethernetInterface stringValue] UTF8String]); |
396 |
|
SavePrefs(); |
397 |
+ |
#ifdef STANDALONE_PREFS |
398 |
|
PrefsExit(); |
399 |
+ |
#endif |
400 |
|
|
401 |
< |
[[self window] close]; |
402 |
< |
[NSApp stopModal]; |
403 |
< |
cancelWasClicked = NO; |
401 |
> |
[[self window] close]; |
402 |
> |
[NSApp stopModal]; |
403 |
> |
cancelWasClicked = NO; |
404 |
|
} |
405 |
|
|
406 |
|
- (BOOL) cancelWasClicked |