From 245fb6923c876eed98e737e6ae39002d2970a3e0 Mon Sep 17 00:00:00 2001 From: filux Date: Wed, 29 Apr 2015 20:26:00 +0200 Subject: [PATCH] since now you can write also port number in the 'LAN menu' --- .../glest_game/menu/menu_state_join_game.cpp | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/source/glest_game/menu/menu_state_join_game.cpp b/source/glest_game/menu/menu_state_join_game.cpp index 337aefd6e..911e5d1e0 100644 --- a/source/glest_game/menu/menu_state_join_game.cpp +++ b/source/glest_game/menu/menu_state_join_game.cpp @@ -154,7 +154,7 @@ void MenuStateJoinGame::CommonInit(bool connect, Ip serverIp,int portNumberOverr //server ip labelServerIp.registerGraphicComponent(containerName,"labelServerIp"); labelServerIp.setEditable(true); - labelServerIp.setMaxEditWidth(20); + labelServerIp.setMaxEditWidth(26); labelServerIp.setMaxEditRenderWidth(210); labelServerIp.init(labelXright, 460); @@ -696,7 +696,7 @@ void MenuStateJoinGame::keyPress(SDL_KeyboardEvent c) { ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface(); if(clientInterface->isConnected() == false) { - int maxTextSize= 16; + int maxTextSize= 22; //Config &configKeys = Config::getInstance(std::pair(cfgMainKeys,cfgUserKeys)); @@ -708,8 +708,8 @@ void MenuStateJoinGame::keyPress(SDL_KeyboardEvent c) { if((int)labelServerIp.getText().size() < maxTextSize) { string text= labelServerIp.getText(); //text.insert(text.end()-1, key); - char szCharText[20]=""; - snprintf(szCharText,20,"%c",key); + char szCharText[26]=""; + snprintf(szCharText,26,"%c",key); char *utfStr = ConvertToUTF8(&szCharText[0]); if(text.size() > 0) { text.insert(text.end() -1, utfStr[0]); @@ -734,6 +734,20 @@ void MenuStateJoinGame::keyPress(SDL_KeyboardEvent c) { text = "."; } + labelServerIp.setText(text); + } + } + //else if (c==':') { + else if (key == SDLK_COLON) { + if((int)labelServerIp.getText().size() < maxTextSize) { + string text= labelServerIp.getText(); + if(text.size() > 0) { + text.insert(text.end() -1, ':'); + } + else { + text = ":"; + } + labelServerIp.setText(text); } }