Skip to content

Commit

Permalink
Add version number to project settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jia Liu committed May 8, 2013
1 parent ad43f42 commit fdd5e81
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CocosBuilder/ccBuilder/ProjectSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
BOOL deviceOrientationLandscapeLeft;
BOOL deviceOrientationLandscapeRight;
int resourceAutoScaleFactor;

NSString* versionStr;
BOOL needRepublish;
}

@property (nonatomic, copy) NSString* projectPath;
Expand Down Expand Up @@ -150,6 +153,8 @@
@property (nonatomic, readonly) NSDictionary* generatedSpriteSheets;

@property (nonatomic,readonly) NSDictionary* breakpoints;
@property (nonatomic, copy) NSString* versionStr;
@property (nonatomic, assign) BOOL needRepublish;

- (id) initWithSerialization:(id)dict;
- (BOOL) store;
Expand Down
24 changes: 24 additions & 0 deletions CocosBuilder/ccBuilder/ProjectSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ @implementation ProjectSettings
@synthesize resourceAutoScaleFactor;
@synthesize generatedSpriteSheets;
@synthesize breakpoints;
@synthesize versionStr;
@synthesize needRepublish;

This comment has been minimized.

Copy link
@Ricardo1980

Ricardo1980 Aug 17, 2013

Why do you use synthesize? I thought was not anymore necessary with the new compilers, unless you really wanted a different name and avoid using common name conventions (_someVar)


- (id) init
{
Expand Down Expand Up @@ -196,6 +198,8 @@ - (id) init
}

[self detectBrowserPresence];
self.versionStr = [self getVersion];
self.needRepublish = NO;
return self;
}

Expand Down Expand Up @@ -273,6 +277,16 @@ - (id) initWithSerialization:(id)dict
self.javascriptMainCCB = mainCCB;

[self detectBrowserPresence];
NSString* old = [dict objectForKey:@"versionStr"];
NSString* new = [self getVersion];
if(![new isEqual:old])
{
self.versionStr = [self getVersion];
self.needRepublish = YES;
}else{
self.needRepublish = NO;
}
[self store];
return self;
}

Expand Down Expand Up @@ -350,6 +364,8 @@ - (id) serialize
}
[dict setObject:generatedSpriteSheetsDict forKey:@"generatedSpriteSheets"];

[dict setObject:versionStr forKey:@"versionStr"];
[dict setObject:[NSNumber numberWithBool:needRepublish] forKey:@"needsRepublis"];
return dict;
}

Expand Down Expand Up @@ -507,4 +523,12 @@ - (void) detectBrowserPresence
isFirefoxExist = TRUE;
}
}

- (NSString* ) getVersion
{
NSString* versionPath = [[NSBundle mainBundle] pathForResource:@"Version" ofType:@"txt" inDirectory:@"version"];

NSString* version = [NSString stringWithContentsOfFile:versionPath encoding:NSUTF8StringEncoding error:NULL];
return version;
}
@end

0 comments on commit fdd5e81

Please sign in to comment.