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 [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/wesnoth/wesnoth/blob/master/changelog.md"]];
84 - (void) applicationDidFinishLaunching: (NSNotification *) note
88 setenv (
"SDL_ENABLEAPPEVENTS",
"1", 1);
89 setenv (
"SDL_VIDEO_ALLOW_SCREENSAVER",
"1", 1);
92 setenv (
"PANGO_RC_FILE",
"./pangorc", 1);
93 setenv (
"PANGO_SYSCONFDIR",
".", 1);
94 setenv (
"PANGO_LIBDIR",
".", 1);
95 setenv (
"FONTCONFIG_PATH",
"./fonts/", 1);
96 setenv (
"FONTCONFIG_FILE",
"fonts.conf", 1);
101 chdir([[[NSBundle mainBundle] resourcePath] fileSystemRepresentation]);
112 bool str_eq(
const char* str,
const char(& cstr)[sz]) {
113 return strncmp(str, cstr, sz) == 0;
121 int main (
int argc,
char **argv)
123 gArgs.push_back(argv[0]);
124 for (
int i = 1;
i < argc;
i++) {
126 if (
str_eq(argv[
i],
"-ApplePersistenceIgnoreState")) {
130 if (
str_eq(argv[i],
"-NSDocumentRevisionsDebugMode")) {
135 if (strncmp(argv[i],
"-psn", 4) == 0) {
138 gArgs.push_back(argv[i]);
140 gArgs.push_back(
nullptr);
144 [[NSBundle mainBundle] loadNibNamed:@"SDLMain" owner:NSApp topLevelObjects:nil];
static std::vector< char * > gArgs
#define NSEventModifierFlagCommand
int main(int argc, char **argv)
bool str_eq(const char *str, const char(&cstr)[sz])
int wesnoth_main(int argc, char **argv)
#define NSEventTypeKeyDown