StandalonePlayerAppDelegate.mm 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // StandalonePlayerAppDelegate.m
  3. // StandalonePlayer
  4. //
  5. // Created by Ivan Safrin on 5/25/11.
  6. // Copyright 2011 Tomatogon. All rights reserved.
  7. //
  8. #import "StandalonePlayerAppDelegate.h"
  9. @implementation StandalonePlayerAppDelegate
  10. @synthesize window;
  11. @synthesize mainView;
  12. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
  13. {
  14. chdir([[[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/Contents/Resources"] UTF8String]);
  15. player = new CocoaPolycodePlayer(mainView, "main.polyapp", false, false);
  16. player->windowData = self;
  17. player->runPlayer();
  18. timer = [NSTimer timerWithTimeInterval:(1.0f/90.0f) target:self selector:@selector(animationTimer:) userInfo:nil repeats:YES];
  19. [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
  20. [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode]; // ensure timer fires during resize
  21. }
  22. - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
  23. {
  24. return YES;
  25. }
  26. - (void)animationTimer:(NSTimer *)timer
  27. {
  28. if(!player->Update()) {
  29. [window close];
  30. }
  31. }
  32. @end