mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 21:33:59 +02:00
- final bugfix for 3.3.7, playernames got mixed up when first slot was closed. Also fixed editing when typing playername
This commit is contained in:
@@ -456,8 +456,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
}
|
||||
|
||||
if(labelPlayerNames[i].mouseClick(x, y) && ( activeInputLabel != &labelPlayerNames[i] )){
|
||||
if(clientInterface->getGameSettings() != NULL &&
|
||||
i == clientInterface->getGameSettings()->getThisFactionIndex()) {
|
||||
if(i == clientInterface->getPlayerIndex()) {
|
||||
setActiveInputLabel(&labelPlayerNames[i]);
|
||||
}
|
||||
}
|
||||
@@ -1018,7 +1017,7 @@ void MenuStateConnectedGame::update() {
|
||||
if( initialSettingsReceivedFromServer == true &&
|
||||
clientInterface->getIntroDone() == true &&
|
||||
(switchSetupRequestFlagType & ssrft_NetworkPlayerName) == ssrft_NetworkPlayerName) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] getHumanPlayerName() = [%s], clientInterface->getGameSettings()->getThisFactionIndex() = %d\n",__FILE__,__FUNCTION__,__LINE__,getHumanPlayerName().c_str(),clientInterface->getGameSettings()->getThisFactionIndex());
|
||||
//needToSetChangedGameSettings = false;
|
||||
//lastSetChangedGameSettings = time(NULL);
|
||||
clientInterface->sendSwitchSetupRequest("",clientInterface->getPlayerIndex(),-1,-1,getHumanPlayerName(),switchSetupRequestFlagType);
|
||||
@@ -1188,6 +1187,10 @@ void MenuStateConnectedGame::keyDown(char key) {
|
||||
if(text.size() > 1) {
|
||||
text.erase(text.end() - 2);
|
||||
}
|
||||
if(text.size() == 1) {
|
||||
text.erase(text.end() - 1);
|
||||
}
|
||||
|
||||
activeInputLabel->setText(text);
|
||||
|
||||
switchSetupRequestFlagType |= ssrft_NetworkPlayerName;
|
||||
@@ -1257,17 +1260,15 @@ void MenuStateConnectedGame::keyUp(char key) {
|
||||
void MenuStateConnectedGame::setActiveInputLabel(GraphicLabel *newLable) {
|
||||
if(newLable != NULL) {
|
||||
string text= newLable->getText();
|
||||
size_t found;
|
||||
found=text.find_last_of("_");
|
||||
size_t found = text.find_last_of("_");
|
||||
if (found == string::npos) {
|
||||
text=text+"_";
|
||||
text += "_";
|
||||
}
|
||||
newLable->setText(text);
|
||||
}
|
||||
if(activeInputLabel!=NULL && !activeInputLabel->getText().empty()) {
|
||||
if(activeInputLabel != NULL && activeInputLabel->getText().empty() == false) {
|
||||
string text= activeInputLabel->getText();
|
||||
size_t found;
|
||||
found=text.find_last_of("_");
|
||||
size_t found = text.find_last_of("_");
|
||||
if (found != string::npos) {
|
||||
text = text.substr(0,found);
|
||||
}
|
||||
@@ -1283,8 +1284,7 @@ string MenuStateConnectedGame::getHumanPlayerName() {
|
||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||
for(int j=0; j<GameConstants::maxPlayers; ++j) {
|
||||
if( clientInterface != NULL &&
|
||||
clientInterface->getGameSettings() != NULL &&
|
||||
j == clientInterface->getGameSettings()->getThisFactionIndex() &&
|
||||
j == clientInterface->getPlayerIndex() &&
|
||||
labelPlayerNames[j].getText() != "") {
|
||||
result = labelPlayerNames[j].getText();
|
||||
|
||||
|
@@ -813,11 +813,8 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
lastSetChangedGameSettings = time(NULL);;
|
||||
}
|
||||
}
|
||||
else if(labelPlayerNames[i].mouseClick(x, y) && ( activeInputLabel != &labelPlayerNames[i] )){
|
||||
ControlType ct= static_cast<ControlType>(listBoxControls[i].getSelectedItemIndex());
|
||||
if(ct == ctHuman) {
|
||||
setActiveInputLabel(&labelPlayerNames[i]);
|
||||
}
|
||||
else if(labelPlayerNames[i].mouseClick(x, y)) {
|
||||
SetActivePlayerNameEditor();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -825,6 +822,16 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::SetActivePlayerNameEditor() {
|
||||
for(int i = 0; i < mapInfo.players; ++i) {
|
||||
ControlType ct= static_cast<ControlType>(listBoxControls[i].getSelectedItemIndex());
|
||||
if(ct == ctHuman) {
|
||||
setActiveInputLabel(&labelPlayerNames[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::RestoreLastGameSettings() {
|
||||
// Ensure we have set the gamesettings at least once
|
||||
GameSettings gameSettings = loadGameSettingsFromFile("lastCustomGamSettings.mgg");
|
||||
@@ -1207,7 +1214,7 @@ void MenuStateCustomGame::update() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] switchSetupRequests[i]->getSwitchFlags() = %d\n",__FILE__,__FUNCTION__,__LINE__,switchSetupRequests[i]->getSwitchFlags());
|
||||
|
||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] switchSetupRequests[i]->getToFactionIndex() = %d\n",__FILE__,__FUNCTION__,__LINE__,switchSetupRequests[i]->getToFactionIndex());
|
||||
//printf("switchSetupRequests[i]->getSelectedFactionName()=%s\n",switchSetupRequests[i]->getSelectedFactionName().c_str());
|
||||
//printf("switchSetupRequests[i]->getToTeam()=%d\n",switchSetupRequests[i]->getToTeam());
|
||||
|
||||
@@ -1235,6 +1242,7 @@ void MenuStateCustomGame::update() {
|
||||
if(switchSetupRequests[i]->getNetworkPlayerName() != "") {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] i = %d, labelPlayerNames[newFactionIdx].getText() [%s] switchSetupRequests[i]->getNetworkPlayerName() [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,labelPlayerNames[newFactionIdx].getText().c_str(),switchSetupRequests[i]->getNetworkPlayerName().c_str());
|
||||
labelPlayerNames[newFactionIdx].setText(switchSetupRequests[i]->getNetworkPlayerName());
|
||||
SetActivePlayerNameEditor();
|
||||
}
|
||||
}
|
||||
catch(const runtime_error &e) {
|
||||
@@ -1260,6 +1268,7 @@ void MenuStateCustomGame::update() {
|
||||
else {
|
||||
labelPlayerNames[i].setText("");
|
||||
}
|
||||
SetActivePlayerNameEditor();
|
||||
//switchSetupRequests[i]->clearSwitchFlag(ssrft_NetworkPlayerName);
|
||||
}
|
||||
}
|
||||
@@ -1754,11 +1763,10 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
||||
|
||||
gameSettings->setThisFactionIndex(slotIndex);
|
||||
gameSettings->setNetworkPlayerName(slotIndex, getHumanPlayerName(i));
|
||||
labelPlayerNames[i].setText(getHumanPlayerName(i));
|
||||
//labelPlayerNames[i].setText(getHumanPlayerName(i));
|
||||
//SetActivePlayerNameEditor();
|
||||
}
|
||||
|
||||
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,factionFiles[listBoxFactions[i].getSelectedItemIndex()].c_str());
|
||||
gameSettings->setFactionTypeName(slotIndex, factionFiles[listBoxFactions[i].getSelectedItemIndex()]);
|
||||
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] == formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
||||
@@ -1802,6 +1810,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
||||
labelPlayerNames[i].setText("");
|
||||
}
|
||||
}
|
||||
|
||||
// Next save closed slots
|
||||
int closedCount = 0;
|
||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
@@ -2016,6 +2025,8 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
||||
labelPlayerNames[i].setText(gameSettings.getNetworkPlayerName(i));
|
||||
}
|
||||
|
||||
SetActivePlayerNameEditor();
|
||||
|
||||
updateControlers();
|
||||
updateNetworkSlots();
|
||||
needToRepublishToMasterserver = true;
|
||||
@@ -2262,6 +2273,10 @@ void MenuStateCustomGame::keyDown(char key) {
|
||||
if(text.size() > 1) {
|
||||
text.erase(text.end() - 2);
|
||||
}
|
||||
if(text.size() == 1) {
|
||||
text.erase(text.end() - 1);
|
||||
}
|
||||
|
||||
activeInputLabel->setText(text);
|
||||
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
@@ -2390,20 +2405,16 @@ string MenuStateCustomGame::getCurrentMapFile(){
|
||||
void MenuStateCustomGame::setActiveInputLabel(GraphicLabel *newLable) {
|
||||
if(newLable != NULL) {
|
||||
string text= newLable->getText();
|
||||
size_t found;
|
||||
found=text.find_last_of("_");
|
||||
if (found==string::npos)
|
||||
{
|
||||
text=text+"_";
|
||||
size_t found = text.find_last_of("_");
|
||||
if (found == string::npos) {
|
||||
text += "_";
|
||||
}
|
||||
newLable->setText(text);
|
||||
}
|
||||
if(activeInputLabel!=NULL && !activeInputLabel->getText().empty()){
|
||||
if(activeInputLabel != NULL && activeInputLabel->getText().empty() == false) {
|
||||
string text= activeInputLabel->getText();
|
||||
size_t found;
|
||||
found=text.find_last_of("_");
|
||||
if (found!=string::npos)
|
||||
{
|
||||
size_t found = text.find_last_of("_");
|
||||
if (found != string::npos) {
|
||||
text = text.substr(0,found);
|
||||
}
|
||||
activeInputLabel->setText(text);
|
||||
|
@@ -176,6 +176,8 @@ private:
|
||||
|
||||
void RestoreLastGameSettings();
|
||||
void PlayNow();
|
||||
|
||||
void SetActivePlayerNameEditor();
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -460,6 +460,7 @@ void ClientInterface::updateLobby() {
|
||||
|
||||
networkMessageLaunch.buildGameSettings(&gameSettings);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got networkMessageLaunch.getMessageType() = %d\n",__FILE__,__FUNCTION__,__LINE__,networkMessageLaunch.getMessageType());
|
||||
//replace server player by network
|
||||
for(int i= 0; i<gameSettings.getFactionCount(); ++i) {
|
||||
//replace by network
|
||||
@@ -470,6 +471,7 @@ void ClientInterface::updateLobby() {
|
||||
//set the faction index
|
||||
if(gameSettings.getStartLocationIndex(i) == playerIndex) {
|
||||
gameSettings.setThisFactionIndex(i);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] gameSettings.getThisFactionIndex(i) = %d, playerIndex = %d, i = %d\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getThisFactionIndex(),playerIndex,i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -107,6 +107,7 @@ const char vkF9 = -22;
|
||||
const char vkF10 = -23;
|
||||
const char vkF11 = -24;
|
||||
const char vkF12 = -25;
|
||||
const char vkDelete = -26;
|
||||
|
||||
enum WindowStyle{
|
||||
wsFullscreen,
|
||||
|
@@ -904,6 +904,8 @@ bool isKeyDown(int virtualKey) {
|
||||
return keystate[SDLK_RETURN] | keystate[SDLK_KP_ENTER];
|
||||
case vkBack:
|
||||
return keystate[SDLK_BACKSPACE];
|
||||
case vkDelete:
|
||||
return keystate[SDLK_DELETE];
|
||||
default:
|
||||
std::cerr << "isKeyDown called with unknown key.\n";
|
||||
break;
|
||||
|
@@ -620,6 +620,8 @@ char Window::getKey(SDL_keysym keysym,bool skipSpecialKeys) {
|
||||
return vkTab;
|
||||
case SDLK_BACKSPACE:
|
||||
return vkBack;
|
||||
case SDLK_DELETE:
|
||||
return vkDelete;
|
||||
case SDLK_F1:
|
||||
return vkF1;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user