mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 20:22:31 +01:00
fixed name editing and cleanup
This commit is contained in:
parent
2cecb2c3a0
commit
21760072a4
@ -234,43 +234,6 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||||||
|
|
||||||
// Network Frame Period
|
// Network Frame Period
|
||||||
xoffset=0;
|
xoffset=0;
|
||||||
labelNetworkFramePeriod.registerGraphicComponent(containerName,"labelNetworkFramePeriod");
|
|
||||||
labelNetworkFramePeriod.init(xoffset+170, networkHeadPos, 80);
|
|
||||||
labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod"));
|
|
||||||
|
|
||||||
listBoxNetworkFramePeriod.registerGraphicComponent(containerName,"listBoxNetworkFramePeriod");
|
|
||||||
listBoxNetworkFramePeriod.init(xoffset+170, networkPos, 80);
|
|
||||||
listBoxNetworkFramePeriod.pushBackItem("10");
|
|
||||||
listBoxNetworkFramePeriod.pushBackItem("20");
|
|
||||||
listBoxNetworkFramePeriod.pushBackItem("30");
|
|
||||||
listBoxNetworkFramePeriod.pushBackItem("40");
|
|
||||||
listBoxNetworkFramePeriod.setSelectedItem("20");
|
|
||||||
listBoxNetworkFramePeriod.setEditable(false);
|
|
||||||
|
|
||||||
// Network Frame Period
|
|
||||||
labelNetworkPauseGameForLaggedClients.registerGraphicComponent(containerName,"labelNetworkPauseGameForLaggedClients");
|
|
||||||
labelNetworkPauseGameForLaggedClients.init(xoffset+420, networkHeadPos, 80);
|
|
||||||
labelNetworkPauseGameForLaggedClients.setText(lang.get("NetworkPauseGameForLaggedClients"));
|
|
||||||
|
|
||||||
listBoxNetworkPauseGameForLaggedClients.registerGraphicComponent(containerName,"listBoxNetworkPauseGameForLaggedClients");
|
|
||||||
listBoxNetworkPauseGameForLaggedClients.init(xoffset+420, networkPos, 80);
|
|
||||||
listBoxNetworkPauseGameForLaggedClients.pushBackItem(lang.get("No"));
|
|
||||||
listBoxNetworkPauseGameForLaggedClients.pushBackItem(lang.get("Yes"));
|
|
||||||
listBoxNetworkPauseGameForLaggedClients.setSelectedItem(lang.get("No"));
|
|
||||||
listBoxNetworkPauseGameForLaggedClients.setEditable(false);
|
|
||||||
|
|
||||||
|
|
||||||
// Enable Server Controlled AI
|
|
||||||
labelEnableServerControlledAI.registerGraphicComponent(containerName,"labelEnableServerControlledAI");
|
|
||||||
labelEnableServerControlledAI.init(xoffset+640, networkHeadPos, 80);
|
|
||||||
labelEnableServerControlledAI.setText(lang.get("EnableServerControlledAI"));
|
|
||||||
|
|
||||||
listBoxEnableServerControlledAI.registerGraphicComponent(containerName,"listBoxEnableServerControlledAI");
|
|
||||||
listBoxEnableServerControlledAI.init(xoffset+640, networkPos, 80);
|
|
||||||
listBoxEnableServerControlledAI.pushBackItem(lang.get("Yes"));
|
|
||||||
listBoxEnableServerControlledAI.pushBackItem(lang.get("No"));
|
|
||||||
listBoxEnableServerControlledAI.setSelectedItemIndex(0);
|
|
||||||
listBoxEnableServerControlledAI.setEditable(false);
|
|
||||||
|
|
||||||
xoffset=70;
|
xoffset=70;
|
||||||
//map listBox
|
//map listBox
|
||||||
@ -782,6 +745,10 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
|
|
||||||
if (initialSettingsReceivedFromServer == false) return;
|
if (initialSettingsReceivedFromServer == false) return;
|
||||||
|
|
||||||
|
if(activeInputLabel!=NULL && !(activeInputLabel->mouseClick(x,y))){
|
||||||
|
setActiveInputLabel(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
// Only allow changes after we get game settings from the server
|
// Only allow changes after we get game settings from the server
|
||||||
if(clientInterface->isConnected() == true) {
|
if(clientInterface->isConnected() == true) {
|
||||||
int myCurrentIndex= -1;
|
int myCurrentIndex= -1;
|
||||||
@ -1205,32 +1172,6 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
|||||||
// lastSetChangedGameSettings = time(NULL);
|
// lastSetChangedGameSettings = time(NULL);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//broadCastGameSettingsToMasterserver();
|
|
||||||
needToBroadcastServerSettings=true;
|
|
||||||
broadcastServerSettingsDelayTimer=time(NULL);
|
|
||||||
}
|
|
||||||
// else if(listBoxPublishServer.mouseClick(x, y) && listBoxPublishServer.getEditable()) {
|
|
||||||
// MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
// needToRepublishToMasterserver = true;
|
|
||||||
// soundRenderer.playFx(coreData.getClickSoundC());
|
|
||||||
//
|
|
||||||
// ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
|
||||||
// serverInterface->setPublishEnabled(listBoxPublishServer.getSelectedItemIndex() == 0);
|
|
||||||
// }
|
|
||||||
else if(listBoxNetworkPauseGameForLaggedClients.mouseClick(x, y)) {
|
|
||||||
// MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
//
|
|
||||||
// if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
// needToRepublishToMasterserver = true;
|
|
||||||
// }
|
|
||||||
// if(hasNetworkGameSettings() == true)
|
|
||||||
// {
|
|
||||||
// needToSetChangedGameSettings = true;
|
|
||||||
// lastSetChangedGameSettings = time(NULL);
|
|
||||||
// }
|
|
||||||
|
|
||||||
soundRenderer.playFx(coreData.getClickSoundC());
|
|
||||||
|
|
||||||
//broadCastGameSettingsToMasterserver();
|
//broadCastGameSettingsToMasterserver();
|
||||||
needToBroadcastServerSettings=true;
|
needToBroadcastServerSettings=true;
|
||||||
broadcastServerSettingsDelayTimer=time(NULL);
|
broadcastServerSettingsDelayTimer=time(NULL);
|
||||||
@ -1262,94 +1203,12 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
|||||||
listBoxControls[i].mouseClick(x, y);
|
listBoxControls[i].mouseClick(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
//look for human players
|
|
||||||
// int humanIndex1= -1;
|
|
||||||
// int humanIndex2= -1;
|
|
||||||
// for(int j=0; j<GameConstants::maxPlayers; ++j) {
|
|
||||||
// ControlType ct= static_cast<ControlType>(listBoxControls[j].getSelectedItemIndex());
|
|
||||||
// if(ct == ctHuman) {
|
|
||||||
// if(humanIndex1 == -1) {
|
|
||||||
// humanIndex1= j;
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// humanIndex2= j;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] humanIndex1 = %d, humanIndex2 = %d\n",__FILE__,__FUNCTION__,__LINE__,humanIndex1,humanIndex2);
|
|
||||||
//
|
|
||||||
// //no human
|
|
||||||
// if(humanIndex1 == -1 && humanIndex2 == -1) {
|
|
||||||
// listBoxControls[i].setSelectedItemIndex(ctHuman);
|
|
||||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] i = %d, labelPlayerNames[i].getText() [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,labelPlayerNames[i].getText().c_str());
|
|
||||||
// }
|
|
||||||
// //2 humans
|
|
||||||
// else if(humanIndex1 != -1 && humanIndex2 != -1) {
|
|
||||||
// int closeSlotIndex = (humanIndex1 == i ? humanIndex2: humanIndex1);
|
|
||||||
// int humanSlotIndex = (closeSlotIndex == humanIndex1 ? humanIndex2 : humanIndex1);
|
|
||||||
//
|
|
||||||
// string origPlayName = labelPlayerNames[closeSlotIndex].getText();
|
|
||||||
//
|
|
||||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] closeSlotIndex = %d, origPlayName [%s]\n",__FILE__,__FUNCTION__,__LINE__,closeSlotIndex,origPlayName.c_str());
|
|
||||||
//
|
|
||||||
// listBoxControls[closeSlotIndex].setSelectedItemIndex(ctClosed);
|
|
||||||
// labelPlayerNames[humanSlotIndex].setText((origPlayName != "" ? origPlayName : getHumanPlayerName()));
|
|
||||||
// }
|
|
||||||
// updateNetworkSlots();
|
|
||||||
//
|
|
||||||
// if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
// needToRepublishToMasterserver = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(hasNetworkGameSettings() == true) {
|
|
||||||
// needToSetChangedGameSettings = true;
|
|
||||||
// lastSetChangedGameSettings = time(NULL);
|
|
||||||
// }
|
|
||||||
updateResourceMultiplier(i);
|
updateResourceMultiplier(i);
|
||||||
|
|
||||||
//broadCastGameSettingsToMasterserver();
|
//broadCastGameSettingsToMasterserver();
|
||||||
needToBroadcastServerSettings=true;
|
needToBroadcastServerSettings=true;
|
||||||
broadcastServerSettingsDelayTimer=time(NULL);
|
broadcastServerSettingsDelayTimer=time(NULL);
|
||||||
}
|
}
|
||||||
// else if(buttonClearBlockedPlayers.mouseClick(x, y)) {
|
|
||||||
// ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
|
||||||
// if(serverInterface != NULL) {
|
|
||||||
// ServerSocket *serverSocket = serverInterface->getServerSocket();
|
|
||||||
// if(serverSocket != NULL) {
|
|
||||||
// serverSocket->clearBlockedIPAddress();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else if(buttonBlockPlayers[i].mouseClick(x, y)) {
|
|
||||||
// ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
|
||||||
// if(serverInterface != NULL) {
|
|
||||||
// if(serverInterface->getSlot(i) != NULL &&
|
|
||||||
// serverInterface->getSlot(i)->isConnected()) {
|
|
||||||
//
|
|
||||||
// ServerSocket *serverSocket = serverInterface->getServerSocket();
|
|
||||||
// if(serverSocket != NULL) {
|
|
||||||
// serverSocket->addIPAddressToBlockedList(serverInterface->getSlot(i)->getIpAddress());
|
|
||||||
//
|
|
||||||
// Lang &lang= Lang::getInstance();
|
|
||||||
// const vector<string> languageList = serverInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
|
||||||
// for(unsigned int j = 0; j < languageList.size(); ++j) {
|
|
||||||
// char szMsg[1024]="";
|
|
||||||
// if(lang.hasString("BlockPlayerServerMsg",languageList[j]) == true) {
|
|
||||||
// sprintf(szMsg,lang.get("BlockPlayerServerMsg",languageList[j]).c_str(),serverInterface->getSlot(i)->getIpAddress().c_str());
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// sprintf(szMsg,"The server has temporarily blocked IP Address [%s] from this game.",serverInterface->getSlot(i)->getIpAddress().c_str());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// serverInterface->sendTextMessage(szMsg,-1, true,languageList[j]);
|
|
||||||
// }
|
|
||||||
// sleep(1);
|
|
||||||
// serverInterface->getSlot(i)->close();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
else if(clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()) != i &&
|
else if(clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()) != i &&
|
||||||
listBoxFactions[i].mouseClick(x, y)) {
|
listBoxFactions[i].mouseClick(x, y)) {
|
||||||
// Disallow CPU players to be observers
|
// Disallow CPU players to be observers
|
||||||
@ -1358,17 +1217,6 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
|||||||
listBoxControls[i].getSelectedItemIndex() == ctCpuUltra || listBoxControls[i].getSelectedItemIndex() == ctCpuMega)) {
|
listBoxControls[i].getSelectedItemIndex() == ctCpuUltra || listBoxControls[i].getSelectedItemIndex() == ctCpuMega)) {
|
||||||
listBoxFactions[i].setSelectedItemIndex(0);
|
listBoxFactions[i].setSelectedItemIndex(0);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
|
|
||||||
// if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
// needToRepublishToMasterserver = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(hasNetworkGameSettings() == true)
|
|
||||||
// {
|
|
||||||
// needToSetChangedGameSettings = true;
|
|
||||||
// lastSetChangedGameSettings = time(NULL);
|
|
||||||
// }
|
|
||||||
|
|
||||||
//broadCastGameSettingsToMasterserver();
|
//broadCastGameSettingsToMasterserver();
|
||||||
needToBroadcastServerSettings=true;
|
needToBroadcastServerSettings=true;
|
||||||
@ -1385,57 +1233,13 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
|||||||
//lastSelectedTeamIndex[i] = -1;
|
//lastSelectedTeamIndex[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
// needToRepublishToMasterserver = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(hasNetworkGameSettings() == true)
|
|
||||||
// {
|
|
||||||
// needToSetChangedGameSettings = true;
|
|
||||||
// lastSetChangedGameSettings = time(NULL);;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//broadCastGameSettingsToMasterserver();
|
//broadCastGameSettingsToMasterserver();
|
||||||
needToBroadcastServerSettings=true;
|
needToBroadcastServerSettings=true;
|
||||||
broadcastServerSettingsDelayTimer=time(NULL);
|
broadcastServerSettingsDelayTimer=time(NULL);
|
||||||
}
|
}
|
||||||
// else if(labelPlayerNames[i].mouseClick(x, y)) {
|
|
||||||
// SetActivePlayerNameEditor();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// if(hasNetworkGameSettings() == true && listBoxPlayerStatus.mouseClick(x,y)) {
|
|
||||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
//
|
|
||||||
// soundRenderer.playFx(coreData.getClickSoundC());
|
|
||||||
// if(getNetworkPlayerStatus()==npst_PickSettings)
|
|
||||||
// {
|
|
||||||
// listBoxPlayerStatus.setTextColor(Vec3f(1.0f,0.0f,0.0f));
|
|
||||||
// listBoxPlayerStatus.setLighted(true);
|
|
||||||
// }
|
|
||||||
// else if(getNetworkPlayerStatus()==npst_BeRightBack)
|
|
||||||
// {
|
|
||||||
// listBoxPlayerStatus.setTextColor(Vec3f(1.0f,1.0f,0.0f));
|
|
||||||
// listBoxPlayerStatus.setLighted(true);
|
|
||||||
// }
|
|
||||||
// else if(getNetworkPlayerStatus()==npst_Ready)
|
|
||||||
// {
|
|
||||||
// listBoxPlayerStatus.setTextColor(Vec3f(0.0f,1.0f,0.0f));
|
|
||||||
// listBoxPlayerStatus.setLighted(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
//
|
|
||||||
// if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
// needToRepublishToMasterserver = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(hasNetworkGameSettings() == true) {
|
|
||||||
// needToSetChangedGameSettings = true;
|
|
||||||
// lastSetChangedGameSettings = time(NULL);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
catch(const std::exception &ex) {
|
catch(const std::exception &ex) {
|
||||||
char szBuf[4096]="";
|
char szBuf[4096]="";
|
||||||
@ -1716,7 +1520,6 @@ void MenuStateConnectedGame::loadGameSettings(GameSettings *gameSettings) {
|
|||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
gameSettings->setEnableServerControlledAI(config.getBool("ServerControlledAI","true"));
|
gameSettings->setEnableServerControlledAI(config.getBool("ServerControlledAI","true"));
|
||||||
gameSettings->setNetworkFramePeriod(config.getInt("NetworkSendFrameCount","20"));
|
gameSettings->setNetworkFramePeriod(config.getInt("NetworkSendFrameCount","20"));
|
||||||
gameSettings->setNetworkPauseGameForLaggedClients(((listBoxNetworkPauseGameForLaggedClients.getSelectedItemIndex() != 0)));
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true) {
|
if(hasNetworkGameSettings() == true) {
|
||||||
if( gameSettings->getTileset() != "") {
|
if( gameSettings->getTileset() != "") {
|
||||||
@ -1817,21 +1620,12 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms) {
|
|||||||
buttonCancelDownloads.mouseMove(x, y);
|
buttonCancelDownloads.mouseMove(x, y);
|
||||||
buttonDisconnect.mouseMove(x, y);
|
buttonDisconnect.mouseMove(x, y);
|
||||||
|
|
||||||
bool editingPlayerName = false;
|
|
||||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||||
listBoxControls[i].mouseMove(x, y);
|
listBoxControls[i].mouseMove(x, y);
|
||||||
listBoxFactions[i].mouseMove(x, y);
|
listBoxFactions[i].mouseMove(x, y);
|
||||||
listBoxTeams[i].mouseMove(x, y);
|
listBoxTeams[i].mouseMove(x, y);
|
||||||
grabSlotButton[i].mouseMove(x, y);
|
grabSlotButton[i].mouseMove(x, y);
|
||||||
|
|
||||||
if(labelPlayerNames[i].mouseMove(x, y) == true) {
|
|
||||||
editingPlayerName = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if(editingPlayerName == false) {
|
|
||||||
setActiveInputLabel(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
listBoxMap.mouseMove(x, y);
|
listBoxMap.mouseMove(x, y);
|
||||||
listBoxFogOfWar.mouseMove(x, y);
|
listBoxFogOfWar.mouseMove(x, y);
|
||||||
@ -1989,13 +1783,6 @@ void MenuStateConnectedGame::render() {
|
|||||||
renderer.renderListBox(&listBoxEnableObserverMode);
|
renderer.renderListBox(&listBoxEnableObserverMode);
|
||||||
renderer.renderListBox(&listBoxPathFinderType);
|
renderer.renderListBox(&listBoxPathFinderType);
|
||||||
|
|
||||||
renderer.renderListBox(&listBoxEnableServerControlledAI);
|
|
||||||
renderer.renderLabel(&labelEnableServerControlledAI);
|
|
||||||
renderer.renderLabel(&labelNetworkFramePeriod);
|
|
||||||
renderer.renderListBox(&listBoxNetworkFramePeriod);
|
|
||||||
renderer.renderLabel(&labelNetworkPauseGameForLaggedClients);
|
|
||||||
renderer.renderListBox(&listBoxNetworkPauseGameForLaggedClients);
|
|
||||||
|
|
||||||
renderer.renderListBox(&listBoxEnableSwitchTeamMode);
|
renderer.renderListBox(&listBoxEnableSwitchTeamMode);
|
||||||
renderer.renderListBox(&listBoxAISwitchTeamAcceptPercent);
|
renderer.renderListBox(&listBoxAISwitchTeamAcceptPercent);
|
||||||
|
|
||||||
@ -2091,7 +1878,6 @@ void MenuStateConnectedGame::update() {
|
|||||||
listBoxFogOfWar.setEditable(isMasterserverAdmin());
|
listBoxFogOfWar.setEditable(isMasterserverAdmin());
|
||||||
listBoxEnableObserverMode.setEditable(isMasterserverAdmin());
|
listBoxEnableObserverMode.setEditable(isMasterserverAdmin());
|
||||||
listBoxAllowObservers.setEditable(isMasterserverAdmin());
|
listBoxAllowObservers.setEditable(isMasterserverAdmin());
|
||||||
listBoxNetworkPauseGameForLaggedClients.setEditable(isMasterserverAdmin());
|
|
||||||
|
|
||||||
if(isMasterserverAdmin() == true) {
|
if(isMasterserverAdmin() == true) {
|
||||||
for(unsigned int i = 0; i < GameConstants::maxPlayers; ++i) {
|
for(unsigned int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||||
@ -2822,18 +2608,6 @@ void MenuStateConnectedGame::update() {
|
|||||||
else {
|
else {
|
||||||
listBoxEnableObserverMode.setSelectedItemIndex(1);
|
listBoxEnableObserverMode.setSelectedItemIndex(1);
|
||||||
}
|
}
|
||||||
if(gameSettings->getEnableServerControlledAI()) {
|
|
||||||
listBoxEnableServerControlledAI.setSelectedItemIndex(0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
listBoxEnableServerControlledAI.setSelectedItemIndex(1);
|
|
||||||
}
|
|
||||||
if(gameSettings->getNetworkPauseGameForLaggedClients()) {
|
|
||||||
listBoxNetworkPauseGameForLaggedClients.setSelectedItemIndex(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
listBoxNetworkPauseGameForLaggedClients.setSelectedItemIndex(0);
|
|
||||||
}
|
|
||||||
if(gameSettings->getPathFinderType() == pfBasic) {
|
if(gameSettings->getPathFinderType() == pfBasic) {
|
||||||
listBoxPathFinderType.setSelectedItemIndex(0);
|
listBoxPathFinderType.setSelectedItemIndex(0);
|
||||||
}
|
}
|
||||||
@ -2841,8 +2615,6 @@ void MenuStateConnectedGame::update() {
|
|||||||
listBoxPathFinderType.setSelectedItemIndex(1);
|
listBoxPathFinderType.setSelectedItemIndex(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
listBoxNetworkFramePeriod.setSelectedItem(intToStr(gameSettings->getNetworkFramePeriod()),false);
|
|
||||||
|
|
||||||
// Control
|
// Control
|
||||||
for(int i=0; i<GameConstants::maxPlayers; ++i) {
|
for(int i=0; i<GameConstants::maxPlayers; ++i) {
|
||||||
listBoxControls[i].setSelectedItemIndex(ctClosed);
|
listBoxControls[i].setSelectedItemIndex(ctClosed);
|
||||||
@ -3247,6 +3019,12 @@ void MenuStateConnectedGame::keyPress(SDL_KeyboardEvent c) {
|
|||||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||||
if(&labelPlayerNames[i] == activeInputLabel) {
|
if(&labelPlayerNames[i] == activeInputLabel) {
|
||||||
SDLKey key = extractKeyPressed(c);
|
SDLKey key = extractKeyPressed(c);
|
||||||
|
if(isKeyPressed(SDLK_ESCAPE,c,false) == true || isKeyPressed(SDLK_RETURN,c,false) == true )
|
||||||
|
{
|
||||||
|
setActiveInputLabel(NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//if((c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z') ||
|
//if((c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z') ||
|
||||||
// (c=='-') || (c=='(') || (c==')')) {
|
// (c=='-') || (c=='(') || (c==')')) {
|
||||||
if(isAllowedInputTextKey(key)) {
|
if(isAllowedInputTextKey(key)) {
|
||||||
@ -3295,6 +3073,9 @@ void MenuStateConnectedGame::keyUp(SDL_KeyboardEvent key) {
|
|||||||
|
|
||||||
void MenuStateConnectedGame::setActiveInputLabel(GraphicLabel *newLable) {
|
void MenuStateConnectedGame::setActiveInputLabel(GraphicLabel *newLable) {
|
||||||
if(newLable != NULL) {
|
if(newLable != NULL) {
|
||||||
|
if( newLable==activeInputLabel){
|
||||||
|
return;
|
||||||
|
}
|
||||||
string text= newLable->getText();
|
string text= newLable->getText();
|
||||||
size_t found = text.find_last_of("_");
|
size_t found = text.find_last_of("_");
|
||||||
if (found == string::npos) {
|
if (found == string::npos) {
|
||||||
|
@ -56,13 +56,13 @@ private:
|
|||||||
|
|
||||||
GraphicLabel labelEnableObserverMode;
|
GraphicLabel labelEnableObserverMode;
|
||||||
GraphicListBox listBoxEnableObserverMode;
|
GraphicListBox listBoxEnableObserverMode;
|
||||||
GraphicLabel labelEnableServerControlledAI;
|
//GraphicLabel labelEnableServerControlledAI;
|
||||||
GraphicListBox listBoxEnableServerControlledAI;
|
//GraphicListBox listBoxEnableServerControlledAI;
|
||||||
GraphicLabel labelNetworkPauseGameForLaggedClients;
|
//GraphicLabel labelNetworkPauseGameForLaggedClients;
|
||||||
GraphicListBox listBoxNetworkPauseGameForLaggedClients;
|
//GraphicListBox listBoxNetworkPauseGameForLaggedClients;
|
||||||
|
|
||||||
GraphicListBox listBoxNetworkFramePeriod;
|
//GraphicListBox listBoxNetworkFramePeriod;
|
||||||
GraphicLabel labelNetworkFramePeriod;
|
//GraphicLabel labelNetworkFramePeriod;
|
||||||
|
|
||||||
GraphicLabel labelPathFinderType;
|
GraphicLabel labelPathFinderType;
|
||||||
GraphicListBox listBoxPathFinderType;
|
GraphicListBox listBoxPathFinderType;
|
||||||
|
@ -745,379 +745,380 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(activeInputLabel!=NULL && !(activeInputLabel->mouseClick(x,y)))
|
|
||||||
{
|
|
||||||
setActiveInputLabel(NULL);
|
|
||||||
}
|
|
||||||
else if(buttonReturn.mouseClick(x,y) || serverInitError == true) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
needToBroadcastServerSettings = false;
|
|
||||||
needToRepublishToMasterserver = false;
|
|
||||||
lastNetworkPing = time(NULL);
|
|
||||||
safeMutex.ReleaseLock();
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
returnToParentMenu();
|
|
||||||
}
|
|
||||||
else if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
PlayNow(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if(buttonRestoreLastSettings.mouseClick(x,y) && buttonRestoreLastSettings.getEnabled()) {
|
|
||||||
RestoreLastGameSettings();
|
|
||||||
}
|
|
||||||
else if(listBoxMap.mouseClick(x, y)){
|
|
||||||
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__));
|
|
||||||
|
|
||||||
loadMapInfo(Map::getMapPath(getCurrentMapFile(),"",false), &mapInfo, true);
|
|
||||||
labelMapInfo.setText(mapInfo.desc);
|
|
||||||
updateControlers();
|
|
||||||
updateNetworkSlots();
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true) {
|
|
||||||
//delay publishing for 5 seconds
|
|
||||||
needToPublishDelayed=true;
|
|
||||||
mapPublishingDelayTimer=time(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxFogOfWar.mouseClick(x, y)) {
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
|
|
||||||
cleanupMapPreviewTexture();
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true) {
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxAllowObservers.mouseClick(x, y)) {
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
reloadFactions(true);
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true) {
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxEnableObserverMode.mouseClick(x, y)) {
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxEnableSwitchTeamMode.mouseClick(x, y)) {
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxAISwitchTeamAcceptPercent.getEnabled() && listBoxAISwitchTeamAcceptPercent.mouseClick(x, y)) {
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxPathFinderType.mouseClick(x, y)) {
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (listBoxAdvanced.mouseClick(x, y)) {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
else if(listBoxTileset.mouseClick(x, y)){
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
if(hasNetworkGameSettings() == true)
|
|
||||||
{
|
|
||||||
|
|
||||||
//delay publishing for 5 seconds
|
|
||||||
needToPublishDelayed=true;
|
|
||||||
mapPublishingDelayTimer=time(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(listBoxMapFilter.mouseClick(x, y)){
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
switchToNextMapGroup(listBoxMapFilter.getSelectedItemIndex()-oldListBoxMapfilterIndex);
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str());
|
|
||||||
|
|
||||||
loadMapInfo(Map::getMapPath(getCurrentMapFile()), &mapInfo, true);
|
|
||||||
labelMapInfo.setText(mapInfo.desc);
|
|
||||||
updateControlers();
|
|
||||||
updateNetworkSlots();
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(listBoxTechTree.mouseClick(x, y)){
|
|
||||||
reloadFactions(false);
|
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(listBoxPublishServer.mouseClick(x, y) && listBoxPublishServer.getEditable()) {
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
soundRenderer.playFx(coreData.getClickSoundC());
|
|
||||||
|
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
|
||||||
serverInterface->setPublishEnabled(listBoxPublishServer.getSelectedItemIndex() == 0);
|
|
||||||
}
|
|
||||||
else if(labelGameName.mouseClick(x, y) && listBoxPublishServer.getEditable()){
|
|
||||||
setActiveInputLabel(&labelGameName);
|
|
||||||
}
|
|
||||||
else if(listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxNetworkPauseGameForLaggedClients.mouseClick(x, y)){
|
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
if(hasNetworkGameSettings() == true)
|
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
soundRenderer.playFx(coreData.getClickSoundC());
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
for(int i = 0; i < mapInfo.players; ++i) {
|
if(activeInputLabel!=NULL && !(activeInputLabel->mouseClick(x,y))){
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
setActiveInputLabel(NULL);
|
||||||
|
}
|
||||||
|
if(buttonReturn.mouseClick(x,y) || serverInitError == true) {
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//if (listBoxAdvanced.getSelectedItemIndex() == 1) {
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
// set multiplier
|
|
||||||
if(listBoxRMultiplier[i].mouseClick(x, y)) {
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
|
|
||||||
//ensure thet only 1 human player is present
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
needToBroadcastServerSettings = false;
|
||||||
ConnectionSlot *slot = serverInterface->getSlot(i);
|
needToRepublishToMasterserver = false;
|
||||||
|
lastNetworkPing = time(NULL);
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
bool checkControTypeClicked = false;
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
int selectedControlItemIndex = listBoxControls[i].getSelectedItemIndex();
|
|
||||||
if(selectedControlItemIndex != ctNetwork ||
|
|
||||||
(selectedControlItemIndex == ctNetwork && (slot == NULL || slot->isConnected() == false))) {
|
|
||||||
checkControTypeClicked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//printf("checkControTypeClicked = %d selectedControlItemIndex = %d i = %d\n",checkControTypeClicked,selectedControlItemIndex,i);
|
returnToParentMenu();
|
||||||
|
}
|
||||||
|
else if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(checkControTypeClicked == true && listBoxControls[i].mouseClick(x, y)) {
|
PlayNow(true);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
return;
|
||||||
//printf("listBoxControls[i].mouseClick(x, y) is TRUE i = %d newcontrol = %d\n",i,listBoxControls[i].getSelectedItemIndex());
|
}
|
||||||
|
else if(buttonRestoreLastSettings.mouseClick(x,y) && buttonRestoreLastSettings.getEnabled()) {
|
||||||
|
RestoreLastGameSettings();
|
||||||
|
}
|
||||||
|
else if(listBoxMap.mouseClick(x, y)){
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str());
|
||||||
|
|
||||||
// Skip over networkunassigned
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned &&
|
|
||||||
selectedControlItemIndex != ctNetworkUnassigned) {
|
|
||||||
listBoxControls[i].mouseClick(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
//look for human players
|
loadMapInfo(Map::getMapPath(getCurrentMapFile(),"",false), &mapInfo, true);
|
||||||
int humanIndex1= -1;
|
labelMapInfo.setText(mapInfo.desc);
|
||||||
int humanIndex2= -1;
|
updateControlers();
|
||||||
for(int j = 0; j < GameConstants::maxPlayers; ++j) {
|
updateNetworkSlots();
|
||||||
ControlType ct= static_cast<ControlType>(listBoxControls[j].getSelectedItemIndex());
|
|
||||||
if(ct == ctHuman) {
|
|
||||||
if(humanIndex1 == -1) {
|
|
||||||
humanIndex1= j;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
humanIndex2= j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] humanIndex1 = %d, humanIndex2 = %d\n",__FILE__,__FUNCTION__,__LINE__,humanIndex1,humanIndex2);
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
|
||||||
//no human
|
if(hasNetworkGameSettings() == true) {
|
||||||
if(humanIndex1 == -1 && humanIndex2 == -1) {
|
//delay publishing for 5 seconds
|
||||||
listBoxControls[i].setSelectedItemIndex(ctHuman);
|
needToPublishDelayed=true;
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] i = %d, labelPlayerNames[i].getText() [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,labelPlayerNames[i].getText().c_str());
|
mapPublishingDelayTimer=time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxFogOfWar.mouseClick(x, y)) {
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
//printf("humanIndex1 = %d humanIndex2 = %d i = %d listBoxControls[i].getSelectedItemIndex() = %d\n",humanIndex1,humanIndex2,i,listBoxControls[i].getSelectedItemIndex());
|
cleanupMapPreviewTexture();
|
||||||
}
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
//2 humans
|
needToRepublishToMasterserver = true;
|
||||||
else if(humanIndex1 != -1 && humanIndex2 != -1) {
|
}
|
||||||
int closeSlotIndex = (humanIndex1 == i ? humanIndex2: humanIndex1);
|
|
||||||
int humanSlotIndex = (closeSlotIndex == humanIndex1 ? humanIndex2 : humanIndex1);
|
|
||||||
|
|
||||||
string origPlayName = labelPlayerNames[closeSlotIndex].getText();
|
if(hasNetworkGameSettings() == true) {
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxAllowObservers.mouseClick(x, y)) {
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] closeSlotIndex = %d, origPlayName [%s]\n",__FILE__,__FUNCTION__,__LINE__,closeSlotIndex,origPlayName.c_str());
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
//printf("humanIndex1 = %d humanIndex2 = %d i = %d closeSlotIndex = %d humanSlotIndex = %d\n",humanIndex1,humanIndex2,i,closeSlotIndex,humanSlotIndex);
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
|
||||||
listBoxControls[closeSlotIndex].setSelectedItemIndex(ctClosed);
|
reloadFactions(true);
|
||||||
labelPlayerNames[humanSlotIndex].setText((origPlayName != "" ? origPlayName : getHumanPlayerName()));
|
|
||||||
}
|
|
||||||
updateNetworkSlots();
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
if(hasNetworkGameSettings() == true) {
|
||||||
needToRepublishToMasterserver = true;
|
needToSetChangedGameSettings = true;
|
||||||
}
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxEnableObserverMode.mouseClick(x, y)) {
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true) {
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
needToSetChangedGameSettings = true;
|
needToRepublishToMasterserver = true;
|
||||||
lastSetChangedGameSettings = time(NULL);
|
}
|
||||||
}
|
|
||||||
updateResourceMultiplier(i);
|
if(hasNetworkGameSettings() == true)
|
||||||
}
|
{
|
||||||
else if(buttonClearBlockedPlayers.mouseClick(x, y)) {
|
needToSetChangedGameSettings = true;
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
lastSetChangedGameSettings = time(NULL);
|
||||||
if(serverInterface != NULL) {
|
}
|
||||||
ServerSocket *serverSocket = serverInterface->getServerSocket();
|
}
|
||||||
if(serverSocket != NULL) {
|
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxEnableSwitchTeamMode.mouseClick(x, y)) {
|
||||||
serverSocket->clearBlockedIPAddress();
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasNetworkGameSettings() == true)
|
||||||
|
{
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxAISwitchTeamAcceptPercent.getEnabled() && listBoxAISwitchTeamAcceptPercent.mouseClick(x, y)) {
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasNetworkGameSettings() == true)
|
||||||
|
{
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxPathFinderType.mouseClick(x, y)) {
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasNetworkGameSettings() == true)
|
||||||
|
{
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (listBoxAdvanced.mouseClick(x, y)) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
else if(listBoxTileset.mouseClick(x, y)){
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
if(hasNetworkGameSettings() == true)
|
||||||
|
{
|
||||||
|
|
||||||
|
//delay publishing for 5 seconds
|
||||||
|
needToPublishDelayed=true;
|
||||||
|
mapPublishingDelayTimer=time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(listBoxMapFilter.mouseClick(x, y)){
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
switchToNextMapGroup(listBoxMapFilter.getSelectedItemIndex()-oldListBoxMapfilterIndex);
|
||||||
|
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str());
|
||||||
|
|
||||||
|
loadMapInfo(Map::getMapPath(getCurrentMapFile()), &mapInfo, true);
|
||||||
|
labelMapInfo.setText(mapInfo.desc);
|
||||||
|
updateControlers();
|
||||||
|
updateNetworkSlots();
|
||||||
|
|
||||||
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasNetworkGameSettings() == true)
|
||||||
|
{
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(listBoxTechTree.mouseClick(x, y)){
|
||||||
|
reloadFactions(false);
|
||||||
|
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasNetworkGameSettings() == true)
|
||||||
|
{
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(listBoxPublishServer.mouseClick(x, y) && listBoxPublishServer.getEditable()) {
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundC());
|
||||||
|
|
||||||
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
serverInterface->setPublishEnabled(listBoxPublishServer.getSelectedItemIndex() == 0);
|
||||||
|
}
|
||||||
|
else if(labelGameName.mouseClick(x, y) && listBoxPublishServer.getEditable()){
|
||||||
|
setActiveInputLabel(&labelGameName);
|
||||||
|
}
|
||||||
|
else if(listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxNetworkPauseGameForLaggedClients.mouseClick(x, y)){
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
if(hasNetworkGameSettings() == true)
|
||||||
|
{
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundC());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(int i = 0; i < mapInfo.players; ++i) {
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
|
//if (listBoxAdvanced.getSelectedItemIndex() == 1) {
|
||||||
|
// set multiplier
|
||||||
|
if(listBoxRMultiplier[i].mouseClick(x, y)) {
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
else if(buttonBlockPlayers[i].mouseClick(x, y)) {
|
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
|
||||||
if(serverInterface != NULL) {
|
|
||||||
if(serverInterface->getSlot(i) != NULL &&
|
|
||||||
serverInterface->getSlot(i)->isConnected()) {
|
|
||||||
|
|
||||||
ServerSocket *serverSocket = serverInterface->getServerSocket();
|
//ensure thet only 1 human player is present
|
||||||
if(serverSocket != NULL) {
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
serverSocket->addIPAddressToBlockedList(serverInterface->getSlot(i)->getIpAddress());
|
ConnectionSlot *slot = serverInterface->getSlot(i);
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
bool checkControTypeClicked = false;
|
||||||
const vector<string> languageList = serverInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
int selectedControlItemIndex = listBoxControls[i].getSelectedItemIndex();
|
||||||
for(unsigned int j = 0; j < languageList.size(); ++j) {
|
if(selectedControlItemIndex != ctNetwork ||
|
||||||
char szMsg[1024]="";
|
(selectedControlItemIndex == ctNetwork && (slot == NULL || slot->isConnected() == false))) {
|
||||||
if(lang.hasString("BlockPlayerServerMsg",languageList[j]) == true) {
|
checkControTypeClicked = true;
|
||||||
sprintf(szMsg,lang.get("BlockPlayerServerMsg",languageList[j]).c_str(),serverInterface->getSlot(i)->getIpAddress().c_str());
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
sprintf(szMsg,"The server has temporarily blocked IP Address [%s] from this game.",serverInterface->getSlot(i)->getIpAddress().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
serverInterface->sendTextMessage(szMsg,-1, true,languageList[j]);
|
//printf("checkControTypeClicked = %d selectedControlItemIndex = %d i = %d\n",checkControTypeClicked,selectedControlItemIndex,i);
|
||||||
}
|
|
||||||
sleep(1);
|
if(checkControTypeClicked == true && listBoxControls[i].mouseClick(x, y)) {
|
||||||
serverInterface->getSlot(i)->close();
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
//printf("listBoxControls[i].mouseClick(x, y) is TRUE i = %d newcontrol = %d\n",i,listBoxControls[i].getSelectedItemIndex());
|
||||||
|
|
||||||
|
// Skip over networkunassigned
|
||||||
|
if(listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned &&
|
||||||
|
selectedControlItemIndex != ctNetworkUnassigned) {
|
||||||
|
listBoxControls[i].mouseClick(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
//look for human players
|
||||||
|
int humanIndex1= -1;
|
||||||
|
int humanIndex2= -1;
|
||||||
|
for(int j = 0; j < GameConstants::maxPlayers; ++j) {
|
||||||
|
ControlType ct= static_cast<ControlType>(listBoxControls[j].getSelectedItemIndex());
|
||||||
|
if(ct == ctHuman) {
|
||||||
|
if(humanIndex1 == -1) {
|
||||||
|
humanIndex1= j;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
humanIndex2= j;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(listBoxFactions[i].mouseClick(x, y)) {
|
|
||||||
// Disallow CPU players to be observers
|
|
||||||
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] == formatString(GameConstants::OBSERVER_SLOTNAME) &&
|
|
||||||
(listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == ctCpu ||
|
|
||||||
listBoxControls[i].getSelectedItemIndex() == ctCpuUltra || listBoxControls[i].getSelectedItemIndex() == ctCpuMega)) {
|
|
||||||
listBoxFactions[i].setSelectedItemIndex(0);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] humanIndex1 = %d, humanIndex2 = %d\n",__FILE__,__FUNCTION__,__LINE__,humanIndex1,humanIndex2);
|
||||||
needToRepublishToMasterserver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
//no human
|
||||||
{
|
if(humanIndex1 == -1 && humanIndex2 == -1) {
|
||||||
needToSetChangedGameSettings = true;
|
listBoxControls[i].setSelectedItemIndex(ctHuman);
|
||||||
lastSetChangedGameSettings = time(NULL);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] i = %d, labelPlayerNames[i].getText() [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,labelPlayerNames[i].getText().c_str());
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(listBoxTeams[i].mouseClick(x, y))
|
|
||||||
{
|
|
||||||
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] != formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
|
||||||
if(listBoxTeams[i].getSelectedItemIndex() + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
|
||||||
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
lastSelectedTeamIndex[i] = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
//printf("humanIndex1 = %d humanIndex2 = %d i = %d listBoxControls[i].getSelectedItemIndex() = %d\n",humanIndex1,humanIndex2,i,listBoxControls[i].getSelectedItemIndex());
|
||||||
needToRepublishToMasterserver = true;
|
}
|
||||||
}
|
//2 humans
|
||||||
|
else if(humanIndex1 != -1 && humanIndex2 != -1) {
|
||||||
|
int closeSlotIndex = (humanIndex1 == i ? humanIndex2: humanIndex1);
|
||||||
|
int humanSlotIndex = (closeSlotIndex == humanIndex1 ? humanIndex2 : humanIndex1);
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
string origPlayName = labelPlayerNames[closeSlotIndex].getText();
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] closeSlotIndex = %d, origPlayName [%s]\n",__FILE__,__FUNCTION__,__LINE__,closeSlotIndex,origPlayName.c_str());
|
||||||
lastSetChangedGameSettings = time(NULL);;
|
//printf("humanIndex1 = %d humanIndex2 = %d i = %d closeSlotIndex = %d humanSlotIndex = %d\n",humanIndex1,humanIndex2,i,closeSlotIndex,humanSlotIndex);
|
||||||
}
|
|
||||||
}
|
listBoxControls[closeSlotIndex].setSelectedItemIndex(ctClosed);
|
||||||
else if(labelPlayerNames[i].mouseClick(x, y)) {
|
labelPlayerNames[humanSlotIndex].setText((origPlayName != "" ? origPlayName : getHumanPlayerName()));
|
||||||
ControlType ct= static_cast<ControlType>(listBoxControls[i].getSelectedItemIndex());
|
}
|
||||||
if(ct == ctHuman) {
|
updateNetworkSlots();
|
||||||
setActiveInputLabel(&labelPlayerNames[i]);
|
|
||||||
break;
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
}
|
needToRepublishToMasterserver = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if(hasNetworkGameSettings() == true) {
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
updateResourceMultiplier(i);
|
||||||
|
}
|
||||||
|
else if(buttonClearBlockedPlayers.mouseClick(x, y)) {
|
||||||
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
if(serverInterface != NULL) {
|
||||||
|
ServerSocket *serverSocket = serverInterface->getServerSocket();
|
||||||
|
if(serverSocket != NULL) {
|
||||||
|
serverSocket->clearBlockedIPAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(buttonBlockPlayers[i].mouseClick(x, y)) {
|
||||||
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
if(serverInterface != NULL) {
|
||||||
|
if(serverInterface->getSlot(i) != NULL &&
|
||||||
|
serverInterface->getSlot(i)->isConnected()) {
|
||||||
|
|
||||||
|
ServerSocket *serverSocket = serverInterface->getServerSocket();
|
||||||
|
if(serverSocket != NULL) {
|
||||||
|
serverSocket->addIPAddressToBlockedList(serverInterface->getSlot(i)->getIpAddress());
|
||||||
|
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
const vector<string> languageList = serverInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||||
|
for(unsigned int j = 0; j < languageList.size(); ++j) {
|
||||||
|
char szMsg[1024]="";
|
||||||
|
if(lang.hasString("BlockPlayerServerMsg",languageList[j]) == true) {
|
||||||
|
sprintf(szMsg,lang.get("BlockPlayerServerMsg",languageList[j]).c_str(),serverInterface->getSlot(i)->getIpAddress().c_str());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sprintf(szMsg,"The server has temporarily blocked IP Address [%s] from this game.",serverInterface->getSlot(i)->getIpAddress().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
serverInterface->sendTextMessage(szMsg,-1, true,languageList[j]);
|
||||||
|
}
|
||||||
|
sleep(1);
|
||||||
|
serverInterface->getSlot(i)->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(listBoxFactions[i].mouseClick(x, y)) {
|
||||||
|
// Disallow CPU players to be observers
|
||||||
|
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] == formatString(GameConstants::OBSERVER_SLOTNAME) &&
|
||||||
|
(listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == ctCpu ||
|
||||||
|
listBoxControls[i].getSelectedItemIndex() == ctCpuUltra || listBoxControls[i].getSelectedItemIndex() == ctCpuMega)) {
|
||||||
|
listBoxFactions[i].setSelectedItemIndex(0);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasNetworkGameSettings() == true)
|
||||||
|
{
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(listBoxTeams[i].mouseClick(x, y))
|
||||||
|
{
|
||||||
|
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] != formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
||||||
|
if(listBoxTeams[i].getSelectedItemIndex() + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
||||||
|
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lastSelectedTeamIndex[i] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasNetworkGameSettings() == true)
|
||||||
|
{
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(labelPlayerNames[i].mouseClick(x, y)) {
|
||||||
|
ControlType ct= static_cast<ControlType>(listBoxControls[i].getSelectedItemIndex());
|
||||||
|
if(ct == ctHuman) {
|
||||||
|
setActiveInputLabel(&labelPlayerNames[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true && listBoxPlayerStatus.mouseClick(x,y)) {
|
if(hasNetworkGameSettings() == true && listBoxPlayerStatus.mouseClick(x,y)) {
|
||||||
@ -3467,6 +3468,11 @@ void MenuStateCustomGame::keyPress(SDL_KeyboardEvent c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDLKey key = extractKeyPressed(c);
|
SDLKey key = extractKeyPressed(c);
|
||||||
|
if(isKeyPressed(SDLK_ESCAPE,c,false) == true || isKeyPressed(SDLK_RETURN,c,false) == true )
|
||||||
|
{
|
||||||
|
setActiveInputLabel(NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
//if((c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z') ||
|
//if((c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z') ||
|
||||||
// (c=='-') || (c=='(') || (c==')')) {
|
// (c=='-') || (c=='(') || (c==')')) {
|
||||||
if(isAllowedInputTextKey(key)) {
|
if(isAllowedInputTextKey(key)) {
|
||||||
@ -3559,8 +3565,10 @@ string MenuStateCustomGame::getCurrentMapFile(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::setActiveInputLabel(GraphicLabel *newLable) {
|
void MenuStateCustomGame::setActiveInputLabel(GraphicLabel *newLable) {
|
||||||
|
|
||||||
if(newLable != NULL) {
|
if(newLable != NULL) {
|
||||||
|
if( newLable==activeInputLabel){
|
||||||
|
return;
|
||||||
|
}
|
||||||
string text= newLable->getText();
|
string text= newLable->getText();
|
||||||
size_t found = text.find_last_of("_");
|
size_t found = text.find_last_of("_");
|
||||||
if (found == string::npos) {
|
if (found == string::npos) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user