AppDelegate.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // AppDelegate.m
  3. // danmaku
  4. //
  5. // Created by Sam Jaffe on 5/24/19.
  6. // Copyright © 2019 Sam Jaffe. All rights reserved.
  7. //
  8. #import "AppDelegate.h"
  9. @implementation AppDelegate
  10. @synthesize gameview;
  11. NSWindowStyleMask const resizable = NSWindowStyleMaskResizable;
  12. NSWindowStyleMask const borderless = NSWindowStyleMaskBorderless;
  13. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
  14. gameview = [[GameView alloc] initWithFrame:[[self window] frame]];
  15. // Insert code here to initialize your application
  16. [[self window] setStyleMask:[[self window] styleMask] & ~resizable];
  17. [[self window] setDelegate:[self gameview]];
  18. [[self window] makeMainWindow];
  19. }
  20. - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app {
  21. return YES;
  22. }
  23. @end
  24. @implementation GameWindow
  25. - (id)initWithContentRect:(NSRect)contentRect
  26. styleMask:(NSWindowStyleMask)aStyle
  27. backing:(NSBackingStoreType)bufferingType
  28. defer:(BOOL)flag {
  29. // Using NSBorderlessWindowMask results in a window without a title bar.
  30. self = [super initWithContentRect:contentRect
  31. styleMask:(aStyle | borderless) & ~resizable
  32. backing:NSBackingStoreBuffered
  33. defer:NO];
  34. return self;
  35. }
  36. - (BOOL)canBecomeMainWindow {
  37. return YES;
  38. }
  39. - (BOOL)canBecomeKeyWindow {
  40. return YES;
  41. }
  42. @end