AppDelegate.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 gamebridge;
  11. @synthesize gameview;
  12. NSWindowStyleMask const resizable = NSWindowStyleMaskResizable;
  13. NSWindowStyleMask const borderless = NSWindowStyleMaskBorderless;
  14. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
  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. gamebridge = [[GameBridge alloc] init];
  21. [[self gameview] setGamebridge:[self gamebridge]];
  22. [[self window] setGamebridge:[self gamebridge]];
  23. [[self gamebridge] refresh];
  24. }
  25. - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app {
  26. return YES;
  27. }
  28. @end
  29. @implementation GameWindow
  30. - (id)initWithContentRect:(NSRect)contentRect
  31. styleMask:(NSWindowStyleMask)aStyle
  32. backing:(NSBackingStoreType)bufferingType
  33. defer:(BOOL)flag {
  34. // Using NSBorderlessWindowMask results in a window without a title bar.
  35. self = [super initWithContentRect:contentRect
  36. styleMask:(aStyle | borderless) & ~resizable
  37. backing:NSBackingStoreBuffered
  38. defer:NO];
  39. return self;
  40. }
  41. - (BOOL)canBecomeMainWindow {
  42. return YES;
  43. }
  44. - (BOOL)canBecomeKeyWindow {
  45. return YES;
  46. }
  47. @end