From be9d8859d4908bb76d8e2f97d7d622ef01f82167 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 29 Dec 2010 19:31:51 +0000 Subject: [PATCH] - messagebox prompt for downloading maps --- .../menu/menu_state_connected_game.cpp | 52 +++++++++++++++++-- .../menu/menu_state_connected_game.h | 2 + 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 9672be897..3a3f72422 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -85,6 +85,10 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM mainMessageBox.setEnabled(false); mainMessageBoxState=0; + ftpMessageBox.registerGraphicComponent(containerName,"ftpMessageBox"); + ftpMessageBox.init(lang.get("Yes"),lang.get("no")); + ftpMessageBox.setEnabled(false); + NetworkManager &networkManager= NetworkManager::getInstance(); Config &config = Config::getInstance(); defaultPlayerName = config.getString("NetPlayerName",Socket::getHostName().c_str()); @@ -420,6 +424,24 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){ } } } + else if(ftpMessageBox.getEnabled()) { + int button= 1; + if(ftpMessageBox.mouseClick(x, y, button)) { + soundRenderer.playFx(coreData.getClickSoundA()); + ftpMessageBox.setEnabled(false); + if(button == 1) { + getMissingMapFromFTPServerInProgress = true; + + char szMsg[1024]=""; + sprintf(szMsg,"Player: %s is attempting to download the map: %s",getHumanPlayerName().c_str(),getMissingMapFromFTPServer.c_str()); + clientInterface->sendTextMessage(szMsg,-1, true); + + if(ftpClientThread != NULL) { + ftpClientThread->addMapToRequests(getMissingMapFromFTPServer); + } + } + } + } else if(buttonDisconnect.mouseClick(x,y)){ SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -533,6 +555,10 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms){ mainMessageBox.mouseMove(x, y); } + if (ftpMessageBox.getEnabled()) { + ftpMessageBox.mouseMove(x, y); + } + buttonDisconnect.mouseMove(x, y); buttonPlayNow.mouseMove(x, y); @@ -568,6 +594,10 @@ void MenuStateConnectedGame::render() { renderer.renderMessageBox(&mainMessageBox); } + if(ftpMessageBox.getEnabled()){ + renderer.renderMessageBox(&ftpMessageBox); + } + if (!initialSettingsReceivedFromServer) return; //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -967,9 +997,10 @@ void MenuStateConnectedGame::update() { else { // try to get the map via ftp if(ftpClientThread != NULL && getMissingMapFromFTPServer != currentMap) { - getMissingMapFromFTPServer = currentMap; - getMissingMapFromFTPServerInProgress = true; - ftpClientThread->addMapToRequests(currentMap); + if(ftpMessageBox.getEnabled() == false) { + getMissingMapFromFTPServer = currentMap; + showFTPMessageBox("Download missing map: " + currentMap + " ?", "Question", false); + } } maps.push_back("***missing***"); } @@ -1571,6 +1602,21 @@ void MenuStateConnectedGame::showMessageBox(const string &text, const string &he } } +void MenuStateConnectedGame::showFTPMessageBox(const string &text, const string &header, bool toggle) { + if(!toggle) { + ftpMessageBox.setEnabled(false); + } + + if(!ftpMessageBox.getEnabled()) { + ftpMessageBox.setText(text); + ftpMessageBox.setHeader(header); + ftpMessageBox.setEnabled(true); + } + else { + ftpMessageBox.setEnabled(false); + } +} + void MenuStateConnectedGame::FTPClient_CallbackEvent(string mapFilename, FTP_Client_ResultType result) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/menu/menu_state_connected_game.h b/source/glest_game/menu/menu_state_connected_game.h index c9fc98cd3..cb4a9d45b 100644 --- a/source/glest_game/menu/menu_state_connected_game.h +++ b/source/glest_game/menu/menu_state_connected_game.h @@ -136,6 +136,7 @@ private: std::vector tileSets; + GraphicMessageBox ftpMessageBox; FTPClientThread *ftpClientThread; string getMissingMapFromFTPServer; bool getMissingMapFromFTPServerInProgress; @@ -169,6 +170,7 @@ private: bool loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview); void showMessageBox(const string &text, const string &header, bool toggle); + void showFTPMessageBox(const string &text, const string &header, bool toggle); virtual void FTPClient_CallbackEvent(string mapFilename, FTP_Client_ResultType result); };