AppDelegate.m 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. {
  15. gameview = [[GameView alloc] initWithFrame:[[self window] frame]];
  16. // Insert code here to initialize your application
  17. [[self window] setStyleMask:[[self window] styleMask] & ~resizable];
  18. [[self window] setDelegate:[self gameview]];
  19. [[self window] makeMainWindow];
  20. }
  21. - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {
  22. return YES;
  23. }
  24. @end
  25. @implementation GameWindow
  26. - (id)initWithContentRect:(NSRect)contentRect
  27. styleMask:(NSWindowStyleMask)aStyle
  28. backing:(NSBackingStoreType)bufferingType
  29. defer:(BOOL)flag {
  30. // Using NSBorderlessWindowMask results in a window without a title bar.
  31. self = [super initWithContentRect:contentRect
  32. styleMask:(aStyle | borderless) & ~resizable
  33. backing:NSBackingStoreBuffered
  34. defer:NO];
  35. return self;
  36. }
  37. - (BOOL)canBecomeMainWindow {
  38. return YES;
  39. }
  40. - (BOOL)canBecomeKeyWindow {
  41. return YES;
  42. }
  43. @end