From 9ec58bbcb1f1dd78f2154075ed58a0fae1961a6e Mon Sep 17 00:00:00 2001 From: hilnius Date: Thu, 1 Aug 2013 23:28:21 +0000 Subject: [PATCH] working karts online selection git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13405 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/states_screens/kart_selection.cpp | 53 +++++++++++++++++++ src/states_screens/network_kart_selection.cpp | 51 ------------------ 2 files changed, 53 insertions(+), 51 deletions(-) diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index ca496208c..0af6366ba 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -1504,6 +1504,59 @@ void KartSelectionScreen::playerConfirm(const int playerID) if (allPlayersReady && (!m_multiplayer || amount > 1)) allPlayersDone(); } // playerConfirm +// ---------------------------------------------------------------------------- + +void KartSelectionScreen::considerKartHovered(uint8_t widget_id, std::string selection) +{ + ModelViewWidget* w3 = m_kart_widgets[widget_id].m_model_view; + assert( w3 != NULL ); + + if (selection == RANDOM_KART_ID) + { + // Random kart + scene::IMesh* model = + ItemManager::getItemModel(Item::ITEM_BONUS_BOX); + w3->clearModels(); + w3->addModel( model, Vec3(0.0f, -12.0f, 0.0f), + Vec3(35.0f, 35.0f, 35.0f) ); + w3->update(0); + m_kart_widgets[widget_id].m_kart_name->setText( + _("Random Kart"), false ); + } + else + { + const KartProperties *kp = + kart_properties_manager->getKart(selection); + if (kp != NULL) + { + const KartModel &kart_model = kp->getMasterKartModel(); + + w3->clearModels(); + w3->addModel( kart_model.getModel(), Vec3(0,0,0), + Vec3(35.0f, 35.0f, 35.0f), + kart_model.getBaseFrame() ); + w3->addModel( kart_model.getWheelModel(0), + kart_model.getWheelGraphicsPosition(0) ); + w3->addModel( kart_model.getWheelModel(1), + kart_model.getWheelGraphicsPosition(1) ); + w3->addModel( kart_model.getWheelModel(2), + kart_model.getWheelGraphicsPosition(2) ); + w3->addModel( kart_model.getWheelModel(3), + kart_model.getWheelGraphicsPosition(3) ); + w3->update(0); + + m_kart_widgets[widget_id].m_kart_name->setText( + selection.c_str(), false ); + } + else + { + fprintf(stderr, "[KartSelectionScreen] WARNING: could not " + "find a kart named '%s'\n", + selection.c_str()); + } + } +} + // ---------------------------------------------------------------------------- /** * Callback handling events from the kart selection menu diff --git a/src/states_screens/network_kart_selection.cpp b/src/states_screens/network_kart_selection.cpp index 3aad251f5..ec346a3a6 100644 --- a/src/states_screens/network_kart_selection.cpp +++ b/src/states_screens/network_kart_selection.cpp @@ -132,57 +132,6 @@ void NetworkKartSelectionScreen::playerConfirm(const int playerID) } } -void NetworkKartSelectionScreen::considerKartHovered(uint8_t widget_id, std::string selection) -{ - ModelViewWidget* w3 = m_kart_widgets[widget_id].m_model_view; - assert( w3 != NULL ); - - if (selection == RANDOM_KART_ID) - { - // Random kart - scene::IMesh* model = - ItemManager::getItemModel(Item::ITEM_BONUS_BOX); - w3->clearModels(); - w3->addModel( model, Vec3(0.0f, -12.0f, 0.0f), - Vec3(35.0f, 35.0f, 35.0f) ); - w3->update(0); - m_kart_widgets[widget_id].m_kart_name->setText( - _("Random Kart"), false ); - } - else - { - const KartProperties *kp = - kart_properties_manager->getKart(selection); - if (kp != NULL) - { - const KartModel &kart_model = kp->getMasterKartModel(); - - //w3->clearModels(); - w3->addModel( kart_model.getModel(), Vec3(0,0,0), - Vec3(35.0f, 35.0f, 35.0f), - kart_model.getBaseFrame() ); - w3->addModel( kart_model.getWheelModel(0), - kart_model.getWheelGraphicsPosition(0) ); - w3->addModel( kart_model.getWheelModel(1), - kart_model.getWheelGraphicsPosition(1) ); - w3->addModel( kart_model.getWheelModel(2), - kart_model.getWheelGraphicsPosition(2) ); - w3->addModel( kart_model.getWheelModel(3), - kart_model.getWheelGraphicsPosition(3) ); - w3->update(0); - - m_kart_widgets[widget_id].m_kart_name->setText( - selection.c_str(), false ); - } - else - { - fprintf(stderr, "[KartSelectionScreen] WARNING: could not " - "find a kart named '%s'\n", - selection.c_str()); - } - } -} - void NetworkKartSelectionScreen::playerSelected(uint8_t race_id, std::string kart_name) { uint8_t widget_id = -1;