From 3119dec5c2fc83fcd8bc0b3176dac407bbdfb5a7 Mon Sep 17 00:00:00 2001 From: rforder Date: Thu, 13 Aug 2009 21:58:55 +0000 Subject: [PATCH] temporary work around for multiplayer kart selection git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3855 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/input/device_manager.cpp | 4 +--- src/states_screens/kart_selection.cpp | 29 ++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/input/device_manager.cpp b/src/input/device_manager.cpp index 7842cb1af..1374d1568 100644 --- a/src/input/device_manager.cpp +++ b/src/input/device_manager.cpp @@ -170,7 +170,6 @@ InputDevice *DeviceManager::mapKeyboardInput( int deviceID, if (m_assign_mode == NO_ASSIGN) // Don't set the player in NO_ASSIGN mode { *player = NULL; - if (!progGen) m_latest_used_device = keyboard; } else *player = keyboard->m_player; } @@ -198,8 +197,6 @@ InputDevice *DeviceManager::mapGamepadInput( Input::InputType type, if (m_assign_mode == NO_ASSIGN) // Don't set the player in NO_ASSIGN mode { *player = NULL; - // IT_STICKMOTION happens all the time, don't consider it discrete input - if ((!progGen) && (type == Input::IT_STICKBUTTON)) m_latest_used_device = gPad; } else { @@ -241,6 +238,7 @@ bool DeviceManager::translateInput( Input::InputType type, }; // Return true if input was successfully translated to an action and player + if (device != NULL) m_latest_used_device = device; return (device != NULL); } //----------------------------------------------------------------------------- diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index ce40a06d8..6a5bc5b41 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -382,12 +382,31 @@ class KartHoverListener : public RibbonGridHoverListener public: void onSelectionChanged(RibbonGridWidget* theWidget, const std::string& selectionID) { + InputDevice *device; + ActivePlayer *player; + int pKartIndex = -1; //std::cout << "hovered " << selectionID.c_str() << std::endl; - if(selectionID.size() == 0) return; + // FIXME: temporary work around for multiplayer support on the kart selection screen + // The ribbon grid widget needs to be rewritten to support multiple selection boxes - // TODO : support players other than player 0 (i.e. multiplayer) - ModelViewWidget* w3 = g_player_karts[0].modelView; + device = input_manager->getDeviceList()->getLatestUsedDevice(); + if(selectionID.size() == 0) return; + if((player = device->getPlayer()) == NULL) return; + + for (int n = 0; (n < g_player_karts.size() && pKartIndex == -1); n++) + { + if (g_player_karts[n].m_associatedPlayer == player) + pKartIndex = n; + } + if (pKartIndex == -1) + { + fprintf(stderr, "onSelectionChanged(): Unable to determine kart associated with device\n"); + return; + } + + + ModelViewWidget* w3 = g_player_karts[pKartIndex].modelView; assert( w3 != NULL ); const KartProperties* kart = kart_properties_manager->getKart(selectionID); @@ -402,8 +421,8 @@ class KartHoverListener : public RibbonGridHoverListener w3->addModel( kartModel->getWheelModel(3), kartModel->getWheelGraphicsPosition(3) ); w3->update(0); - // TODO : support players other than player 0 (i.e. multiplayer) - g_player_karts[0].kartName->setText( kart->getName().c_str() ); + + g_player_karts[pKartIndex].kartName->setText( kart->getName().c_str() ); } }; KartHoverListener* karthoverListener = NULL;