- attempt to fix client timeout issues in client connected menu when downloading files

- in lobby hold SHIFT + a letter when clicking a map, tileset or techtree and it jumps to the first found item of that letter
This commit is contained in:
Mark Vejvoda 2012-10-15 07:44:44 +00:00
parent b337b069eb
commit 052fd3373c
6 changed files with 99 additions and 21 deletions

View File

@ -450,23 +450,50 @@ bool GraphicListBox::mouseMove(int x, int y){
graphButton2.mouseMove(x, y);
}
bool GraphicListBox::mouseClick(int x, int y){
bool GraphicListBox::mouseClick(int x, int y,string advanceToItemStartingWith) {
if(this->getVisible() == false) {
return false;
}
if(!items.empty()){
if(!items.empty()) {
bool b1= graphButton1.mouseClick(x, y);
bool b2= graphButton2.mouseClick(x, y);
if(b1){
selectedItemIndex--;
if(b1) {
bool bFound = false;
if(advanceToItemStartingWith != "") {
for(unsigned int i = 0; i < items.size(); ++i) {
string item = items[i];
if(StartsWith(toLower(item),toLower(advanceToItemStartingWith)) == true) {
bFound = true;
selectedItemIndex = i;
break;
}
}
}
if(bFound == false) {
selectedItemIndex--;
}
if(selectedItemIndex<0){
selectedItemIndex=items.size()-1;
}
}
else if(b2){
selectedItemIndex++;
else if(b2) {
bool bFound = false;
if(advanceToItemStartingWith != "") {
for(unsigned int i = 0; i < items.size(); ++i) {
string item = items[i];
//printf("Trying to match [%s] with item [%s]\n",advanceToItemStartingWith.c_str(),item.c_str());
if(StartsWith(toLower(item),toLower(advanceToItemStartingWith)) == true) {
bFound = true;
selectedItemIndex = i;
break;
}
}
}
if(bFound == false) {
selectedItemIndex++;
}
if(selectedItemIndex>=items.size()){
selectedItemIndex=0;
}

View File

@ -249,7 +249,7 @@ public:
virtual void setY(int y);
virtual bool mouseMove(int x, int y);
virtual bool mouseClick(int x, int y);
virtual bool mouseClick(int x, int y, string advanceToItemStartingWith="");
};
// ===========================================================

View File

@ -2052,17 +2052,21 @@ void MenuStateConnectedGame::update() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
clientInterface->updateLobby();
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
if(fileFTPProgressList.empty() == true) {
Lang &lang= Lang::getInstance();
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
for(unsigned int i = 0; i < languageList.size(); ++i) {
//string playerNameStr = getHumanPlayerName();
clientInterface->sendTextMessage(lang.get("ConnectionTimedOut",languageList[i]),-1,false,languageList[i]);
sleep(1);
clientInterface->close();
if(clientInterface->isConnected() &&
pingCount >= 3 && clientInterface->getLastPingLag() >= (GameConstants::networkPingInterval * 3)) {
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
if(fileFTPProgressList.empty() == true) {
Lang &lang= Lang::getInstance();
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
for(unsigned int i = 0; i < languageList.size(); ++i) {
//string playerNameStr = getHumanPlayerName();
clientInterface->sendTextMessage(lang.get("ConnectionTimedOut",languageList[i]),-1,false,languageList[i]);
sleep(1);
clientInterface->close();
}
}
}
}
}
pingCount++;

View File

@ -1026,7 +1026,13 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
}
}
else {
if(activeInputLabel!=NULL && !(activeInputLabel->mouseClick(x,y))){
string advanceToItemStartingWith = "";
if(Shared::Platform::Window::isKeyStateModPressed(KMOD_SHIFT) == true) {
wchar_t lastKey = Shared::Platform::Window::extractLastKeyPressed();
//printf("lastKey = %d [%c]\n",lastKey,lastKey);
advanceToItemStartingWith = lastKey;
}
if(activeInputLabel!=NULL && !(activeInputLabel->mouseClick(x,y))){
setActiveInputLabel(NULL);
}
if(buttonReturn.mouseClick(x,y) || serverInitError == true) {
@ -1054,7 +1060,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
else if(buttonRestoreLastSettings.mouseClick(x,y) && buttonRestoreLastSettings.getEnabled()) {
RestoreLastGameSettings();
}
else if(listBoxMap.mouseClick(x, y)){
else if(listBoxMap.mouseClick(x, y,advanceToItemStartingWith)){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str());
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
@ -1169,7 +1175,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
else if (listBoxAdvanced.mouseClick(x, y)) {
//TODO
}
else if(listBoxTileset.mouseClick(x, y)) {
else if(listBoxTileset.mouseClick(x, y,advanceToItemStartingWith)) {
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
@ -1204,7 +1210,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
lastSetChangedGameSettings = time(NULL);
}
}
else if(listBoxTechTree.mouseClick(x, y)){
else if(listBoxTechTree.mouseClick(x, y,advanceToItemStartingWith)){
reloadFactions(false,(checkBoxScenario.getValue() == true ? scenarioFiles[listBoxScenario.getSelectedItemIndex()] : ""));
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));

View File

@ -138,6 +138,7 @@ public:
static void setIsFullScreen(bool value) { isFullScreen = value; }
//static SDL_keysym getKeystate() { return keystate; }
static bool isKeyStateModPressed(int mod);
static wchar_t extractLastKeyPressed();
Window();
virtual ~Window();

View File

@ -1131,4 +1131,44 @@ bool Window::isKeyStateModPressed(int mod) {
return false;
}
wchar_t Window::extractLastKeyPressed() {
wchar_t c = SDLK_UNKNOWN;
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
if(keystate.unicode > 0) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,keystate.unicode,keystate.mod);
c = keystate.unicode;
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
// c = SDLKey(c & 0xFF);
// }
//c = toupper(c);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d] c = [%lc]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF),c);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d] c = [%lc]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF),c);
}
if(c == SDLK_UNKNOWN) {
c = keystate.sym;
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d][%lc]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
//c = (SDLKey)(c & 0xFF);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
string pressKeyName = SDL_GetKeyName((SDLKey)c);
string inputKeyName = SDL_GetKeyName(keystate.sym);
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
// c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str());
return c;
}
}}//end namespace