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:
techdragon.nguyen@gmail.com
2011-12-15 11:11:08 +00:00
parent f9016f70ab
commit dc7d52c48c
14 changed files with 785 additions and 535 deletions

View File

@@ -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();
};

View File

@@ -44,7 +44,8 @@ public:
void Render();
void Update(float dt);
void pressKey(unsigned char id);
void CancelEdit();
SimplePad();
~SimplePad();

View File

@@ -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 -

View File

@@ -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()

View 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