added new signature for SendCommand in JGE that takes in a command string and a parameter
added native keyboard handling in iOS TODO: add same feature for Android tablets/phones
This commit is contained in:
@@ -369,6 +369,7 @@ class JGE
|
||||
/// Sends a message through JGE
|
||||
/// Currently used only to communicate with the JNI Layer in Android
|
||||
void SendCommand(std::string command);
|
||||
void SendCommand(std::string command, std::string parameter);
|
||||
|
||||
#if defined (ANDROID)
|
||||
/// Access to JNI Environment
|
||||
|
||||
@@ -588,12 +588,17 @@ void JGE::SendCommand(string command)
|
||||
#if defined (ANDROID)
|
||||
sendJNICommand(command);
|
||||
#endif
|
||||
#ifdef IOS
|
||||
}
|
||||
|
||||
void JGE::SendCommand(std::string command, std::string parameter)
|
||||
{
|
||||
#if defined (IOS)
|
||||
// get the app delegate and have it handle the command
|
||||
wagicAppDelegate *delegate = [ [UIApplication sharedApplication] delegate];
|
||||
const char* commandString = command.c_str();
|
||||
DebugTrace("Command: "<< command << endl);
|
||||
[delegate handleWEngineCommand:[NSString stringWithUTF8String: commandString]];
|
||||
DebugTrace("Command: "<< command << " with parameter: " << parameter << endl);
|
||||
[delegate handleWEngineCommand:[NSString stringWithCString: command.c_str() encoding: NSUTF8StringEncoding]
|
||||
withParameter: [NSString stringWithCString: parameter.c_str() encoding:NSUTF8StringEncoding]];
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import "AdWhirlDelegateProtocol.h"
|
||||
#import "EAGLViewController.h"
|
||||
#import "EAGLView.h"
|
||||
#import "ESRenderer.h"
|
||||
|
||||
// This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
|
||||
@@ -35,6 +36,7 @@
|
||||
- (void)stopAnimation;
|
||||
- (void)drawView:(id)sender;
|
||||
|
||||
- (void)updateKeyboard: (NSString *) inputString;
|
||||
- (void)removeAds;
|
||||
- (void)displayAds;
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "JRenderer.h"
|
||||
#include "JGameLauncher.h"
|
||||
|
||||
#include "GameApp.h"
|
||||
|
||||
#import "AdWhirlView.h"
|
||||
#import "wagicAppDelegate.h"
|
||||
|
||||
@@ -532,6 +534,31 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#include "GameOptions.h"
|
||||
#pragma mark Keyboard related methods
|
||||
|
||||
- (void) updateKeyboard:( NSString *) inputString
|
||||
{
|
||||
// send the new string to JGE to update the string
|
||||
unsigned char key = [inputString characterAtIndex: 0];
|
||||
if ([inputString length] > 1)
|
||||
{
|
||||
if ([inputString isEqualToString: @"DELETE"])
|
||||
key = 127;
|
||||
else if ([inputString isEqualToString:@"SPACE"])
|
||||
key = 32;
|
||||
else if ([inputString isEqualToString: @"SAVE"])
|
||||
key = 1;
|
||||
else if ([inputString isEqualToString: @"CANCEL"])
|
||||
key = 10;
|
||||
}
|
||||
|
||||
options.keypadUpdateText( key );
|
||||
if ( key < 11 )
|
||||
g_engine->HoldKey_NoRepeat( JGE_BTN_OK) ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//These are the methods for the AdWhirl Delegate, you have to implement them
|
||||
#pragma mark AdWhirlDelegate methods
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "AdWhirlDelegateProtocol.h"
|
||||
|
||||
@interface EAGLViewController : UIViewController {
|
||||
@interface EAGLViewController : UIViewController<UITextFieldDelegate> {
|
||||
|
||||
BOOL bannerIsVisible;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) id eaglView;
|
||||
@property (nonatomic, retain) UITextField *inputField;
|
||||
@property (nonatomic, assign) BOOL bannerIsVisible;
|
||||
@property (nonatomic, retain) id eaglView;
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,15 +10,26 @@
|
||||
|
||||
@synthesize bannerIsVisible;
|
||||
@synthesize eaglView;
|
||||
@synthesize inputField;
|
||||
|
||||
#pragma mark initialization / deallocation methods
|
||||
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
inputField = [[UITextField alloc] initWithFrame: CGRectMake(-50, -50, 25, 25)] ;
|
||||
[self.inputField setEnablesReturnKeyAutomatically: YES];
|
||||
[self.inputField setEnabled: YES];
|
||||
[self.inputField setDelegate: self];
|
||||
[inputField setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
|
||||
[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;
|
||||
}
|
||||
@@ -26,6 +37,7 @@
|
||||
- (void)dealloc {
|
||||
[eaglView setDelegate: nil];
|
||||
[eaglView release], eaglView = nil;
|
||||
[inputField release], inputField = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -157,4 +169,46 @@
|
||||
|
||||
#pragma mark -
|
||||
|
||||
#pragma mark UITextFieldDelegate methods
|
||||
- (void)toggleKeyboardWithState: (NSString *) initialText
|
||||
{
|
||||
UIView *blockerView = [[[UIView alloc] initWithFrame: [self.view frame]] autorelease];
|
||||
[blockerView setBackgroundColor: [UIColor clearColor]];
|
||||
[self.view addSubview: blockerView];
|
||||
if ([[self inputField] becomeFirstResponder])
|
||||
{
|
||||
[inputField setText: initialText];
|
||||
// success in displaying the keyboard
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
|
||||
{
|
||||
if ([string isEqualToString:@" "])
|
||||
[eaglView updateKeyboard: @"SPACE"];
|
||||
else if ( (string == nil || [string isEqualToString: @""]) && (1 == range.length))
|
||||
[eaglView updateKeyboard: @"DELETE"];
|
||||
else if ( (string == nil || [string isEqualToString: @""]) && (range.location == (range.length-1)))
|
||||
[eaglView updateKeyboard: @"CLEAR"];
|
||||
else
|
||||
[eaglView updateKeyboard: string];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
|
||||
{
|
||||
[eaglView updateKeyboard: @"SAVE"];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) textFieldShouldReturn:(UITextField *)textField
|
||||
{
|
||||
[textField resignFirstResponder];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
@end
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "Reachability.h"
|
||||
#import "WagicDownloadProgressViewController.h"
|
||||
#import "Reachability.h"
|
||||
|
||||
@class EAGLViewController;
|
||||
|
||||
@interface wagicAppDelegate : NSObject <UIApplicationDelegate> {
|
||||
UIWindow *window;
|
||||
EAGLViewController *glViewController;
|
||||
//Reachability variables
|
||||
Reachability* hostReach;
|
||||
Reachability* internetReach;
|
||||
Reachability* wifiReach;
|
||||
Reachability *hostReach, *internetReach, *wifiReach;
|
||||
|
||||
}
|
||||
- (void) rotateBackgroundImage:(UIInterfaceOrientation)fromInterfaceOrientation toInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;
|
||||
|
||||
- (void) handleWEngineCommand:(NSString *) command;
|
||||
- (void) handleWEngineCommand:(NSString *) command withParameter: (NSString *) parameter;
|
||||
|
||||
@property (nonatomic, retain) IBOutlet UIWindow *window;
|
||||
@property (nonatomic, retain) EAGLViewController *glViewController;
|
||||
|
||||
@@ -103,6 +103,8 @@
|
||||
|
||||
[self.window setBackgroundColor: [UIColor blackColor]];
|
||||
[self.window makeKeyAndVisible];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application
|
||||
@@ -137,8 +139,13 @@
|
||||
[self.glViewController.view stopAnimation];
|
||||
}
|
||||
|
||||
- (void)initializeKeyboard: (id) initialState
|
||||
{
|
||||
[self.glViewController toggleKeyboardWithState: initialState];
|
||||
}
|
||||
|
||||
- (void)handleWEngineCommand:(NSString *) command
|
||||
|
||||
- (void)handleWEngineCommand:(NSString *) command withParameter: (NSString *) parameter
|
||||
{
|
||||
BOOL isDevicePhone = (UI_USER_INTERFACE_IDIOM()) == UIUserInterfaceIdiomPhone;
|
||||
|
||||
@@ -154,10 +161,13 @@
|
||||
if (isDevicePhone)
|
||||
[glViewController.eaglView removeAds];
|
||||
}
|
||||
else if ([command isEqualToString: @"displayKeyboard"])
|
||||
{
|
||||
[self initializeKeyboard: parameter];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void) rotateBackgroundImage:(UIInterfaceOrientation)fromInterfaceOrientation toInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
|
||||
{
|
||||
bool isPhone = (UI_USER_INTERFACE_IDIOM()) == UIUserInterfaceIdiomPhone;
|
||||
|
||||
@@ -347,7 +347,7 @@ public:
|
||||
string mFilename;
|
||||
int save();
|
||||
int load();
|
||||
|
||||
|
||||
GameOption * get(int);
|
||||
GameOption * get(string optionName);
|
||||
GameOption& operator[](int);
|
||||
@@ -383,6 +383,31 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void keypadUpdateText(unsigned char key)
|
||||
{
|
||||
if (keypad)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 1: // save the current text
|
||||
keypad->pressKey( key);
|
||||
break;
|
||||
case 10: // cancel the edit
|
||||
keypad->CancelEdit();
|
||||
break;
|
||||
case 32:
|
||||
keypad->pressKey( KPD_SPACE );
|
||||
break;
|
||||
case 127:
|
||||
keypad->pressKey( KPD_DEL );
|
||||
break;
|
||||
default:
|
||||
keypad->pressKey( key );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void keypadUpdate(float dt)
|
||||
{
|
||||
if(keypad)
|
||||
@@ -422,6 +447,7 @@ public:
|
||||
private:
|
||||
GameApp* theGame;
|
||||
SimplePad* keypad;
|
||||
|
||||
StyleManager* styleMan;
|
||||
void createProfileFolders();
|
||||
};
|
||||
|
||||
@@ -44,7 +44,8 @@ public:
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void pressKey(unsigned char id);
|
||||
|
||||
void CancelEdit();
|
||||
|
||||
SimplePad();
|
||||
~SimplePad();
|
||||
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#include "StyleManager.h"
|
||||
#include "Credits.h"
|
||||
|
||||
#ifdef IOS
|
||||
#include "JGE.h"
|
||||
#endif
|
||||
|
||||
const string Options::optionNames[] = {
|
||||
//Global options
|
||||
"Profile",
|
||||
@@ -71,6 +75,8 @@ const string Options::optionNames[] = {
|
||||
"aw_collector",
|
||||
|
||||
};
|
||||
|
||||
#pragma mark Options
|
||||
int Options::getID(string name)
|
||||
{
|
||||
if (0 == name.size())
|
||||
@@ -187,6 +193,10 @@ int Options::optionInterrupt(int gamePhase)
|
||||
return INVALID_OPTION;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
#pragma mark GameOption
|
||||
|
||||
GameOption::GameOption(int value) :
|
||||
number(value)
|
||||
{
|
||||
@@ -307,6 +317,9 @@ bool GameOption::write(std::ofstream * file, string name)
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
#pragma mark GameOptions
|
||||
GameOptions::GameOptions(string filename)
|
||||
{
|
||||
mFilename = filename;
|
||||
@@ -397,6 +410,12 @@ int GameOptions::save()
|
||||
return 1;
|
||||
}
|
||||
|
||||
GameSettings GameOptions::getGameSettings()
|
||||
{
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
GameOption& GameOptions::operator[](int optionID)
|
||||
{
|
||||
GameOption * go = get(optionID);
|
||||
@@ -524,6 +543,10 @@ GameOptions::~GameOptions()
|
||||
unknownMap.clear();
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
#pragma mark GameSettings
|
||||
|
||||
GameSettings options;
|
||||
|
||||
GameSettings::GameSettings()
|
||||
@@ -828,6 +851,14 @@ SimplePad * GameSettings::keypadStart(string input, string * _dest, bool _cancel
|
||||
{
|
||||
if (keypad == NULL)
|
||||
keypad = NEW SimplePad();
|
||||
// show keyboard
|
||||
#ifdef IOS
|
||||
JGE *engine = JGE::GetInstance();
|
||||
engine->SendCommand( "displayKeyboard", input);
|
||||
#elif ANDROID
|
||||
JGE *engine = JGE::GetInstance();
|
||||
engine->SendCommand( "displayKeyboard:" << input);
|
||||
#endif
|
||||
keypad->bShowCancel = _cancel;
|
||||
keypad->bShowNumpad = _numpad;
|
||||
keypad->mX = _x;
|
||||
@@ -848,6 +879,10 @@ void GameSettings::keypadShutdown()
|
||||
SAFE_DELETE(keypad);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
#pragma mark EnumDefinition
|
||||
|
||||
//EnumDefinition
|
||||
int EnumDefinition::findIndex(int value)
|
||||
{
|
||||
@@ -908,6 +943,10 @@ bool GameOptionEnum::read(string input)
|
||||
return false;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
#pragma mark OptionMaxGrade
|
||||
|
||||
//Enum Definitions
|
||||
OptionMaxGrade OptionMaxGrade::mDef;
|
||||
OptionMaxGrade::OptionMaxGrade()
|
||||
@@ -921,6 +960,10 @@ OptionMaxGrade::OptionMaxGrade()
|
||||
|
||||
}
|
||||
;
|
||||
#pragma mark -
|
||||
|
||||
#pragma mark OptionASkipPhase
|
||||
|
||||
OptionASkipPhase OptionASkipPhase::mDef;
|
||||
OptionASkipPhase::OptionASkipPhase()
|
||||
{
|
||||
@@ -929,6 +972,9 @@ OptionASkipPhase::OptionASkipPhase()
|
||||
mDef.values.push_back(EnumDefinition::assoc(Constants::ASKIP_FULL, "Full"));
|
||||
}
|
||||
;
|
||||
#pragma mark -
|
||||
|
||||
#pragma mark OptionWhosFirst
|
||||
|
||||
OptionWhosFirst OptionWhosFirst::mDef;
|
||||
OptionWhosFirst::OptionWhosFirst()
|
||||
@@ -996,6 +1042,10 @@ OptionKicker::OptionKicker()
|
||||
mDef.values.push_back(EnumDefinition::assoc(Constants::KICKER_CHOICE, "Offer Choice"));
|
||||
}
|
||||
;
|
||||
#pragma mark -
|
||||
|
||||
#pragma mark GameOptionAward
|
||||
|
||||
//GameOptionAward
|
||||
GameOptionAward::GameOptionAward()
|
||||
{
|
||||
@@ -1131,6 +1181,10 @@ static JButton u32_to_button(u32 b)
|
||||
return JGE_BTN_NONE;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
#pragma mark GameOptionKeyBindings
|
||||
|
||||
bool GameOptionKeyBindings::read(string input)
|
||||
{
|
||||
istringstream iss(input);
|
||||
@@ -1178,3 +1232,4 @@ bool GameOptionKeyBindings::write(std::ofstream* file, string name)
|
||||
*file << endl;
|
||||
return true;
|
||||
}
|
||||
#pragma mark -
|
||||
@@ -44,7 +44,11 @@ SimplePad::SimplePad()
|
||||
{
|
||||
nbitems = 0;
|
||||
bActive = false;
|
||||
#ifdef IOS
|
||||
selected = KPD_OK;
|
||||
#else
|
||||
selected = 0;
|
||||
#endif
|
||||
priorKey = 0;
|
||||
cursor = 0;
|
||||
bShowCancel = false;
|
||||
@@ -175,11 +179,16 @@ void SimplePad::pressKey(unsigned char key)
|
||||
Finish();
|
||||
else if (key == KPD_CANCEL)
|
||||
{
|
||||
bCanceled = true;
|
||||
Finish();
|
||||
CancelEdit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SimplePad::CancelEdit()
|
||||
{
|
||||
bCanceled = true;
|
||||
Finish();
|
||||
}
|
||||
void SimplePad::MoveSelection(unsigned char moveto)
|
||||
{
|
||||
if (!bShowNumpad && moveto >= KPD_0 && moveto <= KPD_9)
|
||||
@@ -370,7 +379,8 @@ void SimplePad::Render()
|
||||
offY += kH + 12;
|
||||
|
||||
if (!bShowNumpad) vSpacing -= kH + 12;
|
||||
|
||||
#ifndef IOS
|
||||
|
||||
for (int x = 0; x < nbitems; x++)
|
||||
if (keys[x])
|
||||
{
|
||||
@@ -445,6 +455,7 @@ void SimplePad::Render()
|
||||
mFont->DrawString(keys[x]->displayValue.c_str(), mX + offX, mY + offY);
|
||||
offX += kW + 14;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned int SimplePad::cursorPos()
|
||||
|
||||
58
projects/mtg/wagic copy-Info.plist
Executable file
58
projects/mtg/wagic copy-Info.plist
Executable file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array/>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string></string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>wagic-64x64.png</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>net.wagic.core</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array/>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainWindow</string>
|
||||
<key>UIFileSharingEnabled</key>
|
||||
<true/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
</array>
|
||||
<key>UTExportedTypeDeclarations</key>
|
||||
<array/>
|
||||
<key>UTImportedTypeDeclarations</key>
|
||||
<array/>
|
||||
</dict>
|
||||
</plist>
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user