/** * Updates the depth slider accordingly when terrain selection changes. * @param action Pointer to an action. */ void NewBattleState::cbxTerrainChange(Action *) { AlienDeployment *ruleDeploy = _game->getMod()->getDeployment(_missionTypes[_cbxMission->getSelected()]); int minDepth = 0; int maxDepth = 0; if (ruleDeploy->getMaxDepth() > 0 || _game->getMod()->getTerrain(_terrainTypes.at(_cbxTerrain->getSelected()))->getMaxDepth() > 0 || (!ruleDeploy->getTerrains().empty() && _game->getMod()->getTerrain(ruleDeploy->getTerrains().front())->getMaxDepth() > 0)) { minDepth = 1; maxDepth = 3; } _txtDepth->setVisible(minDepth != maxDepth); _slrDepth->setVisible(minDepth != maxDepth); _slrDepth->setRange(minDepth, maxDepth); _slrDepth->setValue(minDepth); }
/** * Updates Map Options based on the * current Mission type. * @param action Pointer to an action. */ void NewBattleState::cbxMissionChange(Action *) { AlienDeployment *ruleDeploy = _game->getMod()->getDeployment(_missionTypes[_cbxMission->getSelected()]); std::set<std::string> terrains; // Get terrains associated with this mission std::vector<std::string> deployTerrains, globeTerrains; deployTerrains = ruleDeploy->getTerrains(); if (deployTerrains.empty()) { globeTerrains = _game->getMod()->getGlobe()->getTerrains(""); } else { globeTerrains = _game->getMod()->getGlobe()->getTerrains(ruleDeploy->getType()); } for (std::vector<std::string>::const_iterator i = deployTerrains.begin(); i != deployTerrains.end(); ++i) { terrains.insert(*i); } for (std::vector<std::string>::const_iterator i = globeTerrains.begin(); i != globeTerrains.end(); ++i) { terrains.insert(*i); } _terrainTypes.clear(); std::vector<std::string> terrainStrings; for (std::set<std::string>::const_iterator i = terrains.begin(); i != terrains.end(); ++i) { _terrainTypes.push_back(*i); terrainStrings.push_back("MAP_" + *i); } // Hide controls that don't apply to mission _txtDarkness->setVisible(ruleDeploy->getShade() == -1); _slrDarkness->setVisible(ruleDeploy->getShade() == -1); _txtTerrain->setVisible(_terrainTypes.size() > 1); _cbxTerrain->setVisible(_terrainTypes.size() > 1); _cbxTerrain->setOptions(terrainStrings, true); _cbxTerrain->setSelected(0); cbxTerrainChange(0); }