diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-01-29 00:58:07 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-01-29 00:58:07 +0100 |
| commit | c1062208bb54cce8dffa04e9697ae124f271ecaf (patch) | |
| tree | 5d387dcb76ec26a87d7ecafb983939b359c8f11e /app/mac/view-controller.mm | |
| parent | 117f584b3f3d7945732a29848eb6d4ead1f57bee (diff) | |
use game controller api for input
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 |
