From d52924f214c2192559c08faa7526a3795aafb622 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 21 Sep 2011 08:00:00 +0000 Subject: [PATCH] - added new strings to language file --- source/glest_game/game/commander.cpp | 51 ++++++++++++++++++---- source/glest_game/game/game.cpp | 29 +++++++++--- source/glest_game/menu/menu_state_root.cpp | 2 +- 3 files changed, 65 insertions(+), 17 deletions(-) diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index eb49f091..00369c66 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -696,9 +696,20 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const { world->setThisTeamIndex(newTeam); GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); if(gameNetworkInterface != NULL) { - char szMsg[1024]=""; - sprintf(szMsg,"Player %s switched from team# %d to team# %d.",settings->getNetworkPlayerName(factionIndex).c_str(),oldTeam,newTeam); - gameNetworkInterface->sendTextMessage(szMsg,-1, true, ""); + + Lang &lang= Lang::getInstance(); + const vector languageList = settings->getUniqueNetworkPlayerLanguages(); + for(unsigned int i = 0; i < languageList.size(); ++i) { + char szMsg[1024]=""; + if(lang.hasString("PlayerSwitchedTeam",languageList[i]) == true) { + sprintf(szMsg,lang.get("PlayerSwitchedTeam",languageList[i]).c_str(),settings->getNetworkPlayerName(factionIndex).c_str(),oldTeam,newTeam); + } + else { + sprintf(szMsg,"Player %s switched from team# %d to team# %d.",settings->getNetworkPlayerName(factionIndex).c_str(),oldTeam,newTeam); + } + bool localEcho = lang.isLanguageLocal(languageList[i]); + gameNetworkInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]); + } } } } @@ -774,9 +785,20 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const { world->setThisTeamIndex(vote->newTeam); GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); if(gameNetworkInterface != NULL) { - char szMsg[1024]=""; - sprintf(szMsg,"Player %s switched from team# %d to team# %d.",settings->getNetworkPlayerName(factionIndex).c_str(),oldTeam,vote->newTeam); - gameNetworkInterface->sendTextMessage(szMsg,-1, true, ""); + + Lang &lang= Lang::getInstance(); + const vector languageList = settings->getUniqueNetworkPlayerLanguages(); + for(unsigned int i = 0; i < languageList.size(); ++i) { + char szMsg[1024]=""; + if(lang.hasString("PlayerSwitchedTeam",languageList[i]) == true) { + sprintf(szMsg,lang.get("PlayerSwitchedTeam",languageList[i]).c_str(),settings->getNetworkPlayerName(factionIndex).c_str(),oldTeam,vote->newTeam); + } + else { + sprintf(szMsg,"Player %s switched from team# %d to team# %d.",settings->getNetworkPlayerName(factionIndex).c_str(),oldTeam,vote->newTeam); + } + bool localEcho = lang.isLanguageLocal(languageList[i]); + gameNetworkInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]); + } } } } @@ -788,9 +810,20 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const { GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); if(gameNetworkInterface != NULL) { - char szMsg[1024]=""; - sprintf(szMsg,"Player %s was denied the request to switch from team# %d to team# %d.",settings->getNetworkPlayerName(factionIndex).c_str(),oldTeam,vote->newTeam); - gameNetworkInterface->sendTextMessage(szMsg,-1, true, ""); + + Lang &lang= Lang::getInstance(); + const vector languageList = settings->getUniqueNetworkPlayerLanguages(); + for(unsigned int i = 0; i < languageList.size(); ++i) { + char szMsg[1024]=""; + if(lang.hasString("PlayerSwitchedTeamDenied",languageList[i]) == true) { + sprintf(szMsg,lang.get("PlayerSwitchedTeamDenied",languageList[i]).c_str(),settings->getNetworkPlayerName(factionIndex).c_str(),oldTeam,vote->newTeam); + } + else { + sprintf(szMsg,"Player %s was denied the request to switch from team# %d to team# %d.",settings->getNetworkPlayerName(factionIndex).c_str(),oldTeam,vote->newTeam); + } + bool localEcho = lang.isLanguageLocal(languageList[i]); + gameNetworkInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]); + } } } } diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 70b98fbc..9ac4d33d 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -938,10 +938,17 @@ void Game::update() { if(world.getThisFaction()->getFirstSwitchTeamVote() != NULL) { const SwitchTeamVote *vote = world.getThisFaction()->getFirstSwitchTeamVote(); GameSettings *settings = world.getGameSettingsPtr(); - char szBuf[1024]=""; - sprintf(szBuf,"Allow player [%s] to join your team\n(changing from team# %d to team# %d)?",settings->getNetworkPlayerName(vote->factionIndex).c_str(),vote->oldTeam,vote->newTeam); - Lang &lang= Lang::getInstance(); + Lang &lang= Lang::getInstance(); + + char szBuf[1024]=""; + if(lang.hasString("AllowPlayerJoinTeam") == true) { + sprintf(szBuf,lang.get("AllowPlayerJoinTeam").c_str(),settings->getNetworkPlayerName(vote->factionIndex).c_str(),vote->oldTeam,vote->newTeam); + } + else { + sprintf(szBuf,"Allow player [%s] to join your team\n(changing from team# %d to team# %d)?",settings->getNetworkPlayerName(vote->factionIndex).c_str(),vote->oldTeam,vote->newTeam); + } + switchTeamConfirmMessageBox.setText(szBuf); switchTeamConfirmMessageBox.init(lang.get("Yes"), lang.get("No")); switchTeamConfirmMessageBox.setEnabled(true); @@ -1260,6 +1267,8 @@ void Game::mouseDownLeft(int x, int y) { showMessageBox(Lang::getInstance().get("ExitGame?"), "", true); } else if(result.first == joinTeamPopupMenuIndex) { + + Lang &lang= Lang::getInstance(); switchTeamIndexMap.clear(); std::map uniqueTeamNumbersUsed; std::vector menuItems; @@ -1272,23 +1281,29 @@ void Game::mouseDownLeft(int x, int y) { if(world.getThisFaction()->getIndex() != faction->getIndex() && world.getThisFaction()->getTeam() != faction->getTeam()) { char szBuf[1024]=""; - sprintf(szBuf,"Join player #%d - %s on Team: %d",faction->getIndex(),this->gameSettings.getNetworkPlayerName(i).c_str(),faction->getTeam()); + if(lang.hasString("JoinPlayerTeam") == true) { + sprintf(szBuf,lang.get("JoinPlayerTeam").c_str(),faction->getIndex(),this->gameSettings.getNetworkPlayerName(i).c_str(),faction->getTeam()); + } + else { + sprintf(szBuf,"Join player #%d - %s on Team: %d",faction->getIndex(),this->gameSettings.getNetworkPlayerName(i).c_str(),faction->getTeam()); + } menuItems.push_back(szBuf); switchTeamIndexMap[menuItems.size()-1] = faction->getTeam(); } } + if(uniqueTeamNumbersUsed.size() < 8) { - menuItems.push_back("Create New Team"); + menuItems.push_back(lang.get("CreateNewTeam")); switchTeamIndexMap[menuItems.size()-1] = CREATE_NEW_TEAM; } - menuItems.push_back("Cancel"); + menuItems.push_back(lang.get("Cancel")); switchTeamIndexMap[menuItems.size()-1] = CANCEL_SWITCH_TEAM; popupMenuSwitchTeams.setW(400); popupMenuSwitchTeams.setH(400); - popupMenuSwitchTeams.init("Switch Teams",menuItems); + popupMenuSwitchTeams.init(lang.get("SwitchTeams"),menuItems); popupMenuSwitchTeams.setEnabled(true); popupMenuSwitchTeams.setVisible(true); } diff --git a/source/glest_game/menu/menu_state_root.cpp b/source/glest_game/menu/menu_state_root.cpp index a4340c8d..d99f33f9 100644 --- a/source/glest_game/menu/menu_state_root.cpp +++ b/source/glest_game/menu/menu_state_root.cpp @@ -100,7 +100,7 @@ void MenuStateRoot::mouseClick(int x, int y, MouseButton mouseButton){ if(popupMenu.mouseClick(x, y)) { std::pair result = popupMenu.mouseClickedMenuItem(x, y); - printf("In popup callback menuItemSelected [%s] menuIndexSelected = %d\n",result.second.c_str(),result.first); + //printf("In popup callback menuItemSelected [%s] menuIndexSelected = %d\n",result.second.c_str(),result.first); } else if(mainMessageBox.getEnabled() == false && buttonNewGame.mouseClick(x, y)){ soundRenderer.playFx(coreData.getClickSoundB());