Commits

ant512  committed 9508294

Added menu controls popup to appease Apple reviewers who never owned a Game Boy.

  • Participants
  • Parent commits 6c9b455
  • Tags v1.4

Comments (0)

Files changed (7)

File SuperFoulEgg.xcodeproj/project.pbxproj

 		C248FD63159816D0002D474D /* rotate.wav in Resources */ = {isa = PBXBuildFile; fileRef = C248FD33159816D0002D474D /* rotate.wav */; };
 		C248FD64159816D0002D474D /* title.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C248FD34159816D0002D474D /* title.mp3 */; };
 		C248FD65159816D0002D474D /* win.wav in Resources */ = {isa = PBXBuildFile; fileRef = C248FD35159816D0002D474D /* win.wav */; };
+		C2579F7816095DC8002BEA03 /* MenuControlsLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = C2579F7716095DC8002BEA03 /* MenuControlsLayer.m */; };
 		C29A916E15A92E5B009BE33C /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = C29A916D15A92E5B009BE33C /* Credits.html */; };
 		C2F8683415F01F2A00DD6B99 /* BlockBase.m in Sources */ = {isa = PBXBuildFile; fileRef = C2F8680A15F01F2A00DD6B99 /* BlockBase.m */; };
 		C2F8683515F01F2A00DD6B99 /* BlockFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = C2F8680C15F01F2A00DD6B99 /* BlockFactory.m */; };
 		C248FD33159816D0002D474D /* rotate.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = rotate.wav; sourceTree = "<group>"; };
 		C248FD34159816D0002D474D /* title.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = title.mp3; sourceTree = "<group>"; };
 		C248FD35159816D0002D474D /* win.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = win.wav; sourceTree = "<group>"; };
+		C2579F7616095DC8002BEA03 /* MenuControlsLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuControlsLayer.h; sourceTree = "<group>"; };
+		C2579F7716095DC8002BEA03 /* MenuControlsLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuControlsLayer.m; sourceTree = "<group>"; };
 		C29A916D15A92E5B009BE33C /* Credits.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = Credits.html; path = Resources/Credits.html; sourceTree = "<group>"; };
 		C2B78C1915CD725A0087CCD6 /* SuperFoulEgg.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = SuperFoulEgg.entitlements; sourceTree = "<group>"; };
 		C2F8680915F01F2A00DD6B99 /* BlockBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockBase.h; sourceTree = "<group>"; };
 				C2F8685C15F01F3800DD6B99 /* TitleScreenLayer.m */,
 				C2F8685D15F01F3800DD6B99 /* ZombieLayer.h */,
 				C2F8685E15F01F3800DD6B99 /* ZombieLayer.m */,
+				C2579F7616095DC8002BEA03 /* MenuControlsLayer.h */,
+				C2579F7716095DC8002BEA03 /* MenuControlsLayer.m */,
 			);
 			path = UI;
 			sourceTree = "<group>";
 				C2F8686715F01F3800DD6B99 /* SZPreferencesPanel.m in Sources */,
 				C2F8686815F01F3800DD6B99 /* TitleScreenLayer.m in Sources */,
 				C2F8686915F01F3800DD6B99 /* ZombieLayer.m in Sources */,
