bsnes/higan/phoenix/cocoa/browser-window.cpp
Tim Allen fdd3ea490e Update to v092r04 release.
byuu says:

This is the first release with full support for OS X, although it's
certainly still very buggy.

Known issues:
- window status bars are still unsupported (they just don't show up)
- you get the bad keypress chime when you use the keyboard
- window geometry and font metrics aren't perfect (bit of clipping here
  and there)
- list view headers that aren't auto-sized are sometimes too short (file
  browser)
- input assignment is really rough (assigning a key also moves around in
  the list or beeps at you)

Custom OS X integration support so far:
- 512x512 ICNS application icon: will look razor-sharp even on a retina
  display
- basic Info.plist added to application bundle
- program menu about, preferences, quit all connected
- Settings->Configuration removed (use higan->Preferences instead)
- global menubar

To compile and use this, you'll need:
- Xz Utils (to extract .tar.xz)
- Xcode 4.6
- Lion 10.7.4 or newer

    mkdir higan_v092r04
    tar -xJf higan_v092r04.tar.xz -C higan_v092r04
    cd higan_v092r04
    make -j 2

ananke is missing, and I haven't updated purify yet, so you'll have to
move game folders from Windows or Linux over, or make them by hand (a
not so enjoyable experience, to say the least.)
2013-03-19 19:48:50 +11:00

70 lines
2.3 KiB
C++

namespace phoenix {
string pBrowserWindow::directory(BrowserWindow::State &state) {
string result;
@autoreleasepool {
NSOpenPanel *panel = [NSOpenPanel openPanel];
if(state.title) [panel setTitle:[NSString stringWithUTF8String:state.title]];
[panel setCanChooseDirectories:YES];
[panel setCanChooseFiles:NO];
if([panel runModalForDirectory:[NSString stringWithUTF8String:state.path] file:nil] == NSOKButton) {
NSArray *names = [panel filenames];
const char *name = [[names objectAtIndex:0] UTF8String];
if(name) result = name;
}
}
return result;
}
string pBrowserWindow::open(BrowserWindow::State &state) {
string result;
@autoreleasepool {
NSMutableArray *filters = [[NSMutableArray alloc] init];
for(auto &rule : state.filters) {
string pattern = rule.split<1>("(")(1).rtrim<1>(")");
if(!pattern.empty()) [filters addObject:[NSString stringWithUTF8String:pattern]];
}
NSOpenPanel *panel = [NSOpenPanel openPanel];
if(state.title) [panel setTitle:[NSString stringWithUTF8String:state.title]];
[panel setCanChooseDirectories:NO];
[panel setCanChooseFiles:YES];
[panel setAllowedFileTypes:filters];
if([panel runModalForDirectory:[NSString stringWithUTF8String:state.path] file:nil] == NSOKButton) {
NSArray *names = [panel filenames];
const char *name = [[names objectAtIndex:0] UTF8String];
if(name) result = name;
}
[filters release];
}
return result;
}
string pBrowserWindow::save(BrowserWindow::State &state) {
string result;
@autoreleasepool {
NSMutableArray *filters = [[NSMutableArray alloc] init];
for(auto &rule : state.filters) {
string pattern = rule.split<1>("(")(1).rtrim<1>(")");
if(!pattern.empty()) [filters addObjects:[NSString stringWithUTF8String:pattern]];
}
NSSavePanel *panel = [NSSavePanel savePanel];
if(state.title) [panel setTitle:[NSString stringWithUTF8String:state.title]];
[panel setAllowedFileTypes:filters];
if([panel runModalForDirectory:[NSString stringWithUTF8String:state.path] file:nil] == NSOKButton) {
NSArray *names = [panel filenames];
const char *name = [[names objectAtIndex:0] UTF8String];
if(name) result = name;
}
[filters release];
}
return result;
}
}