diff options
Diffstat (limited to 'app/mac/view-controller.mm')
| -rw-r--r-- | app/mac/view-controller.mm | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/app/mac/view-controller.mm b/app/mac/view-controller.mm new file mode 100644 index 0000000..8a1fcbd --- /dev/null +++ b/app/mac/view-controller.mm @@ -0,0 +1,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
\ No newline at end of file |
