30 |
|
self = [super init]; |
31 |
|
|
32 |
|
numItems = 0; |
33 |
< |
col1 = [[NSMutableArray alloc] init]; |
34 |
< |
col2 = [[NSMutableArray alloc] init]; |
33 |
> |
col1 = [NSMutableArray new]; |
34 |
> |
col2 = [NSMutableArray new]; |
35 |
|
|
36 |
|
return self; |
37 |
|
} |
126 |
|
|
127 |
|
devs = @"/dev"; |
128 |
|
home = NSHomeDirectory(); |
129 |
< |
volsDS = [[TableDS alloc] init]; |
130 |
< |
SCSIds = [[TableDS alloc] init]; |
129 |
> |
volsDS = [TableDS new]; |
130 |
> |
SCSIds = [TableDS new]; |
131 |
|
|
132 |
< |
lockCell = [[NSImageCell alloc] init]; |
132 |
> |
lockCell = [NSImageCell new]; |
133 |
|
if ( lockCell == nil ) |
134 |
|
NSLog (@"%s - Can't create NSImageCell?", __PRETTY_FUNCTION__); |
135 |
|
|
136 |
< |
blank = [[NSImage alloc] init]; |
136 |
> |
blank = [NSImage new]; |
137 |
|
locked = [NSImage alloc]; |
138 |
|
if ( [locked initWithContentsOfFile: |
139 |
|
[[NSBundle mainBundle] |
260 |
|
|
261 |
|
- (IBAction) ChangeDisableSound: (NSButton *)sender |
262 |
|
{ |
263 |
< |
PrefsReplaceBool("nosound", [disableSound state]); |
263 |
> |
BOOL noSound = [disableSound state]; |
264 |
> |
|
265 |
> |
if ( ! noSound ) |
266 |
> |
WarningSheet(@"Sound is currently unimplemented", panel); |
267 |
> |
|
268 |
> |
PrefsReplaceBool("nosound", noSound); |
269 |
|
edited = YES; |
270 |
|
} |
271 |
|
|
281 |
|
edited = YES; |
282 |
|
} |
283 |
|
|
284 |
< |
// Screen/window changing stuff |
285 |
< |
|
286 |
< |
// This is called when any of the screen/window, width, height or depth is changed |
284 |
> |
// This is called when any of the screen/openGL/window, |
285 |
> |
// width, height or depth is clicked. |
286 |
> |
// |
287 |
> |
// Note that sender may not actually be an NSMatrix. |
288 |
|
|
289 |
|
- (IBAction) ChangeScreen: (NSMatrix *)sender |
290 |
|
{ |
291 |
+ |
NSButton *cell = [sender selectedCell]; |
292 |
+ |
|
293 |
|
short newx = [width intValue]; |
294 |
|
short newy = [height intValue]; |
295 |
|
short newbpp = [depth intValue]; |
296 |
< |
short newtype = DISPLAY_WINDOW; |
296 |
> |
short newtype; |
297 |
|
char str[20]; |
298 |
|
|
299 |
< |
if ( [sender selectedCell] == openGL ) |
299 |
> |
if ( cell == openGL ) |
300 |
|
newtype = DISPLAY_OPENGL; |
301 |
< |
if ( [sender selectedCell] == screen ) |
301 |
> |
else if ( cell == screen ) |
302 |
|
newtype = DISPLAY_SCREEN; |
303 |
+ |
else if ( cell == window ) |
304 |
+ |
newtype = DISPLAY_WINDOW; |
305 |
+ |
else |
306 |
+ |
newtype = display_type; |
307 |
|
|
308 |
|
// Check that a field actually changed |
309 |
|
if ( newbpp == init_depth && newx == init_width && |
310 |
|
newy == init_height && newtype == display_type ) |
311 |
+ |
{ |
312 |
+ |
D(NSLog(@"No changed GUI items in ChangeScreen")); |
313 |
|
return; |
314 |
< |
|
314 |
> |
} |
315 |
|
|
316 |
|
// If we are changing type, supply some sensible defaults |
317 |
|
if ( newtype != display_type ) |
318 |
|
{ |
319 |
+ |
D(NSLog(@"Changing display type in ChangeScreen")); |
320 |
|
if ( newtype == DISPLAY_SCREEN ) // If changing to full screen |
321 |
|
{ |
322 |
|
// supply main screen dimensions as a default |
323 |
< |
NSScreen *s = [NSScreen mainScreen]; |
324 |
< |
NSRect sr = [s frame]; |
310 |
< |
|
311 |
< |
newx = (short) sr.size.width; |
312 |
< |
newy = (short) sr.size.height; |
313 |
< |
// This always returns 24, despite the mode |
314 |
< |
//newbpp = NSBitsPerPixelFromDepth([s depth]); |
323 |
> |
newx = CGDisplayPixelsWide (kCGDirectMainDisplay); |
324 |
> |
newy = CGDisplayPixelsHigh (kCGDirectMainDisplay); |
325 |
|
newbpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay); |
326 |
|
} |
327 |
|
|
328 |
|
if ( display_type == DISPLAY_SCREEN ) // If changing from full screen |
329 |
+ |
{ |
330 |
|
newx = MIN_WIDTH, newy = MIN_HEIGHT; |
331 |
+ |
#ifndef MAC_OS_X_VERSION_SUPPORTS_LOWER_DEPTHS |
332 |
+ |
newbpp = 32; |
333 |
+ |
#endif |
334 |
+ |
} |
335 |
|
|
336 |
|
[width setIntValue: newx]; |
337 |
|
[height setIntValue: newy]; |
339 |
|
} |
340 |
|
else |
341 |
|
{ |
342 |
+ |
#ifndef MAC_OS_X_VERSION_SUPPORTS_LOWER_DEPTHS |
343 |
+ |
// Check depth |
344 |
+ |
|
345 |
+ |
if ( display_type == DISPLAY_WINDOW && newbpp != 32 ) |
346 |
+ |
{ |
347 |
+ |
WarningSheet(@"Sorry - In windowed mode, depth must be 32", panel); |
348 |
+ |
[depth setIntValue: 32]; |
349 |
+ |
} |
350 |
+ |
#endif |
351 |
|
// Check size is within ranges of MIN_WIDTH ... MAX_WIDTH |
352 |
|
// and MIN_HEIGHT ... MAX_HEIGHT |
353 |
|
// ??? |
384 |
|
edited = YES; |
385 |
|
|
386 |
|
if ( display_type != DISPLAY_SCREEN ) |
387 |
+ |
{ |
388 |
+ |
D(NSLog(@"Display type is not SCREEN (%d), resizing window", |
389 |
+ |
display_type)); |
390 |
|
resizeWinTo(newx, newy); |
391 |
+ |
} |
392 |
|
} |
393 |
|
|
394 |
|
- (IBAction) CreateVolume: (id)sender |
413 |
|
NSString *details = [NSString stringWithFormat: |
414 |
|
@"The dd command failed.\nReturn status %d (%s)", |
415 |
|
retVal, strerror(errno)]; |
416 |
< |
WarningSheet(@"Unable to create volume", details, @"OK", panel); |
416 |
> |
WarningSheet(@"Unable to create volume", details, nil, panel); |
417 |
|
} |
418 |
|
else |
419 |
|
{ |
425 |
|
} |
426 |
|
} |
427 |
|
|
428 |
+ |
- (BOOL) fileManager: (NSFileManager *) manager |
429 |
+ |
shouldProceedAfterError: (NSDictionary *) errorDict |
430 |
+ |
{ |
431 |
+ |
NSRunAlertPanel(@"File operation error", |
432 |
+ |
@"%@ %@, toPath %@", |
433 |
+ |
@"Bugger!", nil, nil, |
434 |
+ |
[errorDict objectForKey:@"Error"], |
435 |
+ |
[errorDict objectForKey:@"Path"], |
436 |
+ |
[errorDict objectForKey:@"ToPath"]); |
437 |
+ |
return NO; |
438 |
+ |
} |
439 |
+ |
|
440 |
|
- (IBAction) DeleteVolume: (id)sender |
441 |
|
{ |
442 |
< |
const char *path = [self RemoveVolumeEntry]; |
443 |
< |
if ( unlink(path) == -1 ) |
442 |
> |
// const char *path = [self RemoveVolumeEntry]; |
443 |
> |
// if ( unlink(path) == -1 ) |
444 |
> |
NSString *Path = [self RemoveVolumeEntry]; |
445 |
> |
|
446 |
> |
if ( ! [[NSFileManager defaultManager] removeFileAtPath: Path |
447 |
> |
handler: self] ) |
448 |
|
{ |
449 |
< |
NSLog(@"%s unlink(%s) failed", __PRETTY_FUNCTION__, path, strerror(errno)); |
449 |
> |
WarningSheet(@"Unable to delete volume", panel); |
450 |
> |
// NSLog(@"%s unlink(%s) failed - %s", __PRETTY_FUNCTION__, path, strerror(errno)); |
451 |
|
} |
452 |
|
} |
453 |
|
|
472 |
|
int B = (int) [bytes floatValue]; |
473 |
|
float M = B / 1024 / 1024; |
474 |
|
|
475 |
< |
NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B); |
475 |
> |
D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B)); |
476 |
|
PrefsReplaceInt32("ramsize", B); |
477 |
|
[MB setFloatValue: M]; |
478 |
|
edited = YES; |
516 |
|
float M = [MB floatValue]; |
517 |
|
int B = (int) (M * 1024 * 1024); |
518 |
|
|
519 |
< |
NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B); |
519 |
> |
D(NSLog(@"%s = %f %d", __PRETTY_FUNCTION__, M, B)); |
520 |
|
PrefsReplaceInt32("ramsize", B); |
521 |
|
[bytes setIntValue: B]; |
522 |
|
edited = YES; |
530 |
|
edited = YES; |
531 |
|
} |
532 |
|
|
488 |
– |
- (IBAction) EditRAMsize: (NSTextField *)sender |
489 |
– |
{ |
490 |
– |
int B = [bytes intValue]; |
491 |
– |
float M = B / (1024.0 * 1024.0); |
492 |
– |
|
493 |
– |
NSLog(@"%s = %d %f", __PRETTY_FUNCTION__, B, M); |
494 |
– |
PrefsReplaceInt32("ramsize", B); |
495 |
– |
[MB setFloatValue: M]; |
496 |
– |
edited = YES; |
497 |
– |
} |
498 |
– |
|
533 |
|
- (IBAction) EditROMpath: (NSTextField *)sender |
534 |
|
{ |
535 |
|
NSString *path = [ROMfile stringValue]; |
550 |
|
PrefsRemoveItem(pref,0); |
551 |
|
} |
552 |
|
|
553 |
< |
- (const char *) RemoveVolumeEntry |
553 |
> |
//- (const char *) RemoveVolumeEntry |
554 |
> |
- (NSString *) RemoveVolumeEntry |
555 |
|
{ |
556 |
|
int row = [diskImages selectedRow]; |
557 |
|
|
558 |
|
if ( row != -1 ) |
559 |
|
{ |
560 |
< |
const char *path = [[volsDS pathAtRow: row] cString], |
560 |
> |
NSString *Path = [volsDS pathAtRow: row]; |
561 |
> |
const char *path = [Path cString], |
562 |
|
*str; |
563 |
|
int tmp = 0; |
564 |
|
|
567 |
|
if ( strcmp(str, path) == 0 ) |
568 |
|
{ |
569 |
|
PrefsRemoveItem("disk", tmp); |
570 |
< |
D(NSLog(@"%s - Deleted prefs entry \"disk\", %d", __PRETTY_FUNCTION__, tmp)); |
570 |
> |
D(NSLog(@"%s - Deleted prefs entry \"disk\", %d", |
571 |
> |
__PRETTY_FUNCTION__, tmp)); |
572 |
|
edited = YES; |
573 |
|
break; |
574 |
|
} |
577 |
|
|
578 |
|
if ( str == NULL ) |
579 |
|
{ |
580 |
< |
NSLog(@"%s - Couldn't find any disk preference to match %s", __PRETTY_FUNCTION__, path); |
580 |
> |
NSLog(@"%s - Couldn't find any disk preference to match %s", |
581 |
> |
__PRETTY_FUNCTION__, path); |
582 |
|
return NULL; |
583 |
|
} |
584 |
|
|
585 |
|
if ( ! [volsDS deleteRow: row] ) |
586 |
|
NSLog (@"%s - RemoveVolume %d failed", __PRETTY_FUNCTION__, tmp); |
587 |
|
[diskImages reloadData]; |
588 |
< |
return path; |
588 |
> |
// return path; |
589 |
> |
return Path; |
590 |
|
} |
591 |
|
else |
592 |
|
{ |
593 |
< |
WarningSheet(@"Please select a volume first", @"", @"OK", panel); |
593 |
> |
WarningSheet(@"Please select a volume first", panel); |
594 |
|
return NULL; |
595 |
|
} |
596 |
|
} |
698 |
|
// Window already created by NIB file, just display |
699 |
|
[panel makeKeyAndOrderFront:self]; |
700 |
|
WarningSheet(@"Compiled-in memory model does not support 24bit", |
701 |
< |
@"Disabling Mac Classic emulation", @"OK", panel); |
701 |
> |
@"Disabling Mac Classic emulation", nil, panel); |
702 |
|
cpu = [CPU68030 tag]; |
703 |
|
PrefsReplaceInt32("cpu", cpu); |
704 |
|
tmp = [IIci tag]; |