Conflicts:
	JGE/include/JTypes.h
This commit is contained in:
xawotihs
2013-10-29 23:36:07 +01:00
180 changed files with 725 additions and 23783 deletions
+1 -6
View File
@@ -1,6 +1,5 @@
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "AdWhirlDelegateProtocol.h"
#import "EAGLViewController.h"
#import "EAGLView.h"
#import "ESRenderer.h"
@@ -8,9 +7,8 @@
// This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
// The view content is basically an EAGL surface you render your OpenGL scene into.
// Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
@interface EAGLView : UIView<AdWhirlDelegate,UIGestureRecognizerDelegate>
@interface EAGLView : UIView<UIGestureRecognizerDelegate>
{
AdWhirlView *adView;
//This is a trick, AdMob uses a viewController to display its Ads, trust me, you'll need this
EAGLViewController *viewController;
@@ -27,7 +25,6 @@
id displayLink;
CGPoint currentLocation;
}
@property (nonatomic, retain) AdWhirlView *adView;
@property (readonly, nonatomic, getter=isAnimating) BOOL animating;
@property (nonatomic) NSInteger animationFrameInterval;
@property (nonatomic, readwrite) CGPoint currentLocation;
@@ -37,8 +34,6 @@
- (void)drawView:(id)sender;
- (void)updateKeyboard: (NSString *) inputString;
- (void)removeAds;
- (void)displayAds;
- (void)destroyGame;
-127
View File
@@ -12,7 +12,6 @@
#include "GameApp.h"
#import "AdWhirlView.h"
#import "wagicAppDelegate.h"
@@ -67,15 +66,10 @@ void DestroyGame(void)
}
#pragma mark Ad management constants
static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPHONE = @"b86aba511597401ca6b41c1626aa3013";
static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170c8d268f";
#pragma mark -
@implementation EAGLView
@synthesize adView;
@synthesize animating;
@dynamic animationFrameInterval;
@synthesize currentLocation;
@@ -91,7 +85,6 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
- (void)dealloc
{
[renderer release];
[self removeAds];
[super dealloc];
}
@@ -635,30 +628,6 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
}
//These are the methods for the AdWhirl Delegate, you have to implement them
#pragma mark AdWhirlDelegate methods
- (void)adWhirlWillPresentFullScreenModal {
//It's recommended to invoke whatever you're using as a "Pause Menu" so your
//game won't keep running while the user is "playing" with the Ad (for example, iAds)
[self pauseGame];
}
- (void)adWhirlDidDismissFullScreenModal {
//Once the user closes the Ad he'll want to return to the game and continue where
//he left it
[self resumeGame];
}
- (NSString *)adWhirlApplicationKey {
if ((UI_USER_INTERFACE_IDIOM()) == UIUserInterfaceIdiomPad)
return _MY_AD_WHIRL_APPLICATION_KEY_IPAD;
return _MY_AD_WHIRL_APPLICATION_KEY_IPHONE;
}
- (UIViewController *)viewControllerForPresentingModalView {
//Remember that UIViewController we created in the Game.h file? AdMob will use it.
//If you want to use "return self;" instead, AdMob will cancel the Ad requests.
@@ -666,101 +635,5 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
}
- (void)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlView {
[UIView beginAnimations:@"AdWhirlDelegate.adWhirlDidReceiveAd:"
context:nil];
BOOL isLandscape = UIDeviceOrientationIsLandscape( [UIDevice currentDevice].orientation);
[UIView setAnimationDuration:0.7];
CGSize adSize = [adWhirlView actualAdSize];
CGRect newFrame = [adWhirlView frame];
CGSize screenSize = [self.window bounds].size;
newFrame.size = adSize;
// ads are 320 x 50
newFrame.origin.x = ( (isLandscape ? screenSize.height : screenSize.width) - adSize.width)/ 2;
newFrame.origin.y = ( (isLandscape ? screenSize.width : screenSize.height) - 50);
[adWhirlView setFrame: newFrame];
[UIView commitAnimations];
}
-(void)adWhirlDidFailToReceiveAd:(AdWhirlView *)adWhirlView usingBackup:(BOOL)yesOrNo {
//The code to show my own Ad banner again
NSLog(@"failed to get an Ad");
}
-(void) removeAds {
//There's something weird about AdWhirl because setting the adView delegate
//to "nil" doesn't stops the Ad requests and also it doesn't remove the adView
//from superView; do the following to remove AdWhirl from your scene.
//
//If adView exists, remove everything
if (adView) {
//Remove adView from superView
[adView removeFromSuperview];
//Replace adView's view with "nil"
[adView replaceBannerViewWith:nil];
//Tell AdWhirl to stop requesting Ads
[adView ignoreNewAdRequests];
//Set adView delegate to "nil"
[adView setDelegate:nil];
//Release adView
[adView release];
//set adView to "nil"
adView = nil;
}
}
-(void) displayAds
{
BOOL isLandscape = UIDeviceOrientationIsLandscape( [UIDevice currentDevice].orientation);
//Assign the AdWhirl Delegate to our adView
if ( adView != nil )
[self removeAds];
//Let's allocate the viewController (it's the same RootViewController as declared
//in our AppDelegate; will be used for the Ads)
viewController = [(wagicAppDelegate *)[[UIApplication sharedApplication] delegate] glViewController];
self.adView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
//Set auto-resizing mask
self.adView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
//This isn't really needed but also it makes no harm. It just retrieves the configuration
//from adwhirl.com so it knows what Ad networks to use
[adView updateAdWhirlConfig];
//Get the actual size for the requested Ad
CGSize adSize = [adView actualAdSize];
//
//Set the position; remember that we are using 4 values (in this order): X, Y, Width, Height
//You can comment this line if your game is in portrait mode and you want your Ad on the top
//if you want the Ad in other position (portrait or landscape), use the following code,
//for this example, the Ad will be positioned in the bottom+center of the screen
//(in landscape mode):
//Same explanation as the one in the method "adjustAdSize" for the Ad's width
int screenWidth = [viewController.parentViewController.view bounds].size.width;
float yOffset = [viewController.parentViewController.view bounds].size.height - adSize.height;
if ( isLandscape )
{
screenWidth = [viewController.parentViewController.view bounds].size.height;
yOffset = screenWidth - adSize.height;
}
self.adView.frame = CGRectMake((screenWidth - adSize.width) / 2, yOffset, adSize.width, adSize.height);
//Trying to keep everything inside the Ad bounds
self.adView.clipsToBounds = YES;
//Adding the adView (used for our Ads) to our viewController
[viewController.view addSubview:adView];
//Bring our view to front
[viewController.view bringSubviewToFront:adView];
}
@end
-1
View File
@@ -1,5 +1,4 @@
#import <UIKit/UIKit.h>
#import "AdWhirlDelegateProtocol.h"
@interface EAGLViewController : UIViewController<UITextFieldDelegate> {
+41 -19
View File
@@ -25,10 +25,13 @@
[inputField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[inputField setAutocorrectionType:UITextAutocorrectionTypeNo];
[inputField setKeyboardType: UIKeyboardTypeNamePhonePad];
CGRect frame = [[UIScreen mainScreen] applicationFrame];
eaglView = [[EAGLView alloc] initWithFrame:frame];
[self setView: eaglView];
[self.view addSubview: inputField];
[inputField release];
}
return self;
@@ -50,7 +53,7 @@
- (void)viewWillAppear:(BOOL)animated {
NSLog(@"EAGL ViewController - view Will Appear");
[self.view resumeGame];
[self.view resumeGame];
}
@@ -75,14 +78,14 @@
}
- (void)viewDidAppear:(BOOL)animated {
NSLog(@"EAGL ViewController - view Did Appear");
UIDeviceOrientation currentDeviceOrientation = [UIDevice currentDevice].orientation;
UIInterfaceOrientation currentInterfaceOrientation = self.interfaceOrientation;
NSLog(@"Current Interface: %@. Current Device: %@",
[self interfaceOrientationName:currentInterfaceOrientation],
NSLog(@"Current Interface: %@. Current Device: %@",
[self interfaceOrientationName:currentInterfaceOrientation],
[self deviceOrientationName:currentDeviceOrientation]);
}
@@ -91,7 +94,7 @@
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
@@ -103,6 +106,25 @@
}
#pragma mark - device orientation handlers
- (NSUInteger)supportedInterfaceOrientations
{
//I want to support portrait in ABCView at iPhone only.
//and support all orientation in other views and iPad.
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
{
return UIInterfaceOrientationMaskLandscape;
}
//support all
return UIInterfaceOrientationMaskAll;
}
-(BOOL)shouldAutorotate {
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
@@ -110,23 +132,23 @@
if ( isSmallScreen && UIInterfaceOrientationIsPortrait(interfaceOrientation))
return NO;
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[[eaglView adView] rotateToOrientation: toInterfaceOrientation];
// [[eaglView adView] rotateToOrientation: toInterfaceOrientation];
}
#pragma mark -
#pragma mark Orientation Information
- (NSString*)interfaceOrientationName:(UIInterfaceOrientation) interfaceOrientation {
NSString* result = nil;
switch (interfaceOrientation) {
case UIInterfaceOrientationPortrait:
result = @"Portrait";
break;
@@ -142,16 +164,16 @@
default:
result = @"Unknown Interface Orientation";
}
return result;
};
- (NSString*)deviceOrientationName:(UIDeviceOrientation) deviceOrientation {
NSString* result = nil;
switch (deviceOrientation) {
case UIDeviceOrientationUnknown:
result = @"Unknown";
break;
@@ -176,7 +198,7 @@
default:
result = @"Unknown Device Orientation";
}
return result;
};
@@ -205,7 +227,7 @@
[eaglView updateKeyboard: @"CLEAR"];
else
[eaglView updateKeyboard: string];
return YES;
}
@@ -215,7 +237,7 @@
}
- (BOOL) textFieldShouldReturn:(UITextField *)textField
- (BOOL) textFieldShouldReturn:(UITextField *)textField
{
[eaglView updateKeyboard: @"SAVE"];
[textField resignFirstResponder];
+37 -28
View File
@@ -33,7 +33,7 @@ bool checkFramebufferStatus();
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if ( context == nil)
context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
if (!context || ![EAGLContext setCurrentContext:context])
{
[self release];
@@ -46,20 +46,29 @@ bool checkFramebufferStatus();
- (void)render
{
// NSLog(@"Renderer - render");
struct timeval tv;
uint dt;
// This application only creates a single context which is already set current at this point.
// This call is redundant, but needed if dealing with multiple contexts.
[EAGLContext setCurrentContext:context];
// This application only creates a single default framebuffer which is already bound at this point.
// This call is redundant, but needed if dealing with multiple framebuffers.
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
GLfloat currentRatio = (GLfloat) backingWidth / (GLfloat) backingHeight;
if ((GLfloat)backingWidth / (GLfloat)backingHeight < ACTUAL_RATIO)
// for retina devices. because of the 568 px, the ratio between height-width skews the
// frame a bit
if ( backingHeight == 568 || backingWidth == 568) {
viewPort.left = 0;
viewPort.top = -((backingWidth/ACTUAL_RATIO)-backingHeight)/2 + 22; // account for status bar
viewPort.right = backingWidth;
viewPort.bottom = -((backingWidth/ACTUAL_RATIO)-backingHeight)/2 + backingWidth / ACTUAL_RATIO - 22;
}
else if (currentRatio < ACTUAL_RATIO)
{
viewPort.left = 0;
viewPort.top = -((backingWidth/ACTUAL_RATIO)-backingHeight)/2;
@@ -73,21 +82,21 @@ bool checkFramebufferStatus();
viewPort.right = backingHeight * ACTUAL_RATIO;
viewPort.bottom = -((backingWidth/ACTUAL_RATIO)-backingHeight)/2 + backingWidth / ACTUAL_RATIO + backingHeight;
}
glViewport(viewPort.left, viewPort.top, viewPort.right-viewPort.left, viewPort.bottom-viewPort.top);
JRenderer::GetInstance()->SetActualWidth(viewPort.right-viewPort.left);
JRenderer::GetInstance()->SetActualHeight(viewPort.bottom-viewPort.top);
gettimeofday(&tv, NULL);
uint64_t tickCount = tv.tv_sec * 1000 + tv.tv_usec / 1000;
dt = (tickCount - lastTickCount);
lastTickCount = tickCount;
g_engine->SetDelta((float)dt / 1000.0f);
g_engine->Update((float)dt / 1000.0f);
g_engine->Render();
// This application only creates a single color renderbuffer which is already bound at this point.
@@ -103,18 +112,18 @@ bool checkFramebufferStatus();
glDeleteFramebuffers(1, &defaultFramebuffer);
defaultFramebuffer = 0;
}
if(colorRenderbuffer) {
glDeleteRenderbuffers(1, &colorRenderbuffer);
colorRenderbuffer = 0;
}
glGenFramebuffers(1, &defaultFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
glGenRenderbuffers(1, &colorRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
// Allocate color buffer backing based on the current layer size
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:layer];
@@ -127,41 +136,41 @@ bool checkFramebufferStatus();
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE); // do not calculate inside of poly's
glFrontFace(GL_CCW);
glFrontFace(GL_CCW);
glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glEnable(GL_SCISSOR_TEST); // Enable Clipping
// glEnable(GL_SCISSOR_TEST); // Enable Clipping
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background (yes that's the way fuckers)
glClearDepthf(1.0f); // Depth Buffer Setup
return YES;
}
bool checkFramebufferStatus() {
GLenum status = (GLenum)glCheckFramebufferStatus(GL_FRAMEBUFFER);
switch(status) {
case GL_FRAMEBUFFER_COMPLETE:
return true;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
printf("Framebuffer incomplete,incomplete attachment\n");
return false;
case GL_FRAMEBUFFER_UNSUPPORTED:
printf("Unsupported framebuffer format\n");
return false;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
printf("Framebuffer incomplete,missing attachment\n");
return false;
}
return false;
}
@@ -187,7 +196,7 @@ bool checkFramebufferStatus() {
[context release];
context = nil;
[super dealloc];
}
+59 -71
View File
@@ -17,7 +17,7 @@
- (void) updateComplete: (id) notificationMsg
{
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
[dnc removeObserver: self name: @"coreComplete" object: nil];
[dnc removeObserver: self name: @"iosConfigComplete" object: nil];
[dnc postNotificationName: @"initializeGame" object: self];
@@ -34,12 +34,12 @@
- (void) downloadResources
{
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
[dnc addObserver:self selector:@selector(initIosUpdate:) name:@"coreComplete" object: nil];
wagicDownloadController = [[WagicDownloadProgressViewController alloc] init];
[wagicDownloadController performSelectorInBackground: @selector(startDownload:) withObject:@"core"];
[self.window addSubview: wagicDownloadController.view];
[self.window makeKeyWindow];
@@ -51,16 +51,16 @@
NSString *pathPrefix = nil;
if ( pathNamePrefix == nil ) // default to User
pathPrefix = @"User";
else
else
pathPrefix = pathNamePrefix;
NSError *error = nil;
NSFileManager *fm = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
NSString *userDocumentsDirectory = [paths objectAtIndex:0];
NSString *downloadFilePath = [userDocumentsDirectory stringByAppendingString: [NSString stringWithFormat: @"/%@/%@.zip", pathPrefix, folderName]];
ZipArchive *za = [[ZipArchive alloc] init];
if ([za UnzipOpenFile: downloadFilePath])
{
@@ -73,7 +73,7 @@
NSLog(@"An Error occurred while unpacking zip file.");
}
[za UnzipCloseFile];
if (ret == YES)
{
// delete the archive
@@ -85,7 +85,7 @@
}
}
[za release], za = nil;
}
@@ -98,15 +98,15 @@
{
NSString *pathname = [NSString stringWithFormat: @"%@/%@", path, filename];
[data appendFormat: @"%@\n", pathname];
BOOL isDirectory = [[fileManager attributesOfItemAtPath: pathname error: nil] objectForKey: NSFileType] == NSFileTypeDirectory;
if (isDirectory)
[data appendString: [self getDirContents: pathname]];
}
NSString *manifestList = [data stringByAppendingFormat: @"\n"];
[data release];
return manifestList;
}
@@ -114,37 +114,37 @@
{
NSString *manifestFile = [docsPath stringByAppendingPathComponent:@"Manifest"];
[[self getDirContents: docsPath] writeToFile:manifestFile atomically:YES encoding:NSUTF8StringEncoding error: nil];
}
/**
check for any zip files dropped into the documents directory before loading the game.
If so, move the "core" files into the "Res" directory and move all other zip files into the "User" directory.
check for any zip files dropped into the documents directory before loading the game.
If so, move the "core" files into the "Res" directory and move all other zip files into the "User" directory.
Check for a "core" zip file in the Res directory. If it exists, then return YES. Otherwise, return NO.
*/
- (void) initializeResources
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex: 0];
NSArray *docsPathContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: docsPath error:nil];
NSString *versionPredicate = [NSString stringWithFormat: @"(self BEGINSWITH '%@')", [NSString stringWithCString: WAGIC_CORE_VERSION_STRING encoding:NSUTF8StringEncoding]];
NSCompoundPredicate *compoundPredicate = [[NSCompoundPredicate alloc] initWithType:NSAndPredicateType subpredicates: [NSArray arrayWithObjects: [NSPredicate predicateWithFormat:@"self ENDSWITH '.zip'"], [NSPredicate predicateWithFormat: [NSString stringWithFormat: @" NOT ( %@ ) ", versionPredicate]], nil]];
NSArray *coreFiles = [docsPathContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat: versionPredicate]];
NSArray *resourceZipFiles = [docsPathContents filteredArrayUsingPredicate: compoundPredicate];
NSString *userPath = [NSString stringWithFormat: @"%@/User", docsPath];
NSString *resPath = [NSString stringWithFormat: @"%@/Res", docsPath];
NSError *error = nil;
[compoundPredicate release], compoundPredicate = nil;
if ( ([resourceZipFiles count] > 0 ) && ![fileManager fileExistsAtPath: userPath] )
[fileManager createDirectoryAtPath: userPath withIntermediateDirectories: YES attributes:nil error:nil ];
for (NSString *zipFile in resourceZipFiles)
{
NSString *oldPath = [NSString stringWithFormat: @"%@/%@", docsPath, zipFile];
@@ -155,7 +155,7 @@
[fileManager removeItemAtPath: newPath error: &error];
}
error = nil;
[fileManager moveItemAtPath: oldPath toPath:newPath error: &error];
NSLog(@"Moving %@ to %@", oldPath, newPath);
if ( error != nil )
@@ -175,7 +175,7 @@
[fileManager removeItemAtPath: newPath error: &error];
}
error = nil;
[fileManager moveItemAtPath: oldPath toPath:newPath error: &error];
NSLog(@"Moving %@ to %@", oldPath, newPath);
if ( error != nil )
@@ -187,21 +187,21 @@
}
- (BOOL) hasResourceFiles
{
{
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex: 0];
NSString *resPath = [NSString stringWithFormat: @"%@/Res", docsPath];
NSArray *resDirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: resPath error:nil];
NSString *versionPredicate = [NSString stringWithFormat: @"(self BEGINSWITH '%@')", [NSString stringWithCString: WAGIC_CORE_VERSION_STRING encoding:NSUTF8StringEncoding]];
NSArray *coreFiles = [resDirContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat: versionPredicate]];
if ([coreFiles count] >= 2)
{
return YES;
}
return NO;
}
@@ -211,30 +211,30 @@
NSString *docsPath = [NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0];
NSFileManager *fm = [NSFileManager defaultManager];
NSString *userPath = [docsPath stringByAppendingString: @"/User"];
NSArray *userDirectories = [fm contentsOfDirectoryAtPath: userPath error: nil];
for (NSString *userFilename in userDirectories)
{
NSString *userPathname = [userPath stringByAppendingFormat: @"/%@", userFilename];
NSString *zipFileName = [userPathname stringByAppendingString: @".zip"];
if ([[fm attributesOfItemAtPath: userPathname error: nil] objectForKey: NSFileType] == NSFileTypeDirectory && ([fm fileExistsAtPath:zipFileName]))
{
[self unpackageResources: userFilename pathPrefixName: @"User"];
[fm removeItemAtPath: zipFileName error: nil];
}
else if ( [userFilename hasPrefix: @"ai_decks"] ) // special case to allow manual override of AI decks in User directory
{
[self unpackageResources: @"ai_decks" pathPrefixName: @"User/ai/baka"];
}
}
// scan for deck*.txt and collection.dat as well as options.txt in the Documents directory and copy them into the player directory
NSArray *playerDataFilePredicates = [NSArray arrayWithObjects:
[NSPredicate predicateWithFormat: @"SELF BEGINSWITH[cd] 'deck' AND SELF ENDSWITH '.txt'"],
[NSPredicate predicateWithFormat: @"SELF BEGINSWITH[cd] 'options' AND SELF ENDSWITH '.txt'"],
[NSPredicate predicateWithFormat: @"SELF BEGINSWITH[cd] 'tasks' AND SELF ENDSWITH '.dat'"],
NSArray *playerDataFilePredicates = [NSArray arrayWithObjects:
[NSPredicate predicateWithFormat: @"SELF BEGINSWITH[cd] 'deck' AND SELF ENDSWITH '.txt'"],
[NSPredicate predicateWithFormat: @"SELF BEGINSWITH[cd] 'options' AND SELF ENDSWITH '.txt'"],
[NSPredicate predicateWithFormat: @"SELF BEGINSWITH[cd] 'tasks' AND SELF ENDSWITH '.dat'"],
[NSPredicate predicateWithFormat: @"SELF BEGINSWITH[cd] 'collection' AND SELF ENDSWITH '.dat'"], nil];
NSCompoundPredicate *playerDataPredicate = [[NSCompoundPredicate alloc] initWithType:NSOrPredicateType subpredicates: playerDataFilePredicates];
@@ -246,23 +246,23 @@
NSString *toPath = [docsPath stringByAppendingFormat: @"/User/player/%@", [file lowercaseString]];
[fm moveItemAtPath: fromPath toPath: toPath error: nil];
}
[playerDataPredicate release], playerDataPredicate = nil;
[self createManifest: docsPath];
[[NSNotificationCenter defaultCenter] postNotificationName: @"readyToStartGame" object: nil];
}
- (void) startGame
{
if (glViewController != nil)
if (glViewController != nil)
[glViewController release];
glViewController = [[EAGLViewController alloc] init];
[[[self.window subviews] lastObject] removeFromSuperview];
[self.window addSubview:self.glViewController.view];
[self.window setRootViewController: glViewController];
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
[dnc removeObserver: self name: @"intializeGame" object: nil];
@@ -286,7 +286,7 @@
[internetReach release];
[glViewController release];
[wagicDownloadController release];
[super dealloc];
}
@@ -298,23 +298,23 @@
hostReach = [[Reachability reachabilityForGoogleDNS] retain];
internetReach = [[Reachability reachabilityForInternetConnection] retain];
wifiReach = [[Reachability reachabilityForLocalWiFi] retain];
[hostReach startNotifier];
[internetReach startNotifier];
[wifiReach startNotifier];
}
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.glViewController = nil;
[self setupNetworkListeners];
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
[dnc addObserver:self selector:@selector(preGameInitialization) name:@"initializeGame" object: nil];
[dnc addObserver:self selector:@selector(startGame) name:@"readyToStartGame" object: nil];
[self initializeResources];
// check to see if the Res folder exists. If it does continue
// otherwise bring up the download dialog and download the core files
@@ -328,7 +328,7 @@
{
[self preGameInitialization];
}
[self.window setBackgroundColor: [UIColor blackColor]];
[self.window makeKeyAndVisible];
@@ -337,7 +337,7 @@
- (void)applicationWillTerminate:(UIApplication *)application
{
[self.glViewController.view destroyGame];
[self.glViewController.view destroyGame];
}
- (void)initializeKeyboard: (id) initialState
@@ -345,31 +345,18 @@
[self.glViewController toggleKeyboardWithState: initialState];
}
- (void) handleWEngineCommand:(NSString *) command
withUIParameters: (CGFloat) x
yCoordinate: (CGFloat) y
width: (CGFloat) width
- (void) handleWEngineCommand:(NSString *) command
withUIParameters: (CGFloat) x
yCoordinate: (CGFloat) y
width: (CGFloat) width
height: (CGFloat) height
{
}
- (void)handleWEngineCommand:(NSString *) command withParameter: (NSString *) parameter
{
BOOL isDevicePhone = (UI_USER_INTERFACE_IDIOM()) == UIUserInterfaceIdiomPhone;
if ([command isEqualToString: @"entergamestate:menu"] )
[glViewController.eaglView displayAds];
else if ([command isEqualToString: @"enterduelphase:end"] && isDevicePhone)
[glViewController.eaglView displayAds];
else if ([command isEqualToString: @"leaveduelphase:end"] ||
[command isEqualToString: @"leavegamestate:menu"])
{
if (isDevicePhone)
[glViewController.eaglView removeAds];
}
else if ([command isEqualToString: @"displayKeyboard"])
if ([command isEqualToString: @"displayKeyboard"])
{
[self initializeKeyboard: parameter];
}
@@ -379,16 +366,17 @@
}
- (void) rotateBackgroundImage:(UIInterfaceOrientation)fromInterfaceOrientation toInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
bool isPhone = (UI_USER_INTERFACE_IDIOM()) == UIUserInterfaceIdiomPhone;
if (isPhone)
if (isPhone)
{
UIImage *bgImage = [UIImage imageNamed: @"Default-Portrait.png"];
[[[self.window subviews] objectAtIndex: 0] setBackgroundColor: [UIColor colorWithPatternImage: bgImage]];
}
else
else
{
[self.window setBackgroundColor: [UIColor clearColor]];
if (UIInterfaceOrientationIsLandscape( toInterfaceOrientation)) {
@@ -410,12 +398,12 @@
{
BOOL netAvailable = NO;
//NSDate *startTime = [[[NSDate alloc ] init] autorelease];
hostReach = [[Reachability reachabilityForGoogleDNS] retain];
NetworkStatus netStatus = [hostReach currentReachabilityStatus];
if (netStatus == ReachableViaWiFi || netStatus == ReachableViaWWAN) {
netAvailable = YES;
}