Added code to let user specify the server address.
Updated SimplePad to include dot and fixed problem with digits.
This commit is contained in:
@@ -28,7 +28,7 @@ JSocket::JSocket(string ipAddr)
|
|||||||
mfd(-1)
|
mfd(-1)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
struct hostent *hostentptr;
|
struct hostent *hostentptr = 0;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
SOCKADDR_IN Adresse_Socket_Server;
|
SOCKADDR_IN Adresse_Socket_Server;
|
||||||
WORD wVersionRequested;
|
WORD wVersionRequested;
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public:
|
|||||||
Rules * rules;
|
Rules * rules;
|
||||||
CardEffect *effect;
|
CardEffect *effect;
|
||||||
#ifdef NETWORK_SUPPORT
|
#ifdef NETWORK_SUPPORT
|
||||||
|
string mServerAddress;
|
||||||
JNetwork* mpNetwork;
|
JNetwork* mpNetwork;
|
||||||
#endif //NETWORK_SUPPORT
|
#endif //NETWORK_SUPPORT
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ enum SIMPLE_KEYS{
|
|||||||
KPD_S, KPD_T, KPD_U, KPD_V, KPD_W, KPD_X,
|
KPD_S, KPD_T, KPD_U, KPD_V, KPD_W, KPD_X,
|
||||||
KPD_Y, KPD_Z, KPD_SPACE, KPD_OK, KPD_CANCEL,
|
KPD_Y, KPD_Z, KPD_SPACE, KPD_OK, KPD_CANCEL,
|
||||||
KPD_DEL, KPD_CAPS, KPD_0, KPD_1, KPD_2, KPD_3,
|
KPD_DEL, KPD_CAPS, KPD_0, KPD_1, KPD_2, KPD_3,
|
||||||
KPD_4, KPD_5, KPD_6, KPD_7, KPD_8, KPD_9,
|
KPD_4, KPD_5, KPD_6, KPD_7, KPD_8, KPD_9, KPD_DOT,
|
||||||
KPD_MAX,
|
KPD_MAX,
|
||||||
KPD_NOWHERE = 254,
|
KPD_NOWHERE = 254,
|
||||||
KPD_INPUT = 255,
|
KPD_INPUT = 255,
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ GameApp::GameApp() :
|
|||||||
JApp()
|
JApp()
|
||||||
#ifdef NETWORK_SUPPORT
|
#ifdef NETWORK_SUPPORT
|
||||||
,mpNetwork(NULL)
|
,mpNetwork(NULL)
|
||||||
|
, mServerAddress("")
|
||||||
#endif //NETWORK_SUPPORT
|
#endif //NETWORK_SUPPORT
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|||||||
@@ -455,6 +455,35 @@ void GameStateMenu::ensureMGuiController()
|
|||||||
|
|
||||||
void GameStateMenu::Update(float dt)
|
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;
|
timeIndex += dt * 2;
|
||||||
switch (MENU_STATE_MAJOR & currentState)
|
switch (MENU_STATE_MAJOR & currentState)
|
||||||
{
|
{
|
||||||
@@ -766,6 +795,8 @@ void GameStateMenu::Render()
|
|||||||
{
|
{
|
||||||
subMenuController->Render();
|
subMenuController->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.keypadActive()) options.keypadRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||||
@@ -843,7 +874,7 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
|||||||
{
|
{
|
||||||
if(!mParent->mpNetwork)
|
if(!mParent->mpNetwork)
|
||||||
{
|
{
|
||||||
mParent->mpNetwork = new JNetwork();
|
mParent->mpNetwork = new JNetwork();
|
||||||
}
|
}
|
||||||
mParent->mpNetwork->connect();
|
mParent->mpNetwork->connect();
|
||||||
subMenuController->Close();
|
subMenuController->Close();
|
||||||
@@ -854,17 +885,9 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
|||||||
{
|
{
|
||||||
if(!mParent->mpNetwork)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
#endif //NETWORK_SUPPORT
|
#endif //NETWORK_SUPPORT
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ SimplePad::SimplePad()
|
|||||||
if (x < 8) linkKeys(KPD_0 + x, KPD_A + x, KPD_DOWN);
|
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);
|
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_8]->adjacency[KPD_DOWN] = KPD_DEL;
|
||||||
keys[KPD_9]->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
|
//Auto swap capitalization
|
||||||
if (bCapslock && buffer.size() == 1) bCapslock = !bCapslock;
|
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)
|
else if (key == KPD_SPACE)
|
||||||
{
|
{
|
||||||
if (cursor < buffer.size()) cursor++;
|
if (cursor < buffer.size()) cursor++;
|
||||||
@@ -392,7 +406,7 @@ void SimplePad::Render()
|
|||||||
if (keys[x])
|
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)
|
switch (x)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user