blob: 8a1fcbd44c681720e52a10ea11b19f5f025a9531 (
plain)
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
|
#import "view-controller.hh"
#import "controller-adapter-keyboard.hh"
#import "scene.hh"
@implementation ViewController
{
Scene* _scene;
NSSize _sceneSize;
ControllerAdapterKeyboard* _keyboardController;
}
- (instancetype)initWithFilePath:(NSString*)filePath
{
self = [super initWithNibName:nil bundle:nil];
if (self)
{
_scene = [[Scene alloc] initWithFilePath:filePath];
_sceneSize = [_scene size];
_keyboardController = [[ControllerAdapterKeyboard alloc] init];
[_scene setPrimaryController:_keyboardController];
}
return self;
}
- (void)loadView
{
auto view = [[SKView alloc] init];
[view setIgnoresSiblingOrder:YES];
[view setShowsFPS:YES];
[view presentScene:_scene];
[self setView:view];
}
- (NSSize)minimumDisplaySize
{
return _sceneSize;
}
- (NSSize)preferredDisplaySize
{
return NSMakeSize(_sceneSize.width * 3., _sceneSize.height * 3.);
}
@end
|