- messagebox prompt for downloading maps

This commit is contained in:
Mark Vejvoda
2010-12-29 19:31:51 +00:00
parent 41899507a9
commit be9d8859d4
2 changed files with 51 additions and 3 deletions

View File

@@ -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__);

View File

@@ -136,6 +136,7 @@ private:
std::vector<std::string> 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);
};