cleanup the resource multiplier code to be consistent in the menus

This commit is contained in:
Mark Vejvoda 2013-11-02 22:30:16 +00:00
parent 122c945c67
commit f74198129b
2 changed files with 22 additions and 16 deletions

View File

@ -209,7 +209,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
listBoxFallbackCpuMultiplier.registerGraphicComponent(containerName,"listBoxFallbackCpuMultiplier");
listBoxFallbackCpuMultiplier.init(xoffset+460, aPos, 80);
listBoxFallbackCpuMultiplier.setItems(rMultiplier);
listBoxFallbackCpuMultiplier.setSelectedItemIndex(0);
listBoxFallbackCpuMultiplier.setSelectedItem("1.0");
// Allow Switch Team Mode
@ -403,7 +403,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
listBoxTeams[i].setSelectedItemIndex(i);
listBoxControls[i].setItems(controlItems);
listBoxRMultiplier[i].setItems(rMultiplier);
listBoxRMultiplier[i].setSelectedItemIndex(5);
listBoxRMultiplier[i].setSelectedItem("1.0");
labelNetStatus[i].setText("V");
}
@ -1635,25 +1635,25 @@ void MenuStateConnectedGame::updateResourceMultiplier(const int index) {
ControlType ct= static_cast<ControlType>(listBoxControls[index].getSelectedItemIndex());
if(ct == ctCpuEasy || ct == ctNetworkCpuEasy)
{
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::easyMultiplier-0.5f)*10);
listBoxRMultiplier[index].setSelectedItem(floatToStr(GameConstants::easyMultiplier,1));
listBoxRMultiplier[index].setEnabled(true);
}
else if(ct == ctCpu || ct == ctNetworkCpu) {
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::normalMultiplier-0.5f)*10);
listBoxRMultiplier[index].setSelectedItem(floatToStr(GameConstants::normalMultiplier,1));
listBoxRMultiplier[index].setEnabled(true);
}
else if(ct == ctCpuUltra || ct == ctNetworkCpuUltra)
{
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::ultraMultiplier-0.5f)*10);
listBoxRMultiplier[index].setSelectedItem(floatToStr(GameConstants::ultraMultiplier,1));
listBoxRMultiplier[index].setEnabled(true);
}
else if(ct == ctCpuMega || ct == ctNetworkCpuMega)
{
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::megaMultiplier-0.5f)*10);
listBoxRMultiplier[index].setSelectedItem(floatToStr(GameConstants::megaMultiplier,1));
listBoxRMultiplier[index].setEnabled(true);
}
else {
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::normalMultiplier-0.5f)*10);
listBoxRMultiplier[index].setSelectedItem(floatToStr(GameConstants::normalMultiplier,1));
listBoxRMultiplier[index].setEnabled(false);
}
@ -2093,7 +2093,7 @@ void MenuStateConnectedGame::loadGameSettings(GameSettings *gameSettings) {
Lang &lang= Lang::getInstance();
gameSettings->setNetworkPlayerLanguages(slotIndex, lang.getLanguage());
gameSettings->setResourceMultiplierIndex(slotIndex, (GameConstants::normalMultiplier-0.5f)*10);
gameSettings->setResourceMultiplierIndex(slotIndex, 5);
}
else {
gameSettings->setResourceMultiplierIndex(slotIndex, listBoxRMultiplier[i].getSelectedItemIndex());
@ -2143,7 +2143,7 @@ void MenuStateConnectedGame::loadGameSettings(GameSettings *gameSettings) {
gameSettings->setStartLocationIndex(slotIndex, i);
//printf("!!! setStartLocationIndex #2 slotIndex = %d, i = %d\n",slotIndex, i);
gameSettings->setResourceMultiplierIndex(slotIndex, (GameConstants::normalMultiplier-0.5f)*10);
gameSettings->setResourceMultiplierIndex(slotIndex, 5);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,factionFiles[listBoxFactions[i].getSelectedItemIndex()].c_str());

View File

@ -1238,7 +1238,9 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
//printf("checkControTypeClicked = %d selectedControlItemIndex = %d i = %d\n",checkControTypeClicked,selectedControlItemIndex,i);
if(selectedControlItemIndex != ctHuman && checkControTypeClicked == true && listBoxControls[i].mouseClick(x, y)) {
if(selectedControlItemIndex != ctHuman &&
checkControTypeClicked == true &&
listBoxControls[i].mouseClick(x, y)) {
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());
@ -1461,26 +1463,26 @@ void MenuStateCustomGame::updateResourceMultiplier(const int index) {
ControlType ct= static_cast<ControlType>(listBoxControls[index].getSelectedItemIndex());
if(ct == ctCpuEasy || ct == ctNetworkCpuEasy)
{
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::easyMultiplier-0.5f)*10);
listBoxRMultiplier[index].setSelectedItem(floatToStr(GameConstants::easyMultiplier,1));
listBoxRMultiplier[index].setEnabled(checkBoxScenario.getValue() == false);
}
else if(ct == ctCpu || ct == ctNetworkCpu) {
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::normalMultiplier-0.5f)*10);
listBoxRMultiplier[index].setSelectedItem(floatToStr(GameConstants::normalMultiplier,1));
listBoxRMultiplier[index].setEnabled(checkBoxScenario.getValue() == false);
}
else if(ct == ctCpuUltra || ct == ctNetworkCpuUltra)
{
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::ultraMultiplier-0.5f)*10);
listBoxRMultiplier[index].setSelectedItem(floatToStr(GameConstants::ultraMultiplier,1));
listBoxRMultiplier[index].setEnabled(checkBoxScenario.getValue() == false);
}
else if(ct == ctCpuMega || ct == ctNetworkCpuMega)
{
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::megaMultiplier-0.5f)*10);
listBoxRMultiplier[index].setSelectedItem(floatToStr(GameConstants::megaMultiplier,1));
listBoxRMultiplier[index].setEnabled(checkBoxScenario.getValue() == false);
}
//if(ct == ctHuman || ct == ctNetwork || ct == ctClosed) {
else {
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::normalMultiplier-0.5f)*10);
listBoxRMultiplier[index].setSelectedItem(floatToStr(GameConstants::normalMultiplier,1));
listBoxRMultiplier[index].setEnabled(false);
//!!!listBoxRMultiplier[index].setEnabled(checkBoxScenario.getValue() == false);
}
@ -4739,8 +4741,12 @@ void MenuStateCustomGame::reloadFactions(bool keepExistingSelectedItem, string s
}
void MenuStateCustomGame::setSlotHuman(int i) {
if(labelPlayerNames[i].getEditable()) return;
if(labelPlayerNames[i].getEditable()) {
return;
}
listBoxControls[i].setSelectedItemIndex(ctHuman);
listBoxRMultiplier[i].setSelectedItem("1.0");
labelPlayerNames[i].setText(getHumanPlayerName());
for(int j = 0; j < GameConstants::maxPlayers; ++j) {
labelPlayerNames[j].setEditable(false);