updates to cocoa port

This commit is contained in:
gecko_reverse 2008-02-25 08:21:36 +00:00
parent 5aa777c461
commit 9b6457db86
18 changed files with 446 additions and 419 deletions

View File

@ -3,13 +3,14 @@
- Save State As function now works. [Jeff B]
- Recent Items menu now works. [Jeff B]
- Opening NDS files from Finder now works. [Jeff B]
- Added screenshot to file feature (bmp, jpg, gif, png, tiff). [Jeff B]
- Added screenshot to separate window feature. [Jeff B]
- Added the preferences window. [Jeff B]
- Added option to disable execution upon loading. [Jeff B]
- Added screenshot feature. [Jeff B]
- Added preferences window. [Jeff B]
- Many more strings are translatable now. [Jeff B]
- Default screen color now black (better represents being "off" and easier on eyes at night) [Jeff B]
- Added sound [Jeff B]
- Default screen color is black (better represents being "off" and easier on eyes at night). [Jeff B]
- Added sound. [Jeff B]
- Now is a universal binary. [Jeff B]
- Leopard resolution icon added. [Jeff B]
- Added a Japanese translation. [Jeff B]
general:
- Fixed possible segfault in ROMReader on ia64 and amd64. [evilynux]
- Fixed a crash bug with 2D background corrupting memory [shash]

View File

@ -5,6 +5,7 @@
<Option title="DeSmuME Cocoa" />
<Option platforms="Mac;" />
<Option pch_mode="2" />
<Option default_target="Cocoa X86" />
<Option compiler="gcc" />
<Option show_notes="0">
<notes>
@ -31,39 +32,38 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA]]>
<Target title="Cocoa X86">
<Option platforms="Mac;" />
<Option output="DeSmuME.app/Contents/MacOS/DeSmuME" prefix_auto="0" extension_auto="0" />
<Option object_output="obj/Release/" />
<Option working_dir="DeSmuME.app/Contents/MacOS" />
<Option object_output="obj/X86" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-march=pentium-m" />
<Add option="-arch i386" />
<Add option="-g" />
<Add option="-msse2" />
<Add option="-DDESMUME_COCOA" />
</Compiler>
<Linker>
<Add option="-framework Cocoa" />
<Add option="-framework OpenGL" />
<Add option="-framework CoreAudio" />
<Add option="-framework AudioUnit" />
<Add option="-framework AudioToolbox" />
</Linker>
<ExtraCommands>
<Add after="cp DeSmuME.app/Contents/MacOS/DeSmuME DeSmuME.app/Contents/MacOS/DeSmuME_x86" />
</ExtraCommands>
</Target>
<Target title="Cocoa PPC">
<Option platforms="Mac;" />
<Option output="DeSmuME.app/Contents/MacOS/DeSmuME" prefix_auto="0" extension_auto="0" />
<Option object_output="obj/Release/" />
<Option working_dir="DeSmuME.app/Contents/MacOS" />
<Option object_output="obj/PPC" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-arch ppc" />
<Add option="-DDESMUME_COCOA" />
<Add option="-DWORDS_BIGENDIAN" />
</Compiler>
<Linker>
<Add option="-framework Cocoa" />
<Add option="-framework OpenGL" />
<Add option="-framework CoreAudio" />
<Add option="-framework AudioUnit" />
<Add option="-framework AudioToolbox" />
<Add option="-arch ppc" />
</Linker>
<ExtraCommands>
<Add after="cp DeSmuME.app/Contents/MacOS/DeSmuME DeSmuME.app/Contents/MacOS/DeSmuME_ppc" />
</ExtraCommands>
</Target>
</Build>
<VirtualTargets>
@ -72,10 +72,20 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA]]>
<Compiler>
<Add option="-fexpensive-optimizations" />
<Add option="-O3" />
<Add option="-DDETECT_LEAKS" />
</Compiler>
<Linker>
<Add option="-s" />
<Add option="-framework Cocoa" />
<Add option="-framework OpenGL" />
<Add option="-framework CoreAudio" />
<Add option="-framework AudioUnit" />
<Add option="-framework AudioToolbox" />
</Linker>
<ExtraCommands>
<Add after="./makeapp.sh" />
<Mode after="always" />
</ExtraCommands>
<Unit filename="../ARM9.h" />
<Unit filename="../Disassembler.c">
<Option compilerVar="CC" />
@ -122,6 +132,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA]]>
<Option compilerVar="CC" />
</Unit>
<Unit filename="../cflash.h" />
<Unit filename="English.strings" />
<Unit filename="Japanese.strings" />
<Unit filename="cocoa_util.m">
<Option compile="1" />
<Option link="1" />
@ -224,6 +236,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA]]>
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

BIN
desmume/src/cocoa/DeSmuME.icns Executable file

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>nds</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>DeSmuME</string>
<key>CFBundleTypeName</key>
<string>Nintendo DS Software</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>DeSmuME</string>
<key>CFBundleIconFile</key>
<string>DeSmuME</string>
<key>CFBundleIdentifier</key>
<string>com.DeSmuME.DeSmuME</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>DeSmuME</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.7.4alpha</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.7.4alpha</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
APPL????

View File

@ -19,35 +19,6 @@
#import "globals.h"
void setTitle(int i)
{
[main_window setTitle:[NSString stringWithFormat:@"%d", i]];
}
////////////////////////////////////////////////////////////////
//Menu Item implementation--------------------------------------
////////////////////////////////////////////////////////////////
@implementation NSMenu (localization)
- (id <NSMenuItem>)addItemWithTitle:(NSString *)aString action:(SEL)aSelector keyEquivalent:(NSString *)keyEquiv
{
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:localizedString(aString, nil) action:aSelector keyEquivalent:keyEquiv];
[self addItem:item];
return item;
}
- (id <NSMenuItem>)addItemWithTitle:(NSString *)aString withInt:(int)number action:(SEL)aSelector keyEquivalent:(NSString *)keyEquiv
{
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:localizedString(aString, nil),number] action:aSelector keyEquivalent:keyEquiv];
[self addItem:item];
return item;
}
@end
////////////////////////////////////////////////////////////////
//Dialog Boxes-------------------------------------------------
////////////////////////////////////////////////////////////////
@ -91,11 +62,3 @@ NSString* openDialog(NSArray *file_types)
return NULL;
}
////////////////////////////////////////////////////////////////
//Language Stuff-----------------------------------------------
////////////////////////////////////////////////////////////////
NSString *localizedString(NSString *string, NSString *comment)
{
return NSLocalizedString(string,nil);
}

View File

@ -17,7 +17,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//fixme headers conform to desmume?
#ifndef GLOBALS_H_INCLUDED
#define GLOBALS_H_INCLUDED
@ -49,30 +48,13 @@
//defined in cocoa_util.m
//c string to NSString
#define NSSTRc(x) ([[NSString alloc] initWithCString:(x) encoding:NSASCIIStringEncoding])
//these class extensions do the localstring lookup so we dont have to type it over and over again
/*
@interface NSMenuItem (localization)
- (id)initWithTitle:(NSString *)not_localized_name action:(SEL)action keyEquivalent:(NSString*)key;
@end
*/
@interface NSMenu (localization)
- (id <NSMenuItem>)addItemWithTitle:(NSString *)aString action:(SEL)aSelector keyEquivalent:(NSString *)keyEquiv;
- (id <NSMenuItem>)addItemWithTitle:(NSString *)aString withInt:(int)number action:(SEL)aSelector keyEquivalent:(NSString *)keyEquiv;
@end
//dialogs
#define NSSTRc(x) ([[NSString alloc] initWithCString:(x) encoding:NSASCIIStringEncoding])//dialogs
void messageDialogBlank();
void messageDialog(NSString *title, NSString *text);
BOOL messageDialogYN(NSString *title, NSString *text);
NSString* openDialog(NSArray *file_types);
//
NSString* localizedString(NSString *stuff, NSString *comment);
//Menus -------------------------------------------------------------------------------------------
//These are all the menu items that need checkmarks
//or their enabled status managed
@ -156,5 +138,12 @@ extern volatile int /*desmume_BOOL*/ execute;
extern volatile BOOL finished;
extern volatile BOOL paused;
//--------------------------------------------------------------------------------------------------
#ifndef __OBJC2__
typedef int NSInteger;
typedef unsigned NSUInteger;
#endif
#endif // GLOBALS_H_INCLUDED

View File

