25 #if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
26 #define NSEventTypeKeyDown NSKeyDown
27 #define NSEventTypeKeyUp NSKeyUp
28 #define NSEventModifierFlagCommand NSCommandKeyMask
32 static std::vector<char*>
gArgs;
39 - (void)terminate:(
id)sender
44 event.type = SDL_QUIT;
45 SDL_PushEvent(&event);
48 - (BOOL)_handleKeyEquivalent:(NSEvent *)theEvent
50 [[
super mainMenu] performKeyEquivalent:theEvent];
54 - (void) sendEvent:(NSEvent *)
event
60 [
super sendEvent: event];
63 [
super sendEvent: event];
71 - (IBAction) openHomepage:(
id)sender
74 [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.wesnoth.org/"]];
77 - (IBAction) openChangelog:(
id)sender
80 NSString* version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
81 NSString* url = [NSString stringWithFormat:@"https://changelog.wesnoth.org/%@", version];
82 [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
86 - (void) applicationDidFinishLaunching: (NSNotification *) note
90 setenv (
"SDL_ENABLEAPPEVENTS",
"1", 1);
91 setenv (
"SDL_VIDEO_ALLOW_SCREENSAVER",
"1", 1);
94 setenv (
"PANGO_RC_FILE",
"./pangorc", 1);
95 setenv (
"PANGO_SYSCONFDIR",
".", 1);
96 setenv (
"PANGO_LIBDIR",
".", 1);
97 setenv (
"FONTCONFIG_PATH",
"./fonts/", 1);
98 setenv (
"FONTCONFIG_FILE",
"fonts.conf", 1);
103 chdir([[[NSBundle mainBundle] resourcePath] fileSystemRepresentation]);
114 bool str_eq(
const char* str,
const char(& cstr)[sz]) {
115 return strncmp(str, cstr, sz) == 0;
123 int main (
int argc,
char **argv)
125 gArgs.push_back(argv[0]);
126 for (
int i = 1;
i < argc;
i++) {
128 if (
str_eq(argv[
i],
"-ApplePersistenceIgnoreState")) {
132 if (
str_eq(argv[
i],
"-NSDocumentRevisionsDebugMode")) {
137 if (strncmp(argv[
i],
"-psn", 4) == 0) {
142 gArgs.push_back(
nullptr);
146 [[NSBundle mainBundle] loadNibNamed:@"SDLMain" owner:NSApp topLevelObjects:nil];
bool str_eq(const char *str, const char(&cstr)[sz])
#define NSEventModifierFlagCommand
int main(int argc, char **argv)
#define NSEventTypeKeyDown
int wesnoth_main(int argc, char **argv)
static std::vector< char * > gArgs