void OptionsScreenInput2::updateInputButtons() { assert(m_config != NULL); //TODO: detect duplicates GUIEngine::ListWidget* actions = getWidget<GUIEngine::ListWidget>("actions"); assert( actions != NULL ); int i = 0; i++; // section header //I18N: Key binding name renameRow(actions, i++, _("Steer Left"), PA_STEER_LEFT); //I18N: Key binding name renameRow(actions, i++, _("Steer Right"), PA_STEER_RIGHT); //I18N: Key binding name renameRow(actions, i++, _("Accelerate"), PA_ACCEL); //I18N: Key binding name renameRow(actions, i++, _("Brake"), PA_BRAKE); //I18N: Key binding name renameRow(actions, i++, _("Fire"), PA_FIRE); //I18N: Key binding name renameRow(actions, i++, _("Nitro"), PA_NITRO); //I18N: Key binding name renameRow(actions, i++, _("Skidding"), PA_DRIFT); //I18N: Key binding name renameRow(actions, i++, _("Look Back"), PA_LOOK_BACK); //I18N: Key binding name renameRow(actions, i++, _("Rescue"), PA_RESCUE); //I18N: Key binding name renameRow(actions, i++, _("Pause Game"), PA_PAUSE_RACE); i++; // section header //I18N: Key binding name renameRow(actions, i++, _("Up"), PA_MENU_UP); //I18N: Key binding name renameRow(actions, i++, _("Down"), PA_MENU_DOWN); //I18N: Key binding name renameRow(actions, i++, _("Left"), PA_MENU_LEFT); //I18N: Key binding name renameRow(actions, i++, _("Right"), PA_MENU_RIGHT); //I18N: Key binding name renameRow(actions, i++, _("Select"), PA_MENU_SELECT); //I18N: Key binding name renameRow(actions, i++, _("Cancel/Back"), PA_MENU_CANCEL); bool conflicts_between = false; bool conflicts_inside = false; // ---- make sure there are no binding conflicts // (same key used for two actions) std::set<irr::core::stringw> currentlyUsedKeys; for (PlayerAction action = PA_FIRST_GAME_ACTION; action <= PA_LAST_GAME_ACTION; action=PlayerAction(action+1)) { const irr::core::stringw item = m_config->getMappingIdString(action); if (currentlyUsedKeys.find(item) == currentlyUsedKeys.end()) { currentlyUsedKeys.insert( item ); if (m_config->getType() == DEVICE_CONFIG_TYPE_KEYBOARD && conflictsBetweenKbdConfig(action, PA_FIRST_GAME_ACTION, PA_LAST_GAME_ACTION)) { conflicts_between = true; actions->markItemBlue (KartActionStrings[action]); } } else { // binding conflict! actions->markItemRed( KartActionStrings[action] ); // also mark others for (PlayerAction others = PA_FIRST_GAME_ACTION; others < action; others=PlayerAction(others+1)) { const irr::core::stringw others_item = m_config->getMappingIdString(others); if (others_item == item) { conflicts_inside = true; actions->markItemRed( KartActionStrings[others] ); } } //actions->renameItem( KartActionStrings[action], // _("Binding Conflict!") ); } } // menu keys and game keys can overlap, no problem, so forget game keys // before checking menu keys currentlyUsedKeys.clear(); for (PlayerAction action = PA_FIRST_MENU_ACTION; action <= PA_LAST_MENU_ACTION; action=PlayerAction(action+1)) { const irr::core::stringw item = m_config->getBindingAsString(action); if (currentlyUsedKeys.find(item) == currentlyUsedKeys.end()) { currentlyUsedKeys.insert( item ); if (m_config->getType() == DEVICE_CONFIG_TYPE_KEYBOARD && conflictsBetweenKbdConfig(action, PA_FIRST_MENU_ACTION, PA_LAST_MENU_ACTION)) { conflicts_between = true; actions->markItemBlue (KartActionStrings[action]); } } else { // binding conflict! actions->markItemRed( KartActionStrings[action] ); // also mark others for (PlayerAction others = PA_FIRST_MENU_ACTION; others < action; others=PlayerAction(others+1)) { const irr::core::stringw others_item = m_config->getBindingAsString(others); if (others_item == item) { conflicts_inside = true; actions->markItemRed( KartActionStrings[others] ); } } //actions->renameItem( KartActionStrings[action], // _("Binding Conflict!") ); } } GUIEngine::Widget* conflict_label = getWidget<GUIEngine::LabelWidget>("conflict"); std::wostringstream oss; if (conflicts_between) { oss << _("* A blue item means a conflict with another configuration"); if (conflicts_inside) oss << "\n"; } if (conflicts_inside) oss << _("* A red item means a conflict in the current configuration"); conflict_label->setText(oss.str().c_str()); } // updateInputButtons