- if holding ctrl while click to change the player type we will change all non human slots to the same player control type
This commit is contained in:
parent
778bb788ef
commit
194e1868b9
|
@ -1240,60 +1240,73 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
//printf("listBoxControls[i].mouseClick(x, y) is TRUE i = %d newcontrol = %d\n",i,listBoxControls[i].getSelectedItemIndex());
|
//printf("listBoxControls[i].mouseClick(x, y) is TRUE i = %d newcontrol = %d\n",i,listBoxControls[i].getSelectedItemIndex());
|
||||||
|
|
||||||
// Skip over networkunassigned
|
int slotsToChangeStart = i;
|
||||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned &&
|
int slotsToChangeEnd = i;
|
||||||
selectedControlItemIndex != ctNetworkUnassigned) {
|
// If control is pressed while changing player types then change all other slots to same type
|
||||||
listBoxControls[i].mouseClick(x, y);
|
if(Window::isKeyStateModPressed(KMOD_CTRL) == true) {
|
||||||
|
slotsToChangeStart = 0;
|
||||||
|
slotsToChangeEnd = mapInfo.players-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//look for human players
|
for(int index = slotsToChangeStart; index <= slotsToChangeEnd; ++index) {
|
||||||
int humanIndex1= -1;
|
if(index != i) {
|
||||||
int humanIndex2= -1;
|
listBoxControls[index].setSelectedItemIndex(listBoxControls[i].getSelectedItemIndex());
|
||||||
for(int j = 0; j < GameConstants::maxPlayers; ++j) {
|
}
|
||||||
ControlType ct= static_cast<ControlType>(listBoxControls[j].getSelectedItemIndex());
|
// Skip over networkunassigned
|
||||||
if(ct == ctHuman) {
|
if(listBoxControls[index].getSelectedItemIndex() == ctNetworkUnassigned &&
|
||||||
if(humanIndex1 == -1) {
|
selectedControlItemIndex != ctNetworkUnassigned) {
|
||||||
humanIndex1= j;
|
listBoxControls[index].mouseClick(x, y);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
humanIndex2= j;
|
//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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,humanIndex1,humanIndex2);
|
||||||
|
|
||||||
|
//no human
|
||||||
|
if(humanIndex1 == -1 && humanIndex2 == -1) {
|
||||||
|
listBoxControls[index].setSelectedItemIndex(ctHuman);
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] i = %d, labelPlayerNames[i].getText() [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,index,labelPlayerNames[index].getText().c_str());
|
||||||
|
|
||||||
|
//printf("humanIndex1 = %d humanIndex2 = %d i = %d listBoxControls[i].getSelectedItemIndex() = %d\n",humanIndex1,humanIndex2,i,listBoxControls[i].getSelectedItemIndex());
|
||||||
|
}
|
||||||
|
//2 humans
|
||||||
|
else if(humanIndex1 != -1 && humanIndex2 != -1) {
|
||||||
|
int closeSlotIndex = (humanIndex1 == index ? 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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,closeSlotIndex,origPlayName.c_str());
|
||||||
|
//printf("humanIndex1 = %d humanIndex2 = %d i = %d closeSlotIndex = %d humanSlotIndex = %d\n",humanIndex1,humanIndex2,i,closeSlotIndex,humanSlotIndex);
|
||||||
|
|
||||||
|
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(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] humanIndex1 = %d, humanIndex2 = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,labelPlayerNames[i].getText().c_str());
|
|
||||||
|
|
||||||
//printf("humanIndex1 = %d humanIndex2 = %d i = %d listBoxControls[i].getSelectedItemIndex() = %d\n",humanIndex1,humanIndex2,i,listBoxControls[i].getSelectedItemIndex());
|
|
||||||
}
|
|
||||||
//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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,closeSlotIndex,origPlayName.c_str());
|
|
||||||
//printf("humanIndex1 = %d humanIndex2 = %d i = %d closeSlotIndex = %d humanSlotIndex = %d\n",humanIndex1,humanIndex2,i,closeSlotIndex,humanSlotIndex);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
else if(buttonClearBlockedPlayers.mouseClick(x, y)) {
|
else if(buttonClearBlockedPlayers.mouseClick(x, y)) {
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
|
|
@ -135,6 +135,7 @@ public:
|
||||||
static const bool getIsFullScreen() { return isFullScreen; }
|
static const bool getIsFullScreen() { return isFullScreen; }
|
||||||
static void setIsFullScreen(bool value) { isFullScreen = value; }
|
static void setIsFullScreen(bool value) { isFullScreen = value; }
|
||||||
//static SDL_keysym getKeystate() { return keystate; }
|
//static SDL_keysym getKeystate() { return keystate; }
|
||||||
|
static bool isKeyStateModPressed(int mod);
|
||||||
|
|
||||||
Window();
|
Window();
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
|
|
|
@ -1022,4 +1022,13 @@ bool isAllowedInputTextKey(SDLKey key) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Window::isKeyStateModPressed(int mod) {
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("isKeyStateModPressed mod = %d, keystate.mod = %d, keystate.mod & mod = %d\n",mod,keystate.mod,(keystate.mod & mod));
|
||||||
|
|
||||||
|
if(keystate.mod & mod) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
Loading…
Reference in New Issue
Block a user