- added a new cancel button for connected menu to cancel all current and queued file transfers
This commit is contained in:
parent
431ca8e6fb
commit
d14b13e285
|
@ -141,8 +141,9 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
buttonDisconnect.registerGraphicComponent(containerName,"buttonDisconnect");
|
||||
buttonDisconnect.init(350, 180, 125);
|
||||
|
||||
|
||||
|
||||
buttonCancelDownloads.registerGraphicComponent(containerName,"buttonCancelDownloads");
|
||||
buttonCancelDownloads.init(10, 150, 125);
|
||||
buttonCancelDownloads.setText(lang.get("CancelDownloads"));
|
||||
|
||||
xoffset=170;
|
||||
// fog - o - war
|
||||
|
@ -580,6 +581,76 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(buttonCancelDownloads.mouseClick(x,y)) {
|
||||
if(ftpClientThread != NULL && fileFTPProgressList.size() > 0) {
|
||||
ftpClientThread->setCallBackObject(NULL);
|
||||
if(ftpClientThread->shutdownAndWait() == true) {
|
||||
delete ftpClientThread;
|
||||
}
|
||||
|
||||
fileFTPProgressList.clear();
|
||||
getMissingMapFromFTPServerInProgress = false;
|
||||
getMissingTilesetFromFTPServerInProgress = false;
|
||||
getMissingTechtreeFromFTPServerInProgress = false;
|
||||
getMissingMapFromFTPServer = "";
|
||||
getMissingTilesetFromFTPServer = "";
|
||||
getMissingTechtreeFromFTPServer = "";
|
||||
|
||||
ClientInterface *clientInterface = networkManager.getClientInterface();
|
||||
string serverUrl = clientInterface->getServerIpAddress();
|
||||
//int portNumber = config.getInt("FTPServerPort",intToStr(ServerSocket::getFTPServerPort()).c_str());
|
||||
int portNumber = clientInterface->getServerFTPPort();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] Using FTP port #: %d\n",__FILE__,__FUNCTION__,__LINE__,portNumber);
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
vector<string> mapPathList = config.getPathListForType(ptMaps);
|
||||
std::pair<string,string> mapsPath;
|
||||
if(mapPathList.size() > 0) {
|
||||
mapsPath.first = mapPathList[0];
|
||||
}
|
||||
if(mapPathList.size() > 1) {
|
||||
mapsPath.second = mapPathList[1];
|
||||
}
|
||||
std::pair<string,string> tilesetsPath;
|
||||
vector<string> tilesetsList = Config::getInstance().getPathListForType(ptTilesets);
|
||||
if(tilesetsList.size() > 0) {
|
||||
tilesetsPath.first = tilesetsList[0];
|
||||
if(tilesetsList.size() > 1) {
|
||||
tilesetsPath.second = tilesetsList[1];
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<string,string> techtreesPath;
|
||||
vector<string> techtreesList = Config::getInstance().getPathListForType(ptTechs);
|
||||
if(techtreesList.size() > 0) {
|
||||
techtreesPath.first = techtreesList[0];
|
||||
if(techtreesList.size() > 1) {
|
||||
techtreesPath.second = techtreesList[1];
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<string,string> scenariosPath;
|
||||
vector<string> scenariosList = Config::getInstance().getPathListForType(ptScenarios);
|
||||
if(scenariosList.size() > 0) {
|
||||
scenariosPath.first = scenariosList[0];
|
||||
if(scenariosList.size() > 1) {
|
||||
scenariosPath.second = scenariosList[1];
|
||||
}
|
||||
}
|
||||
|
||||
string fileArchiveExtension = config.getString("FileArchiveExtension","");
|
||||
string fileArchiveExtractCommand = config.getString("FileArchiveExtractCommand","");
|
||||
string fileArchiveExtractCommandParameters = config.getString("FileArchiveExtractCommandParameters","");
|
||||
int32 fileArchiveExtractCommandSuccessResult = config.getInt("FileArchiveExtractCommandSuccessResult","0");
|
||||
|
||||
ftpClientThread = new FTPClientThread(portNumber,serverUrl,
|
||||
mapsPath,tilesetsPath,techtreesPath,scenariosPath,
|
||||
this,fileArchiveExtension,fileArchiveExtractCommand,
|
||||
fileArchiveExtractCommandParameters,fileArchiveExtractCommandSuccessResult);
|
||||
ftpClientThread->start();
|
||||
}
|
||||
}
|
||||
else if(buttonDisconnect.mouseClick(x,y)){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -759,6 +830,7 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms) {
|
|||
ftpMessageBox.mouseMove(x, y);
|
||||
}
|
||||
|
||||
buttonCancelDownloads.mouseMove(x, y);
|
||||
buttonDisconnect.mouseMove(x, y);
|
||||
|
||||
bool editingPlayerName = false;
|
||||
|
@ -925,7 +997,8 @@ void MenuStateConnectedGame::render() {
|
|||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(fileFTPProgressList.size() > 0) {
|
||||
Lang &lang= Lang::getInstance();
|
||||
int yLocation = buttonDisconnect.getY();
|
||||
renderer.renderButton(&buttonCancelDownloads);
|
||||
int yLocation = buttonCancelDownloads.getY() - 20;
|
||||
for(std::map<string,pair<int,string> >::iterator iterMap = fileFTPProgressList.begin();
|
||||
iterMap != fileFTPProgressList.end(); ++iterMap) {
|
||||
string progressLabelPrefix = lang.get("ModDownloading") + " " + iterMap->first + " ";
|
||||
|
|
|
@ -167,6 +167,7 @@ private:
|
|||
vector<pair<string,int32> > factionCRCList;
|
||||
|
||||
std::map<string,pair<int,string> > fileFTPProgressList;
|
||||
GraphicButton buttonCancelDownloads;
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -1513,6 +1513,7 @@ string getFullFileArchiveExtractCommand(string fileArchiveExtractCommand,
|
|||
bool executeShellCommand(string cmd, int expectedResult) {
|
||||
bool result = false;
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"About to run [%s]", cmd.c_str());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("About to run [%s]", cmd.c_str());
|
||||
|
||||
#ifdef WIN32
|
||||
FILE *file = _popen(cmd.c_str(),"r");
|
||||
|
@ -1521,12 +1522,14 @@ bool executeShellCommand(string cmd, int expectedResult) {
|
|||
#endif
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"file = [%p]", file);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("file = [%p]", file);
|
||||
|
||||
if(file != NULL) {
|
||||
char szBuf[4096]="";
|
||||
while(feof(file) == false) {
|
||||
if(fgets( szBuf, 4095, file) != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s",szBuf);
|
||||
}
|
||||
}
|
||||
#ifdef WIN32
|
||||
|
@ -1537,6 +1540,7 @@ bool executeShellCommand(string cmd, int expectedResult) {
|
|||
|
||||
/* Close pipe and print return value. */
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"Process returned %d\n", cmdRet);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Process returned %d\n", cmdRet);
|
||||
result = (expectedResult == IGNORE_CMD_RESULT_VALUE || expectedResult == cmdRet);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -679,11 +679,13 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getTilesetFromServer(pair<st
|
|||
pWantDirListOnly = &wantDirListOnly;
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("FTPClientThread::getTilesetFromServer [%s] remotePath [%s] destFileSaveAs [%s] getFolderContents = %d\n",tileSetName.first.c_str(),remotePath.c_str(),destFileSaveAs.c_str(),getFolderContents);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("FTPClientThread::getTilesetFromServer [%s] remotePath [%s] destFileSaveAs [%s] getFolderContents = %d findArchive = %d\n",tileSetName.first.c_str(),remotePath.c_str(),destFileSaveAs.c_str(),getFolderContents,findArchive);
|
||||
|
||||
pair<FTP_Client_ResultType,string> result = getFileFromServer(ftp_cct_Tileset,
|
||||
tileSetName, remotePath, destFileSaveAs,ftpUser, ftpUserPassword, pWantDirListOnly);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("FTPClientThread::getTilesetFromServer [%s] remotePath [%s] destFileSaveAs [%s] getFolderContents = %d result.first = %d [%s] findArchive = %d\n",tileSetName.first.c_str(),remotePath.c_str(),destFileSaveAs.c_str(),getFolderContents,result.first,result.second.c_str(),findArchive);
|
||||
|
||||
// Extract the archive
|
||||
if(result.first == ftp_crt_SUCCESS) {
|
||||
if(findArchive == true) {
|
||||
|
@ -1154,6 +1156,8 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getFileFromServer(FTP_Clien
|
|||
else {
|
||||
result.first = ftp_crt_SUCCESS;
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] result.first = %d wantDirListOnly = %p\n",__FILE__,__FUNCTION__,__LINE__,result.first,wantDirListOnly);
|
||||
|
||||
if(wantDirListOnly) {
|
||||
if(ftpfile.stream) {
|
||||
fclose(ftpfile.stream);
|
||||
|
@ -1185,6 +1189,8 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getFileFromServer(FTP_Clien
|
|||
ftpfile.stream = NULL;
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] result.first = %d\n",__FILE__,__FUNCTION__,__LINE__,result.first);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue