Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Misc updates

  • Loading branch information...
commit 3b7d4876ecf7273cdc422d90117cb1394590f409 1 parent 09a0250
@mslinklater authored
View
3  Core/FCTypes.h
@@ -24,3 +24,6 @@
#import "FCKeys.h"
typedef unsigned int FCHandle;
+
+static const FCHandle kFCHandleInvalid = 0;
+static const FCHandle kFCHandleFirstValid = 1;
View
3  Framework/Actor/FCActorSystem.h
@@ -65,9 +65,6 @@
-(NSArray*)getActorsOfClass:(NSString*)actorClass;
-//-(FCActor*)actorAtPosition:(FC::Vector2f)pos;
-// new stuff
-
-(NSArray*)createActorsOfClass:(NSString*)actorClass
withResource:(FCResource*)res
named:(NSString*)name;
View
33 Framework/Actor/FCActorSystem.mm
@@ -188,6 +188,8 @@ -(id)createActor:(NSDictionary*)actorDict ofClass:(NSString *)actorClass withRes
[_actorHandleDictionary setObject:actor forKey:[NSNumber numberWithInt:((FCActor*)actor).handle]];
+ NSLog(@"numActors %d", [_allActorsArray count]);
+
return actor;
}
@@ -327,37 +329,6 @@ -(NSArray*)renderGather
return _renderActorsArray;
}
-//-(FCActor*)actorAtPosition:(FC::Vector2f)pos
-//{
-// FCActor* ret = nil;
-//
-// NSMutableArray* candidates = [NSMutableArray arrayWithCapacity:[_tapGestureActorsArray count]];
-//
-// // Find candidates using radius checks
-//
-// for( FCActor* actor in _tapGestureActorsArray )
-// {
-// FC::Vector2f actorPos = actor.position;
-// if ([actor radius] >= FC::Distance(actorPos, pos))
-// {
-// [candidates addObject:actor];
-// }
-// }
-//
-// // do proper check by asking actor if pos is within bounds
-//
-// for( FCActor* actor in candidates )
-// {
-// if ([actor posWithinBounds:pos])
-// {
-// ret = actor;
-// break;
-// }
-// }
-//
-// return ret;
-//}
-
@end
View
1  Framework/Analytics/FCAnalytics.mm
@@ -100,6 +100,7 @@ -(id)init
self = [super init];
if (self) {
_currentTimedEvents = [NSMutableDictionary dictionary];
+ _nextHandle = kFCHandleFirstValid;
}
return self;
}
View
38 Framework/App/FCApplication.h
@@ -45,35 +45,37 @@
@interface FCApplication : NSObject
#endif
++(FCApplication*)instance;
+
#if TARGET_OS_IPHONE
-+(void)coldBootWithViewController:(UIViewController*)vc delegate:(id<FCAppDelegate>)delegate;
+-(void)coldBootWithViewController:(UIViewController*)vc delegate:(id<FCAppDelegate>)delegate;
#else
-+(void)coldBootWithDelegate:(id<FCAppDelegate>)delegate;
+-(void)coldBootWithDelegate:(id<FCAppDelegate>)delegate;
#endif
-+(void)warmBoot;
-+(void)shutdown;
-+(void)update;
-+(void)pause;
-+(void)resume;
-+(void)setUpdateFrequency:(int)fps;
+-(void)warmBoot;
+-(void)shutdown;
+-(void)update;
+-(void)pause;
+-(void)resume;
+-(void)setUpdateFrequency:(int)fps;
-+(void)willResignActive;
-+(void)didEnterBackground;
-+(void)willEnterForeground;
-+(void)didBecomeActive;
-+(void)willTerminate;
+-(void)willResignActive;
+-(void)didEnterBackground;
+-(void)willEnterForeground;
+-(void)didBecomeActive;
+-(void)willTerminate;
#if TARGET_OS_IPHONE
-+(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
-+(void)showGameCenterLeaderboard;
+-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
+-(void)showGameCenterLeaderboard;
#endif
-+(CGSize)mainViewSize;
+-(CGSize)mainViewSize;
#if defined(FC_LUA)
-+(FCLuaVM*)lua;
+-(FCLuaVM*)lua;
#endif
-+(void)launchExternalURL:(NSString*)stringURL;
+-(void)launchExternalURL:(NSString*)stringURL;
@end
View
85 Framework/App/FCApplication.mm
@@ -43,6 +43,8 @@ of this software and associated documentation files (the "Software"), to deal
static FCLuaVM* s_lua;
#endif
+static FCHandle s_sessionActiveAnalyticsHandle = kFCHandleInvalid;
+
#if TARGET_OS_IPHONE
static UIViewController* s_viewController;
static CADisplayLink* s_displayLink;
@@ -102,7 +104,7 @@ static int lua_SetBackgroundColor( lua_State* _state )
static int lua_ShowGameCenterLeaderboards( lua_State* _state )
{
- [FCApplication showGameCenterLeaderboard];
+ [[FCApplication instance] showGameCenterLeaderboard];
return 0;
}
@@ -112,7 +114,7 @@ static int lua_LaunchExternalURL( lua_State* _state )
NSString* urlString = [NSString stringWithUTF8String:lua_tostring(_state, 1)];
- [FCApplication launchExternalURL:urlString];
+ [[FCApplication instance] launchExternalURL:urlString];
return 0;
}
@@ -134,9 +136,9 @@ static int lua_PauseGame( lua_State* _state )
FC_ASSERT(lua_isboolean(_state, 1));
if (lua_toboolean(_state, 1)) {
- [FCApplication pause];
+ [[FCApplication instance] pause];
} else {
- [FCApplication resume];
+ [[FCApplication instance] resume];
}
return 0;
@@ -147,7 +149,7 @@ static int lua_SetUpdateFrequency( lua_State* _state )
FC_ASSERT(lua_gettop(_state) == 1);
FC_ASSERT(lua_type(_state, 1) == LUA_TNUMBER);
- [FCApplication setUpdateFrequency:lua_tointeger(_state, 1)];
+ [[FCApplication instance] setUpdateFrequency:lua_tointeger(_state, 1)];
return 0;
}
@@ -159,10 +161,28 @@ static int lua_SetUpdateFrequency( lua_State* _state )
@implementation FCApplication
++(FCApplication*)instance
+{
+ static FCApplication* pInstance;
+ if (!pInstance) {
+ pInstance = [[FCApplication alloc] init];
+ }
+ return pInstance;
+}
+
+-(id)init
+{
+ self = [super init];
+ if (self) {
+ // blah
+ }
+ return self;
+}
+
#if TARGET_OS_IPHONE
-+(void)coldBootWithViewController:(UIViewController *)vc delegate:(id<FCAppDelegate>)delegate
+-(void)coldBootWithViewController:(UIViewController *)vc delegate:(id<FCAppDelegate>)delegate
#else
-+(void)coldBootWithDelegate:(id<FCAppDelegate>)delegate
+-(void)coldBootWithDelegate:(id<FCAppDelegate>)delegate
#endif
{
#if TARGET_OS_IPHONE
@@ -172,7 +192,7 @@ +(void)coldBootWithDelegate:(id<FCAppDelegate>)delegate
s_perfCounter = [[FCPerformanceCounter alloc] init];
#if TARGET_OS_IPHONE
- s_displayLink = [CADisplayLink displayLinkWithTarget:[FCApplication class] selector:@selector(update)];
+ s_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)];
[s_displayLink setFrameInterval:1];
[s_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
@@ -230,7 +250,7 @@ +(void)coldBootWithDelegate:(id<FCAppDelegate>)delegate
[self warmBoot];
}
-+(void)warmBoot
+-(void)warmBoot
{
[s_delegate registerPhasesWithManager:[FCPhaseManager instance]];
[s_delegate initialiseSystems];
@@ -240,7 +260,7 @@ +(void)warmBoot
#endif
}
-+(void)shutdown
+-(void)shutdown
{
#if TARGET_OS_IPHONE
[s_displayLink invalidate];
@@ -254,17 +274,17 @@ +(void)shutdown
#endif
}
-+(void)setUpdateFrequency:(int)fps
+-(void)setUpdateFrequency:(int)fps
{
[s_displayLink invalidate];
s_displayLink = nil;
- s_displayLink = [CADisplayLink displayLinkWithTarget:[FCApplication class] selector:@selector(update)];
+ s_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)];
[s_displayLink setFrameInterval:60 / fps];
[s_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
-+(void)update
+-(void)update
{
static int fps = 0;
static float seconds = 0.0f;
@@ -320,7 +340,7 @@ +(void)update
if (fps < 55) {
// [s_displayLink invalidate];
// s_displayLink = nil;
-// s_displayLink = [CADisplayLink displayLinkWithTarget:[FCApplication class] selector:@selector(update)];
+// s_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)];
// [s_displayLink setFrameInterval:1];
// [s_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
@@ -332,7 +352,7 @@ +(void)update
}
}
-+(void)pause
+-(void)pause
{
s_paused = YES;
#if defined (FC_LUA)
@@ -340,7 +360,7 @@ +(void)pause
#endif
}
-+(void)resume
+-(void)resume
{
s_paused = NO;
#if defined (FC_LUA)
@@ -348,11 +368,15 @@ +(void)resume
#endif
}
-+(void)willResignActive
+-(void)willResignActive
{
#if TARGET_OS_IPHONE
[[FCConnect instance] stop];
-// [[FCAnalytics instance] eventEndPlaySession];
+
+ FC_ASSERT(s_sessionActiveAnalyticsHandle != kFCHandleInvalid);
+
+ [[FCAnalytics instance] endTimedEvent:s_sessionActiveAnalyticsHandle];
+ s_sessionActiveAnalyticsHandle = kFCHandleInvalid;
#endif
[[FCPersistentData instance] saveData];
@@ -361,26 +385,29 @@ +(void)willResignActive
#endif
}
-+(void)didEnterBackground
+-(void)didEnterBackground
{
#if defined (FC_LUA)
[s_lua call:@"FCApp.DidEnterBackground" required:NO withSig:@""];
#endif
}
-+(void)willEnterForeground
+-(void)willEnterForeground
{
#if defined (FC_LUA)
[s_lua call:@"FCApp.WillEnterForeground" required:NO withSig:@""];
#endif
}
-+(void)didBecomeActive
+-(void)didBecomeActive
{
#if TARGET_OS_IPHONE
[[FCConnect instance] start:nil];
[[FCConnect instance] enableBonjourWithName:@"FCConnect"];
-// [[FCAnalytics instance] eventStartPlaySession];
+
+ FC_ASSERT(s_sessionActiveAnalyticsHandle == kFCHandleInvalid);
+
+ s_sessionActiveAnalyticsHandle = [[FCAnalytics instance] beginTimedEvent:@"playSessionTime"];
#endif
#if defined (FC_LUA)
@@ -388,7 +415,7 @@ +(void)didBecomeActive
#endif
}
-+(void)willTerminate
+-(void)willTerminate
{
#if TARGET_OS_IPHONE
// [[FCAnalytics instance] shutdown];
@@ -400,7 +427,7 @@ +(void)willTerminate
}
#if TARGET_OS_IPHONE
-+(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
BOOL ret = YES;
if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
@@ -412,7 +439,7 @@ +(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceO
return ret;
}
-+(void)showGameCenterLeaderboard
+-(void)showGameCenterLeaderboard
{
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
@@ -423,7 +450,7 @@ +(void)showGameCenterLeaderboard
}
}
-+(void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
+-(void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
[s_viewController dismissModalViewControllerAnimated:YES];
@@ -431,7 +458,7 @@ +(void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewCon
}
#endif
-+(CGSize)mainViewSize
+-(CGSize)mainViewSize
{
#if TARGET_OS_IPHONE
return s_viewController.view.frame.size;
@@ -441,14 +468,14 @@ +(CGSize)mainViewSize
}
#if defined (FC_LUA)
-+(FCLuaVM*)lua
+-(FCLuaVM*)lua
{
return s_lua;
}
#endif
-+(void)launchExternalURL:(NSString*)stringURL
+-(void)launchExternalURL:(NSString*)stringURL
{
#if TARGET_OS_IPHONE
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:stringURL]];
View
15 Framework/Facebook/FCFacebook.mm
@@ -136,4 +136,19 @@ -(void)fbDidLogout {
_loginStatus = kOffline;
}
+- (void)fbDidNotLogin:(BOOL)cancelled
+{
+ _loginStatus = kOffline;
+}
+
+- (void)fbDidExtendToken:(NSString*)accessToken expiresAt:(NSDate*)expiresAt
+{
+
+}
+
+- (void)fbSessionInvalidated
+{
+ _loginStatus = kOffline;
+}
+
@end
View
1  Framework/UI/FCViewManager.h
@@ -59,6 +59,7 @@
@private
NSMutableDictionary* _viewDictionary;
NSMutableDictionary* _groupDictionary;
+
#if TARGET_OS_IPHONE
UIView* _rootView;
#else
View
6 Framework/UI/FCViewManager.mm
@@ -431,7 +431,7 @@ -(CGRect)rectForRect:(CGRect)rect containedInView:(NSView*)view;
scaledFrame.origin.x = view.frame.size.width * rect.origin.x;
scaledFrame.origin.y = view.frame.size.height * rect.origin.y;
- CGSize mainViewSize = [FCApplication mainViewSize];
+ CGSize mainViewSize = [[FCApplication instance] mainViewSize];
scaledFrame.size.width = mainViewSize.width * rect.size.width;
scaledFrame.size.height = mainViewSize.height * rect.size.height;
@@ -450,7 +450,7 @@ -(void)setView:(NSString*)viewName text:(NSString*)text
FC_ASSERT( thisView );
#if defined (DEBUG)
- if ([thisView respondsToSelector:@selector(setText:)])
+ if ([thisView respondsToSelector:@selector(setText:)])
#endif
{
NSMethodSignature* sig = [[thisView class] instanceMethodSignatureForSelector:@selector(setText:)];
@@ -517,7 +517,7 @@ -(void)setView:(NSString*)viewName frame:(CGRect)frame over:(float)seconds
scaledFrame.origin.x = containerFrame.size.width * frame.origin.x;
scaledFrame.origin.y = containerFrame.size.height * frame.origin.y;
- CGSize mainViewSize = [FCApplication mainViewSize];
+ CGSize mainViewSize = [[FCApplication instance] mainViewSize];
if (frame.size.width < 0) {
scaledFrame.size.width = thisView.frame.size.width;
Please sign in to comment.
Something went wrong with that request. Please try again.