Added code to let user specify the server address.
Updated SimplePad to include dot and fixed problem with digits.
This commit is contained in:
@@ -52,6 +52,7 @@ GameApp::GameApp() :
|
||||
JApp()
|
||||
#ifdef NETWORK_SUPPORT
|
||||
,mpNetwork(NULL)
|
||||
, mServerAddress("")
|
||||
#endif //NETWORK_SUPPORT
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
||||
@@ -455,6 +455,35 @@ void GameStateMenu::ensureMGuiController()
|
||||
|
||||
void GameStateMenu::Update(float dt)
|
||||
{
|
||||
#ifdef NETWORK_SUPPORT
|
||||
if (options.keypadActive())
|
||||
{
|
||||
options.keypadUpdate(dt);
|
||||
|
||||
if (mParent->mServerAddress != "")
|
||||
{
|
||||
mParent->mServerAddress = options.keypadFinish();
|
||||
|
||||
if (mParent->mServerAddress != "")
|
||||
{
|
||||
mParent->mpNetwork = new JNetwork();
|
||||
|
||||
mParent->mpNetwork->connect(mParent->mServerAddress);
|
||||
// we let the server choose the game mode
|
||||
mParent->gameType = GAME_TYPE_SLAVE;
|
||||
// just to select one, the HOST is in control here.
|
||||
mParent->rules = Rules::getRulesByFilename("classic.txt");
|
||||
hasChosenGameType = true;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_NETWORK_WAIT | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
}
|
||||
mParent->mServerAddress = "";
|
||||
}
|
||||
//Prevent screen from updating.
|
||||
return;
|
||||
}
|
||||
#endif //NETWORK_SUPPORT
|
||||
|
||||
timeIndex += dt * 2;
|
||||
switch (MENU_STATE_MAJOR & currentState)
|
||||
{
|
||||
@@ -766,6 +795,8 @@ void GameStateMenu::Render()
|
||||
{
|
||||
subMenuController->Render();
|
||||
}
|
||||
|
||||
if (options.keypadActive()) options.keypadRender();
|
||||
}
|
||||
|
||||
void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||
@@ -843,7 +874,7 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||
{
|
||||
if(!mParent->mpNetwork)
|
||||
{
|
||||
mParent->mpNetwork = new JNetwork();
|
||||
mParent->mpNetwork = new JNetwork();
|
||||
}
|
||||
mParent->mpNetwork->connect();
|
||||
subMenuController->Close();
|
||||
@@ -854,17 +885,9 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||
{
|
||||
if(!mParent->mpNetwork)
|
||||
{
|
||||
mParent->mpNetwork = new JNetwork();
|
||||
options.keypadStart("127.0.0.1", &(mParent->mServerAddress), true, true);
|
||||
options.keypadTitle("Enter device address to connect");
|
||||
}
|
||||
// FIXME needs to be able to specify the server ip
|
||||
mParent->mpNetwork->connect("127.0.0.1");
|
||||
// we let the server choose the game mode
|
||||
mParent->gameType = GAME_TYPE_SLAVE;
|
||||
// just to select one, the HOST is in control here.
|
||||
mParent->rules = Rules::getRulesByFilename("classic.txt");
|
||||
hasChosenGameType = true;
|
||||
subMenuController->Close();
|
||||
currentState = MENU_STATE_NETWORK_WAIT | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
}
|
||||
#endif //NETWORK_SUPPORT
|
||||
|
||||
@@ -112,6 +112,9 @@ SimplePad::SimplePad()
|
||||
if (x < 8) linkKeys(KPD_0 + x, KPD_A + x, KPD_DOWN);
|
||||
if (x > 0) linkKeys(KPD_0 + x, KPD_0 + x - 1, KPD_LEFT);
|
||||
}
|
||||
k = Add(_("."), KPD_DOT);
|
||||
linkKeys(KPD_DOT, KPD_9, KPD_LEFT);
|
||||
keys[KPD_DOT]->adjacency[KPD_DOWN] = KPD_DEL;
|
||||
|
||||
keys[KPD_8]->adjacency[KPD_DOWN] = KPD_DEL;
|
||||
keys[KPD_9]->adjacency[KPD_DOWN] = KPD_DEL;
|
||||
@@ -158,6 +161,17 @@ void SimplePad::pressKey(unsigned char key)
|
||||
//Auto swap capitalization
|
||||
if (bCapslock && buffer.size() == 1) bCapslock = !bCapslock;
|
||||
}
|
||||
else if (key >= KPD_0 && key <= KPD_9)
|
||||
{
|
||||
input += ('0' + key - KPD_0);
|
||||
if (cursor < buffer.size()) cursor++;
|
||||
buffer.insert(cursor, input);
|
||||
}
|
||||
else if (key == KPD_DOT)
|
||||
{
|
||||
if (cursor < buffer.size()) cursor++;
|
||||
buffer.insert(cursor, ".");
|
||||
}
|
||||
else if (key == KPD_SPACE)
|
||||
{
|
||||
if (cursor < buffer.size()) cursor++;
|
||||
@@ -392,7 +406,7 @@ void SimplePad::Render()
|
||||
if (keys[x])
|
||||
{
|
||||
|
||||
if ((x == KPD_CANCEL && !bShowCancel) || (x >= KPD_0 && x <= KPD_9 && !bShowNumpad)) continue;
|
||||
if ((x == KPD_CANCEL && !bShowCancel) || (x >= KPD_0 && x <= KPD_DOT && !bShowNumpad)) continue;
|
||||
|
||||
switch (x)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user