From d14f01349174dda667f5d125b52edc837a4a47bf Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Tue, 8 Jun 2010 00:00:28 +0000 Subject: [PATCH] some chat changes and custom game with NetworkFramePeriod --- source/glest_game/facilities/game_util.cpp | 2 +- source/glest_game/game/chat_manager.cpp | 34 +++++++----- source/glest_game/menu/main_menu.cpp | 4 ++ source/glest_game/menu/main_menu.h | 4 +- .../menu/menu_state_connected_game.cpp | 7 ++- .../menu/menu_state_connected_game.h | 1 + .../menu/menu_state_custom_game.cpp | 53 +++++++++++++------ .../glest_game/menu/menu_state_custom_game.h | 7 ++- .../sources/platform/sdl/gl_wrap.cpp | 2 +- 9 files changed, 82 insertions(+), 32 deletions(-) diff --git a/source/glest_game/facilities/game_util.cpp b/source/glest_game/facilities/game_util.cpp index ce8d9741..e12e1b69 100644 --- a/source/glest_game/facilities/game_util.cpp +++ b/source/glest_game/facilities/game_util.cpp @@ -26,7 +26,7 @@ using namespace Shared::Platform; namespace Glest{ namespace Game{ const string mailString= "contact_game@glest.org"; -const string glestVersionString= "v3.3.5-alpha3"; +const string glestVersionString= "v3.3.5-alpha5"; string getCrashDumpFileName(){ return "glest" + glestVersionString + ".dmp"; diff --git a/source/glest_game/game/chat_manager.cpp b/source/glest_game/game/chat_manager.cpp index e43b3e3c..c5716909 100644 --- a/source/glest_game/game/chat_manager.cpp +++ b/source/glest_game/game/chat_manager.cpp @@ -93,19 +93,29 @@ void ChatManager::keyDown(char key){ } if(key==vkReturn){ - if(editEnabled){ - GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); - - editEnabled= false; - if(!text.empty()) { - console->addLine(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": " + text); - gameNetworkInterface->sendTextMessage(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": "+ - text, teamMode? thisTeamIndex: -1); - } + SDL_keysym keystate = Window::getKeystate(); + if(keystate.mod & (KMOD_LALT | KMOD_RALT)){ + // alt+enter is ignored } - else{ - editEnabled= true; - text.clear(); + else + { + if(editEnabled){ + GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); + if(!text.empty()) { + console->addLine(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": " + text); + gameNetworkInterface->sendTextMessage(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": "+ + text, teamMode? thisTeamIndex: -1); + } + else + { + editEnabled= false; + } + text.clear(); + } + else{ + editEnabled= true; + text.clear(); + } } } else if(key==vkBack){ diff --git a/source/glest_game/menu/main_menu.cpp b/source/glest_game/menu/main_menu.cpp index df5c2217..b7d1e165 100644 --- a/source/glest_game/menu/main_menu.cpp +++ b/source/glest_game/menu/main_menu.cpp @@ -150,6 +150,10 @@ void MainMenu::keyDown(char key){ state->keyDown(key); } +void MainMenu::keyUp(char key){ + state->keyUp(key); +} + void MainMenu::keyPress(char c){ state->keyPress(c); } diff --git a/source/glest_game/menu/main_menu.h b/source/glest_game/menu/main_menu.h index 7008461a..4b4232a1 100644 --- a/source/glest_game/menu/main_menu.h +++ b/source/glest_game/menu/main_menu.h @@ -91,8 +91,9 @@ public: virtual void mouseDownLeft(int x, int y); virtual void mouseDownRight(int x, int y); virtual void keyDown(char key); + virtual void keyUp(char key); virtual void keyPress(char key); - + void setState(MenuState *state); }; @@ -117,6 +118,7 @@ public: virtual void update(){}; virtual void keyDown(char key){}; virtual void keyPress(char c){}; + virtual void keyUp(char key){}; const Camera *getCamera() const {return &camera;} }; diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 3ec01673..8cfe5023 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -380,7 +380,7 @@ void MenuStateConnectedGame::render(){ renderer.renderListBox(&listBoxTechTree); renderer.renderChatManager(&chatManager); - renderer.renderConsole(&console); + renderer.renderConsole(&console,true); } catch(const std::exception &ex) { char szBuf[1024]=""; @@ -762,4 +762,9 @@ void MenuStateConnectedGame::keyPress(char c) chatManager.keyPress(c); } +void MenuStateConnectedGame::keyUp(char key) +{ + chatManager.keyUp(key); +} + }}//end namespace diff --git a/source/glest_game/menu/menu_state_connected_game.h b/source/glest_game/menu/menu_state_connected_game.h index 4541d891..38b85c64 100644 --- a/source/glest_game/menu/menu_state_connected_game.h +++ b/source/glest_game/menu/menu_state_connected_game.h @@ -82,6 +82,7 @@ public: virtual void keyDown(char key); virtual void keyPress(char c); + virtual void keyUp(char key); private: diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index e4dd8f7e..ab8f1c23 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -78,9 +78,9 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b vector teamItems, controlItems, results; //create - buttonReturn.init(300, 180, 125); - buttonRestoreLastSettings.init(440, 180, 125); - buttonPlayNow.init(580, 180, 125); + buttonReturn.init(250, 180, 125); + buttonRestoreLastSettings.init(250+130, 180, 200); + buttonPlayNow.init(250+130+205, 180, 125); int setupPos=610; int mapHeadPos=330; @@ -151,9 +151,9 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b labelTechTree.init(600, mapHeadPos); - labelPublishServer.init(300, networkHeadPos, 100); + labelPublishServer.init(190, networkHeadPos, 100); labelPublishServer.setText(lang.get("PublishServer")); - listBoxPublishServer.init(300, networkPos, 100); + listBoxPublishServer.init(200, networkPos, 100); listBoxPublishServer.pushBackItem(lang.get("Yes")); listBoxPublishServer.pushBackItem(lang.get("No")); if(openNetworkSlots) @@ -161,14 +161,26 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b else listBoxPublishServer.setSelectedItemIndex(1); + // Network Frame Period + labelNetworkFramePeriod.init(440, networkHeadPos, 80); + labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod")); + listBoxNetworkFramePeriod.init(450, networkPos, 80); + listBoxNetworkFramePeriod.pushBackItem("10"); + listBoxNetworkFramePeriod.pushBackItem("20"); + listBoxNetworkFramePeriod.pushBackItem("30"); + listBoxNetworkFramePeriod.pushBackItem("40"); + listBoxNetworkFramePeriod.setSelectedItem("20"); + + // Enable Server Controlled AI - labelEnableServerControlledAI.init(600, networkHeadPos, 80); - listBoxEnableServerControlledAI.init(600, networkPos, 80); + labelEnableServerControlledAI.init(690, networkHeadPos, 80); + labelEnableServerControlledAI.setText(lang.get("EnableServerControlledAI")); + listBoxEnableServerControlledAI.init(700, networkPos, 80); listBoxEnableServerControlledAI.pushBackItem(lang.get("Yes")); listBoxEnableServerControlledAI.pushBackItem(lang.get("No")); listBoxEnableServerControlledAI.setSelectedItemIndex(0); - labelNetworkFramePeriod.init(420, networkHeadPos, 80); + //list boxes for(int i=0; isetFactionCount(factionCount); gameSettings->setEnableServerControlledAI(listBoxEnableServerControlledAI.getSelectedItemIndex() == 0); - + gameSettings->setNetworkFramePeriod((listBoxNetworkFramePeriod.getSelectedItemIndex()+1)*10); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getTileset() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getTileset().c_str()); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getTech() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getTech().c_str()); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getMap() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getMap().c_str()); @@ -1222,7 +1238,7 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName) gameSettings.setFogOfWar(properties.getBool("FogOfWar")); gameSettings.setEnableObserverModeAtEndGame(properties.getBool("EnableObserverModeAtEndGame")); gameSettings.setEnableServerControlledAI(properties.getBool("EnableServerControlledAI","false")); - gameSettings.setNetworkFramePeriod(properties.getBool("NetworkFramePeriod",intToStr(GameConstants::networkFramePeriod).c_str())); + gameSettings.setNetworkFramePeriod(properties.getInt("NetworkFramePeriod",intToStr(GameConstants::networkFramePeriod).c_str())/10*10); gameSettings.setThisFactionIndex(properties.getInt("FactionThisFactionIndex")); gameSettings.setFactionCount(properties.getInt("FactionCount")); @@ -1265,7 +1281,9 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName) listBoxEnableObserverMode.setSelectedItem(gameSettings.getEnableObserverModeAtEndGame() == true ? lang.get("Yes") : lang.get("No")); listBoxEnableServerControlledAI.setSelectedItem(gameSettings.getEnableServerControlledAI() == true ? lang.get("Yes") : lang.get("No")); - labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod") + " " + intToStr(gameSettings.getNetworkFramePeriod())); + labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod")); + + listBoxNetworkFramePeriod.setSelectedItem(intToStr(gameSettings.getNetworkFramePeriod()/10*10)); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); @@ -1483,6 +1501,11 @@ void MenuStateCustomGame::keyPress(char c) chatManager.keyPress(c); } +void MenuStateCustomGame::keyUp(char key) +{ + chatManager.keyUp(key); +} + void MenuStateCustomGame::showMessageBox(const string &text, const string &header, bool toggle){ if(!toggle){ mainMessageBox.setEnabled(false); diff --git a/source/glest_game/menu/menu_state_custom_game.h b/source/glest_game/menu/menu_state_custom_game.h index d5948b34..7da69438 100644 --- a/source/glest_game/menu/menu_state_custom_game.h +++ b/source/glest_game/menu/menu_state_custom_game.h @@ -36,7 +36,7 @@ private: GraphicLabel labelMapInfo; GraphicLabel labelEnableObserverMode; GraphicLabel labelEnableServerControlledAI; - GraphicLabel labelNetworkFramePeriod; + GraphicListBox listBoxMap; GraphicListBox listBoxFogOfWar; @@ -62,6 +62,9 @@ private: GraphicMessageBox mainMessageBox; int mainMessageBoxState; + GraphicListBox listBoxNetworkFramePeriod; + GraphicLabel labelNetworkFramePeriod; + bool needToSetChangedGameSettings; time_t lastSetChangedGameSettings; @@ -92,6 +95,8 @@ public: virtual void keyDown(char key); virtual void keyPress(char c); + virtual void keyUp(char key); + virtual void simpleTask(); diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index c4ea41db..6c506351 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -162,7 +162,7 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width, } } else { - float width = static_cast (fontInfo->per_char[p].rbearing - fontInfo->per_char[p].lbearing); + float width = static_cast(fontInfo->per_char[p].width); //( fontInfo->per_char[p].rbearing - fontInfo->per_char[p].lbearing); if(width <= 0) { width = static_cast(6); }