summary refs log tree commit diff stats
path: root/Classes/GameModeSelection.m
diff options
context:
space:
mode:
Diffstat (limited to 'Classes/GameModeSelection.m')
-rw-r--r--Classes/GameModeSelection.m53
1 files changed, 22 insertions, 31 deletions
diff --git a/Classes/GameModeSelection.m b/Classes/GameModeSelection.m index 582c9dd..69f1ddb 100644 --- a/Classes/GameModeSelection.m +++ b/Classes/GameModeSelection.m
@@ -9,6 +9,7 @@
9#import "GameModeSelection.h" 9#import "GameModeSelection.h"
10#import "UIImage+ColorMasking.h" 10#import "UIImage+ColorMasking.h"
11#import "NMPanelMenu.h" 11#import "NMPanelMenu.h"
12#import "Highscore.h"
12 13
13@implementation GameModeSelection 14@implementation GameModeSelection
14 15
@@ -19,11 +20,6 @@
19 return [[[GameModeSelection alloc] initWithName:name location:location filename:filename unlocked:unlocked] autorelease]; 20 return [[[GameModeSelection alloc] initWithName:name location:location filename:filename unlocked:unlocked] autorelease];
20} 21}
21 22
22+ (id)selectionWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename highscore:(int)highscore
23{
24 return [[[GameModeSelection alloc] initWithName:name location:location filename:filename highscore:highscore] autorelease];
25}
26
27+ (id)selectionWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename unlockCondition:(NSString*)unlockCondition 23+ (id)selectionWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename unlockCondition:(NSString*)unlockCondition
28{ 24{
29 return [[[GameModeSelection alloc] initWithName:name location:location filename:filename unlockCondition:unlockCondition] autorelease]; 25 return [[[GameModeSelection alloc] initWithName:name location:location filename:filename unlockCondition:unlockCondition] autorelease];
@@ -162,34 +158,29 @@
162 CCSprite* titleSprite = [CCSprite spriteWithCGImage:titleImage key:[NSString stringWithFormat:@"gms-%@-title", filenameMod]]; 158 CCSprite* titleSprite = [CCSprite spriteWithCGImage:titleImage key:[NSString stringWithFormat:@"gms-%@-title", filenameMod]];
163 titleSprite.position = ccp(-10, (boxSize.height)/2+(combinedTitleSize.height)/2); 159 titleSprite.position = ccp(-10, (boxSize.height)/2+(combinedTitleSize.height)/2);
164 [self addChild:titleSprite]; 160 [self addChild:titleSprite];
165 } 161
166 162 if (unlocked)
167 return self;
168}
169
170- (id)initWithName:(NSString *)m_name location:(NSString *)m_location filename:(NSString *)m_filename highscore:(int)m_highscore
171{
172 self = [self initWithName:m_name location:m_location filename:m_filename unlocked:YES];
173
174 if (nil != self)
175 {
176 if (m_highscore != 0)
177 { 163 {
178 // Render the highscore label 164 Highscore* localHighscore = [Highscore localHighscoreForGameMode:name];
179 NSString* highscoreString = [NSString stringWithFormat:@"Highscore: %d", m_highscore];
180 UIFont* highscoreFont = [UIFont fontWithName:@"AmericanTypewriter" size:16.0f];
181 CGSize highscoreSize = [highscoreString sizeWithFont:highscoreFont];
182
183 UIGraphicsBeginImageContext(CGSizeMake(highscoreSize.width+10, highscoreSize.height+10));
184 CGContextRef context = UIGraphicsGetCurrentContext();
185 CGContextSetShadow(context, CGSizeMake(-6, 6), 4.0f);
186 [highscoreString drawInRect:CGRectMake(10, 0, highscoreSize.width, highscoreSize.height) withFont:highscoreFont];
187 165
188 CGImageRef highscoreImage = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; 166 if (localHighscore != nil)
189 UIGraphicsEndImageContext(); 167 {
190 CCSprite* highscoreSprite = [CCSprite spriteWithCGImage:highscoreImage key:[NSString stringWithFormat:@"gms-%@-highscore", m_filename]]; 168 // Render the highscore label
191 highscoreSprite.position = ccp((128-highscoreSize.width)/2, 0-64-(highscoreSize.height)/2-10); 169 NSString* highscoreString = [NSString stringWithFormat:@"Highscore: %d", localHighscore.score];
192 [self addChild:highscoreSprite]; 170 UIFont* highscoreFont = [UIFont fontWithName:@"AmericanTypewriter" size:16.0f];
171 CGSize highscoreSize = [highscoreString sizeWithFont:highscoreFont];
172
173 UIGraphicsBeginImageContext(CGSizeMake(highscoreSize.width+10, highscoreSize.height+10));
174 CGContextRef context = UIGraphicsGetCurrentContext();
175 CGContextSetShadow(context, CGSizeMake(-6, 6), 4.0f);
176 [highscoreString drawInRect:CGRectMake(10, 0, highscoreSize.width, highscoreSize.height) withFont:highscoreFont];
177
178 CGImageRef highscoreImage = [UIGraphicsGetImageFromCurrentImageContext() CGImage];
179 UIGraphicsEndImageContext();
180 CCSprite* highscoreSprite = [CCSprite spriteWithCGImage:highscoreImage key:[NSString stringWithFormat:@"gms-%@-highscore", filename]];
181 highscoreSprite.position = ccp(-5, 0-64-(highscoreSize.height)/2-10);
182 [self addChild:highscoreSprite];
183 }
193 } 184 }
194 } 185 }
195 186