updaed for iOS6
This commit is contained in:
+112
-112
@@ -39,10 +39,10 @@
|
||||
#define MAX_CHANNEL 128
|
||||
|
||||
enum {
|
||||
JGE_ERR_CANT_OPEN_FILE = -1,
|
||||
JGE_ERR_PNG = -2,
|
||||
JGE_ERR_MALLOC_FAILED = -4,
|
||||
JGE_ERR_GENERIC = -5,
|
||||
JGE_ERR_CANT_OPEN_FILE = -1,
|
||||
JGE_ERR_PNG = -2,
|
||||
JGE_ERR_MALLOC_FAILED = -4,
|
||||
JGE_ERR_GENERIC = -5,
|
||||
};
|
||||
|
||||
#ifdef PSP
|
||||
@@ -80,20 +80,20 @@ enum {
|
||||
// #define BLEND_OPTION_ADD BLEND_COLORADD
|
||||
// #define BLEND_OPTION_BLEND (BLEND_COLORADD | BLEND_ALPHABLEND | BLEND_NOZWRITE)
|
||||
#else
|
||||
#define DEFAULT_BLEND GU_TFX_MODULATE
|
||||
#define BLEND_OPTION_ADD GU_TFX_ADD
|
||||
#define BLEND_OPTION_BLEND GU_TFX_BLEND
|
||||
#define DEFAULT_BLEND GU_TFX_MODULATE
|
||||
#define BLEND_OPTION_ADD GU_TFX_ADD
|
||||
#define BLEND_OPTION_BLEND GU_TFX_BLEND
|
||||
#endif
|
||||
|
||||
#if (defined WIN32) && (!defined LINUX)
|
||||
#include <windows.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#if defined(LINUX) && (!defined WIN32) || defined(IOS) || defined (ANDROID)
|
||||
typedef uint8_t byte;
|
||||
typedef uint32_t DWORD;
|
||||
typedef uint8_t BYTE;
|
||||
typedef uint8_t byte;
|
||||
typedef uint32_t DWORD;
|
||||
typedef uint8_t BYTE;
|
||||
#ifndef IOS
|
||||
typedef bool BOOL;
|
||||
typedef bool BOOL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -101,16 +101,16 @@ enum {
|
||||
|
||||
#ifndef QT_CONFIG
|
||||
#if defined (IOS)
|
||||
#import <OpenGLES/ES2/gl.h>
|
||||
#import <OpenGLES/ES2/glext.h>
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
# import <OpenGLES/ES1/glext.h>
|
||||
#import <OpenGLES/ES2/gl.h>
|
||||
#import <OpenGLES/ES2/glext.h>
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
#import <OpenGLES/ES1/glext.h>
|
||||
#elif defined (ANDROID)
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#elif defined (WIN32) || defined (LINUX)
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#elif defined (WIN32) || defined (LINUX)
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
#else
|
||||
# include <QtOpenGL>
|
||||
@@ -128,90 +128,90 @@ enum {
|
||||
|
||||
#if defined (PSP)
|
||||
|
||||
#ifndef ABGR8888
|
||||
#define ABGR8888
|
||||
#endif
|
||||
#ifndef ABGR8888
|
||||
#define ABGR8888
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (ABGR8888)
|
||||
#define PIXEL_TYPE u32
|
||||
#ifndef ARGB
|
||||
#define ARGB(a, r, g, b) (PIXEL_TYPE)((a << 24) | (b << 16) | (g << 8) | r) // macro to assemble pixels in correct format
|
||||
#endif
|
||||
#define MAKE_COLOR(a, c) (a << 24 | c)
|
||||
#define MASK_ALPHA 0xFF000000 // masks for accessing individual pixels
|
||||
#define MASK_BLUE 0x00FF0000
|
||||
#define MASK_GREEN 0x0000FF00
|
||||
#define MASK_RED 0x000000FF
|
||||
#if defined (ABGR8888)
|
||||
#define PIXEL_TYPE u32
|
||||
#ifndef ARGB
|
||||
#define ARGB(a, r, g, b) (PIXEL_TYPE)((a << 24) | (b << 16) | (g << 8) | r) // macro to assemble pixels in correct format
|
||||
#endif
|
||||
#define MAKE_COLOR(a, c) (a << 24 | c)
|
||||
#define MASK_ALPHA 0xFF000000 // masks for accessing individual pixels
|
||||
#define MASK_BLUE 0x00FF0000
|
||||
#define MASK_GREEN 0x0000FF00
|
||||
#define MASK_RED 0x000000FF
|
||||
|
||||
#define PIXEL_SIZE 4
|
||||
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_8888
|
||||
#define PIXEL_SIZE 4
|
||||
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_8888
|
||||
|
||||
#define BUFFER_FORMAT GU_PSM_8888
|
||||
#define TEXTURE_FORMAT GU_PSM_8888
|
||||
#define TEXTURE_COLOR_FORMAT GU_COLOR_8888
|
||||
#define BUFFER_FORMAT GU_PSM_8888
|
||||
#define TEXTURE_FORMAT GU_PSM_8888
|
||||
#define TEXTURE_COLOR_FORMAT GU_COLOR_8888
|
||||
|
||||
|
||||
#elif defined (ABGR5551)
|
||||
#elif defined (ABGR5551)
|
||||
|
||||
#ifndef ARGB
|
||||
#define ARGB(a, r, g, b) ((r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10) | ((a >> 7) << 15))
|
||||
#endif
|
||||
#define MAKE_COLOR(a, c) (((a>>7)<<15) | c)
|
||||
#define MASK_ALPHA 0x8000
|
||||
#define MASK_BLUE 0x7C00
|
||||
#define MASK_GREEN 0x03E0
|
||||
#define MASK_RED 0x001F
|
||||
#define PIXEL_TYPE u16
|
||||
#define PIXEL_SIZE 2
|
||||
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_5551
|
||||
#ifndef ARGB
|
||||
#define ARGB(a, r, g, b) ((r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10) | ((a >> 7) << 15))
|
||||
#endif
|
||||
#define MAKE_COLOR(a, c) (((a>>7)<<15) | c)
|
||||
#define MASK_ALPHA 0x8000
|
||||
#define MASK_BLUE 0x7C00
|
||||
#define MASK_GREEN 0x03E0
|
||||
#define MASK_RED 0x001F
|
||||
#define PIXEL_TYPE u16
|
||||
#define PIXEL_SIZE 2
|
||||
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_5551
|
||||
|
||||
#define BUFFER_FORMAT GU_PSM_8888
|
||||
#define TEXTURE_FORMAT GU_PSM_5551
|
||||
#define TEXTURE_COLOR_FORMAT GU_COLOR_5551
|
||||
#define BUFFER_FORMAT GU_PSM_8888
|
||||
#define TEXTURE_FORMAT GU_PSM_5551
|
||||
#define TEXTURE_COLOR_FORMAT GU_COLOR_5551
|
||||
|
||||
#elif defined (ABGR4444)
|
||||
#ifndef ARGB
|
||||
#define ARGB(a, r, g, b) ((r >> 4) | ((g >> 4) << 4) | ((b >> 4) << 8) | ((a >> 4) << 12))
|
||||
#endif
|
||||
#define MAKE_COLOR(a, c) (((a>>4)<<12) | c)
|
||||
#define MASK_ALPHA 0xF000
|
||||
#define MASK_BLUE 0x0F00
|
||||
#define MASK_GREEN 0x00F0
|
||||
#define MASK_RED 0x000F
|
||||
#define PIXEL_TYPE u16
|
||||
#define PIXEL_SIZE 2
|
||||
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_4444
|
||||
#elif defined (ABGR4444)
|
||||
#ifndef ARGB
|
||||
#define ARGB(a, r, g, b) ((r >> 4) | ((g >> 4) << 4) | ((b >> 4) << 8) | ((a >> 4) << 12))
|
||||
#endif
|
||||
#define MAKE_COLOR(a, c) (((a>>4)<<12) | c)
|
||||
#define MASK_ALPHA 0xF000
|
||||
#define MASK_BLUE 0x0F00
|
||||
#define MASK_GREEN 0x00F0
|
||||
#define MASK_RED 0x000F
|
||||
#define PIXEL_TYPE u16
|
||||
#define PIXEL_SIZE 2
|
||||
#define PIXEL_FORMAT PSP_DISPLAY_PIXEL_FORMAT_4444
|
||||
|
||||
#define BUFFER_FORMAT GU_PSM_4444
|
||||
#define TEXTURE_FORMAT GU_PSM_4444
|
||||
#define TEXTURE_COLOR_FORMAT GU_COLOR_4444
|
||||
#define BUFFER_FORMAT GU_PSM_4444
|
||||
#define TEXTURE_FORMAT GU_PSM_4444
|
||||
#define TEXTURE_COLOR_FORMAT GU_COLOR_4444
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define FRAME_BUFFER_WIDTH 512
|
||||
#define FRAME_BUFFER_SIZE FRAME_BUFFER_WIDTH*SCREEN_HEIGHT*PIXEL_SIZE
|
||||
#define FRAME_BUFFER_WIDTH 512
|
||||
#define FRAME_BUFFER_SIZE FRAME_BUFFER_WIDTH*SCREEN_HEIGHT*PIXEL_SIZE
|
||||
|
||||
#define SLICE_SIZE_F 64.0f
|
||||
typedef unsigned int DWORD;
|
||||
#define SLICE_SIZE_F 64.0f
|
||||
typedef unsigned int DWORD;
|
||||
|
||||
#define BLEND_ZERO 0x1000
|
||||
#define BLEND_ONE 0x1002
|
||||
#define BLEND_SRC_COLOR GU_SRC_COLOR
|
||||
#define BLEND_ONE_MINUS_SRC_COLOR GU_ONE_MINUS_SRC_COLOR
|
||||
#define BLEND_SRC_ALPHA GU_SRC_ALPHA
|
||||
#define BLEND_ONE_MINUS_SRC_ALPHA GU_ONE_MINUS_SRC_ALPHA
|
||||
#define BLEND_DST_ALPHA GU_DST_ALPHA
|
||||
#define BLEND_ONE_MINUS_DST_ALPHA GU_ONE_MINUS_DST_ALPHA
|
||||
#define BLEND_DST_COLOR GU_DST_COLOR
|
||||
#define BLEND_ONE_MINUS_DST_COLOR GU_ONE_MINUS_DST_COLOR
|
||||
#define BLEND_SRC_ALPHA_SATURATE BLEND_ONE
|
||||
#define BLEND_ZERO 0x1000
|
||||
#define BLEND_ONE 0x1002
|
||||
#define BLEND_SRC_COLOR GU_SRC_COLOR
|
||||
#define BLEND_ONE_MINUS_SRC_COLOR GU_ONE_MINUS_SRC_COLOR
|
||||
#define BLEND_SRC_ALPHA GU_SRC_ALPHA
|
||||
#define BLEND_ONE_MINUS_SRC_ALPHA GU_ONE_MINUS_SRC_ALPHA
|
||||
#define BLEND_DST_ALPHA GU_DST_ALPHA
|
||||
#define BLEND_ONE_MINUS_DST_ALPHA GU_ONE_MINUS_DST_ALPHA
|
||||
#define BLEND_DST_COLOR GU_DST_COLOR
|
||||
#define BLEND_ONE_MINUS_DST_COLOR GU_ONE_MINUS_DST_COLOR
|
||||
#define BLEND_SRC_ALPHA_SATURATE BLEND_ONE
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ScePspFVector2 texture;
|
||||
ScePspFVector3 pos;
|
||||
} PSPVertex3D;
|
||||
typedef struct
|
||||
{
|
||||
ScePspFVector2 texture;
|
||||
ScePspFVector3 pos;
|
||||
} PSPVertex3D;
|
||||
|
||||
#else //non PSP
|
||||
|
||||
@@ -223,34 +223,34 @@ typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
|
||||
|
||||
#define BLEND_ZERO GL_ZERO
|
||||
#define BLEND_ONE GL_ONE
|
||||
#define BLEND_SRC_COLOR GL_SRC_COLOR
|
||||
#define BLEND_ONE_MINUS_SRC_COLOR GL_ONE_MINUS_SRC_COLOR
|
||||
#define BLEND_SRC_ALPHA GL_SRC_ALPHA
|
||||
#define BLEND_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
#define BLEND_DST_ALPHA GL_DST_ALPHA
|
||||
#define BLEND_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_DST_ALPHA
|
||||
#define BLEND_DST_COLOR GL_DST_COLOR
|
||||
#define BLEND_ONE_MINUS_DST_COLOR GL_ONE_MINUS_DST_COLOR
|
||||
#define BLEND_SRC_ALPHA_SATURATE GL_SRC_ALPHA_SATURATE
|
||||
#define BLEND_ZERO GL_ZERO
|
||||
#define BLEND_ONE GL_ONE
|
||||
#define BLEND_SRC_COLOR GL_SRC_COLOR
|
||||
#define BLEND_ONE_MINUS_SRC_COLOR GL_ONE_MINUS_SRC_COLOR
|
||||
#define BLEND_SRC_ALPHA GL_SRC_ALPHA
|
||||
#define BLEND_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
#define BLEND_DST_ALPHA GL_DST_ALPHA
|
||||
#define BLEND_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_DST_ALPHA
|
||||
#define BLEND_DST_COLOR GL_DST_COLOR
|
||||
#define BLEND_ONE_MINUS_DST_COLOR GL_ONE_MINUS_DST_COLOR
|
||||
#define BLEND_SRC_ALPHA_SATURATE GL_SRC_ALPHA_SATURATE
|
||||
|
||||
#define ARGB(a, r, g, b) ((PIXEL_TYPE)((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
|
||||
#define RGBA(r, g, b, a) ((PIXEL_TYPE)((a) << 24) | ((b) << 16) | ((g) << 8) | (r))
|
||||
#define ARGB(a, r, g, b) ((PIXEL_TYPE)((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
|
||||
#define RGBA(r, g, b, a) ((PIXEL_TYPE)((a) << 24) | ((b) << 16) | ((g) << 8) | (r))
|
||||
|
||||
#define TEXTURE_FORMAT 0
|
||||
#define GU_PSM_8888 0
|
||||
#define GU_PSM_5551 0
|
||||
#define GU_PSM_4444 0
|
||||
#define GU_PSM_5650 0
|
||||
#define PIXEL_TYPE DWORD
|
||||
#define TEXTURE_FORMAT 0
|
||||
#define GU_PSM_8888 0
|
||||
#define GU_PSM_5551 0
|
||||
#define GU_PSM_4444 0
|
||||
#define GU_PSM_5650 0
|
||||
#define PIXEL_TYPE DWORD
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef enum Buttons
|
||||
{
|
||||
{
|
||||
JGE_BTN_NONE = 0, // No button pressed
|
||||
JGE_BTN_QUIT, // Home on PSP
|
||||
JGE_BTN_MENU, // Start on PSP
|
||||
@@ -270,7 +270,7 @@ typedef enum Buttons
|
||||
JGE_BTN_FULLSCREEN, // Switch to fullscreen (obviously, PC only)
|
||||
|
||||
JGE_BTN_MAX = JGE_BTN_FULLSCREEN + 1
|
||||
} JButton;
|
||||
} JButton;
|
||||
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ public:
|
||||
|
||||
int mFilter;
|
||||
|
||||
#if defined (PSP)
|
||||
#if defined (PSP)
|
||||
int mTextureFormat;
|
||||
int mTexId;
|
||||
bool mInVideoRAM;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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,5 +1,4 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "AdWhirlDelegateProtocol.h"
|
||||
|
||||
@interface EAGLViewController : UIViewController<UITextFieldDelegate> {
|
||||
|
||||
|
||||
@@ -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
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user