From c4526aff5c81040e3cff285c91223df59511d124 Mon Sep 17 00:00:00 2001 From: gecko_reverse Date: Thu, 24 Apr 2008 06:00:20 +0000 Subject: [PATCH] cocoa port: uses utf8 to pass strings to the emulator core instead of ascii. the load state from file menu item was actually saving the state instead of loading. the save state to file option now pauses emulation, so you can save the state the emulator is in when you choose to save, not when you choose the file. also, cocoa port changes in the chanlog will be listed under under macos x instead of cocoa since thats probably more well understood --- desmume/ChangeLog | 6 ++++++ desmume/src/cocoa/globals.h | 3 --- desmume/src/cocoa/main_window.m | 16 ++++++++++++++-- desmume/src/cocoa/nds_control.m | 8 ++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/desmume/ChangeLog b/desmume/ChangeLog index b61e7e528..1d0ff22d2 100644 --- a/desmume/ChangeLog +++ b/desmume/ChangeLog @@ -1,3 +1,9 @@ +0.8 -> ? + Mac OS X: + - Fixed: Filenames and paths with unicode characters now work. [Jeff] + - Fixed: Load state from file button works again. [Jeff] + - Save State panel now pauses emulation while the file selection box is open. [Jeff] + 0.7.3 -> 0.8 Cocoa: - Save State As function now works. [Jeff B] diff --git a/desmume/src/cocoa/globals.h b/desmume/src/cocoa/globals.h index 325e559b7..9f13d9472 100644 --- a/desmume/src/cocoa/globals.h +++ b/desmume/src/cocoa/globals.h @@ -19,9 +19,6 @@ #import -//cocoa utils -#define NSSTRc(x) ([[NSString alloc] initWithCString:(x) encoding:NSASCIIStringEncoding]) - void messageDialogBlank(); void messageDialog(NSString *title, NSString *text); BOOL messageDialogYN(NSString *title, NSString *text); diff --git a/desmume/src/cocoa/main_window.m b/desmume/src/cocoa/main_window.m index 683552c93..98142d5a1 100644 --- a/desmume/src/cocoa/main_window.m +++ b/desmume/src/cocoa/main_window.m @@ -380,13 +380,25 @@ NSMenuItem *screenshot_to_file_item; - (BOOL)saveStateAs { + //pause emulation so it doesnt save the state after + BOOL was_executing = [self executing]; + [self pause]; + + //file select NSSavePanel *panel = [NSSavePanel savePanel]; [panel setTitle:NSLocalizedString(@"Save State...", nil)]; [panel setRequiredFileType:@"DST"]; + //save it if([panel runModal] == NSFileHandlingPanelOKButton) + { + if(was_executing == YES)[self execute]; return [self saveState:[panel filename]]; - + } + + //unpause emulation if needed + if(was_executing == YES)[self execute]; + return NO; } @@ -399,7 +411,7 @@ NSMenuItem *screenshot_to_file_item; [panel setAllowsMultipleSelection:NO]; if([panel runModalForTypes:[NSArray arrayWithObject:@"DST"]] == NSFileHandlingPanelOKButton) - return [self saveState:[panel filename]]; + return [self loadState:[panel filename]]; return NO; } diff --git a/desmume/src/cocoa/nds_control.m b/desmume/src/cocoa/nds_control.m index acaac5276..b58e6b349 100644 --- a/desmume/src/cocoa/nds_control.m +++ b/desmume/src/cocoa/nds_control.m @@ -233,7 +233,7 @@ struct NDS_fw_config_data firmware; flash = NULL; //load the rom - if(!NDS_LoadROM([filename cStringUsingEncoding:NSASCIIStringEncoding], backupmemorytype, backupmemorysize, flash) > 0) + if(!NDS_LoadROM([filename cStringUsingEncoding:NSUTF8StringEncoding], backupmemorytype, backupmemorysize, flash) > 0) { //if it didn't work give an error and dont unpause messageDialog(NSLocalizedString(@"Error", nil), @"Could not open file"); @@ -369,7 +369,7 @@ struct NDS_fw_config_data firmware; - (NSString*)ROMTitle { - return NSSTRc(NDS_getROMHeader()->gameTile); + return [[NSString alloc] initWithCString:(NDS_getROMHeader()->gameTile) encoding:NSUTF8StringEncoding]; } - (NSInteger)ROMMaker @@ -863,7 +863,7 @@ struct NDS_fw_config_data firmware; [execution_lock lock]; BOOL result = NO; - if(savestate_save([file cStringUsingEncoding:NSASCIIStringEncoding])) + if(savestate_save([file cStringUsingEncoding:NSUTF8StringEncoding])) result = YES; [execution_lock unlock]; @@ -876,7 +876,7 @@ struct NDS_fw_config_data firmware; [execution_lock lock]; BOOL result = NO; - if(savestate_load([file cStringUsingEncoding:NSASCIIStringEncoding])) + if(savestate_load([file cStringUsingEncoding:NSUTF8StringEncoding])) result = YES; [execution_lock unlock];