-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyApp.m
60 lines (49 loc) · 1.61 KB
/
myApp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#import "openGL.h"
#import "myApp.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
@implementation myApp
@synthesize window=_window;
@synthesize game=_game;
-(id) initWithArgc: (int) argc Argv: (char**) argv{
self = [super init];
if(self){
[self setupApp];
[self makeGameWithArgc: argc Argv: argv];
[NSApp activateIgnoringOtherApps:YES];
[NSApp run];
}
return self;
}
- (void) setupApp{
//Setup NSApplication
[NSApplication sharedApplication];
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
id menubar = [NSMenu new];
id appMenuItem = [NSMenuItem new];
[menubar addItem:appMenuItem];
[NSApp setMainMenu:menubar];
id appMenu = [NSMenu new];
id appName = [[NSProcessInfo processInfo] processName];
id quitTitle = [@"Quit " stringByAppendingString:appName];
id quitMenuItem = [[NSMenuItem alloc] initWithTitle:quitTitle action:@selector(terminate:) keyEquivalent:@"q"];
[appMenu addItem:quitMenuItem];
[appMenuItem setSubmenu:appMenu];
//Setup a window
_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 600, 600) styleMask:NSTitledWindowMask|NSClosableWindowMask backing:NSBackingStoreBuffered defer:NO];
[_window cascadeTopLeftFromPoint:NSMakePoint(20,20)];
[_window setTitle:appName];
[_window setDelegate: self];
[_window makeKeyAndOrderFront:self];
_view = [[MyOpenGLView alloc] initWithFrame: [[_window contentView] bounds]];
[[_window contentView] addSubview: _view];
}
- (void) makeGameWithArgc: (int) argc Argv: (char**) argv{
_game = [[jsGame alloc] initWithArgc: argc Argv: argv];
[_view setGame: _game];
}
- (int) returnValue{
return 0;
}
@end