@ -44,32 +44,18 @@ FIXME: When cross-platform (core) components end emulation due to error - pause
FIXME: Some bug where states get messed up and hitting execute does nothing......
FIXME: .nds.gba extensions don't work in open panels
FIXME: Traveling windows when constantly resizing
FIXME: Show version number somewhere in the program
*/
//Globals----------------------------------------------------------------------------------------
NSMenu *menu;
NSAutoreleasePool *autorelease;
//Interfaces--------------------------------------------------------------------------------------
@interface NSApplication(custom)
//this prototype was removed from the mac os headers
- (void)setAppleMenu:(NSMenu*)menu;
//here we extend NSApplication
- (void)about;
- (void)preferences;
//help menu
- (void)launchWebsite;
- (void)launchForums;
- (void)bugReport;
@end
@interface NSApplication(delegate)
@interface AppDelegate : NSObject
{}
//delegate methods
- (BOOL)application:(NSApplication*)sender openFile:(NSString*)filename;
@ -77,9 +63,7 @@ NSMenu *menu;
- (void)applicationWillFinishLaunching:(NSNotification*)aNotification;
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification;
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender;
- (void)applicationWillTerminate:(NSNotification*)aNotification;
@end
//Global access gui constructs
@ -104,19 +88,7 @@ GPU3DInterface *core3DList[] = {
NintendoDS *NDS;
void Quit()
{
//stop emulation if it's going
[NDS destroy];
//
finished = true;
//
[NSApp stop:NSApp];
}
void AskForQuit()
bool AskForQuit()
{
BOOL was_paused = paused;
@ -124,10 +96,13 @@ void AskForQuit()
[NDS pause];
//ask the user if quitting is acceptable
if(messageDialogYN(localizedString(@"DeSmuME Emulator", nil), localizedString(@"Are you sure you want to quit?", nil)))
Quit();
if(messageDialogYN(NSLocalizedString(@"DeSmuME Emulator", nil), NSLocalizedString(@"Are you sure you want to quit?", nil)))
return true;
else
{
if(!was_paused)[NDS execute]; //unpaused if we weren't paused before
return false;
}
}
NSEvent *current_event;
@ -148,6 +123,8 @@ void clearEvents(bool wait)
//call after objects (ie NDS main_window) are inited
void CreateMenu()
{
int i;
NSMenuItem *temp;
NSMenu* application_menu;
@ -161,107 +138,43 @@ void CreateMenu()
NSMenu* frame_skip_menu;
SEL action = nil;//@selector(method:);
menu = [NSApp mainMenu];
//Create the outermost menu that contains all the others
menu = [[NSMenu alloc] initWithTitle:@"DeSmuME"];
//Create the "DeSmuME" (application) menu
application_menu = [[NSMenu alloc] initWithTitle:@"DeSmuME"];
//Create the sevices menu
services_menu = [[NSMenu alloc] initWithTitle:@"Services"];
[NSApp setServicesMenu:services_menu];
//Add the about menu
temp = [application_menu addItemWithTitle:@"About DeSmuME" action:@selector(about) keyEquivalent:@""];
[temp setTarget:NSApp];
//
[application_menu addItem: [NSMenuItem separatorItem]];
//Add the preferences menu
temp = [application_menu addItemWithTitle:@"Preferences..." action:@selector(preferences) keyEquivalent:@","];
[temp setTarget:NSApp];
//
[application_menu addItem: [NSMenuItem separatorItem]];
//add the services menu to the application menu (after preferences)
temp = [application_menu addItemWithTitle:@"Services" action:nil keyEquivalent:@""];
[temp setSubmenu:services_menu];
//
[application_menu addItem: [NSMenuItem separatorItem]];
//standard hide option
temp = [application_menu addItemWithTitle:@"Hide DeSmuME" action:@selector(hide:) keyEquivalent:@""];
[temp setTarget:NSApp];
//standard hide others option
temp = [application_menu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@""];
[temp setTarget:NSApp];
//standard show all option
temp = [application_menu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
[temp setTarget:NSApp];
//
[application_menu addItem: [NSMenuItem separatorItem]];
//standard quit option
temp = [application_menu addItemWithTitle:@"Quit DeSmuME" action:@selector(terminate:) keyEquivalent:@"q"];
[temp setTarget: NSApp];
//finally call setAppleMenu to have all our stuff working
[NSApp setAppleMenu:application_menu];
temp = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
[temp setSubmenu:application_menu];
[temp release];
NSMenuItem *file_item = [menu addItemWithTitle:@"File" action:action keyEquivalent:@""];
NSMenuItem *emulation_item = [menu addItemWithTitle:@"Emulation" action:action keyEquivalent:@""];
NSMenuItem *view_item = [menu addItemWithTitle:@"View" action:action keyEquivalent:@""];
NSMenuItem *sound_item = [menu addItemWithTitle:@"Sound" action:action keyEquivalent:@""];
//NSMenuItem *window_item = [menu addItemWithTitle:@"Window" action:action keyEquivalent:@""];
NSMenuItem *help_item = [menu addItemWithTitle:@"Help" action:action keyEquivalent:@""];
NSMenuItem *file_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenuItem *emulation_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenuItem *view_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenuItem *sound_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
//NSMenuItem *window_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenuItem *help_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
//Create the File Menu
file = [[NSMenu alloc] initWithTitle:@"File"];
file = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"File", nil)];
[file setAutoenablesItems:NO];
[menu setSubmenu:file forItem:file_item];
temp = [file addItemWithTitle:@"Open ROM..." action:@selector(pickROM) keyEquivalent:@"o"];
temp = [file addItemWithTitle:NSLocalizedString(@"Open ROM...", nil) action:@selector(pickROM) keyEquivalent:@"o"];
[temp setTarget:NDS];
//recent items menu
/* Thanks to Jeff Johnson and the Lap Cat Software Blog for their information on the Open Recent menu in Cocoa*/
/* http://lapcatsoftware.com/blog/ */
temp = [file addItemWithTitle:@"Open Recent" action:nil keyEquivalent:@""];
temp = [file addItemWithTitle:NSLocalizedString(@"Open Recent", nil) action:nil keyEquivalent:@""];
NSMenu *recent_menu = [[NSMenu alloc] initWithTitle:@"Open Recent"];
//All the recent documents menu stuff is managed by Cocoa
NSMenu *recent_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Open Recent", nil)];
[recent_menu performSelector:@selector(_setMenuName:) withObject:@"NSRecentDocumentsMenu"];
[temp setSubmenu:recent_menu];
NSArray *recent_documents = [[NSDocumentController sharedDocumentController] recentDocumentURLs];
int i;
for(i = 0; i < [recent_documents count]; i++)
{
// [recent_menu addItemWithTitle:[[recent_documents objectAtIndex:i] absoluteString] action:nil keyEquivalent:@""];
}
/*
[recent_menu addItem:[NSMenuItem separatorItem]];
temp = [recent_menu addItemWithTitle:@"Clear" action:@selector(clearRecentDocuments:) keyEquivalent:@""];
if(i == 0)[temp setEnabled:NO];
else [temp setEnabled:YES];
temp = [recent_menu addItemWithTitle:@"Clear Menu" action:@selector(clearRecentDocuments:) keyEquivalent:@""];
[temp setTarget:[NSDocumentController sharedDocumentController]];
*/
[recent_menu release];
[file addItem:[NSMenuItem separatorItem]];
rom_info_item = [file addItemWithTitle:@"ROM Info..." action:@selector(showRomInfo) keyEquivalent:@""];
rom_info_item = [file addItemWithTitle:NSLocalizedString(@"ROM Info...", nil) action:@selector(showRomInfo) keyEquivalent:@""];
[rom_info_item setEnabled:NO];
[rom_info_item setTarget:NDS];
@ -269,33 +182,33 @@ void CreateMenu()
[file addItem:[NSMenuItem separatorItem]];
save_state_as_item = [file addItemWithTitle:@"Save State As..." action:@selector(saveStateAs) keyEquivalent:@""];
save_state_as_item = [file addItemWithTitle:NSLocalizedString(@"Save State As...", nil) action:@selector(saveStateAs) keyEquivalent:@""];
[save_state_as_item setEnabled:NO];
[save_state_as_item setTarget:NDS];
load_state_from_item = [file addItemWithTitle:@"Load State From..." action:@selector(loadStateFrom) keyEquivalent:@""];
load_state_from_item = [file addItemWithTitle:NSLocalizedString(@"Load State From...", nil) action:@selector(loadStateFrom) keyEquivalent:@""];
[load_state_from_item setEnabled:NO];
[load_state_from_item setTarget:NDS];
[file addItem:[NSMenuItem separatorItem]];
temp = [file addItemWithTitle:@"Save State" action:@selector(saveTo:) keyEquivalent:@""];
NSMenu *save_state_menu = [[NSMenu alloc] initWithTitle:@"Save State"];
temp = [file addItemWithTitle:NSLocalizedString(@"Save State", nil) action:@selector(saveTo:) keyEquivalent:@""];
NSMenu *save_state_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Save State", nil)];
[save_state_menu setAutoenablesItems:NO];
[temp setSubmenu:save_state_menu];
temp = [file addItemWithTitle:@"Load State" action:nil keyEquivalent:@""];
NSMenu *load_state_menu = [[NSMenu alloc] initWithTitle:@"Load State"];
temp = [file addItemWithTitle:NSLocalizedString(@"Load State", nil) action:nil keyEquivalent:@""];
NSMenu *load_state_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Load State", nil)];
[load_state_menu setAutoenablesItems:NO];
[temp setSubmenu:load_state_menu];
for(i = 0; i < SAVE_SLOTS; i++)
{
saveSlot_item[i] = [save_state_menu addItemWithTitle:@"Slot %d" withInt:i action:@selector(saveToSlot:) keyEquivalent:@""];
saveSlot_item[i] = [save_state_menu addItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Slot %d", nil), i] action:@selector(saveToSlot:) keyEquivalent:@""];
[saveSlot_item[i] setEnabled:NO];
[saveSlot_item[i] setTarget:NDS];
loadSlot_item[i] = [load_state_menu addItemWithTitle:@"Slot %d" withInt:i action:@selector(loadFromSlot:) keyEquivalent:@""];
loadSlot_item[i] = [load_state_menu addItemWithTitle:[saveSlot_item[i] title] action:@selector(loadFromSlot:) keyEquivalent:@""];
[loadSlot_item[i] setEnabled:NO];
[loadSlot_item[i] setTarget:NDS];
}
@ -317,14 +230,14 @@ a way to get the time of a save that's not string/human formatted...
[save_state_menu addItem:[NSMenuItem separatorItem]];
clear_all_saves_item = [save_state_menu addItemWithTitle:@"Clear All" action:@selector(askAndClearStates) keyEquivalent:@""];
clear_all_saves_item = [save_state_menu addItemWithTitle:@"Clear Menu" action:@selector(askAndClearStates) keyEquivalent:@""];
[clear_all_saves_item setEnabled:NO];
[clear_all_saves_item setTarget:NDS];
*/
/*
[save_state_menu addItem:[NSMenuItem separatorItem]];
temp = [save_state_menu addItemWithTitle:@"View States" action:nil keyEquivalent:@""];
temp = [save_state_menu addItemWithTitle:NSLocalizedString(@"View States", nil) action:nil keyEquivalent:@""];
[temp setEnabled:NO];
[temp setTarget:NDS];
*/
@ -352,178 +265,191 @@ a way to get the time of a save that's not a string / human formatted...
[file addItem:[NSMenuItem separatorItem]];
close_rom_item = [file addItemWithTitle:@"Close ROM" action:@selector(askAndCloseROM) keyEquivalent:@"w"];
close_rom_item = [file addItemWithTitle:NSLocalizedString(@"Close ROM", nil) action:@selector(askAndCloseROM) keyEquivalent:@"w"];
[close_rom_item setEnabled:NO];
[close_rom_item setTarget:NDS];
[file release];
//Create the Emulation Menu
emulation = [[NSMenu alloc] initWithTitle:localizedString(@"Emulation", nil)];
emulation = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Emulation", nil)];
[emulation setAutoenablesItems:NO];
[menu setSubmenu:emulation forItem:emulation_item];
execute_item = [emulation addItemWithTitle:@"Execute" action:@selector(execute) keyEquivalent:@""];
execute_item = [emulation addItemWithTitle:NSLocalizedString(@"Execute", nil) action:@selector(execute) keyEquivalent:@""];
[execute_item setTarget:NDS];
[execute_item setEnabled:NO];
pause_item = [emulation addItemWithTitle:@"Pause" action:@selector(pause) keyEquivalent:@""];
pause_item = [emulation addItemWithTitle:NSLocalizedString(@"Pause", nil) action:@selector(pause) keyEquivalent:@""];
[pause_item setTarget:NDS];
[pause_item setEnabled:NO];
reset_item = [emulation addItemWithTitle:@"Reset" action:@selector(reset) keyEquivalent:@""];
reset_item = [emulation addItemWithTitle:NSLocalizedString(@"Reset", nil) action:@selector(reset) keyEquivalent:@""];
[reset_item setTarget:NDS];
[reset_item setEnabled:NO];
[emulation addItem:[NSMenuItem separatorItem]];
temp = [emulation addItemWithTitle:@"Frame Skip" action:nil keyEquivalent:@""];
frame_skip_menu = [[NSMenu alloc] initWithTitle:localizedString(@"Frame Skip", nil)];
temp = [emulation addItemWithTitle:NSLocalizedString(@"Frame Skip", nil) action:nil keyEquivalent:@""];
frame_skip_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Frame Skip", nil)];
[temp setSubmenu:frame_skip_menu];
frame_skip_auto_item = [frame_skip_menu addItemWithTitle:@"Auto" action:@selector(setFrameSkip:) keyEquivalent:@""];
frame_skip_auto_item = [frame_skip_menu addItemWithTitle:NSLocalizedString(@"Auto", nil) action:@selector(setFrameSkip:) keyEquivalent:@""];
[frame_skip_auto_item setTarget:NDS];
[frame_skip_auto_item setState:NSOnState];
[frame_skip_auto_item setEnabled:YES];
[frame_skip_menu addItem:[NSMenuItem separatorItem]];
frame_skip_item[0] = [frame_skip_menu addItemWithTitle:@"Off" action:@selector(setFrameSkip:) keyEquivalent:@""];
frame_skip_item[0] = [frame_skip_menu addItemWithTitle:NSLocalizedString(@"Off", nil) action:@selector(setFrameSkip:) keyEquivalent:@""];
[frame_skip_item[0] setTarget:NDS];
[frame_skip_item[0] setEnabled:YES];
for(i = 1; i < MAX_FRAME_SKIP; i++)
{
frame_skip_item[i] = [frame_skip_menu addItemWithTitle:@"%d" withInt:i action:@selector(setFrameSkip:) keyEquivalent:@""];
frame_skip_item[i] = [frame_skip_menu addItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Skip %d", nil), i] action:@selector(setFrameSkip:) keyEquivalent:@""];
[frame_skip_item[i] setTarget:NDS];
[frame_skip_item[i] setEnabled:YES];
}
[frame_skip_menu release];
[emulation release];
//Create the screens menu
view = [[NSMenu alloc] initWithTitle:localizedString(@"View", nil)];
view = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"View", nil)];
[menu setSubmenu:view forItem:view_item];
resize1x = [view addItemWithTitle:@"Size 1x" action:@selector(resizeScreen1x) keyEquivalent:@"1"];
resize1x = [view addItemWithTitle:NSLocalizedString(@"Size 1x", nil) action:@selector(resizeScreen1x) keyEquivalent:@"1"];
[resize1x setState:NSOnState];
[resize1x setTarget:main_window];
resize2x = [view addItemWithTitle:@"Size 2x" action:@selector(resizeScreen2x) keyEquivalent:@"2"];
resize2x = [view addItemWithTitle:NSLocalizedString(@"Size 2x", nil) action:@selector(resizeScreen2x) keyEquivalent:@"2"];
[resize2x setTarget:main_window];
resize3x = [view addItemWithTitle:@"Size 3x" action:@selector(resizeScreen3x) keyEquivalent:@"3"];
resize3x = [view addItemWithTitle:NSLocalizedString(@"Size 3x", nil) action:@selector(resizeScreen3x) keyEquivalent:@"3"];
[resize3x setTarget:main_window];
resize4x = [view addItemWithTitle:@"Size 4x" action:@selector(resizeScreen4x) keyEquivalent:@"4"];
resize4x = [view addItemWithTitle:NSLocalizedString(@"Size 4x", nil) action:@selector(resizeScreen4x) keyEquivalent:@"4"];
[resize4x setTarget:main_window];
[view addItem:[NSMenuItem separatorItem]];
/*
[view addItem:[NSMenuItem separatorItem]];
[view addItemWithTitle:NSLocalizedString(@"Full Screen", nil) action:nil keyEquivalent:@"f"];
[view addItemWithTitle:@"Full Screen" action:nil keyEquivalent:@"f"];
[view addItem:[NSMenuItem separatorItem]];
*/
[view addItem:[NSMenuItem separatorItem]];
allows_resize_item = [view addItemWithTitle:@"Allow Resize" action:@selector(toggleAllowsResize) keyEquivalent:@""];
allows_resize_item = [view addItemWithTitle:NSLocalizedString(@"Allow Resize", nil) action:@selector(toggleAllowsResize) keyEquivalent:@""];
[allows_resize_item setState:NSOnState];
[allows_resize_item setTarget:main_window];
constrain_item = [view addItemWithTitle:@"Constrain Proportions" action:@selector(toggleConstrainProportions) keyEquivalent:@""];
constrain_item = [view addItemWithTitle:NSLocalizedString(@"Constrain Proportions", nil) action:@selector(toggleConstrainProportions) keyEquivalent:@""];
[constrain_item setState:NSOnState];
[constrain_item setTarget:main_window];
min_size_item = [view addItemWithTitle: @"No Smaller Than DS" action:@selector(toggleMinSize) keyEquivalent:@""];
min_size_item = [view addItemWithTitle:NSLocalizedString(@"No Smaller Than DS", nil) action:@selector(toggleMinSize) keyEquivalent:@""];
[min_size_item setState:NSOnState];
[min_size_item setTarget:main_window];
[view addItem:[NSMenuItem separatorItem]];
temp = [view addItemWithTitle: @"Rotation" action:nil keyEquivalent:@""];
NSMenu *rotation_menu = [[NSMenu alloc] initWithTitle:@"Rotation"];
temp = [view addItemWithTitle:NSLocalizedString(@"Rotation", nil) action:nil keyEquivalent:@""];
NSMenu *rotation_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Rotation", nil)];
[temp setSubmenu: rotation_menu];
rotation0_item = [rotation_menu addItemWithTitle:@"Rotation 0" action:@selector(setRotation0) keyEquivalent:@""];
rotation0_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 0", nil) action:@selector(setRotation0) keyEquivalent:@""];
[rotation0_item setState:NSOnState];
[rotation0_item setTarget:main_window];
rotation90_item = [rotation_menu addItemWithTitle:@"Rotation 90" action:@selector(setRotation90) keyEquivalent:@""];
rotation90_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 90", nil) action:@selector(setRotation90) keyEquivalent:@""];
[rotation90_item setState:NSOffState];
[rotation90_item setTarget:main_window];
rotation180_item = [rotation_menu addItemWithTitle:@"Rotation 180" action:@selector(setRotation180) keyEquivalent:@""];
rotation180_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 180", nil) action:@selector(setRotation180) keyEquivalent:@""];
[rotation180_item setState:NSOffState];
[rotation180_item setTarget:main_window];
rotation270_item = [rotation_menu addItemWithTitle:@"Rotation 270" action:@selector(setRotation270) keyEquivalent:@""];
rotation270_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 270", nil) action:@selector(setRotation270) keyEquivalent:@""];
[rotation270_item setState:NSOffState];
[rotation270_item setTarget:main_window];
[rotation_menu release];
[view addItem:[NSMenuItem separatorItem]];
temp = [view addItemWithTitle:@"Layers" action:nil keyEquivalent:@""];
NSMenu *layer_menu = [[NSMenu alloc] initWithTitle:@"Layers"];
temp = [view addItemWithTitle:NSLocalizedString(@"Layers", nil) action:nil keyEquivalent:@""];
NSMenu *layer_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Layers", nil)];
[temp setSubmenu: layer_menu];
topBG0_item = [layer_menu addItemWithTitle:@"Top BG0" action:@selector(toggleTopBackground0) keyEquivalent:@""];
topBG0_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG0", nil) action:@selector(toggleTopBackground0) keyEquivalent:@""];
[topBG0_item setState:NSOnState];
[topBG0_item setTarget:main_window];
topBG1_item = [layer_menu addItemWithTitle:@"Top BG1" action:@selector(toggleTopBackground1) keyEquivalent:@""];
topBG1_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG1", nil) action:@selector(toggleTopBackground1) keyEquivalent:@""];
[topBG1_item setState:NSOnState];
[topBG1_item setTarget:main_window];
topBG2_item = [layer_menu addItemWithTitle:@"Top BG2" action:@selector(toggleTopBackground2) keyEquivalent:@""];
topBG2_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG2", nil) action:@selector(toggleTopBackground2) keyEquivalent:@""];
[topBG2_item setState:NSOnState];
[topBG2_item setTarget:main_window];
topBG3_item = [layer_menu addItemWithTitle:@"Top BG3" action:@selector(toggleTopBackground3) keyEquivalent:@""];
topBG3_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG3", nil) action:@selector(toggleTopBackground3) keyEquivalent:@""];
[topBG3_item setState:NSOnState];
[topBG3_item setTarget:main_window];
[layer_menu addItem:[NSMenuItem separatorItem]];
subBG0_item = [layer_menu addItemWithTitle:@"Sub BG0" action:@selector(toggleSubBackground0) keyEquivalent:@""];
subBG0_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG0", nil) action:@selector(toggleSubBackground0) keyEquivalent:@""];
[subBG0_item setState:NSOnState];
[subBG0_item setTarget:main_window];
subBG1_item = [layer_menu addItemWithTitle:@"Sub BG1" action:@selector(toggleSubBackground1) keyEquivalent:@""];
subBG1_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG1", nil) action:@selector(toggleSubBackground1) keyEquivalent:@""];
[subBG1_item setState:NSOnState];
[subBG1_item setTarget:main_window];
subBG2_item = [layer_menu addItemWithTitle:@"Sub BG2" action:@selector(toggleSubBackground2) keyEquivalent:@""];
subBG2_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG2", nil) action:@selector(toggleSubBackground2) keyEquivalent:@""];
[subBG2_item setState:NSOnState];
[subBG2_item setTarget:main_window];
subBG3_item = [layer_menu addItemWithTitle:@"Sub BG3" action:@selector(toggleSubBackground3) keyEquivalent:@""];
subBG3_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG3", nil) action:@selector(toggleSubBackground3) keyEquivalent:@""];
[subBG3_item setState:NSOnState];
[subBG3_item setTarget:main_window];
[layer_menu release];
[view addItem:[NSMenuItem separatorItem]];
allows_resize_item = [view addItemWithTitle:@"Screenshot to File" action:@selector(screenShotToFile) keyEquivalent:@""];
allows_resize_item = [view addItemWithTitle:NSLocalizedString(@"Screenshot to File", nil) action:@selector(screenShotToFile) keyEquivalent:@""];
[allows_resize_item setTarget:main_window];
allows_resize_item = [view addItemWithTitle:@"Screenshot to Window" action:@selector(screenShotToWindow) keyEquivalent:@""];
allows_resize_item = [view addItemWithTitle:NSLocalizedString(@"Screenshot to Window", nil) action:@selector(screenShotToWindow) keyEquivalent:@""];
[allows_resize_item setTarget:main_window];
[view release];
//Create the sound menu
sound_menu = [[NSMenu alloc] initWithTitle:localizedString(@"Sound", nil)];
sound_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Sound", nil)];
[menu setSubmenu:sound_menu forItem:sound_item];
temp = [sound_menu addItemWithTitle:@"Volume" action:nil keyEquivalent:@""];
[temp setTarget:NSApp];
temp = [sound_menu addItemWithTitle:NSLocalizedString(@"Volume", nil) action:nil keyEquivalent:@""];
[temp setTarget:[NSApp delegate]];
NSMenu *volume_menu = [[NSMenu alloc] initWithTitle:localizedString(@"Volume", nil)];
NSMenu *volume_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Volume", nil)];
[sound_menu setSubmenu:volume_menu forItem:temp];
for(i = 0; i < 10; i++)
{
volume_item[i] = [volume_menu addItemWithTitle:@"Volume %d" withInt:(i+1)*10 action:@selector(setVolume:) keyEquivalent:@""];
volume_item[i] = [volume_menu addItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Volume %d", nil), (i+1)*10] action:@selector(setVolume:) keyEquivalent:@""];
[volume_item[i] setTarget:NDS];
if(i == 9)
[volume_item[i] setState:NSOnState]; //check 100% volume since it's defaults
}
[volume_menu release];
[sound_menu addItem:[NSMenuItem separatorItem]];
mute_item = [sound_menu addItemWithTitle:@"Mute" action:@selector(toggleMuting) keyEquivalent:@""];
mute_item = [sound_menu addItemWithTitle:NSLocalizedString(@"Mute", nil) action:@selector(toggleMuting) keyEquivalent:@""];
[mute_item setTarget:NDS];
/*
[sound_menu addItem:[NSMenuItem separatorItem]];
@ -537,9 +463,12 @@ a way to get the time of a save that's not a string / human formatted...
temp = [sound_menu addItemWithTitle:@"Save Recording" action:@selector(pauseRecording) keyEquivalent: @""];
[temp setTarget:NDS];
*/
[sound_menu release];
//Create the window menu
/*
window = [[NSMenu alloc] initWithTitle:localizedString(@"Window", nil)];
window = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Window", nil)];
[menu setSubmenu:window forItem:window_item];
[window addItemWithTitle:@"Minimize" action:nil keyEquivalent:@""];
@ -552,46 +481,38 @@ a way to get the time of a save that's not a string / human formatted...
//[window addItemWithTitle:@"Debugger" action:nil keyEquivalent:@""];
//[window addItem:[NSMenuItem separatorItem]];
//[window addItemWithTitle:@"(screenshots)" action:nil keyEquivalent:@""];
//[window release];
*/
//Create the help menu
help = [[NSMenu alloc] initWithTitle:localizedString(@"Help", nil)];
help = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Help", nil)];
[menu setSubmenu:help forItem:help_item];
temp = [help addItemWithTitle:@"Go to Website" action:@selector(launchWebsite) keyEquivalent: @""];
temp = [help addItemWithTitle:NSLocalizedString(@"Go to Website", nil) action:@selector(launchWebsite) keyEquivalent: @""];
[temp setTarget:NSApp];
temp = [help addItemWithTitle:@"Go to Forums" action:@selector(launchForums) keyEquivalent: @""];
temp = [help addItemWithTitle:NSLocalizedString(@"Go to Forums", nil) action:@selector(launchForums) keyEquivalent: @""];
[temp setTarget:NSApp];
temp = [help addItemWithTitle:@"Submit a Bug Report" action:@selector(bugReport) keyEquivalent: @""];
temp = [help addItemWithTitle:NSLocalizedString(@"Submit a Bug Report", nil) action:@selector(bugReport) keyEquivalent: @""];
[temp setTarget:NSApp];
[NSApp setMainMenu: menu];
[menu update];
[help release];
}
//Main Function--------------------------------------------------------------------------------------
int main(int argc, char *argv[])
{
srand(time(NULL));
//Application Init Stuff----------------------------------------------------------------------
autorelease = [[NSAutoreleasePool alloc] init];
//Get the application instance (global variable called NSApp)
[NSApplication sharedApplication];
[NSApp setDelegate:[[AppDelegate alloc] init]];
//Set the application delegate
[NSApp setDelegate:NSApp];
[NSApp run];
//Program Exit ---------------------------------------------------------------------------------------
return 0;
return NSApplicationMain(argc, (const char **) argv);
}
//gdb stuff--------------------------------------------------------------------------------
@ -608,7 +529,7 @@ void joinThread_gdb(void *thread_handle)
//Implementations-------------------------------------------------------------------------
@implementation NSApplication(delegate)
@implementation AppDelegate
- (BOOL)application:(NSApplication*)sender openFile:(NSString*)filename
{
@ -641,7 +562,6 @@ void joinThread_gdb(void *thread_handle)
fail:
[sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
}
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
@ -651,8 +571,6 @@ fail:
//they work in different preference domains)
setAppDefaults();
//App Init ------------------------------------------------------------------------------
//Bring the application to the front
[NSApp activateIgnoringOtherApps:TRUE];
@ -664,17 +582,14 @@ fail:
//create the menus
CreateMenu();
//init opengl 3d ness
NDS_3D_SetDriver (GPU3D_OPENGL);
if(!gpu3D->NDS_3D_Init())
messageDialog(localizedString(@"Error", nil), @"Unable to initialize OpenGL components");
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
//Start the main program loop ----------------------------------------------------------------------------
//init opengl 3d ness
NDS_3D_SetDriver (GPU3D_OPENGL);
if(!gpu3D->NDS_3D_Init())
messageDialog(NSLocalizedString(@"Error", nil), @"Unable to initialize OpenGL components");
#ifdef MULTITHREADED
@ -682,24 +597,35 @@ fail:
[NSApplication detachDrawingThread:@selector(run) toTarget:NDS withObject:nil];
#else
[NDS run];
//it seems we need an event before it will quit
//(probably has something to do with calling run from applicationDidFinishLaunching?)
//(probably applicationWillTersminatehas something to do with calling run from applicationDidFinishLaunching?)
[NSEvent startPeriodicEventsAfterDelay:0 withPeriod:1];
#endif
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
//Ask user if he wants to quit
AskForQuit();
//Ask user if he/she wants to quit
if(AskForQuit())
return NSTerminateNow;
else
return NSTerminateCancel;
}
//AskForQuit takes care of quitting, dont need cocoa to do it for us
return NSTerminateCancel;
- (void)applicationWillTerminate:(NSNotification*)aNotification
{
//Quit
[NDS destroy];
finished = true;
//Free memory
[main_window release];
[NSApp setServicesMenu:nil];
[NSApp setMainMenu:nil];
[menu release];
}
@end

View File

@ -22,13 +22,23 @@
#import <Cocoa/Cocoa.h>
@class VideoOutputView;
//this is used internally by VideoOutputWindow
//This interface is to create and manaage the window
//that displays DS video output and takes keyboard/mouse input
//do not instanciate more than one of these
@interface VideoOutputWindow : NSWindow {}
@interface VideoOutputWindow : NSWindow
{
@private
NSWindowController *controller;
VideoOutputView *video_output_view;
}
//initialization
- (id)init;
- (void)dealloc;
//call this function to read the screen from the emulator and update the window
//this is the only method involving cocoa that should be called from the run() function

View File

@ -46,10 +46,6 @@ unsigned short title_bar_height;
volatile u8 correction_buffer[DS_SCREEN_WIDTH * DS_SCREEN_HEIGHT_COMBINED * 2 /*bits per pixel*/];
volatile u8 temp_buffer[DS_SCREEN_WIDTH * DS_SCREEN_HEIGHT_COMBINED * 2 /*bits per pixel*/];
//this is th opengl view where we will display the video output
@class VideoOutputView;
VideoOutputView *video_output_view;
//fast access to size of openglview (not size of window)
volatile unsigned short x_size = DS_SCREEN_WIDTH;
volatile unsigned short y_size = DS_SCREEN_HEIGHT_COMBINED;
@ -107,7 +103,6 @@ unsigned short save_slot_10 = 109; //F10
NSOpenGLContext *gpu_context;
//rotation
u8 rotation = ROTATION_0;
//extern unsigned char GPU_screen3D[256*256*4];
@ -117,25 +112,25 @@ u8 gpu_buff[256 * 256 * 4];
//min sizes (window size, not ds screen size)
NSSize min_size;
//Window delegate class ---------------------------------------------------------
@interface WindowDelegate : NSObject {}
- (void)windowDidResize:(NSNotification *)aNotification;
- (BOOL)windowShouldClose:(id)sender;
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize;
@end
////////////////////////////////////////////////////////////////////////////////////////
//Video output view -------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////
@interface VideoOutputView : NSView
{
@public
u8 rotation;
@private
NSOpenGLContext* context;
NSOpenGLPixelFormat* format;
}
- (id)initWithFrame:(NSRect)frame;
- (void)dealloc;
- (void)draw;
- (void)drawRect:(NSRect)bounds;
- (void)setFrame:(NSRect)rect;
- (BOOL) isOpaque;
- (BOOL)isOpaque;
@end
@implementation VideoOutputView
@ -148,7 +143,7 @@ NSSize min_size;
if(self==nil)
{
messageDialog(localizedString(@"Error", nil), @"Could not init frame for OpenGL display");
messageDialog(NSLocalizedString(@"Error", nil), @"Could not init frame for OpenGL display");
return nil;
}
@ -169,14 +164,14 @@ NSSize min_size;
NSOpenGLPixelFormat* pixel_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
if(pixel_format == nil)
{
messageDialog(localizedString(@"Error", nil), @"Couldn't create OpenGL pixel format for video output");
messageDialog(NSLocalizedString(@"Error", nil), @"Couldn't create OpenGL pixel format for video output");
return self;
}
context = [[NSOpenGLContext alloc] initWithFormat:pixel_format shareContext:nil];
if(context == nil)
{
messageDialog(localizedString(@"Error", nil), @"Couldn't create OpenGL context for video output");
messageDialog(NSLocalizedString(@"Error", nil), @"Couldn't create OpenGL context for video output");
return self;
}
@ -199,14 +194,14 @@ NSSize min_size;
NSOpenGLPixelFormat* pixel_format2 = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs2];
if(pixel_format2 == nil)
{
messageDialog(localizedString(@"Error", nil), @"Couldn't create OpenGL pixel format for GPU");
messageDialog(NSLocalizedString(@"Error", nil), @"Couldn't create OpenGL pixel format for GPU");
return self;
}
gpu_context = [[NSOpenGLContext alloc] initWithFormat:pixel_format2 shareContext:nil];
if(gpu_context == nil)
{
messageDialog(localizedString(@"Error", nil), @"Couldn't create OpenGL context for GPU");
messageDialog(NSLocalizedString(@"Error", nil), @"Couldn't create OpenGL context for GPU");
return self;
}
@ -220,6 +215,17 @@ NSSize min_size;
return self;
}
- (void)dealloc
{
if(context)
[context release];
if(format)
[format release];
[super dealloc];
}
- (void) draw
{
NSRect blar;
@ -322,6 +328,12 @@ NSSize min_size;
//Video output window class ----------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////////////
@interface VideoOutputWindow (delegate)
- (void)windowDidResize:(NSNotification*)aNotification;
- (BOOL)windowShouldClose:(id)sender;
- (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)proposedFrameSize;
@end
@implementation VideoOutputWindow
- (id)init
@ -343,7 +355,7 @@ NSSize min_size;
backing:NSBackingStoreBuffered defer:NO screen:nil];
[self setTitle:localizedString(@"DeSmuME Emulator", nil)];
[self setTitle:NSLocalizedString(@"DeSmuME Emulator", nil)];
//set minimum window size (to the starting size, pixel-for-pixel to DS)
//this re-gets the window rect to include the title bar size
@ -361,8 +373,8 @@ NSSize min_size;
//set title_bar_height
title_bar_height = [super frame].size.height - rect.size.height;
//Set the window delegate
[self setDelegate:[[WindowDelegate alloc] init]];
//Set the window delegate to itself
[self setDelegate:self];
//Create the image view where we will display video output
rect.origin.x = WINDOW_BORDER_PADDING;
@ -370,27 +382,56 @@ NSSize min_size;
rect.size.width = DS_SCREEN_WIDTH;
rect.size.height = DS_SCREEN_HEIGHT_COMBINED;
if((video_output_view = [[VideoOutputView alloc] initWithFrame:rect]) == nil)
messageDialog(localizedString(@"Error", nil), @"Couldn't create OpenGL view to display screens");
messageDialog(NSLocalizedString(@"Error", nil), @"Couldn't create OpenGL view to display screens");
else
{
[[self contentView] addSubview:video_output_view];
}
//Show the window
[[[NSWindowController alloc] initWithWindow:self] showWindow:nil];
[controller = [[NSWindowController alloc] initWithWindow:self] showWindow:nil];
//start with a blank screen
//Start with a blank screen
[self clearScreenBlack];
return self;
}
- (void)dealloc
{
[video_output_view release];
[self retain]; //see the comment in init after we initialize the window controller
[controller release];
[resize1x release];
[resize2x release];
[resize3x release];
[resize4x release];
[allows_resize_item release];
[constrain_item release];
[min_size_item release];
[rotation0_item release];
[rotation90_item release];
[rotation180_item release];
[rotation270_item release];
[topBG0_item release];
[topBG1_item release];
[topBG2_item release];
[topBG3_item release];
[subBG0_item release];
[subBG1_item release];
[subBG2_item release];
[subBG3_item release];
[super dealloc];
}
- (void)updateScreen
{
//here we copy gpu_screen to our own buffer
if(rotation == ROTATION_0 || rotation == ROTATION_180)
if(video_output_view->rotation == ROTATION_0 || video_output_view->rotation == ROTATION_180)
memcpy(&correction_buffer, &GPU_screen, DS_SCREEN_WIDTH * DS_SCREEN_HEIGHT_COMBINED * 2);
else
{
@ -428,7 +469,7 @@ NSSize min_size;
- (void)resetMinSize:(bool)resize
{
if(rotation == ROTATION_0 || rotation == ROTATION_180)
if(video_output_view->rotation == ROTATION_0 || video_output_view->rotation == ROTATION_180)
{
min_size.width = DS_SCREEN_WIDTH + WINDOW_BORDER_PADDING * 2;
min_size.height = DS_SCREEN_HEIGHT_COMBINED + WINDOW_BORDER_PADDING + title_bar_height;
@ -502,7 +543,7 @@ NSSize min_size;
- (void)resizeScreen1x
{
if(rotation == ROTATION_0 || rotation == ROTATION_180)
if(video_output_view->rotation == ROTATION_0 || video_output_view->rotation == ROTATION_180)
[self resizeScreen:NSMakeSize(DS_SCREEN_WIDTH, DS_SCREEN_HEIGHT_COMBINED)];
else
[self resizeScreen:NSMakeSize(DS_SCREEN_HEIGHT_COMBINED, DS_SCREEN_WIDTH)];
@ -511,7 +552,7 @@ NSSize min_size;
- (void)resizeScreen2x
{
if(rotation == ROTATION_0 || rotation == ROTATION_180)
if(video_output_view->rotation == ROTATION_0 || video_output_view->rotation == ROTATION_180)
[self resizeScreen:NSMakeSize(DS_SCREEN_WIDTH * 2, DS_SCREEN_HEIGHT_COMBINED * 2)];
else
[self resizeScreen:NSMakeSize(DS_SCREEN_HEIGHT_COMBINED * 2, DS_SCREEN_WIDTH * 2)];
@ -519,7 +560,7 @@ NSSize min_size;
- (void)resizeScreen3x
{
if(rotation == ROTATION_0 || rotation == ROTATION_180)
if(video_output_view->rotation == ROTATION_0 || video_output_view->rotation == ROTATION_180)
[self resizeScreen:NSMakeSize(DS_SCREEN_WIDTH * 3, DS_SCREEN_HEIGHT_COMBINED * 3)];
else
[self resizeScreen:NSMakeSize(DS_SCREEN_HEIGHT_COMBINED * 3, DS_SCREEN_WIDTH * 3)];
@ -527,7 +568,7 @@ NSSize min_size;
- (void)resizeScreen4x
{
if(rotation == ROTATION_0 || rotation == ROTATION_180)
if(video_output_view->rotation == ROTATION_0 || video_output_view->rotation == ROTATION_180)
[self resizeScreen:NSMakeSize(DS_SCREEN_WIDTH * 4, DS_SCREEN_HEIGHT_COMBINED * 4)];
else
[self resizeScreen:NSMakeSize(DS_SCREEN_HEIGHT_COMBINED * 4, DS_SCREEN_WIDTH * 4)];
@ -594,11 +635,11 @@ NSSize min_size;
- (void)setRotation0
{
if(rotation == ROTATION_0)return;
if(video_output_view->rotation == ROTATION_0)return;
if(rotation == ROTATION_180)
if(video_output_view->rotation == ROTATION_180)
{
rotation = ROTATION_0;
video_output_view->rotation = ROTATION_0;
[video_output_view setFrame:[video_output_view frame]];
[self updateScreen];
@ -606,7 +647,7 @@ NSSize min_size;
} else
{
//set the global rotation state
rotation = ROTATION_0;
video_output_view->rotation = ROTATION_0;
//fix the buffer
memcpy(&temp_buffer, &correction_buffer, DS_SCREEN_WIDTH * DS_SCREEN_HEIGHT_COMBINED * 2);
@ -639,12 +680,12 @@ NSSize min_size;
- (void)setRotation90
{
if(rotation == ROTATION_90)return;
if(video_output_view->rotation == ROTATION_90)return;
if(rotation == ROTATION_270)
if(video_output_view->rotation == ROTATION_270)
{
rotation = ROTATION_90;
video_output_view->rotation = ROTATION_90;
[video_output_view setFrame:[video_output_view frame]];
[self updateScreen];
@ -652,7 +693,7 @@ NSSize min_size;
} else
{
//set the global rotation state
rotation = ROTATION_90;
video_output_view->rotation = ROTATION_90;
//fix the buffer
memcpy(&temp_buffer, &correction_buffer, DS_SCREEN_WIDTH * DS_SCREEN_HEIGHT_COMBINED * 2);
@ -685,11 +726,11 @@ NSSize min_size;
- (void)setRotation180
{
if(rotation == ROTATION_180)return;
if(video_output_view->rotation == ROTATION_180)return;
if(rotation == ROTATION_0)
if(video_output_view->rotation == ROTATION_0)
{
rotation = ROTATION_180;
video_output_view->rotation = ROTATION_180;
[video_output_view setFrame:[video_output_view frame]];
[self updateScreen];
@ -697,7 +738,7 @@ NSSize min_size;
} else
{
//set the global rotation state
rotation = ROTATION_180;
video_output_view->rotation = ROTATION_180;
//fix the buffer
memcpy(&temp_buffer, &correction_buffer, DS_SCREEN_WIDTH * DS_SCREEN_HEIGHT_COMBINED * 2);
@ -731,11 +772,11 @@ NSSize min_size;
- (void)setRotation270
{
if(rotation == ROTATION_270)return;
if(video_output_view->rotation == ROTATION_270)return;
if(rotation == ROTATION_90)
if(video_output_view->rotation == ROTATION_90)
{
rotation = ROTATION_270;
video_output_view->rotation = ROTATION_270;
[video_output_view setFrame:[video_output_view frame]];
[self updateScreen];
@ -744,7 +785,7 @@ NSSize min_size;
{
//set the global rotation state
rotation = ROTATION_270;
video_output_view->rotation = ROTATION_270;
//fix the buffer
memcpy(&temp_buffer, &correction_buffer, DS_SCREEN_WIDTH * DS_SCREEN_HEIGHT_COMBINED * 2);
@ -892,7 +933,7 @@ NSSize min_size;
BOOL was_paused = paused;
[NDS pause];
[[Screenshot alloc] initWithBuffer:correction_buffer rotation:rotation saveOnly:YES];
[[Screenshot alloc] initWithBuffer:correction_buffer rotation:video_output_view->rotation saveOnly:YES];
if(!was_paused)[NDS execute];
}
@ -902,7 +943,7 @@ NSSize min_size;
BOOL was_paused = paused;
[NDS pause];
[[Screenshot alloc] initWithBuffer:correction_buffer rotation:rotation saveOnly:NO];
[[Screenshot alloc] initWithBuffer:correction_buffer rotation:video_output_view->rotation saveOnly:NO];
if(!was_paused)[NDS execute];
}
@ -1219,9 +1260,9 @@ NSSize min_size;
if(location.x >= x_size)return;
if(location.y >= y_size)return;
if(rotation == ROTATION_0 || rotation == ROTATION_180)
if(video_output_view->rotation == ROTATION_0 || video_output_view->rotation == ROTATION_180)
{
if(rotation == ROTATION_180)
if(video_output_view->rotation == ROTATION_180)
{
if(location.y < y_size / 2)return;
location.x = x_size - location.x;
@ -1239,7 +1280,7 @@ NSSize min_size;
} else
{
if(rotation == ROTATION_270)
if(video_output_view->rotation == ROTATION_270)
{
if(location.x < x_size / 2)return;
location.x = x_size - location.x;
@ -1260,7 +1301,6 @@ NSSize min_size;
location.x = location.y;
location.y = temp;
}
//[self setTitle:[NSString localizedStringWithFormat:@"%u %u", (unsigned int)location.x, (unsigned int)location.y]];
NDS_setTouchPos((unsigned short)location.x, (unsigned short)location.y);
}
@ -1280,7 +1320,7 @@ NSSize min_size;
//Window Delegate -----------------------------------------------------------------------
@implementation WindowDelegate
@implementation VideoOutputWindow (delegate)
- (BOOL)windowShouldClose:(id)sender
{
[sender hide];
@ -1318,7 +1358,7 @@ NSSize min_size;
unsigned short x_constrained;
unsigned short y_constrained;
if(rotation == ROTATION_0 || rotation == ROTATION_180)
if(video_output_view->rotation == ROTATION_0 || video_output_view->rotation == ROTATION_180)
{
//this is a simple algorithm to constrain to the smallest axis

24
desmume/src/cocoa/makeapp.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
#This script builds the application bundle so that DeSmuME can run.
#
lipo DeSmuME.app/Contents/MacOS/DeSmuME_x86 DeSmuME.app/Contents/MacOS/DeSmuME_ppc -create -output DeSmuME.app/Contents/MacOS/DeSmuME
rm -f DeSmuME.app/Contents/MacOS/DeSmuME_x86
rm -f DeSmuME.app/Contents/MacOS/DeSmuME_ppc
#
mkdir -p DeSmuME.app/Contents/Resources
cp Info.plist DeSmuME.app/Contents/Info.plist
cp PkgInfo DeSmuME.app/Contents/PkgInfo
cp InfoPlist.strings DeSmuME.app/Contents/Resources/InfoPlist.strings
cp DeSmuME.icns DeSmuME.app/Contents/Resources/DeSmuME.icns
#English
mkdir -p DeSmuME.app/Contents/Resources/English.lproj
cp -R English.nib DeSmuME.app/Contents/Resources/English.lproj/MainMenu.nib
cp English.strings DeSmuME.app/Contents/Resources/English.lproj/Localizable.strings
#Japanese
mkdir -p DeSmuME.app/Contents/Resources/Japanese.lproj
cp -R Japanese.nib DeSmuME.app/Contents/Resources/Japanese.lproj/MainMenu.nib
cp Japanese.strings DeSmuME.app/Contents/Resources/Japanese.lproj/Localizable.strings

View File

@ -89,7 +89,7 @@ NSMenuItem *frame_skip_item[MAX_FRAME_SKIP];
NSMenuItem *volume_item[10];
NSMenuItem *mute_item;
volatile u8 frame_skip = 0; //this is one more than the acutal frame skip, a value of 0 signifies auto frame skip
volatile u8 frame_skip = 0; //this is one more than the actual frame skip, a value of 0 signifies auto frame skip
static int backupmemorytype=MC_TYPE_AUTODETECT;
static u32 backupmemorysize=1;
@ -115,7 +115,7 @@ NSString *current_file;
if(SPU_ChangeSoundCore(SNDCORE_OSX, 735 * 4) != 0)
{
messageDialog(localizedString(@"Error", nil), @"Unable to initialize sound core");
messageDialog(NSLocalizedString(@"Error", nil), @"Unable to initialize sound core");
}
SPU_SetVolume(100);
@ -147,7 +147,7 @@ NSString *current_file;
BOOL was_paused = paused;
[self pause];
NSString *temp = openDialog([NSArray arrayWithObjects:@"NDS", @"ds.GBA", nil]);
NSString *temp = openDialog([NSArray arrayWithObjects:@"NDS", @"DS.GBA", nil]);
if(temp)
{
@ -168,7 +168,7 @@ NSString *current_file;
if(!NDS_LoadROM([filename cStringUsingEncoding:NSASCIIStringEncoding], backupmemorytype, backupmemorysize, "temp.sav") > 0)
{
//if it didn't work give an error and dont unpause
messageDialog(localizedString(@"Error", nil), @"Could not open file");
messageDialog(NSLocalizedString(@"Error", nil), @"Could not open file");
//continue playing if load didn't work
if(!was_paused)[self execute];
@ -258,7 +258,7 @@ NSString *current_file;
bool was_paused = paused;
[NDS pause];
if(messageDialogYN(localizedString(@"DeSmuME Emulator", nil), localizedString(@"Are you sure you want to close the ROM?", nil)))
if(messageDialogYN(NSLocalizedString(@"DeSmuME Emulator", nil), NSLocalizedString(@"Are you sure you want to close the ROM?", nil)))
{
[self closeROM];
@ -431,7 +431,7 @@ NSString *current_file;
NSSavePanel *panel = [NSSavePanel savePanel];
[panel setTitle:localizedString(@"Save State to File...", nil)];
[panel setTitle:NSLocalizedString(@"Save State to File...", nil)];
[panel setAllowedFileTypes:[NSArray arrayWithObjects:@"dst",nil]];
if([panel runModal] == NSOKButton)
@ -507,8 +507,8 @@ NSString *current_file;
BOOL was_paused = paused;
[NDS pause];
if(messageDialogYN(localizedString(@"DeSmuME Emulator", nil),
localizedString(@"Are you sure you want to clear all save slots?", nil)))
if(messageDialogYN(NSLocalizedString(@"DeSmuME Emulator", nil),
NSLocalizedString(@"Are you sure you want to clear all save slots?", nil)))
{
@ -544,7 +544,7 @@ NSString *current_file;
NSTitledWindowMask|NSClosableWindowMask|NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO screen:nil];
//set the window title
[rom_info_window setTitle:localizedString(@"ROM Info", nil)];
[rom_info_window setTitle:NSLocalizedString(@"ROM Info", nil)];
//create an NSTableView to display the stuff
TableHelper *helper = [[TableHelper alloc] initWithWindow:rom_info_window];
@ -615,7 +615,7 @@ NSString *current_file;
if(!SNDOSXOpenFile([panel filename]))
{
messageDialog(localizedString(@"Error", nil), @"Couldn't create sound recording output file");
messageDialog(NSLocalizedString(@"Error", nil), @"Couldn't create sound recording output file");
return;
}
@ -637,7 +637,7 @@ NSString *current_file;
//Rom info helper stuff -------------------------------------------------------------
#define ROM_INFO_ROWS 8
#define ROM_INFO_ROWS 7
#define ROM_INFO_WIDTH 400
@implementation TableHelper
- (id)initWithWindow:(NSWindow*)window
@ -646,13 +646,13 @@ NSString *current_file;
type_column = [[NSTableColumn alloc] initWithIdentifier:@""];
[type_column setEditable:NO];
[type_column setResizable:YES];
[type_column setResizingMask:NSTableColumnUserResizingMask];
[[type_column headerCell] setStringValue:@"Attribute"];
[type_column setMinWidth: 1];
value_column = [[NSTableColumn alloc] initWithIdentifier:@""];
[value_column setEditable:NO];
[value_column setResizable:YES];
[value_column setResizingMask:NSTableColumnUserResizingMask];
[[value_column headerCell] setStringValue:@"Value"];
[value_column setMinWidth: 1];
@ -688,6 +688,10 @@ if([table headerView] == nil)messageDialogBlank();
[value_column setWidth:ROM_INFO_WIDTH - [type_column width]];
//
//[table setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
//[[window contentView] setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
//[[window contentView] setAutoresizesSubviews:YES];
//[[window contentView] addSubview:table];
[window setContentView:table];
//grab the header to read data from
@ -695,6 +699,7 @@ if([table headerView] == nil)messageDialogBlank();
return self;
}
- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
{
return ROM_INFO_ROWS;
@ -715,28 +720,26 @@ if([table headerView] == nil)messageDialogBlank();
if(aTableColumn == type_column)
{
if(rowIndex == 0)
return localizedString(@"File", @" ROM Info ");
return NSLocalizedString(@"ROM File", nil);
if(rowIndex == 1)
return localizedString(@"Title", @" ROM Info ");
return NSLocalizedString(@"ROM Title", nil);
if(rowIndex == 2)
return localizedString(@"Maker", @" ROM Info ");
return NSLocalizedString(@"ROM Maker", nil);
if(rowIndex == 3)
return localizedString(@"Size", @" ROM Info ");
return NSLocalizedString(@"ROM Size", nil);
if(rowIndex == 4)
return localizedString(@"ARM9 Size", @" ROM Info ");
return NSLocalizedString(@"ARM9 Size", nil);
if(rowIndex == 5)
return localizedString(@"ARM7 Size", @" ROM Info ");
return NSLocalizedString(@"ARM7 Size", nil);
if(rowIndex == 6)
return localizedString(@"Data Size", @" ROM Info ");
return NSLocalizedString(@"Data Size", nil);
if(rowIndex == 7)
return localizedString(@"Icon", @" ROM Info ");
} else
{//units?
if(rowIndex == 0)return current_file;
@ -772,11 +775,6 @@ if([table headerView] == nil)messageDialogBlank();
return [NSString localizedStringWithFormat:@"%u", header->ARM7binSize + header->ARM7src];
}
if(rowIndex == 7)
{
return @"NOT FINISHED";
}
}
return @"If you see this, there is a bug";

View File

@ -56,7 +56,7 @@ NSDictionary *desmume_defaults;
- (void)windowWillClose:(NSNotification*)aNotification
{
//[preferences_window saveFrameUsingName:@"DeSmuME Preferences Window"];
[preferences_window setFrameAutosaveName:@"DeSmuME Preferences Window"];
//[preferences_window setFrameAutosaveName:@"DeSmuME Preferences Window"];
[NSApp stopModal];
@ -92,10 +92,6 @@ NSDictionary *desmume_defaults;
[[NSUserDefaults standardUserDefaults] setObject:value forKey:PREF_NUM_RECENT_ITEMS];
}*/
- (void)languageChange:(id)sender
{
}
@end
////////////////////////////////////////////////////
@ -117,12 +113,12 @@ NSDictionary *desmume_defaults;
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://sourceforge.net/tracker/?func=add&group_id=164579&atid=832291"]];
}
- (void)about
- (void)orderFrontStandardAboutPanel:(id)sender
{
bool was_paused = paused;
[NDS pause];
NSRunAlertPanel(localizedString(@"About DeSmuME", nil),
NSRunAlertPanel([sender title],
@"DeSmuME is an open source Nintendo DS emulator.\n\nBased off of YopYop's original work, and continued by the DeSmuME team.\n\
\nhttp://www.desmume.org\n\n\n\
This program is free software; you can redistribute it and/or \
@ -163,7 +159,7 @@ NSView *createPreferencesView(NSTabViewItem *tab, NSDictionary *options, id dele
{
object = [object_enumerator nextObject];
key = localizedString(key_raw, nil);
key = NSLocalizedString(key_raw, nil);
NSString *current_setting = [[NSUserDefaults standardUserDefaults] objectForKey:key_raw];
@ -182,8 +178,8 @@ NSView *createPreferencesView(NSTabViewItem *tab, NSDictionary *options, id dele
[button setAction:action];
[button setTarget:delegate];
[button addItemWithTitle:localizedString(@"Yes",nil)];
[button addItemWithTitle:localizedString(@"No",nil)];
[button addItemWithTitle:NSLocalizedString(@"Yes",nil)];
[button addItemWithTitle:NSLocalizedString(@"No",nil)];
[button selectItemAtIndex:([[NSUserDefaults standardUserDefaults] boolForKey:PREF_EXECUTE_UPON_LOAD] == YES) ? 0 : 1];
@ -207,7 +203,7 @@ NSView *createPreferencesView(NSTabViewItem *tab, NSDictionary *options, id dele
for(i = 2; i < [object count]; i++)
{
//add the item to the popup buttons list
[button addItemWithTitle:localizedString([object objectAtIndex:i],nil)];
[button addItemWithTitle:NSLocalizedString([object objectAtIndex:i],nil)];
//if this is the currently selected or default item
if([current_setting compare:[object objectAtIndex:i]] == NSOrderedSame)
@ -224,7 +220,7 @@ NSView *createPreferencesView(NSTabViewItem *tab, NSDictionary *options, id dele
current_setting = [desmume_defaults objectForKey:key_raw];
//show an error
messageDialog(localizedString(@"Error",nil), [NSString stringWithFormat:localizedString(@"%@ setting corrupt, resetting to default (%@)",nil),key, localizedString(current_setting, nil)]);
messageDialog(NSLocalizedString(@"Error",nil), [NSString stringWithFormat:NSLocalizedString(@"%@ setting corrupt, resetting to default (%@)",nil),key, NSLocalizedString(current_setting, nil)]);
//set the setting to default
[[NSUserDefaults standardUserDefaults] setObject:current_setting forKey:key_raw];
@ -279,7 +275,6 @@ NSView *createPreferencesView(NSTabViewItem *tab, NSDictionary *options, id dele
void setAppDefaults()
{
desmume_defaults = [NSDictionary dictionaryWithObjectsAndKeys:
//Interface defaults
@ -289,10 +284,6 @@ void setAppDefaults()
@"DeSmuME User", PREF_FIRMWARE_PLAYER_NAME,
@"English", PREF_FIRMWARE_LANGUAGE,
//Plugin defaults
@"OpenGL 3D", PREF_3D_PLUGIN,
@"None", PREF_SOUND_PLUGIN,
nil];
[desmume_defaults retain];
@ -308,7 +299,11 @@ void setAppDefaults()
}
- (void)preferences
//this is a hack - in the nib we connect preferences to this function name,
//since it's there, and then here we override whatever it's actually supposed to do
//and replace it with the preference panel.
//Incase you were wondering, I actually have no idea what I'm doing.
- (void)orderFrontDataLinkPanel:(id)sender //<- Preferences Display Function
{
bool was_paused = paused;
@ -345,7 +340,7 @@ void setAppDefaults()
NSTitledWindowMask|NSClosableWindowMask backing:NSBackingStoreBuffered defer:NO screen:nil];
//set the window title
[preferences_window setTitle:localizedString(@"DeSmuME Preferences", nil)];
[preferences_window setTitle:NSLocalizedString(@"DeSmuME Preferences", nil)];
//set the window delegate
[preferences_window setDelegate:delegate];
@ -360,19 +355,20 @@ void setAppDefaults()
//Create the "Interface" pane
interface_pane_tab = [[NSTabViewItem alloc] initWithIdentifier:nil];
[interface_pane_tab setLabel:localizedString(@"Interface", nil)];
[interface_pane_tab setLabel:NSLocalizedString(@"Interface", nil)];
[tab_view addTabViewItem:interface_pane_tab];
//Create interface view
NSDictionary *interface_options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSArray arrayWithObjects:@"Bool", [NSData dataWithBytes:&@selector(executeUponLoad:) length:sizeof(SEL)], @"Yes",@"No",nil], PREF_EXECUTE_UPON_LOAD,
nil];
[NSArray arrayWithObjects:@"Bool", [NSData dataWithBytes:&@selector(executeUponLoad:) length:sizeof(SEL)], @"Yes", @"No",nil]
, PREF_EXECUTE_UPON_LOAD, nil];
NSView *interface_view = createPreferencesView(interface_pane_tab, interface_options, delegate);
/*
//Create the firmware pane
firmware_pane_tab = [[NSTabViewItem alloc] initWithIdentifier:nil];
[firmware_pane_tab setLabel:localizedString(@"DS Firmware", nil)];
[firmware_pane_tab setLabel:NSLocalizedString(@"DS Firmware", nil)];
[tab_view addTabViewItem:firmware_pane_tab];
NSDictionary *firmware_options = [NSDictionary dictionaryWithObjectsAndKeys:
@ -381,7 +377,7 @@ void setAppDefaults()
nil];
NSView *firmware_view = createPreferencesView(firmware_pane_tab, firmware_options, delegate);
*/
}
//make the window controller
@ -389,15 +385,14 @@ void setAppDefaults()
[wc setShouldCascadeWindows:NO];
//tell it to store/retrieve window frame from/to previous/later sessions
[preferences_window setFrameUsingName:@"DeSmuME Preferences Window" force:YES];
//[preferences_window setFrameUsingName:@"DeSmuME Preferences Window" force:YES];
//[preferences_window setFrameAutosaveName:@"DeSmuME Preferences Window"];
//messageDialog([preferences_window frameAutosaveName],@"");
//messageDialog([preferences_window frameAutosaveName],@"");
//show the window
[wc showWindow:nil];
[NSApp runModalForWindow:preferences_window];
if(!was_paused)[NDS execute];

View File

@ -28,6 +28,7 @@
@interface Screenshot : NSObject
{
NSWindowController *controller;
NSWindow *window;
NSImage *image;
NSImageView *image_view;
@ -38,7 +39,8 @@
NSPopUpButton *format_button;
}
- (id)initWithBuffer:(const u8*)buffer rotation:(u8)rotation saveOnly:(BOOL)save_only;
- (id)initWithBuffer:(volatile const u8*)buffer rotation:(u8)rotation saveOnly:(BOOL)save_only;
- (void)dealloc;
@end
#endif

View File

@ -65,7 +65,7 @@
rect.origin.x = 230;
rect.origin.y = 200;
[panel setTitle:localizedString(@"Save Screenshot to File", nil)];
[panel setTitle:NSLocalizedString(@"Save Screenshot to File", nil)];
//[panel setAllowedFileTypes:[NSArray arrayWithObjects:@"bmp",@"gif",nil]];
if(!format_selection)
@ -80,7 +80,7 @@
[format_text setMinSize:NSMakeSize(1,1)];
[format_text setHorizontallyResizable:YES];
[format_text setVerticallyResizable:YES];
[format_text setString:localizedString(@"Select Image Format: ", nil)];
[format_text setString:NSLocalizedString(@"Select Image Format: ", nil)];
[format_text sizeToFit];
//center vertically
@ -89,12 +89,12 @@
[format_text setFrame:temp];
format_button = [[NSPopUpButton alloc] initWithFrame:NSMakeRect([format_text frame].size.width,0,200,26) pullsDown:NO];
[format_button addItemWithTitle:localizedString(@"Pick by Extension", nil)];
[format_button addItemWithTitle:localizedString(@"BMP", nil)];
[format_button addItemWithTitle:localizedString(@"GIF", nil)];
[format_button addItemWithTitle:localizedString(@"JPG", nil)];
[format_button addItemWithTitle:localizedString(@"PNG", nil)];
[format_button addItemWithTitle:localizedString(@"TIFF", nil)];
[format_button addItemWithTitle:NSLocalizedString(@"Pick by Extension", nil)];
[format_button addItemWithTitle:NSLocalizedString(@"BMP", nil)];
[format_button addItemWithTitle:NSLocalizedString(@"GIF", nil)];
[format_button addItemWithTitle:NSLocalizedString(@"JPG", nil)];
[format_button addItemWithTitle:NSLocalizedString(@"PNG", nil)];
[format_button addItemWithTitle:NSLocalizedString(@"TIFF", nil)];
//[format_button setAction:@selector(??)];
//[format_button setTarget:self];
@ -214,7 +214,7 @@
@implementation Screenshot
- (id)initWithBuffer:(u8*)buffer rotation:(u8)rotation saveOnly:(BOOL)save_only
- (id)initWithBuffer:(volatile const u8*)buffer rotation:(u8)rotation saveOnly:(BOOL)save_only
{
self = [super init];
@ -249,7 +249,7 @@
if(!image_rep)
{
messageDialog(localizedString(@"Error", nil), @"Could not create NSBitmapImageRep for screenshot");
messageDialog(NSLocalizedString(@"Error", nil), @"Could not create NSBitmapImageRep for screenshot");
return nil;
}
@ -268,6 +268,7 @@
if(save_only)
{
[self saveButtonPressed];
} else
{
@ -276,7 +277,7 @@
if(!image)
{
messageDialog(localizedString(@"Error", nil), @"Could not create NSImage for screenshot window");
messageDialog(NSLocalizedString(@"Error", nil), @"Could not create NSImage for screenshot window");
return nil;
}
@ -288,7 +289,7 @@
if(!image_view)
{
messageDialog(localizedString(@"Error", nil), @"Could not create NSImageView for screenshot window");
messageDialog(NSLocalizedString(@"Error", nil), @"Could not create NSImageView for screenshot window");
return nil;
}
@ -300,12 +301,12 @@
if(!save_button)
{
messageDialog(localizedString(@"Error", nil), @"Could not create save button for screenshot window");
messageDialog(NSLocalizedString(@"Error", nil), @"Could not create save button for screenshot window");
return nil;
}
[save_button setBezelStyle:NSRoundedBezelStyle];
[save_button setTitle:localizedString(@"Save Screenshot", nil)];
[save_button setTitle:NSLocalizedString(@"Save Screenshot", nil)];
[save_button setAction:@selector(saveButtonPressed)];
[save_button setTarget:self];
@ -314,12 +315,12 @@
if(!update_button)
{
messageDialog(localizedString(@"Error", nil), @"Could not create update button for screenshot window");
messageDialog(NSLocalizedString(@"Error", nil), @"Could not create update button for screenshot window");
return nil;
}
[update_button setBezelStyle:NSRoundedBezelStyle];
[update_button setTitle:localizedString(@"Update Screenshot", nil)];
[update_button setTitle:NSLocalizedString(@"Update Screenshot", nil)];
[update_button setAction:@selector(updateButtonPressed)];
[update_button setTarget:self];
@ -329,7 +330,7 @@
NSTitledWindowMask|NSClosableWindowMask|NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO screen:nil];
//set the window title
[window setTitle:localizedString(@"DeSmuME Screenshot", nil)];
[window setTitle:NSLocalizedString(@"DeSmuME Screenshot", nil)];
//set the window delegate
[window setDelegate:self];
@ -343,10 +344,29 @@
[self windowDidResize:nil];
//show the window
[[[NSWindowController alloc] initWithWindow:window] showWindow:nil];
controller = [[NSWindowController alloc] initWithWindow:window];
[controller showWindow:nil];
}
return self;
}
- (void)dealloc
{
[image_rep release];
[window release];
[controller release];
/*
NSImage *image;
NSImageView *image_view;
NSButton *save_button;
NSButton *update_button;
NSBitmapImageRep *image_rep;
NSView *format_selection;
NSPopUpButton *format_button;
*/
[super dealloc];
}
@end