+				C2579F7816095DC8002BEA03 /* MenuControlsLayer.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

File SuperFoulEgg/UI/GameOptionsMenuLayer.h

 
 #import "cocos2d.h"
 #import "MenuRectLayer.h"
+#import "MenuControlsLayer.h"
 
 @interface GameOptionsMenuLayer : CCLayer {
 	MenuRectLayer *_rectLayer;
+	MenuControlsLayer *_controlsLayer;
 	NSMutableArray *_options;
 }
 

File SuperFoulEgg/UI/GameOptionsMenuLayer.m

 		[_rectLayer.selectedRectangleIndexes setObject:[NSNumber numberWithInt:[Settings sharedSettings].height] atIndexedSubscript:1];
 		[_rectLayer.selectedRectangleIndexes setObject:[NSNumber numberWithInt:[Settings sharedSettings].blockColours - 4] atIndexedSubscript:2];
 		[_rectLayer.selectedRectangleIndexes setObject:[NSNumber numberWithInt:([Settings sharedSettings].gamesPerMatch - 3) / 2] atIndexedSubscript:3];
+		
+		_controlsLayer = [[MenuControlsLayer alloc] init];
+		[self addChild:_controlsLayer];
+		[_controlsLayer setVisible:NO];
 	}
 	
 	return self;
 - (void)dealloc {
 	[_options release];
 	[_rectLayer release];
+	[_controlsLayer release];
 	
 	_options = nil;
 	_rectLayer = nil;
+	_controlsLayer = nil;
 	
 	[super dealloc];
 }
 	NSString * character = [event characters];
 	unichar keyCode = [character characterAtIndex:0];
 	
+	[_controlsLayer setVisible:NO];
+	
 	if (keyCode == [Settings sharedSettings].keyCodeTwoDown ||
 		keyCode == [Settings sharedSettings].keyCodeOneDown) {
+		
 		if ([_rectLayer selectBelowRectangle]) {
 			[[SimpleAudioEngine sharedEngine] playEffect:@"move.wav"];
 		}
-	}
-	
-	if (keyCode == [Settings sharedSettings].keyCodeTwoRight ||
+		
+	} else if (keyCode == [Settings sharedSettings].keyCodeTwoRight ||
 		keyCode == [Settings sharedSettings].keyCodeOneRight) {
+		
 		[_rectLayer selectNextRectangle];
 		[[SimpleAudioEngine sharedEngine] playEffect:@"move.wav"];
-	}
-	
-	if (keyCode == [Settings sharedSettings].keyCodeTwoLeft ||
+		
+	} else if (keyCode == [Settings sharedSettings].keyCodeTwoLeft ||
 		keyCode == [Settings sharedSettings].keyCodeOneLeft) {
+		
 		[_rectLayer selectPreviousRectangle];
 		[[SimpleAudioEngine sharedEngine] playEffect:@"move.wav"];
-	}
-	
-	if (keyCode == [Settings sharedSettings].keyCodeTwoUp ||
+		
+	} else if (keyCode == [Settings sharedSettings].keyCodeTwoUp ||
 		keyCode == [Settings sharedSettings].keyCodeOneUp) {
+		
 		if ([_rectLayer selectAboveRectangle]) {
 			[[SimpleAudioEngine sharedEngine] playEffect:@"move.wav"];
 		}
-	}
-	
-	if (keyCode == [Settings sharedSettings].keyCodeTwoA ||
+		
+	} else if (keyCode == [Settings sharedSettings].keyCodeTwoA ||
 		keyCode == [Settings sharedSettings].keyCodeOneA) {
 		
 		[[SimpleAudioEngine sharedEngine] playEffect:@"rotate.wav"];
 		} else {
 			[_rectLayer selectNextGroup];
 		}
-	}
-	
-	if (keyCode == [Settings sharedSettings].keyCodeTwoB ||
+		
+	} else if (keyCode == [Settings sharedSettings].keyCodeTwoB ||
 		keyCode == [Settings sharedSettings].keyCodeOneB) {
 		
 		[[SimpleAudioEngine sharedEngine] playEffect:@"drop.wav"];
 		} else {
 			[_rectLayer selectPreviousGroup];
 		}
+		
+	} else {
+		[_controlsLayer setVisible:YES];
 	}
 	
 	[[Settings sharedSettings] save];

File SuperFoulEgg/UI/GameTypeMenuLayer.h

 
 #import "cocos2d.h"
 #import "MenuRectLayer.h"
+#import "MenuControlsLayer.h"
 
 @interface GameTypeMenuLayer : CCLayer {
 	MenuRectLayer *_rectLayer;
+	MenuControlsLayer *_controlsLayer;
 	NSMutableArray *_options;
 	NSString *_title;
 }

File SuperFoulEgg/UI/GameTypeMenuLayer.m

 		[self addOption:@"Insane"];
 		[self addOption:@"2 Player"];
 		
+		_controlsLayer = [[MenuControlsLayer alloc] init];
+		[self addChild:_controlsLayer];
+		[_controlsLayer setVisible:NO];
+		
 		switch ([Settings sharedSettings].gameType) {
 			case GamePracticeType:
 				[_rectLayer.selectedRectangleIndexes setObject:@0 atIndexedSubscript:0];
 	[_options release];
 	[_title release];
 	[_rectLayer release];
+	[_controlsLayer release];
 	
 	_options = nil;
 	_title = nil;
 	_rectLayer = nil;
+	_controlsLayer = nil;
 	
 	[super dealloc];
 }
 	
 	NSString * character = [event characters];
 	unichar keyCode = [character characterAtIndex:0];
+					   
+	[_controlsLayer setVisible:NO];
 	
 	if (keyCode == [Settings sharedSettings].keyCodeTwoDown ||
 		keyCode == [Settings sharedSettings].keyCodeOneDown) {
+		
 		if ([_rectLayer selectBelowRectangle]) {
 			[[SimpleAudioEngine sharedEngine] playEffect:@"move.wav"];
 		}
-	}
-	
-	if (keyCode == [Settings sharedSettings].keyCodeTwoRight ||
+		
+	} else if (keyCode == [Settings sharedSettings].keyCodeTwoRight ||
 		keyCode == [Settings sharedSettings].keyCodeOneRight) {
+		
 		[_rectLayer selectNextRectangle];
 		[[SimpleAudioEngine sharedEngine] playEffect:@"move.wav"];
-	}
-	
-	if (keyCode == [Settings sharedSettings].keyCodeTwoLeft ||
+		
+	} else if (keyCode == [Settings sharedSettings].keyCodeTwoLeft ||
 		keyCode == [Settings sharedSettings].keyCodeOneLeft) {
+		
 		[_rectLayer selectPreviousRectangle];
 		[[SimpleAudioEngine sharedEngine] playEffect:@"move.wav"];
-	}
-	
-	if (keyCode == [Settings sharedSettings].keyCodeTwoUp ||
+		
+	} else if (keyCode == [Settings sharedSettings].keyCodeTwoUp ||
 		keyCode == [Settings sharedSettings].keyCodeOneUp) {
+		
 		if ([_rectLayer selectAboveRectangle]) {
 			[[SimpleAudioEngine sharedEngine] playEffect:@"move.wav"];
 		}
-	}
-	
-	if (keyCode == [Settings sharedSettings].keyCodeTwoA ||
+		
+	} else if (keyCode == [Settings sharedSettings].keyCodeTwoA ||
 		keyCode == [Settings sharedSettings].keyCodeOneA) {
 		
 		[[SimpleAudioEngine sharedEngine] playEffect:@"rotate.wav"];
 		}
 		
 		[[CCDirector sharedDirector] replaceScene:[GameOptionsMenuLayer scene]];
+	} else {	
+		[_controlsLayer setVisible:YES];
 	}
 	
 	[[Settings sharedSettings] save];

File SuperFoulEgg/UI/MenuControlsLayer.h

+#import "cocos2d.h"
+#import "CCLayer.h"
+
+@interface MenuControlsLayer : CCLayer
+
+@end

File SuperFoulEgg/UI/MenuControlsLayer.m

+#import "MenuControlsLayer.h"
+#import "Constants.h"
+#import "Settings.h"
+
+@implementation MenuControlsLayer
+
+- (id)init {
+	if ((self = [super init])) {
+		int y = 600;
+		int sub = 60;
+		
+		NSArray *strings = @[
+		@"Menu Controls",
+		[NSString stringWithFormat:@"Left: %@", [self stringFromKey:[Settings sharedSettings].keyCodeTwoLeft]],
+		[NSString stringWithFormat:@"Right: %@", [self stringFromKey:[Settings sharedSettings].keyCodeTwoRight]],
+		[NSString stringWithFormat:@"Up: %@", [self stringFromKey:[Settings sharedSettings].keyCodeTwoUp]],
+		[NSString stringWithFormat:@"Down: %@", [self stringFromKey:[Settings sharedSettings].keyCodeTwoDown]],
+		[NSString stringWithFormat:@"Next: %@", [self stringFromKey:[Settings sharedSettings].keyCodeTwoA]],
+		[NSString stringWithFormat:@"Back: %@", [self stringFromKey:[Settings sharedSettings].keyCodeTwoB]],
+		@"Change controls in Preferences menu"
+		];
+		
+		for (NSString *string in strings) {
+			[self addCentredShadowedLabelWithString:string atY:y];
+			y -= sub;
+		}
+	}
+	
+	return self;
+}
+
+- (NSString *)stringFromKey:(unichar)key {
+	switch (key) {
+		case DEFAULT_KEY_CODE_TWO_LEFT:
+			return @"Cursor Left";
+		case DEFAULT_KEY_CODE_TWO_RIGHT:
+			return @"Cursor Right";
+		case DEFAULT_KEY_CODE_TWO_UP:
+			return @"Cursor Up";
+		case DEFAULT_KEY_CODE_TWO_DOWN:
+			return @"Cursor Down";
+		default:
+			return [NSString stringWithCharacters:(unichar [1]){ key } length:1];
+	}
+	
+	return nil;
+}
+
+- (void)addCentredShadowedLabelWithString:(NSString *)text atY:(CGFloat)y {
+	CCLabelBMFont *shadow = [CCLabelBMFont labelWithString:text fntFile:@"font.fnt"];
+	CCLabelBMFont *label = [CCLabelBMFont labelWithString:text fntFile:@"font.fnt"];
+	
+	[shadow.texture setAliasTexParameters];
+	[label.texture setAliasTexParameters];
+	
+	shadow.position = CGPointMake((self.boundingBox.size.width / 2) - SZShadowOffset, y - SZShadowOffset);
+	
+	ccColor3B color;
+	color.b = 0;
+	color.g = 0;
+	color.r = 0;
+	
+	shadow.color = color;
+	shadow.opacity = 192;
+	
+	label.position = CGPointMake(self.boundingBox.size.width / 2, y);
+	
+	[self addChild:shadow];
+	[self addChild:label];
+}
+
+- (void)draw {
+    glEnable(GL_LINE_SMOOTH);
+    glColor4ub(255, 255, 255, 255);
+    glLineWidth(1);
+	
+	CGRect rect = CGRectMake(100, 630, 760, -480);
+	
+	ccColor4F colour = ccc4f(0, 0, 0, 0.9);
+	
+	ccDrawRect(rect.origin, ccp(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height));
+			
+	ccDrawSolidRect(rect.origin, ccp(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height), colour);
+}
+
+@end