diff --git a/src/guiengine/screen.cpp b/src/guiengine/screen.cpp index 0b257faa8..6281a867d 100644 --- a/src/guiengine/screen.cpp +++ b/src/guiengine/screen.cpp @@ -315,7 +315,7 @@ void Screen::addWidgets() // select the first widget (for first players only; if other players need some focus the Screen must provide it). Widget* w = getFirstWidget(); //std::cout << "First widget is " << (w == NULL ? "null" : w->m_properties[PROP_ID].c_str()) << std::endl; - if (w != NULL) w->setFocusForPlayer( GUI_PLAYER_ID ); + if (w != NULL) w->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); else std::cerr << "Couldn't select first widget, NULL was returned\n"; } // ----------------------------------------------------------------------------- diff --git a/src/guiengine/skin.cpp b/src/guiengine/skin.cpp index 5677699df..52d8f71f1 100644 --- a/src/guiengine/skin.cpp +++ b/src/guiengine/skin.cpp @@ -651,13 +651,13 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, Widget* widget, const // we ever need to... if (widget->m_deactivated) return; - bool mark_selected = widget->isSelected(GUI_PLAYER_ID); + bool mark_selected = widget->isSelected(PLAYER_ID_GAME_MASTER); bool always_show_selection = false; IGUIElement* focusedElem = NULL; - if (GUIEngine::getFocusForPlayer(GUI_PLAYER_ID) != NULL) + if (GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER) != NULL) { - focusedElem = GUIEngine::getFocusForPlayer(GUI_PLAYER_ID)->getIrrlichtElement(); + focusedElem = GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER)->getIrrlichtElement(); } const bool parent_focused = (focusedElem == widget->m_event_handler->m_element); @@ -1229,7 +1229,7 @@ void Skin::draw2DRectangle (IGUIElement *element, const video::SColor &color, co if (type == WTYPE_LIST) { // lists not supported in multiplayer screens - const bool focused = GUIEngine::isFocusedForPlayer(widget, GUI_PLAYER_ID); + const bool focused = GUIEngine::isFocusedForPlayer(widget, PLAYER_ID_GAME_MASTER); drawListSelection(rect, widget, focused); } @@ -1260,7 +1260,7 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co return; } - const bool focused = GUIEngine::isFocusedForPlayer(widget, GUI_PLAYER_ID); + const bool focused = GUIEngine::isFocusedForPlayer(widget, PLAYER_ID_GAME_MASTER); /* std::cout << "Skin (3D Pane) : " << (widget == NULL ? "NULL!!" : widget->m_properties[PROP_ID].c_str()) @@ -1412,9 +1412,9 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, bool f const WidgetType type = widget->m_type; IGUIElement* focusedElem = NULL; - if (GUIEngine::getFocusForPlayer(GUI_PLAYER_ID) != NULL) + if (GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER) != NULL) { - focusedElem = GUIEngine::getFocusForPlayer(GUI_PLAYER_ID)->getIrrlichtElement(); + focusedElem = GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER)->getIrrlichtElement(); } const bool focused = (focusedElem == element); diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.cpp b/src/guiengine/widgets/dynamic_ribbon_widget.cpp index 083a40183..000b173e7 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.cpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.cpp @@ -631,7 +631,7 @@ void DynamicRibbonWidget::updateLabel(RibbonWidget* from_this_ribbon) if (!m_has_label) return; // only the master player can update the label - const int playerID = GUI_PLAYER_ID; + const int playerID = PLAYER_ID_GAME_MASTER; RibbonWidget* row = from_this_ribbon ? from_this_ribbon : (RibbonWidget*)getSelectedRibbon(playerID); if (row == NULL) return; diff --git a/src/guiengine/widgets/ribbon_widget.cpp b/src/guiengine/widgets/ribbon_widget.cpp index 3101de2b5..905e2c7c3 100644 --- a/src/guiengine/widgets/ribbon_widget.cpp +++ b/src/guiengine/widgets/ribbon_widget.cpp @@ -20,6 +20,7 @@ #include "guiengine/engine.hpp" #include "input/input_manager.hpp" #include "io/file_manager.hpp" +#include "states_screens/state_manager.hpp" #include "utils/string_utils.hpp" #include @@ -279,8 +280,7 @@ EventPropagation RibbonWidget::rightPressed(const int playerID) if (m_ribbon_type == RIBBON_COMBO) { const int mousePlayerID = input_manager->getPlayerKeyboardID(); - const int MASTER_PLAYER = 0; // FIXME: unclean - if (playerID == mousePlayerID || playerID == MASTER_PLAYER) + if (playerID == mousePlayerID || playerID == PLAYER_ID_GAME_MASTER) { m_mouse_focus = m_children.get(m_selection[playerID]); } @@ -320,8 +320,7 @@ EventPropagation RibbonWidget::leftPressed(const int playerID) if (m_ribbon_type == RIBBON_COMBO) { const int mousePlayerID = input_manager->getPlayerKeyboardID(); - const int MASTER_PLAYER = 0; // FIXME: unclean - if (playerID == mousePlayerID || playerID == MASTER_PLAYER) + if (playerID == mousePlayerID || playerID == PLAYER_ID_GAME_MASTER) { m_mouse_focus = m_children.get(m_selection[playerID]); } @@ -353,8 +352,8 @@ EventPropagation RibbonWidget::focused(const int playerID) if (m_ribbon_type == RIBBON_COMBO) { const int mousePlayerID = input_manager->getPlayerKeyboardID(); - const int MASTER_PLAYER = 0; // FIXME: unclean - if (m_mouse_focus == NULL && m_selection[playerID] != -1 && (playerID == mousePlayerID || playerID == MASTER_PLAYER)) + if (m_mouse_focus == NULL && m_selection[playerID] != -1 && + (playerID == mousePlayerID || playerID == PLAYER_ID_GAME_MASTER)) { m_mouse_focus = m_children.get(m_selection[playerID]); } diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index aaf10f50a..4cdf773fc 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -264,7 +264,7 @@ void InputManager::inputSensing(Input::InputType type, int deviceID, int btnID, int InputManager::getPlayerKeyboardID() const { // In no-assign mode, just return the GUI player ID (devices not assigned yet) - if (m_device_manager->getAssignMode() == NO_ASSIGN) return GUI_PLAYER_ID; + if (m_device_manager->getAssignMode() == NO_ASSIGN) return PLAYER_ID_GAME_MASTER; // Otherwise, after devices are assigned, we can check in more depth // Return the first keyboard that is actually being used diff --git a/src/states_screens/arenas_screen.cpp b/src/states_screens/arenas_screen.cpp index 9ebb1949a..ffd3fe741 100644 --- a/src/states_screens/arenas_screen.cpp +++ b/src/states_screens/arenas_screen.cpp @@ -46,7 +46,7 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const DynamicRibbonWidget* w2 = dynamic_cast(widget); if(w2==NULL) return; - const std::string selection = w2->getSelectionIDString(GUI_PLAYER_ID); + const std::string selection = w2->getSelectionIDString(PLAYER_ID_GAME_MASTER); if(UserConfigParams::m_verbosity>=5) std::cout << "Clicked on arena " << selection.c_str() << std::endl; diff --git a/src/states_screens/challenges.cpp b/src/states_screens/challenges.cpp index b79ffbd1b..7213d370a 100644 --- a/src/states_screens/challenges.cpp +++ b/src/states_screens/challenges.cpp @@ -112,9 +112,8 @@ void ChallengesScreen::eventCallback(GUIEngine::Widget* widget, const std::strin DynamicRibbonWidget* w = this->getWidget("challenges"); assert( w != NULL ); - // FIXME : don't hardcode player 0? - const int playerID = 0; - std::string selection = w->getSelectionIDString( playerID ); + // only player 0 can start a challenge (i.e. we have no multiplayer challenges) + std::string selection = w->getSelectionIDString( PLAYER_ID_GAME_MASTER ); if (selection == "locked") { diff --git a/src/states_screens/dialogs/add_device_dialog.cpp b/src/states_screens/dialogs/add_device_dialog.cpp index ae509c5a7..394ef75a1 100644 --- a/src/states_screens/dialogs/add_device_dialog.cpp +++ b/src/states_screens/dialogs/add_device_dialog.cpp @@ -82,7 +82,7 @@ AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.7f, 0.7f) m_children.push_back(widget); widget->add(); - widget->setFocusForPlayer( GUI_PLAYER_ID ); + widget->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); } diff --git a/src/states_screens/dialogs/confirm_resolution_dialog.cpp b/src/states_screens/dialogs/confirm_resolution_dialog.cpp index 1745e7bde..b4a585153 100644 --- a/src/states_screens/dialogs/confirm_resolution_dialog.cpp +++ b/src/states_screens/dialogs/confirm_resolution_dialog.cpp @@ -88,7 +88,7 @@ ConfirmResolutionDialog::ConfirmResolutionDialog() : ModalDialog(0.7f, 0.7f) m_children.push_back(widget); widget->add(); - widget->setFocusForPlayer( GUI_PLAYER_ID ); + widget->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); } } diff --git a/src/states_screens/dialogs/enter_player_name_dialog.cpp b/src/states_screens/dialogs/enter_player_name_dialog.cpp index 71b51eeb2..e6a7805e3 100644 --- a/src/states_screens/dialogs/enter_player_name_dialog.cpp +++ b/src/states_screens/dialogs/enter_player_name_dialog.cpp @@ -65,7 +65,7 @@ EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) : textCtrl->setParent(m_irrlicht_window); m_children.push_back(textCtrl); textCtrl->add(); - textCtrl->setFocusForPlayer(GUI_PLAYER_ID); + textCtrl->setFocusForPlayer(PLAYER_ID_GAME_MASTER); // TODO : add Ok button diff --git a/src/states_screens/dialogs/gp_info_dialog.cpp b/src/states_screens/dialogs/gp_info_dialog.cpp index 96e0b8487..1e48d0369 100644 --- a/src/states_screens/dialogs/gp_info_dialog.cpp +++ b/src/states_screens/dialogs/gp_info_dialog.cpp @@ -158,7 +158,7 @@ GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const floa okBtn->getIrrlichtElement()->setTabStop(true); okBtn->getIrrlichtElement()->setTabGroup(false); - okBtn->setFocusForPlayer( GUI_PLAYER_ID ); + okBtn->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); } diff --git a/src/states_screens/dialogs/player_info_dialog.cpp b/src/states_screens/dialogs/player_info_dialog.cpp index 4f009d956..adaea7921 100644 --- a/src/states_screens/dialogs/player_info_dialog.cpp +++ b/src/states_screens/dialogs/player_info_dialog.cpp @@ -115,7 +115,7 @@ void PlayerInfoDialog::showRegularDialog() widget->add(); } - textCtrl->setFocusForPlayer( GUI_PLAYER_ID ); + textCtrl->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); } // ------------------------------------------------------------------------------------------------------ @@ -178,7 +178,7 @@ void PlayerInfoDialog::showConfirmDialog() m_children.push_back(widget); widget->add(); - widget->setFocusForPlayer( GUI_PLAYER_ID ); + widget->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); } } diff --git a/src/states_screens/dialogs/race_over_dialog.cpp b/src/states_screens/dialogs/race_over_dialog.cpp index bb6267799..d3685e172 100644 --- a/src/states_screens/dialogs/race_over_dialog.cpp +++ b/src/states_screens/dialogs/race_over_dialog.cpp @@ -270,7 +270,7 @@ RaceOverDialog::RaceOverDialog(const float percentWidth, m_children.push_back(whats_next_btn); whats_next_btn->add(); - whats_next_btn->setFocusForPlayer( GUI_PLAYER_ID ); + whats_next_btn->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); } else if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_SINGLE) { @@ -309,7 +309,7 @@ RaceOverDialog::RaceOverDialog(const float percentWidth, m_children.push_back(whats_next_btn); whats_next_btn->add(); - whats_next_btn->setFocusForPlayer( GUI_PLAYER_ID ); + whats_next_btn->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); } else if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX) { @@ -326,7 +326,7 @@ RaceOverDialog::RaceOverDialog(const float percentWidth, m_children.push_back(whats_next_btn); whats_next_btn->add(); - whats_next_btn->setFocusForPlayer( GUI_PLAYER_ID ); + whats_next_btn->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); ButtonWidget* abort_gp = new ButtonWidget(); diff --git a/src/states_screens/dialogs/race_paused_dialog.cpp b/src/states_screens/dialogs/race_paused_dialog.cpp index 37b8b315d..31ba87b4b 100644 --- a/src/states_screens/dialogs/race_paused_dialog.cpp +++ b/src/states_screens/dialogs/race_paused_dialog.cpp @@ -76,7 +76,7 @@ RacePausedDialog::RacePausedDialog(const float percentWidth, const float percent m_children.push_back(back_btn); back_btn->add(); - back_btn->setFocusForPlayer( GUI_PLAYER_ID ); + back_btn->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); // ---- Choice ribbon m_choice_ribbon = new RibbonWidget(RIBBON_TOOLBAR); @@ -167,7 +167,7 @@ GUIEngine::EventPropagation RacePausedDialog::processEvent(const std::string& ev } else if (eventSource == "choiceribbon") { - const std::string& selection = m_choice_ribbon->getSelectionIDString(GUI_PLAYER_ID); + const std::string& selection = m_choice_ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER); if(UserConfigParams::m_verbosity>=5) std::cout << "RacePausedDialog::processEvent(" diff --git a/src/states_screens/dialogs/track_info_dialog.cpp b/src/states_screens/dialogs/track_info_dialog.cpp index 7469f8c5e..4d2408bf3 100644 --- a/src/states_screens/dialogs/track_info_dialog.cpp +++ b/src/states_screens/dialogs/track_info_dialog.cpp @@ -153,7 +153,7 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core: okBtn->getIrrlichtElement()->setTabStop(true); okBtn->getIrrlichtElement()->setTabGroup(false); - okBtn->setFocusForPlayer( GUI_PLAYER_ID ); + okBtn->setFocusForPlayer( PLAYER_ID_GAME_MASTER ); } diff --git a/src/states_screens/help_screen_1.cpp b/src/states_screens/help_screen_1.cpp index 82623338e..bd1ac8a73 100644 --- a/src/states_screens/help_screen_1.cpp +++ b/src/states_screens/help_screen_1.cpp @@ -38,7 +38,7 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i { if (name == "category") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(GUI_PLAYER_ID).c_str(); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); //if (selection == "page1") StateManager::get()->replaceTopMostScreen(Help1Screen::getInstance()); //else @@ -57,7 +57,7 @@ void HelpScreen1::init() { RibbonWidget* w = this->getWidget("category"); - if (w != NULL) w->select( "page1", GUI_PLAYER_ID ); + if (w != NULL) w->select( "page1", PLAYER_ID_GAME_MASTER ); } // ------------------------------------------------------------------------------------------------------ diff --git a/src/states_screens/help_screen_2.cpp b/src/states_screens/help_screen_2.cpp index b153835fc..2320e69dd 100644 --- a/src/states_screens/help_screen_2.cpp +++ b/src/states_screens/help_screen_2.cpp @@ -38,7 +38,7 @@ void HelpScreen2::eventCallback(Widget* widget, const std::string& name, const i { if (name == "category") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(GUI_PLAYER_ID).c_str(); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); if(selection == "page1") StateManager::get()->replaceTopMostScreen(HelpScreen1::getInstance()); //else if(selection == "page2") StateManager::get()->replaceTopMostScreen(HelpScreen2::getInstance()); @@ -56,7 +56,7 @@ void HelpScreen2::init() { RibbonWidget* w = this->getWidget("category"); - if (w != NULL) w->select( "page2", GUI_PLAYER_ID ); + if (w != NULL) w->select( "page2", PLAYER_ID_GAME_MASTER ); } // ------------------------------------------------------------------------------------------------------ diff --git a/src/states_screens/help_screen_3.cpp b/src/states_screens/help_screen_3.cpp index 724122fbf..9e457b302 100644 --- a/src/states_screens/help_screen_3.cpp +++ b/src/states_screens/help_screen_3.cpp @@ -38,7 +38,7 @@ void HelpScreen3::eventCallback(Widget* widget, const std::string& name, const i { if (name == "category") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(GUI_PLAYER_ID).c_str(); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); if (selection == "page1") StateManager::get()->replaceTopMostScreen(HelpScreen1::getInstance()); else if (selection == "page2") StateManager::get()->replaceTopMostScreen(HelpScreen2::getInstance()); @@ -56,7 +56,7 @@ void HelpScreen3::init() { RibbonWidget* w = this->getWidget("category"); - if (w != NULL) w->select( "page3", GUI_PLAYER_ID ); + if (w != NULL) w->select( "page3", PLAYER_ID_GAME_MASTER ); } // ------------------------------------------------------------------------------------------------------ diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index 199e0cede..59f3b7c96 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -1032,7 +1032,7 @@ void KartSelectionScreen::eventCallback(Widget* widget, const std::string& name, setKartsFromCurrentGroup(); - const std::string selected_kart_group = tabs->getSelectionIDString(GUI_PLAYER_ID); + const std::string selected_kart_group = tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER); // update players selections (FIXME: don't hardcode player 0 below) const int num_players = m_kart_widgets.size(); @@ -1386,7 +1386,7 @@ void KartSelectionScreen::setKartsFromCurrentGroup() RibbonWidget* tabs = this->getWidget("kartgroups"); assert(tabs != NULL); - const std::string selected_kart_group = tabs->getSelectionIDString(GUI_PLAYER_ID); + const std::string selected_kart_group = tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER); DynamicRibbonWidget* w = this->getWidget("karts"); w->clearItems(); diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index f7e1ab9d9..6122f6570 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -69,7 +69,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, cons { RibbonWidget* ribbon = dynamic_cast(widget); if (ribbon == NULL) return; // only interesting stuff in main menu is the ribbons - std::string selection = ribbon->getSelectionIDString(GUI_PLAYER_ID); + std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER); if (selection == "network") diff --git a/src/states_screens/options_screen_av.cpp b/src/states_screens/options_screen_av.cpp index 399e84d7d..90766273b 100644 --- a/src/states_screens/options_screen_av.cpp +++ b/src/states_screens/options_screen_av.cpp @@ -46,7 +46,7 @@ OptionsScreenAV::OptionsScreenAV() : Screen("options_av.stkgui") void OptionsScreenAV::init() { RibbonWidget* ribbon = this->getWidget("options_choice"); - if (ribbon != NULL) ribbon->select( "tab_audio_video", GUI_PLAYER_ID ); + if (ribbon != NULL) ribbon->select( "tab_audio_video", PLAYER_ID_GAME_MASTER ); // ---- sfx volume SpinnerWidget* gauge = this->getWidget("sfx_volume"); @@ -128,7 +128,7 @@ void OptionsScreenAV::init() { //std::cout << "************* Detected right resolution!!! " << n << "\n"; // that's the current one - res->setSelection(n, GUI_PLAYER_ID, false); + res->setSelection(n, PLAYER_ID_GAME_MASTER, false); break; } } // end for @@ -142,7 +142,7 @@ void OptionsScreenAV::eventCallback(Widget* widget, const std::string& name, con { if (name == "options_choice") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(GUI_PLAYER_ID).c_str(); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); if (selection == "tab_audio_video") StateManager::get()->replaceTopMostScreen(OptionsScreenAV::getInstance()); else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance()); @@ -206,7 +206,7 @@ void OptionsScreenAV::eventCallback(Widget* widget, const std::string& name, con DynamicRibbonWidget* w1 = this->getWidget("resolutions"); assert(w1 != NULL); - const std::string& res = w1->getSelectionIDString(GUI_PLAYER_ID); + const std::string& res = w1->getSelectionIDString(PLAYER_ID_GAME_MASTER); int w = -1, h = -1; if (sscanf(res.c_str(), "%ix%i", &w, &h) != 2 || w == -1 || h == -1) diff --git a/src/states_screens/options_screen_input.cpp b/src/states_screens/options_screen_input.cpp index c38ceb2c0..01bb499f8 100644 --- a/src/states_screens/options_screen_input.cpp +++ b/src/states_screens/options_screen_input.cpp @@ -263,7 +263,7 @@ void OptionsScreenInput::buildDeviceList() void OptionsScreenInput::init() { RibbonWidget* tabBar = this->getWidget("options_choice"); - if (tabBar != NULL) tabBar->select( "tab_controls", GUI_PLAYER_ID ); + if (tabBar != NULL) tabBar->select( "tab_controls", PLAYER_ID_GAME_MASTER ); DynamicRibbonWidget* devices = this->getWidget("devices"); @@ -278,7 +278,7 @@ void OptionsScreenInput::init() // trigger displaying bindings for default selected device const std::string name2("devices"); - eventCallback(devices, name2, GUI_PLAYER_ID); + eventCallback(devices, name2, PLAYER_ID_GAME_MASTER); } // ----------------------------------------------------------------------------- @@ -303,7 +303,7 @@ void OptionsScreenInput::gotSensedInput(Input* sensedInput) DynamicRibbonWidget* devices = this->getWidget("devices"); assert( devices != NULL ); - std::string deviceID = devices->getSelectionIDString(GUI_PLAYER_ID); + std::string deviceID = devices->getSelectionIDString(PLAYER_ID_GAME_MASTER); const bool keyboard = sensedInput->type == Input::IT_KEYBOARD && deviceID.find("keyboard") != std::string::npos; const bool gamepad = (sensedInput->type == Input::IT_STICKMOTION || @@ -327,7 +327,7 @@ void OptionsScreenInput::gotSensedInput(Input* sensedInput) // extract keyboard ID from name int configID = -1; - sscanf( devices->getSelectionIDString(GUI_PLAYER_ID).c_str(), "keyboard%i", &configID ); + sscanf( devices->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(), "keyboard%i", &configID ); KeyboardConfig* keyboard = input_manager->getDeviceList()->getKeyboardConfig(configID); keyboard->setBinding(binding_to_set, Input::IT_KEYBOARD, sensedInput->btnID, Input::AD_NEUTRAL); @@ -354,7 +354,7 @@ void OptionsScreenInput::gotSensedInput(Input* sensedInput) // extract gamepad ID from name int configID = -1; - sscanf( devices->getSelectionIDString(GUI_PLAYER_ID).c_str(), "gamepad%i", &configID ); + sscanf( devices->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(), "gamepad%i", &configID ); GamepadConfig* config = input_manager->getDeviceList()->getGamepadConfig(configID); config->setBinding(binding_to_set, sensedInput->type, sensedInput->btnID, @@ -373,7 +373,7 @@ void OptionsScreenInput::gotSensedInput(Input* sensedInput) // re-select the previous button ButtonWidget* btn = this->getWidget(binding_to_set_button.c_str()); - if(btn != NULL) btn->setFocusForPlayer(GUI_PLAYER_ID); + if(btn != NULL) btn->setFocusForPlayer(PLAYER_ID_GAME_MASTER); // save new binding to file input_manager->getDeviceList()->serialize(); @@ -391,7 +391,7 @@ void OptionsScreenInput::eventCallback(Widget* widget, const std::string& name, if (name == "options_choice") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(GUI_PLAYER_ID).c_str(); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); if (selection == "tab_audio_video") StateManager::get()->replaceTopMostScreen(OptionsScreenAV::getInstance()); else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance()); @@ -410,7 +410,7 @@ void OptionsScreenInput::eventCallback(Widget* widget, const std::string& name, DynamicRibbonWidget* devices = this->getWidget("devices"); assert(devices != NULL); - const std::string& selection = devices->getSelectionIDString(GUI_PLAYER_ID); + const std::string& selection = devices->getSelectionIDString(PLAYER_ID_GAME_MASTER); if (selection.find("gamepad") != std::string::npos) { int i = -1, read = 0; @@ -490,11 +490,11 @@ void OptionsScreenInput::eventCallback(Widget* widget, const std::string& name, DynamicRibbonWidget* devices = this->getWidget("devices"); assert( devices != NULL ); - std::cout << "\n% Entering sensing mode for " << devices->getSelectionIDString(GUI_PLAYER_ID).c_str() << std::endl; + std::cout << "\n% Entering sensing mode for " << devices->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str() << std::endl; new PressAKeyDialog(0.4f, 0.4f); - std::string selection = devices->getSelectionIDString(GUI_PLAYER_ID); + std::string selection = devices->getSelectionIDString(PLAYER_ID_GAME_MASTER); if (selection.find("keyboard") != std::string::npos) { input_manager->setMode(InputManager::INPUT_SENSE_KEYBOARD); diff --git a/src/states_screens/options_screen_players.cpp b/src/states_screens/options_screen_players.cpp index 1cc0be026..ecb249f85 100644 --- a/src/states_screens/options_screen_players.cpp +++ b/src/states_screens/options_screen_players.cpp @@ -50,7 +50,7 @@ OptionsScreenPlayers::OptionsScreenPlayers() : Screen("options_players.stkgui") void OptionsScreenPlayers::init() { RibbonWidget* tabBar = this->getWidget("options_choice"); - if (tabBar != NULL) tabBar->select( "tab_players", GUI_PLAYER_ID ); + if (tabBar != NULL) tabBar->select( "tab_players", PLAYER_ID_GAME_MASTER ); ListWidget* players = this->getWidget("players"); assert(players != NULL); @@ -133,7 +133,7 @@ void OptionsScreenPlayers::eventCallback(Widget* widget, const std::string& name { if (name == "options_choice") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(GUI_PLAYER_ID).c_str(); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); if (selection == "tab_audio_video") StateManager::get()->replaceTopMostScreen(OptionsScreenAV::getInstance()); else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance()); diff --git a/src/states_screens/race_setup_screen.cpp b/src/states_screens/race_setup_screen.cpp index 14fea49f3..74e76451a 100644 --- a/src/states_screens/race_setup_screen.cpp +++ b/src/states_screens/race_setup_screen.cpp @@ -64,7 +64,7 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name, con { RibbonWidget* w = dynamic_cast(widget); assert(w != NULL); - const std::string& selection = w->getSelectionIDString(GUI_PLAYER_ID); + const std::string& selection = w->getSelectionIDString(PLAYER_ID_GAME_MASTER); if (selection == "novice") { @@ -85,7 +85,7 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name, con else if (name == "gamemode") { DynamicRibbonWidget* w = dynamic_cast(widget); - const std::string selectedMode = w->getSelectionIDString(GUI_PLAYER_ID); + const std::string selectedMode = w->getSelectionIDString(PLAYER_ID_GAME_MASTER); if (selectedMode == "normal") { @@ -155,7 +155,7 @@ void RaceSetupScreen::init() { RibbonWidget* w = getWidget("difficulty"); assert( w != NULL ); - w->setSelection( race_manager->getDifficulty(), GUI_PLAYER_ID ); + w->setSelection( race_manager->getDifficulty(), PLAYER_ID_GAME_MASTER ); SpinnerWidget* kartamount = getWidget("aikartamount"); kartamount->setValue( race_manager->getNumberOfKarts() - race_manager->getNumPlayers() ); diff --git a/src/states_screens/state_manager.hpp b/src/states_screens/state_manager.hpp index e2c93a756..8b80ffeae 100644 --- a/src/states_screens/state_manager.hpp +++ b/src/states_screens/state_manager.hpp @@ -33,7 +33,7 @@ namespace GUIEngine class Widget; } -const static int GUI_PLAYER_ID = 0; +const static int PLAYER_ID_GAME_MASTER = 0; class StateManager : public GUIEngine::AbstractStateManager { diff --git a/src/states_screens/tracks_screen.cpp b/src/states_screens/tracks_screen.cpp index 04b4e01a6..85365947d 100644 --- a/src/states_screens/tracks_screen.cpp +++ b/src/states_screens/tracks_screen.cpp @@ -78,7 +78,7 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const DynamicRibbonWidget* w2 = dynamic_cast(widget); if (w2 != NULL) { - const std::string selection = w2->getSelectionIDString(GUI_PLAYER_ID); + const std::string selection = w2->getSelectionIDString(PLAYER_ID_GAME_MASTER); if(UserConfigParams::m_verbosity>=5) std::cout << "Clicked on track " << selection.c_str() << std::endl; @@ -128,7 +128,7 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const DynamicRibbonWidget* gps_widget = dynamic_cast(widget); if (gps_widget != NULL) { - std::string selection = gps_widget->getSelectionIDString(GUI_PLAYER_ID); + std::string selection = gps_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER); if (selection == "locked") { @@ -211,8 +211,8 @@ void TracksScreen::init() buildTrackList(); - // FIXME: don't hardcode player 0? - tracks_widget->setSelection(tracks_widget->getItems()[0].m_code_name, 0, true); + // select something for the game master + tracks_widget->setSelection(tracks_widget->getItems()[0].m_code_name, PLAYER_ID_GAME_MASTER, true); } // ----------------------------------------------------------------------------------------------- @@ -262,7 +262,6 @@ void TracksScreen::buildTrackList() } else { - //FIXME: don't hardcode player 0? const std::vector& curr_group = track_manager->getTracksInGroup( curr_group_name ); const int trackAmount = curr_group.size(); @@ -280,13 +279,13 @@ void TracksScreen::buildTrackList() else { tracks_widget->addItem( curr->getName(), curr->getIdent(), curr->getScreenshotFile(), - 0, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE ); + 0 /* no badge */, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE ); } } } tracks_widget->addItem(_("Random Track"), "random_track", "/gui/track_random.png", - 0, IconButtonWidget::ICON_PATH_TYPE_RELATIVE); + 0 /* no badge */, IconButtonWidget::ICON_PATH_TYPE_RELATIVE); tracks_widget->updateItemDisplay(); } @@ -298,8 +297,8 @@ void TracksScreen::setFocusOnTrack(const std::string& trackName) DynamicRibbonWidget* tracks_widget = this->getWidget("tracks"); assert( tracks_widget != NULL ); - // FIXME: don't hardcode player 0? - tracks_widget->setSelection(trackName, 0, true); + // only the game master can select tracks, so it's safe to use 'PLAYER_ID_GAME_MASTER' + tracks_widget->setSelection(trackName, PLAYER_ID_GAME_MASTER, true); } // ----------------------------------------------------------------------------------------------- @@ -309,8 +308,8 @@ void TracksScreen::setFocusOnGP(const std::string& gpName) DynamicRibbonWidget* gps_widget = this->getWidget("gps"); assert( gps_widget != NULL ); - // FIXME: don't hardcode player 0? - gps_widget->setSelection(gpName, 0, true); + // only the game master can select tracks/GPs, so it's safe to use 'PLAYER_ID_GAME_MASTER' + gps_widget->setSelection(gpName, PLAYER_ID_GAME_MASTER, true); } // -----------------------------------------------------------------------------------------------