bsnes/higan/phoenix/cocoa/message-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

80 lines
3.1 KiB
C++

namespace phoenix {
enum class MessageWindowType : unsigned { Error, Information, Question, Warning };
MessageWindow::Response MessageWindow_dialog(MessageWindow::State &state, MessageWindowType type) {
@autoreleasepool {
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
if(state.title) [alert setMessageText:[NSString stringWithUTF8String:state.title]];
[alert setInformativeText:[NSString stringWithUTF8String:state.text]];
switch(state.buttons) {
case MessageWindow::Buttons::Ok:
[alert addButtonWithTitle:@"Ok"];
break;
case MessageWindow::Buttons::OkCancel:
[alert addButtonWithTitle:@"Ok"];
[alert addButtonWithTitle:@"Cancel"];
break;
case MessageWindow::Buttons::YesNo:
[alert addButtonWithTitle:@"Yes"];
[alert addButtonWithTitle:@"No"];
break;
case MessageWindow::Buttons::YesNoCancel:
[alert addButtonWithTitle:@"Yes"];
[alert addButtonWithTitle:@"No"];
[alert addButtonWithTitle:@"Cancel"];
break;
}
switch(type) {
case MessageWindowType::Error: [alert setAlertStyle:NSCriticalAlertStyle]; break;
case MessageWindowType::Information: [alert setAlertStyle:NSInformationalAlertStyle]; break;
case MessageWindowType::Question: [alert setAlertStyle:NSInformationalAlertStyle]; break;
case MessageWindowType::Warning: [alert setAlertStyle:NSWarningAlertStyle]; break;
}
NSInteger response = [alert runModal];
//[alert beginSheetModalForWindow:parent.p.cocoaWindow modalDelegate:self didEndSelector:@selector(...) contextInfo:nil];
switch(state.buttons) {
case MessageWindow::Buttons::Ok:
if(response == NSAlertFirstButtonReturn) return MessageWindow::Response::Ok;
break;
case MessageWindow::Buttons::OkCancel:
if(response == NSAlertFirstButtonReturn) return MessageWindow::Response::Ok;
if(response == NSAlertSecondButtonReturn) return MessageWindow::Response::Cancel;
break;
case MessageWindow::Buttons::YesNo:
if(response == NSAlertFirstButtonReturn) return MessageWindow::Response::Yes;
if(response == NSAlertSecondButtonReturn) return MessageWindow::Response::No;
break;
case MessageWindow::Buttons::YesNoCancel:
if(response == NSAlertFirstButtonReturn) return MessageWindow::Response::Yes;
if(response == NSAlertSecondButtonReturn) return MessageWindow::Response::No;
if(response == NSAlertThirdButtonReturn) return MessageWindow::Response::Cancel;
break;
}
}
throw;
}
MessageWindow::Response pMessageWindow::error(MessageWindow::State &state) {
return MessageWindow_dialog(state, MessageWindowType::Error);
}
MessageWindow::Response pMessageWindow::information(MessageWindow::State &state) {
return MessageWindow_dialog(state, MessageWindowType::Information);
}
MessageWindow::Response pMessageWindow::question(MessageWindow::State &state) {
return MessageWindow_dialog(state, MessageWindowType::Question);
}
MessageWindow::Response pMessageWindow::warning(MessageWindow::State &state) {
return MessageWindow_dialog(state, MessageWindowType::Warning);
}
}