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.m35
1 files changed, 25 insertions, 10 deletions
diff --git a/Classes/GameModeSelection.m b/Classes/GameModeSelection.m index fc6797a..582c9dd 100644 --- a/Classes/GameModeSelection.m +++ b/Classes/GameModeSelection.m
@@ -7,17 +7,31 @@
7// 7//
8 8
9#import "GameModeSelection.h" 9#import "GameModeSelection.h"
10#import "TutorialMode.h"
11#import "ClassicGameMode.h"
12#import "UIImage+ColorMasking.h" 10#import "UIImage+ColorMasking.h"
11#import "NMPanelMenu.h"
13 12
14@implementation GameModeSelection 13@implementation GameModeSelection
15 14
16@synthesize name, location, unlocked; 15@synthesize name, location, unlocked, delegate;
16
17+ (id)selectionWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked
18{
19 return [[[GameModeSelection alloc] initWithName:name location:location filename:filename unlocked:unlocked] autorelease];
20}
21
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
28{
29 return [[[GameModeSelection alloc] initWithName:name location:location filename:filename unlockCondition:unlockCondition] autorelease];
30}
17 31
18- (id)initWithName:(NSString*)m_name location:(NSString*)m_location filename:(NSString*)filename unlocked:(BOOL)m_unlocked; 32- (id)initWithName:(NSString*)m_name location:(NSString*)m_location filename:(NSString*)filename unlocked:(BOOL)m_unlocked;
19{ 33{
20 self = [super init]; 34 self = [super initWithTarget:nil selector:nil];
21 35
22 if (nil != self) 36 if (nil != self)
23 { 37 {
@@ -27,6 +41,8 @@
27 location = m_location; 41 location = m_location;
28 unlocked = m_unlocked; 42 unlocked = m_unlocked;
29 43
44 contentSize_ = CGSizeMake(128, 320);
45
30 NSString* filenameMod; 46 NSString* filenameMod;
31 47
32 if (unlocked) 48 if (unlocked)
@@ -124,7 +140,7 @@
124 CCSprite* selectedButton = [CCSprite spriteWithCGImage:selectedButtonRef key:[NSString stringWithFormat:@"gms-%@-selected", filenameMod]]; 140 CCSprite* selectedButton = [CCSprite spriteWithCGImage:selectedButtonRef key:[NSString stringWithFormat:@"gms-%@-selected", filenameMod]];
125 141
126 CCMenuItemSprite* pictureMenuItem = [CCMenuItemSprite itemFromNormalSprite:picture selectedSprite:selectedButton target:self selector:@selector(buttonTapped)]; 142 CCMenuItemSprite* pictureMenuItem = [CCMenuItemSprite itemFromNormalSprite:picture selectedSprite:selectedButton target:self selector:@selector(buttonTapped)];
127 CCMenu* theMenu = [CCMenu menuWithItems:pictureMenuItem, nil]; 143 NMPanelMenu* theMenu = [NMPanelMenu menuWithItems:pictureMenuItem, nil];
128 theMenu.position = ccp(-5, 0); 144 theMenu.position = ccp(-5, 0);
129 [self addChild:theMenu]; 145 [self addChild:theMenu];
130 146
@@ -196,12 +212,11 @@
196{ 212{
197 if (unlocked) 213 if (unlocked)
198 { 214 {
199 if ([name isEqual:@"Tutorial"]) 215 if (delegate != nil)
200 {
201 [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]];
202 } else if ([name isEqual:@"Collect"])
203 { 216 {
204 [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; 217 [delegate didSelectGameMode:self];
218 } else {
219 NSLog(@"I don't have a GameModeSelectionDelegate to call for some reason...");
205 } 220 }
206 } else { 221 } else {
207 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"To unlock this game mode:" message:unlockCondition delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; 222 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"To unlock this game mode:" message:unlockCondition delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil];