From: <au...@us...> - 2009-12-17 22:18:24
|
Revision: 4316 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4316&view=rev Author: auria Date: 2009-12-17 22:18:14 +0000 (Thu, 17 Dec 2009) Log Message: ----------- When pressing escape to leave track info dialog, focus is now properly restored on previously selected track Modified Paths: -------------- main/trunk/src/states_screens/dialogs/track_info_dialog.cpp main/trunk/src/states_screens/dialogs/track_info_dialog.hpp main/trunk/src/states_screens/tracks_screen.cpp main/trunk/src/states_screens/tracks_screen.hpp Modified: main/trunk/src/states_screens/dialogs/track_info_dialog.cpp =================================================================== --- main/trunk/src/states_screens/dialogs/track_info_dialog.cpp 2009-12-17 22:06:23 UTC (rev 4315) +++ main/trunk/src/states_screens/dialogs/track_info_dialog.cpp 2009-12-17 22:18:14 UTC (rev 4316) @@ -17,6 +17,7 @@ #include "guiengine/engine.hpp" +#include "guiengine/screen.hpp" #include "guiengine/widget.hpp" #include "io/file_manager.hpp" #include "karts/kart_properties_manager.hpp" @@ -26,6 +27,7 @@ #include "race/race_manager.hpp" #include "states_screens/dialogs/track_info_dialog.hpp" #include "states_screens/state_manager.hpp" +#include "states_screens/tracks_screen.hpp" #include "tracks/track.hpp" #include "tracks/track_manager.hpp" #include "utils/string_utils.hpp" @@ -195,7 +197,7 @@ screenshotWidget->y = area_right.UpperLeftCorner.Y; screenshotWidget->w = area_right.getWidth(); screenshotWidget->h = area_right.getHeight(); - std::cout << screenshotWidget->x << ", " << screenshotWidget->y << " : " << screenshotWidget->w << ", " << screenshotWidget->h << std::endl; + //std::cout << screenshotWidget->x << ", " << screenshotWidget->y << " : " << screenshotWidget->w << ", " << screenshotWidget->h << std::endl; screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png"; // temporary icon, will replace it just after //screenshotWidget->setScaleImage(true); @@ -210,6 +212,18 @@ } +TrackInfoDialog::~TrackInfoDialog() +{ + // Place focus back on selected track, in case the dialog was cancelled and we're back to + // the track selection screen after + Screen* curr_screen = GUIEngine::getCurrentScreen(); + if (curr_screen->getName() == "tracks.stkgui") + { + ((TracksScreen*)curr_screen)->setFocusOnTrack(m_track_ident); + } + +} + // ------------------------------------------------------------------------------------------------------ // FIXME : this probably doesn't belong here Modified: main/trunk/src/states_screens/dialogs/track_info_dialog.hpp =================================================================== --- main/trunk/src/states_screens/dialogs/track_info_dialog.hpp 2009-12-17 22:06:23 UTC (rev 4315) +++ main/trunk/src/states_screens/dialogs/track_info_dialog.hpp 2009-12-17 22:18:14 UTC (rev 4316) @@ -40,7 +40,9 @@ * Creates a modal dialog with given percentage of screen width and height */ TrackInfoDialog(const std::string& trackIdent, const irr::core::stringw& trackName, - irr::video::ITexture* screenshot, const float percentWidth, const float percentHeight); + irr::video::ITexture* screenshot, const float percentWidth, const float percentHeight); + virtual ~TrackInfoDialog(); + void onEnterPressedInternal(); GUIEngine::EventPropagation processEvent(std::string& eventSource); }; Modified: main/trunk/src/states_screens/tracks_screen.cpp =================================================================== --- main/trunk/src/states_screens/tracks_screen.cpp 2009-12-17 22:06:23 UTC (rev 4315) +++ main/trunk/src/states_screens/tracks_screen.cpp 2009-12-17 22:18:14 UTC (rev 4316) @@ -112,3 +112,12 @@ void TracksScreen::tearDown() { } + +void TracksScreen::setFocusOnTrack(const std::string& trackName) +{ + DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks"); + assert( w != NULL ); + + // FIXME: don't hardcode player 0? + w->setSelection(trackName, 0, true); +} Modified: main/trunk/src/states_screens/tracks_screen.hpp =================================================================== --- main/trunk/src/states_screens/tracks_screen.hpp 2009-12-17 22:06:23 UTC (rev 4315) +++ main/trunk/src/states_screens/tracks_screen.hpp 2009-12-17 22:18:14 UTC (rev 4316) @@ -33,6 +33,8 @@ void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); void init(); void tearDown(); + + void setFocusOnTrack(const std::string& trackName); }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-22 20:18:30
|
Revision: 4339 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4339&view=rev Author: auria Date: 2009-12-22 20:18:22 +0000 (Tue, 22 Dec 2009) Log Message: ----------- Worked on a few input issues Modified Paths: -------------- main/trunk/src/states_screens/kart_selection.cpp main/trunk/src/states_screens/main_menu_screen.cpp Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2009-12-22 20:06:23 UTC (rev 4338) +++ main/trunk/src/states_screens/kart_selection.cpp 2009-12-22 20:18:22 UTC (rev 4339) @@ -959,7 +959,6 @@ // ----------------------------------------------------------------------------- void KartSelectionScreen::allPlayersDone() { - // FIXME: cancel this when leaving back to main menu input_manager->setMasterPlayerOnly(true); DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("karts"); @@ -1001,7 +1000,7 @@ race_manager->setLocalKartInfo(n, selection); } - // ---- Return to assign mode + // ---- Switch to assign mode input_manager->getDeviceList()->setAssignMode(ASSIGN); StateManager::get()->pushScreen( RaceSetupScreen::getInstance() ); Modified: main/trunk/src/states_screens/main_menu_screen.cpp =================================================================== --- main/trunk/src/states_screens/main_menu_screen.cpp 2009-12-22 20:06:23 UTC (rev 4338) +++ main/trunk/src/states_screens/main_menu_screen.cpp 2009-12-22 20:18:22 UTC (rev 4339) @@ -20,6 +20,8 @@ #include "guiengine/widget.hpp" #include "karts/kart_properties_manager.hpp" #include "main_loop.hpp" +#include "input/device_manager.hpp" +#include "input/input_manager.hpp" #include "states_screens/challenges.hpp" #include "states_screens/credits.hpp" #include "states_screens/kart_selection.hpp" @@ -42,6 +44,8 @@ void MainMenuScreen::init() { + input_manager->getDeviceList()->setAssignMode(NO_ASSIGN); + input_manager->setMasterPlayerOnly(false); } void MainMenuScreen::tearDown() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-01-04 18:59:19
|
Revision: 4394 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4394&view=rev Author: auria Date: 2010-01-04 18:59:07 +0000 (Mon, 04 Jan 2010) Log Message: ----------- Prevent 2 players from selecting the same kart Modified Paths: -------------- main/trunk/src/states_screens/kart_selection.cpp main/trunk/src/states_screens/kart_selection.hpp Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2010-01-04 18:41:04 UTC (rev 4393) +++ main/trunk/src/states_screens/kart_selection.cpp 2010-01-04 18:59:07 UTC (rev 4394) @@ -681,6 +681,7 @@ } m_parent->m_kart_widgets[playerID].setKartInternalName(selectionID); + m_parent->validateKartChoices(); } }; KartHoverListener* karthoverListener = NULL; @@ -1058,7 +1059,7 @@ // check if 2 players took the same name if (m_kart_widgets[n].getAssociatedPlayer()->getProfile() == m_kart_widgets[m].getAssociatedPlayer()->getProfile()) { - printf("\n***\n*** Someone else can't select this identity, you just took it!! ***\n***\n\n"); + printf("\n***\n*** Identity conflict!! ***\n***\n\n"); std::cout << " Player " << n << " chose " << m_kart_widgets[n].getAssociatedPlayer()->getProfile()->getName() << std::endl; std::cout << " Player " << m << " chose " << m_kart_widgets[m].getAssociatedPlayer()->getProfile()->getName() << std::endl; @@ -1088,6 +1089,60 @@ } // ----------------------------------------------------------------------------- + +bool KartSelectionScreen::validateKartChoices() +{ + bool ok = true; + + const int amount = m_kart_widgets.size(); + + // reset all marks, we'll re-add them n ext if errors are still there + for (int n=0; n<amount; n++) + { + m_kart_widgets[n].modelView->m_bad_badge = false; + } + + for (int n=0; n<amount; n++) + { + for (int m=n+1; m<amount; m++) + { + // check if 2 players took the same name + if (m_kart_widgets[n].getKartInternalName() == m_kart_widgets[m].getKartInternalName()) + { + printf("\n***\n*** Kart conflict!! ***\n***\n\n"); + std::cout << " Player " << n << " chose " << m_kart_widgets[n].getKartInternalName() << std::endl; + std::cout << " Player " << m << " chose " << m_kart_widgets[m].getKartInternalName() << std::endl; + + // two players took the same kart. check if one is ready + if (!m_kart_widgets[n].isReady() && m_kart_widgets[m].isReady()) + { + std::cout << "--> Setting red badge on player " << n << std::endl; + // player m is ready, so player n should not choose this name + m_kart_widgets[n].modelView->m_bad_badge = true; + } + else if (m_kart_widgets[n].isReady() && !m_kart_widgets[m].isReady()) + { + std::cout << "--> Setting red badge on player " << m << std::endl; + // player n is ready, so player m should not choose this name + m_kart_widgets[m].modelView->m_bad_badge = true; + } + else if (m_kart_widgets[n].isReady() && m_kart_widgets[m].isReady()) + { + // it should be impossible for two players to confirm they're ready with the same kart + assert(false); + } + + // we know it's not ok (but don't stop right now, all bad ones need red badges) + ok = false; + } + } // end for + } + + return ok; + +} + +// ----------------------------------------------------------------------------- /** * Callback handling events from the kart selection menu */ @@ -1164,7 +1219,7 @@ } else if (name == "karts") { - // make sure no other player selected the same identity + // make sure no other player selected the same identity or kart //std::cout << "\n\n\\\\\\\\ Kart Selected ////\n"; //std::cout << "Making sure no other player has ident " << g_player_karts[playerID].getAssociatedPlayer()->getProfile()->getName() << std::endl; const int amount = m_kart_widgets.size(); @@ -1173,9 +1228,11 @@ if (n == playerID) continue; // don't check a kart against itself if (m_kart_widgets[n].isReady() && - m_kart_widgets[n].getAssociatedPlayer()->getProfile() == m_kart_widgets[playerID].getAssociatedPlayer()->getProfile()) + (m_kart_widgets[n].getAssociatedPlayer()->getProfile() == + m_kart_widgets[playerID].getAssociatedPlayer()->getProfile() || + m_kart_widgets[n].getKartInternalName() == m_kart_widgets[playerID].getKartInternalName())) { - printf("\n***\n*** You can't select this identity, someone already took it!! ***\n***\n\n"); + printf("\n***\n*** You can't select this identity or kart, someone already took it!! ***\n***\n\n"); //SFXType sound; //SOUND_UGH SOUND_CRASH SOUND_USE_ANVIL SOUND_EXPLOSION SOUND_MOVE_MENU SOUND_SELECT_MENU @@ -1192,9 +1249,11 @@ m_kart_widgets[playerID].markAsReady(); // validate choices to notify player of duplicates - const bool ok = validateIdentChoices(); - if (!ok) return; + const bool names_ok = validateIdentChoices(); + const bool karts_ok = validateKartChoices(); + if (!names_ok || !karts_ok) return; + // check if all players are ready bool allPlayersReady = true; for (int n=0; n<amount; n++) @@ -1219,6 +1278,7 @@ // those events may mean that a player selection changed, so validate again validateIdentChoices(); + validateKartChoices(); } } Modified: main/trunk/src/states_screens/kart_selection.hpp =================================================================== --- main/trunk/src/states_screens/kart_selection.hpp 2010-01-04 18:41:04 UTC (rev 4393) +++ main/trunk/src/states_screens/kart_selection.hpp 2010-01-04 18:59:07 UTC (rev 4394) @@ -51,6 +51,10 @@ \return Whether all choices are ok */ bool validateIdentChoices(); + /** Checks karts chosen by players, making sure no duplicates are used. + \return Whether all choices are ok */ + bool validateKartChoices(); + public: /** Called when a player hits 'fire' on his device to join the game */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-01-11 22:08:46
|
Revision: 4432 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4432&view=rev Author: hikerstk Date: 2010-01-11 22:08:33 +0000 (Mon, 11 Jan 2010) Log Message: ----------- Removed calls to gettext in each frame, instead the tranlsation is only done once when the object is created. Modified Paths: -------------- main/trunk/src/states_screens/race_gui.cpp main/trunk/src/states_screens/race_gui.hpp Modified: main/trunk/src/states_screens/race_gui.cpp =================================================================== --- main/trunk/src/states_screens/race_gui.cpp 2010-01-11 21:55:36 UTC (rev 4431) +++ main/trunk/src/states_screens/race_gui.cpp 2010-01-11 22:08:33 UTC (rev 4432) @@ -68,6 +68,16 @@ m_plunger_face = material_manager->getMaterial("plungerface.png"); m_music_icon = material_manager->getMaterial("notes.png"); createMarkerTexture(); + + // Translate strings only one in constructor to avoid calling + // gettext in each frame. + //I18N: Shown at the end of a race + m_string_finished = _("Finished"); + m_string_lap = _("Lap"); + //I18N: as in "ready, set, go", shown at the beginning of the race + m_string_ready = _("Ready!"); + m_string_set = _("Set!"); + m_string_go = _("Go!"); } // RaceGUI //----------------------------------------------------------------------------- @@ -585,19 +595,16 @@ if(kart->hasFinishedRace()) { static video::SColor color = video::SColor(255, 255, 255, 255); - //I18N: Shown at the end of a race - core::stringw s=_("Finished"); pos.UpperLeftCorner.Y -= 2*font_height; pos.LowerRightCorner = pos.UpperLeftCorner; - font->draw(s.c_str(), pos, color); + font->draw(m_string_finished.c_str(), pos, color); } else { static video::SColor color = video::SColor(255, 255, 255, 255); - core::stringw s = _("Lap"); pos.UpperLeftCorner.Y -= 3*font_height; pos.LowerRightCorner = pos.UpperLeftCorner; - font->draw(core::stringw(_("Lap")).c_str(), pos, color); + font->draw(m_string_lap.c_str(), pos, color); char str[256]; sprintf(str, "%d/%d", lap+1, race_manager->getNumLaps()); @@ -775,9 +782,7 @@ core::rect<s32> pos(UserConfigParams::m_width>>1, UserConfigParams::m_height>>1, UserConfigParams::m_width>>1, UserConfigParams::m_height>>1); gui::IGUIFont* font = irr_driver->getRaceFont(); - //I18N: as in "ready, set, go", shown at the beginning of the race - core::stringw s=_("Ready!"); - font->draw(s.c_str(), pos, color, true, true); + font->draw(m_string_ready.c_str(), pos, color, true, true); } break; case SET_PHASE: @@ -787,8 +792,7 @@ UserConfigParams::m_width>>1, UserConfigParams::m_height>>1); gui::IGUIFont* font = irr_driver->getRaceFont(); //I18N: as in "ready, set, go", shown at the beginning of the race - core::stringw s=_("Set!"); - font->draw(s.c_str(), pos, color, true, true); + font->draw(m_string_set.c_str(), pos, color, true, true); } break; case GO_PHASE: @@ -798,8 +802,7 @@ UserConfigParams::m_width>>1, UserConfigParams::m_height>>1); gui::IGUIFont* font = irr_driver->getRaceFont(); //I18N: as in "ready, set, go", shown at the beginning of the race - core::stringw s=_("Go!"); - font->draw(s.c_str(), pos, color, true, true); + font->draw(m_string_go.c_str(), pos, color, true, true); } break; default: Modified: main/trunk/src/states_screens/race_gui.hpp =================================================================== --- main/trunk/src/states_screens/race_gui.hpp 2010-01-11 21:55:36 UTC (rev 4431) +++ main/trunk/src/states_screens/race_gui.hpp 2010-01-11 22:08:33 UTC (rev 4432) @@ -95,6 +95,15 @@ /** Musical notes icon (for music description and credits) */ Material *m_music_icon; + + /** Translated string of 'finished' message. */ + core::stringw m_string_finished; + + /** Translated string 'lap' displayed every frame. */ + core::stringw m_string_lap; + + /** Translated strings 'ready', 'set', 'go'. */ + core::stringw m_string_ready, m_string_set, m_string_go; // Minimap related variables // ------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-01-31 18:57:27
|
Revision: 4580 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4580&view=rev Author: auria Date: 2010-01-31 18:57:21 +0000 (Sun, 31 Jan 2010) Log Message: ----------- Added back the 'all groups' tab to kart and track selection screens Modified Paths: -------------- main/trunk/src/states_screens/kart_selection.cpp main/trunk/src/states_screens/tracks_screen.cpp Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2010-01-31 18:52:24 UTC (rev 4579) +++ main/trunk/src/states_screens/kart_selection.cpp 2010-01-31 18:57:21 UTC (rev 4580) @@ -46,6 +46,7 @@ using irr::core::stringw; const char* RANDOM_KART_ID = "randomkart"; +const char* ALL_KART_GROUPS_ID = "all"; class PlayerKartWidget; @@ -715,6 +716,12 @@ item->m_properties[PROP_ID] = groups[n]; tabs->m_children.push_back(item); } + + ButtonWidget* item = new ButtonWidget(); + //I18N: name of the tab that will show tracks from all groups + item->m_text = _("All"); + item->m_properties[PROP_ID] = ALL_KART_GROUPS_ID; + tabs->m_children.push_back(item); } // ----------------------------------------------------------------------------- void KartSelectionScreen::forgetWhatWasLoaded() @@ -1225,7 +1232,7 @@ // TODO : preserve selection of karts for all players // FIXME: merge this code with the code that adds karts initially, copy-and-paste is ugly - if (selection == "all") + if (selection == ALL_KART_GROUPS_ID) { const int kart_amount = kart_properties_manager->getNumberOfKarts(); Modified: main/trunk/src/states_screens/tracks_screen.cpp =================================================================== --- main/trunk/src/states_screens/tracks_screen.cpp 2010-01-31 18:52:24 UTC (rev 4579) +++ main/trunk/src/states_screens/tracks_screen.cpp 2010-01-31 18:57:21 UTC (rev 4580) @@ -29,6 +29,8 @@ using namespace irr::core; using namespace irr::video; +const char* ALL_TRACK_GROUPS_ID = "all"; + TracksScreen::TracksScreen() : Screen("tracks.stkgui") { // Dynamically add tabs @@ -48,6 +50,12 @@ item->m_properties[PROP_ID] = groups[n]; tabs->m_children.push_back(item); } + + ButtonWidget* item = new ButtonWidget(); + //I18N: name of the tab that will show tracks from all groups + item->m_text = _("All"); + item->m_properties[PROP_ID] = ALL_TRACK_GROUPS_ID; + tabs->m_children.push_back(item); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-02-22 01:09:10
|
Revision: 4792 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4792&view=rev Author: auria Date: 2010-02-22 00:15:36 +0000 (Mon, 22 Feb 2010) Log Message: ----------- Added moving camera in GP end Modified Paths: -------------- main/trunk/src/states_screens/grand_prix_over.cpp main/trunk/src/states_screens/grand_prix_over.hpp Modified: main/trunk/src/states_screens/grand_prix_over.cpp =================================================================== --- main/trunk/src/states_screens/grand_prix_over.cpp 2010-02-21 23:45:13 UTC (rev 4791) +++ main/trunk/src/states_screens/grand_prix_over.cpp 2010-02-22 00:15:36 UTC (rev 4792) @@ -46,9 +46,15 @@ 1.0f /* texture_percent */, 2.0f /* sphere_percent */); m_camera = irr_driver->addCameraSceneNode(); - m_camera->setPosition( core::vector3df(3.0, 0.0f, -5.0f) ); + m_camera_x = 3.0f; + m_camera_y = 0.0f; + m_camera_z = -5.0f; + m_camera->setPosition( core::vector3df(m_camera_x, m_camera_y, m_camera_z) ); m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); - m_camera->setTarget( core::vector3df(1.5f, -2.0f, 0.0f) ); + + m_camera_target_x = 1.5f; + m_camera_target_z = 0.0f; + m_camera->setTarget( core::vector3df(m_camera_target_x, -2.0f, m_camera_target_z) ); m_camera->setFOV( DEGREE_TO_RAD*50.0f ); m_camera->updateAbsolutePosition(); @@ -228,6 +234,27 @@ } + if (m_phase > 1) + { + //m_camera_x = 3.0f; + if (m_camera_z < -2.0f) m_camera_z += dt*0.2f; + if (m_camera_x < m_podium_x[1]) m_camera_x += dt*0.1f; + else if (m_camera_x > m_podium_x[1]) m_camera_x -= dt*0.1f; + + if (m_camera_target_x < m_podium_x[1]) m_camera_target_x += dt*0.1f; + + if (m_camera_y > -1.8f) m_camera_y -= dt*0.1f; + //else if (m_camera_y < -3.0f) m_camera_y += dt*0.1f; + + + m_camera->setTarget( core::vector3df(m_camera_target_x, -2.0f, m_camera_target_z) ); + + m_camera->setPosition( core::vector3df(m_camera_x, m_camera_y, m_camera_z) ); + m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); + m_camera->updateAbsolutePosition(); + } + + // ---- title static const int w = irr_driver->getFrameSize().Width; static const int h = irr_driver->getFrameSize().Height; Modified: main/trunk/src/states_screens/grand_prix_over.hpp =================================================================== --- main/trunk/src/states_screens/grand_prix_over.hpp 2010-02-21 23:45:13 UTC (rev 4791) +++ main/trunk/src/states_screens/grand_prix_over.hpp 2010-02-22 00:15:36 UTC (rev 4792) @@ -35,6 +35,9 @@ float m_podium_x[3], m_podium_z[3]; float m_kart_rotation[3]; + float m_camera_x, m_camera_y, m_camera_z; + float m_camera_target_x, m_camera_target_z; + public: void onUpdate(float dt, irr::video::IVideoDriver*); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-03-03 18:37:45
|
Revision: 4916 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4916&view=rev Author: auria Date: 2010-03-03 18:37:39 +0000 (Wed, 03 Mar 2010) Log Message: ----------- Don't show the 'all groups' tabs when there's only one group Modified Paths: -------------- main/trunk/src/states_screens/kart_selection.cpp main/trunk/src/states_screens/tracks_screen.cpp Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2010-03-03 18:36:38 UTC (rev 4915) +++ main/trunk/src/states_screens/kart_selection.cpp 2010-03-03 18:37:39 UTC (rev 4916) @@ -709,8 +709,8 @@ const std::vector<std::string>& groups = kart_properties_manager->getAllGroups(); - const int amount = groups.size(); - for (int n=0; n<amount; n++) + const int group_amount = groups.size(); + for (int n=0; n<group_amount; n++) { ButtonWidget* item = new ButtonWidget(); item->m_text = groups[n].c_str(); // FIXME: i18n ? @@ -718,11 +718,14 @@ tabs->m_children.push_back(item); } - ButtonWidget* item = new ButtonWidget(); - //I18N: name of the tab that will show tracks from all groups - item->m_text = _("All"); - item->m_properties[PROP_ID] = ALL_KART_GROUPS_ID; - tabs->m_children.push_back(item); + if (group_amount > 1) + { + ButtonWidget* item = new ButtonWidget(); + //I18N: name of the tab that will show tracks from all groups + item->m_text = _("All"); + item->m_properties[PROP_ID] = ALL_KART_GROUPS_ID; + tabs->m_children.push_back(item); + } } // ----------------------------------------------------------------------------- Modified: main/trunk/src/states_screens/tracks_screen.cpp =================================================================== --- main/trunk/src/states_screens/tracks_screen.cpp 2010-03-03 18:36:38 UTC (rev 4915) +++ main/trunk/src/states_screens/tracks_screen.cpp 2010-03-03 18:37:39 UTC (rev 4916) @@ -47,8 +47,8 @@ const std::vector<std::string>& groups = track_manager->getAllGroups(); - const int amount = groups.size(); - for (int n=0; n<amount; n++) + const int group_amount = groups.size(); + for (int n=0; n<group_amount; n++) { ButtonWidget* item = new ButtonWidget(); item->m_text = groups[n].c_str(); // FIXME: i18n ? @@ -56,11 +56,14 @@ tabs->m_children.push_back(item); } - ButtonWidget* item = new ButtonWidget(); - //I18N: name of the tab that will show tracks from all groups - item->m_text = _("All"); - item->m_properties[PROP_ID] = ALL_TRACK_GROUPS_ID; - tabs->m_children.push_back(item); + if (group_amount > 1) + { + ButtonWidget* item = new ButtonWidget(); + //I18N: name of the tab that will show tracks from all groups + item->m_text = _("All"); + item->m_properties[PROP_ID] = ALL_TRACK_GROUPS_ID; + tabs->m_children.push_back(item); + } } // ----------------------------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-03-03 19:40:58
|
Revision: 4919 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4919&view=rev Author: auria Date: 2010-03-03 19:40:49 +0000 (Wed, 03 Mar 2010) Log Message: ----------- Code cleanup in kart selection screen Modified Paths: -------------- main/trunk/src/states_screens/kart_selection.cpp main/trunk/src/states_screens/kart_selection.hpp Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2010-03-03 19:03:56 UTC (rev 4918) +++ main/trunk/src/states_screens/kart_selection.cpp 2010-03-03 19:40:49 UTC (rev 4919) @@ -752,43 +752,9 @@ w->registerHoverListener(karthoverListener); } - // Build kart list - // (it is built everytikme, to account for .g. locking) - w->clearItems(); - std::vector<int> group = kart_properties_manager->getKartsInGroup("standard"); - const int kart_amount = group.size(); + // Build kart list (it is built everytime, to account for .g. locking) + setKartsFromCurrentGroup(); - // add Tux (or whatever default kart) first - std::string& default_kart = UserConfigParams::m_default_kart; - for(int n=0; n<kart_amount; n++) - { - const KartProperties* prop = kart_properties_manager->getKartById(group[n]); - if (prop->getIdent() == default_kart) - { - std::string icon_path = "/karts/" + prop->getIdent() + "/" + prop->getIconFile(); - const bool locked = unlock_manager->isLocked(prop->getIdent()); - w->addItem(prop->getName(), prop->getIdent().c_str(), icon_path.c_str(), locked); - //std::cout << "Add item : " << prop->getIdent().c_str() << std::endl; - break; - } - } - - // add others - for(int n=0; n<kart_amount; n++) - { - const KartProperties* prop = kart_properties_manager->getKartById(group[n]); - if (prop->getIdent() != default_kart) - { - std::string icon_path = "/karts/" + prop->getIdent() + "/" + prop->getIconFile(); - const bool locked = unlock_manager->isLocked(prop->getIdent()); - w->addItem(prop->getName(), prop->getIdent().c_str(), icon_path.c_str(), locked); - //std::cout << "Add item : " << prop->getIdent().c_str() << std::endl; - } - } - - // add random - w->addItem(_("Random Kart"), RANDOM_KART_ID, "/gui/random_kart.png"); - /* TODO: Ultimately, it'd be nice to *not* delete g_player_karts so that @@ -816,8 +782,8 @@ w->updateItemDisplay(); } - // Player 0 select first kart (Tux) - w->setSelection(0, 0, true); + // Player 0 select default kart + w->setSelection(UserConfigParams::m_default_kart, 0, true); } // ----------------------------------------------------------------------------- @@ -1036,52 +1002,15 @@ { RibbonWidget* tabs = this->getWidget<RibbonWidget>("kartgroups"); assert(tabs != NULL); - - std::string selection = tabs->getSelectionIDString(GUI_PLAYER_ID); - DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("karts"); - w->clearItems(); + assert(w != NULL); - // TODO : preserve selection of karts for all players - // FIXME: merge this code with the code that adds karts initially, copy-and-paste is ugly + setKartsFromCurrentGroup(); + + const std::string selected_kart_group = tabs->getSelectionIDString(GUI_PLAYER_ID); - if (selection == ALL_KART_GROUPS_ID) - { - const int kart_amount = kart_properties_manager->getNumberOfKarts(); - - for(int n=0; n<kart_amount; n++) - { - const KartProperties* prop = kart_properties_manager->getKartById(n); - - std::string icon_path = "/karts/" + prop->getIdent() + "/" + prop->getIconFile(); - w->addItem(prop->getName().c_str(), prop->getIdent().c_str(), icon_path.c_str()); - } - } - else if (selection == "locked") - { - unlock_manager->playLockSound(); - } - else if (selection == NO_ITEM_ID) - { - } - else - { - std::vector<int> group = kart_properties_manager->getKartsInGroup(selection); - const int kart_amount = group.size(); - - for(int n=0; n<kart_amount; n++) - { - const KartProperties* prop = kart_properties_manager->getKartById(group[n]); - - std::string icon_path = "/karts/" + prop->getIdent() + "/" + prop->getIconFile(); - w->addItem(prop->getName().c_str(), prop->getIdent().c_str(), icon_path.c_str()); - } - } - // add random - w->addItem(_("Random Kart"), RANDOM_KART_ID, "/gui/random_kart.png"); - - w->updateItemDisplay(); - + // TODO : preserve selection of karts for all players + // update players selections const int num_players = m_kart_widgets.size(); for (int n=0; n<num_players; n++) @@ -1089,8 +1018,8 @@ // player 0 is the one that can change the groups, leave his focus on the tabs if (n > 0) GUIEngine::focusNothingForPlayer(n); - const std::string& selection = m_kart_widgets[n].getKartInternalName(); - if (!w->setSelection( selection, n, true )) + const std::string& selected_kart_group = m_kart_widgets[n].getKartInternalName(); + if (!w->setSelection( selected_kart_group, n, true )) { std::cout << "Player " << n << " lost their selection when switching tabs!!!\n"; // For now, select a random kart in this case (TODO : maybe do something better? ) @@ -1231,9 +1160,9 @@ const int kart_count = m_kart_widgets.size(); for (int n = 0; n < kart_count; n++) { - std::string selection = m_kart_widgets[n].m_kartInternalName; + std::string selected_kart_group = m_kart_widgets[n].m_kartInternalName; - if (selection == RANDOM_KART_ID) + if (selected_kart_group == RANDOM_KART_ID) { // don't select an already selected kart int randomID; @@ -1243,7 +1172,7 @@ randomID = random.get(item_count); if (items[randomID].m_code_name != ID_DONT_USE) { - selection = items[randomID].m_code_name; + selected_kart_group = items[randomID].m_code_name; done = true; } items[randomID].m_code_name = ID_DONT_USE; @@ -1263,7 +1192,7 @@ } // std::cout << "selection=" << selection.c_str() << std::endl; - race_manager->setLocalKartInfo(n, selection); + race_manager->setLocalKartInfo(n, selected_kart_group); } // ---- Switch to assign mode @@ -1404,6 +1333,63 @@ } +// ----------------------------------------------------------------------------- + +void KartSelectionScreen::setKartsFromCurrentGroup() +{ + RibbonWidget* tabs = this->getWidget<RibbonWidget>("kartgroups"); + assert(tabs != NULL); + + const std::string selected_kart_group = tabs->getSelectionIDString(GUI_PLAYER_ID); + + DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("karts"); + w->clearItems(); + + // FIXME: merge this code with the code that adds karts initially, copy-and-paste is ugly + + if (selected_kart_group == ALL_KART_GROUPS_ID) + { + const int kart_amount = kart_properties_manager->getNumberOfKarts(); + + for(int n=0; n<kart_amount; n++) + { + const KartProperties* prop = kart_properties_manager->getKartById(n); + + std::string icon_path = "/karts/" + prop->getIdent() + "/" + prop->getIconFile(); + w->addItem(prop->getName().c_str(), prop->getIdent().c_str(), icon_path.c_str()); + } + } + //FIXME: what does this do there??? + else if (selected_kart_group == "locked") + { + unlock_manager->playLockSound(); + } + //FIXME: what does this do there??? + else if (selected_kart_group == NO_ITEM_ID) + { + } + else + { + std::vector<int> group = kart_properties_manager->getKartsInGroup(selected_kart_group); + const int kart_amount = group.size(); + + for (int n=0; n<kart_amount; n++) + { + const KartProperties* prop = kart_properties_manager->getKartById(group[n]); + + std::string icon_path = "/karts/" + prop->getIdent() + "/" + prop->getIconFile(); + w->addItem(prop->getName().c_str(), prop->getIdent().c_str(), icon_path.c_str()); + } + } + // add random + w->addItem(_("Random Kart"), RANDOM_KART_ID, "/gui/random_kart.png"); + + w->updateItemDisplay(); +} + +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + #if 0 #pragma mark - #endif Modified: main/trunk/src/states_screens/kart_selection.hpp =================================================================== --- main/trunk/src/states_screens/kart_selection.hpp 2010-03-03 19:03:56 UTC (rev 4918) +++ main/trunk/src/states_screens/kart_selection.hpp 2010-03-03 19:40:49 UTC (rev 4919) @@ -64,6 +64,9 @@ */ bool validateKartChoices(); + /** Fill the ribbon with the karts from the currently selected group */ + void setKartsFromCurrentGroup(); + public: /** Called when a player hits 'fire' on his device to join the game */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-03-08 17:04:11
|
Revision: 4958 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4958&view=rev Author: auria Date: 2010-03-08 17:04:05 +0000 (Mon, 08 Mar 2010) Log Message: ----------- The chest scene is now shown for challenges that require beating a GP too Modified Paths: -------------- main/trunk/src/states_screens/dialogs/race_over_dialog.cpp main/trunk/src/states_screens/feature_unlocked.cpp main/trunk/src/states_screens/feature_unlocked.hpp main/trunk/src/states_screens/grand_prix_over.cpp Modified: main/trunk/src/states_screens/dialogs/race_over_dialog.cpp =================================================================== --- main/trunk/src/states_screens/dialogs/race_over_dialog.cpp 2010-03-08 16:44:09 UTC (rev 4957) +++ main/trunk/src/states_screens/dialogs/race_over_dialog.cpp 2010-03-08 17:04:05 UTC (rev 4958) @@ -31,8 +31,8 @@ #include "states_screens/main_menu_screen.hpp" #include "states_screens/race_setup_screen.hpp" #include "states_screens/state_manager.hpp" -#include "tracks/track_manager.hpp" -#include "tracks/track.hpp" +//#include "tracks/track_manager.hpp" +//#include "tracks/track.hpp" #include "utils/string_utils.hpp" #include "utils/translation.hpp" @@ -411,62 +411,7 @@ */ assert(unlocked.size() > 0); - for (unsigned int n=0; n<unlocked.size(); n++) - { - const std::vector<UnlockableFeature>& unlockedFeatures = unlocked[n]->getFeatures(); - assert(unlockedFeatures.size() > 0); - - for (unsigned int i=0; i<unlockedFeatures.size(); i++) - { - - switch (unlockedFeatures[i].type) - { - case UNLOCK_TRACK: - { - Track* track = track_manager->getTrack(unlockedFeatures[i].name); - assert(track != NULL); - const std::string sshot = track->getScreenshotFile(); - scene->addUnlockedPicture( irr_driver->getTexture(sshot.c_str()), 1.0f, 0.75f, - unlockedFeatures[i].getUnlockedMessage() ); - break; - } - case UNLOCK_GP: - { - //TODO - break; - } - case UNLOCK_MODE: - { - const RaceManager::MinorRaceModeType mode = - RaceManager::getModeIDFromInternalName(unlockedFeatures[i].name.c_str()); - const std::string icon = file_manager->getDataDir() + "/" + RaceManager::getIconOf(mode); - scene->addUnlockedPicture( irr_driver->getTexture(icon.c_str()), 0.8f, 0.8f, - unlockedFeatures[i].getUnlockedMessage() ); - break; - } - case UNLOCK_KART: - { - const KartProperties* kart = kart_properties_manager->getKart(unlockedFeatures[i].name); - assert(kart != NULL); - - // the passed kart will not be modified, that's why I allow myself to use const_cast - scene->addUnlockedKart( const_cast<KartProperties*>(kart), - unlockedFeatures[i].getUnlockedMessage() ); - break; - } - case UNLOCK_DIFFICULTY: - { - //TODO - break; - } - default: - { - assert(false); - } - } - - } // next feature - } // next challenge + scene->addUnlockedThings(unlocked); ModalDialog::dismiss(); Modified: main/trunk/src/states_screens/feature_unlocked.cpp =================================================================== --- main/trunk/src/states_screens/feature_unlocked.cpp 2010-03-08 16:44:09 UTC (rev 4957) +++ main/trunk/src/states_screens/feature_unlocked.cpp 2010-03-08 17:04:05 UTC (rev 4958) @@ -1,13 +1,17 @@ #include "states_screens/feature_unlocked.hpp" - +#include "challenges/challenge.hpp" #include "guiengine/engine.hpp" #include "io/file_manager.hpp" #include "items/item_manager.hpp" +#include "karts/kart.hpp" +#include "karts/kart_properties_manager.hpp" #include "modes/world.hpp" #include "states_screens/main_menu_screen.hpp" #include "states_screens/state_manager.hpp" +#include "tracks/track.hpp" +#include "tracks/track_manager.hpp" #include "utils/translation.hpp" #include <SColor.h> @@ -292,6 +296,78 @@ // ------------------------------------------------------------------------------------- +void FeatureUnlockedCutScene::addUnlockedThings(const std::vector<const Challenge*> unlocked) +{ + for (unsigned int n=0; n<unlocked.size(); n++) + { + const std::vector<UnlockableFeature>& unlockedFeatures = unlocked[n]->getFeatures(); + assert(unlockedFeatures.size() > 0); + + for (unsigned int i=0; i<unlockedFeatures.size(); i++) + { + + switch (unlockedFeatures[i].type) + { + case UNLOCK_TRACK: + { + Track* track = track_manager->getTrack(unlockedFeatures[i].name); + assert(track != NULL); + const std::string sshot = track->getScreenshotFile(); + addUnlockedPicture( irr_driver->getTexture(sshot.c_str()), 1.0f, 0.75f, + unlockedFeatures[i].getUnlockedMessage() ); + break; + } + case UNLOCK_GP: + { + //TODO: implement + std::cerr << "OK, I see you unlocked a GP, but this is not supported yet\n"; + + video::ITexture* tex = irr_driver->getTexture( file_manager->getGUIDir() + "/main_help.png"); + addUnlockedPicture( tex, 1.0f, 0.75f, + unlockedFeatures[i].getUnlockedMessage() ); + break; + } + case UNLOCK_MODE: + { + const RaceManager::MinorRaceModeType mode = + RaceManager::getModeIDFromInternalName(unlockedFeatures[i].name.c_str()); + const std::string icon = file_manager->getDataDir() + "/" + RaceManager::getIconOf(mode); + addUnlockedPicture( irr_driver->getTexture(icon.c_str()), 0.8f, 0.8f, + unlockedFeatures[i].getUnlockedMessage() ); + break; + } + case UNLOCK_KART: + { + const KartProperties* kart = kart_properties_manager->getKart(unlockedFeatures[i].name); + assert(kart != NULL); + + // the passed kart will not be modified, that's why I allow myself to use const_cast + addUnlockedKart( const_cast<KartProperties*>(kart), + unlockedFeatures[i].getUnlockedMessage() ); + break; + } + case UNLOCK_DIFFICULTY: + { + //TODO : implement + std::cerr << "OK, I see you unlocked a difficulty, but this is not supported yet\n"; + + video::ITexture* tex = irr_driver->getTexture( file_manager->getGUIDir() + "/main_help.png"); + addUnlockedPicture( tex, 1.0f, 0.75f, + unlockedFeatures[i].getUnlockedMessage() ); + break; + } + default: + { + assert(false); + } + } + + } // next feature + } // next challenge +} + +// ------------------------------------------------------------------------------------- + bool FeatureUnlockedCutScene::onEscapePressed() { continueButtonPressed(); Modified: main/trunk/src/states_screens/feature_unlocked.hpp =================================================================== --- main/trunk/src/states_screens/feature_unlocked.hpp 2010-03-08 16:44:09 UTC (rev 4957) +++ main/trunk/src/states_screens/feature_unlocked.hpp 2010-03-08 17:04:05 UTC (rev 4958) @@ -6,8 +6,8 @@ namespace irr { namespace scene { class ISceneNode; class ICameraSceneNode; class ILightSceneNode; } } class KartProperties; +class Challenge; - class FeatureUnlockedCutScene : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<FeatureUnlockedCutScene> { friend class GUIEngine::ScreenSingleton<FeatureUnlockedCutScene>; @@ -89,6 +89,10 @@ /** Call before showing up the screen to make a picture come out of the chest */ void addUnlockedPicture(irr::video::ITexture* picture, float w, float h, irr::core::stringw msg); + /** Call before showing up the screen to make whatever the passed challenges unlocked + * come out of the chest */ + void addUnlockedThings(const std::vector<const Challenge*> unlocked); + /** override from base class to handle escape press */ virtual bool onEscapePressed(); }; Modified: main/trunk/src/states_screens/grand_prix_over.cpp =================================================================== --- main/trunk/src/states_screens/grand_prix_over.cpp 2010-03-08 16:44:09 UTC (rev 4957) +++ main/trunk/src/states_screens/grand_prix_over.cpp 2010-03-08 17:04:05 UTC (rev 4958) @@ -10,6 +10,7 @@ #include "io/file_manager.hpp" #include "items/item_manager.hpp" #include "karts/kart_properties_manager.hpp" +#include "states_screens/feature_unlocked.hpp" #include "states_screens/state_manager.hpp" #include "utils/translation.hpp" @@ -338,8 +339,26 @@ { if (name == "continue") { - // we assume the main menu was pushed before showing this menu - StateManager::get()->popMenu(); + // un-set the GP mode so that after unlocking, it doesn't try to continue the GP + race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE); + + if (unlock_manager->getRecentlyUnlockedFeatures().size() > 0) + { + std::vector<const Challenge*> unlocked = unlock_manager->getRecentlyUnlockedFeatures(); + unlock_manager->clearUnlocked(); + + FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance(); + + assert(unlocked.size() > 0); + scene->addUnlockedThings(unlocked); + + StateManager::get()->replaceTopMostScreen(scene); + } + else + { + // we assume the main menu was pushed before showing this menu + StateManager::get()->popMenu(); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-03-25 01:05:14
|
Revision: 5068 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5068&view=rev Author: auria Date: 2010-03-25 01:05:08 +0000 (Thu, 25 Mar 2010) Log Message: ----------- Forbid adding 2 players with same name Modified Paths: -------------- main/trunk/src/states_screens/dialogs/enter_player_name_dialog.cpp main/trunk/src/states_screens/dialogs/enter_player_name_dialog.hpp main/trunk/src/states_screens/main_menu_screen.cpp main/trunk/src/states_screens/options_screen_players.cpp main/trunk/src/states_screens/options_screen_players.hpp Modified: main/trunk/src/states_screens/dialogs/enter_player_name_dialog.cpp =================================================================== --- main/trunk/src/states_screens/dialogs/enter_player_name_dialog.cpp 2010-03-25 00:09:35 UTC (rev 5067) +++ main/trunk/src/states_screens/dialogs/enter_player_name_dialog.cpp 2010-03-25 01:05:08 UTC (rev 5068) @@ -15,9 +15,11 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include "states_screens/dialogs/enter_player_name_dialog.hpp" + +#include "audio/sfx_manager.hpp" #include "guiengine/engine.hpp" #include "guiengine/widget.hpp" -#include "states_screens/dialogs/enter_player_name_dialog.hpp" #include "states_screens/options_screen_players.hpp" #include "states_screens/state_manager.hpp" #include "utils/translation.hpp" @@ -32,20 +34,20 @@ EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) : ModalDialog(w, h) { - LabelWidget* widget = new LabelWidget(); + m_label_ctrl = new LabelWidget(); //I18N: In the 'add new player' dialog - widget->m_text = _("Enter the new player's name"); + m_label_ctrl->m_text = _("Enter the new player's name"); - widget->m_properties[PROP_TEXT_ALIGN] = "center"; - widget->x = 0; - widget->y = 0; - widget->w = m_area.getWidth(); - widget->h = m_area.getHeight()/3; - widget->setParent(m_irrlicht_window); + m_label_ctrl->m_properties[PROP_TEXT_ALIGN] = "center"; + m_label_ctrl->x = 0; + m_label_ctrl->y = 0; + m_label_ctrl->w = m_area.getWidth(); + m_label_ctrl->h = m_area.getHeight()/3; + m_label_ctrl->setParent(m_irrlicht_window); - m_children.push_back(widget); - widget->add(); + m_children.push_back(m_label_ctrl); + m_label_ctrl->add(); // ---- @@ -105,7 +107,7 @@ void EnterPlayerNameDialog::onEnterPressedInternal() { // ---- Cancel button pressed - const int playerID = 0; // FIXME: don't ahrdcode player 0? + const int playerID = 0; // FIXME: don't hardcode player 0? if (GUIEngine::isFocusedForPlayer(cancelButton, playerID)) { std::string fakeEvent = "cancel"; @@ -117,7 +119,13 @@ stringw playerName = textCtrl->getText(); if (playerName.size() > 0) { - OptionsScreenPlayers::getInstance()->gotNewPlayerName( playerName ); + const bool success = OptionsScreenPlayers::getInstance()->gotNewPlayerName( playerName ); + if (not success) + { + m_label_ctrl->setText(_("Cannot add a player with this name.")); + sfx_manager->quickSound( "use_anvil" ); + return; + } } // irrLicht is too stupid to remove focus from deleted widgets Modified: main/trunk/src/states_screens/dialogs/enter_player_name_dialog.hpp =================================================================== --- main/trunk/src/states_screens/dialogs/enter_player_name_dialog.hpp 2010-03-25 00:09:35 UTC (rev 5067) +++ main/trunk/src/states_screens/dialogs/enter_player_name_dialog.hpp 2010-03-25 01:05:08 UTC (rev 5068) @@ -25,12 +25,15 @@ { class TextBoxWidget; class ButtonWidget; + class LabelWidget; } class EnterPlayerNameDialog : public GUIEngine::ModalDialog { + GUIEngine::LabelWidget* m_label_ctrl; GUIEngine::TextBoxWidget* textCtrl; - GUIEngine::ButtonWidget* cancelButton; + GUIEngine::ButtonWidget* cancelButton; + public: /** * Creates a modal dialog with given percentage of screen width and height Modified: main/trunk/src/states_screens/main_menu_screen.cpp =================================================================== --- main/trunk/src/states_screens/main_menu_screen.cpp 2010-03-25 00:09:35 UTC (rev 5067) +++ main/trunk/src/states_screens/main_menu_screen.cpp 2010-03-25 01:05:08 UTC (rev 5068) @@ -74,32 +74,31 @@ if (selection == "network") { - // FIXME : remove, temporary test - /* - GrandPrixOver* scene = GrandPrixOver::getInstance(); - const std::string winners[] = { "mriceblock", "nolok", "pidgin" }; - scene->setKarts( winners ); - StateManager::get()->pushScreen(scene); - */ - FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance(); static int i = 0; i++; - if (i % 2 == 0) + if (i % 3 == 0) { // the passed kart will not be modified, that's why I allow myself to use const_cast scene->addUnlockedKart( const_cast<KartProperties*>(kart_properties_manager->getKart("gnu")), L"Unlocked"); StateManager::get()->pushScreen(scene); } - else + else if (i % 3 == 1) { - scene->addUnlockedPicture( irr_driver->getTexture(track_manager->getTrack("beach")->getScreenshotFile().c_str()), + scene->addUnlockedPicture( irr_driver->getTexture(track_manager->getTrack("lighthouse")->getScreenshotFile().c_str()), 1.0, 0.75, L"You did it"); StateManager::get()->pushScreen(scene); } + else + { + GrandPrixOver* scene = GrandPrixOver::getInstance(); + const std::string winners[] = { "mriceblock", "nolok", "pidgin" }; + scene->setKarts( winners ); + StateManager::get()->pushScreen(scene); + } } if (selection == "new") Modified: main/trunk/src/states_screens/options_screen_players.cpp =================================================================== --- main/trunk/src/states_screens/options_screen_players.cpp 2010-03-25 00:09:35 UTC (rev 5067) +++ main/trunk/src/states_screens/options_screen_players.cpp 2010-03-25 01:05:08 UTC (rev 5068) @@ -64,15 +64,23 @@ // ----------------------------------------------------------------------------- -void OptionsScreenPlayers::gotNewPlayerName(const stringw& newName, PlayerProfile* player) +bool OptionsScreenPlayers::gotNewPlayerName(const stringw& newName, PlayerProfile* player) { stringc newNameC( newName ); ListWidget* players = this->getWidget<ListWidget>("players"); - if(players == NULL) return; + if (players == NULL) return false; // ---- Add new player - if(player == NULL) + if (player == NULL) { + // check for duplicates + const int amount = UserConfigParams::m_all_players.size(); + for (int n=0; n<amount; n++) + { + if (stringw(UserConfigParams::m_all_players[n].getName()) == newName) return false; + } + + // add new player UserConfigParams::m_all_players.push_back( new PlayerProfile(newNameC.c_str()) ); players->addItem( newNameC.c_str() ); @@ -90,7 +98,10 @@ } } + // TODO : need to re-save user config here? + + return true; } // ----------------------------------------------------------------------------- Modified: main/trunk/src/states_screens/options_screen_players.hpp =================================================================== --- main/trunk/src/states_screens/options_screen_players.hpp 2010-03-25 00:09:35 UTC (rev 5067) +++ main/trunk/src/states_screens/options_screen_players.hpp 2010-03-25 01:05:08 UTC (rev 5068) @@ -40,8 +40,9 @@ /** * Adds a new player (if 'player' is NULL) or renames an existing player (if 'player' is not NULL) + * @return whether adding was successful (can fail e.g. if trying to add a duplicate) */ - void gotNewPlayerName(const irr::core::stringw& newName, PlayerProfile* player=NULL); + bool gotNewPlayerName(const irr::core::stringw& newName, PlayerProfile* player=NULL); void deletePlayer(PlayerProfile* player); void init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-04-08 01:46:03
|
Revision: 5129 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5129&view=rev Author: auria Date: 2010-04-08 01:45:57 +0000 (Thu, 08 Apr 2010) Log Message: ----------- More removal of unnecessary FIXMEs Modified Paths: -------------- main/trunk/src/states_screens/kart_selection.cpp main/trunk/src/states_screens/race_setup_screen.cpp Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2010-04-08 01:38:10 UTC (rev 5128) +++ main/trunk/src/states_screens/kart_selection.cpp 2010-04-08 01:45:57 UTC (rev 5129) @@ -1410,11 +1410,7 @@ { unlock_manager->playLockSound(); } - //FIXME: what does this do there??? - else if (selected_kart_group == DynamicRibbonWidget::NO_ITEM_ID) - { - } - else + else if (selected_kart_group != DynamicRibbonWidget::NO_ITEM_ID) { std::vector<int> group = kart_properties_manager->getKartsInGroup(selected_kart_group); const int kart_amount = group.size(); Modified: main/trunk/src/states_screens/race_setup_screen.cpp =================================================================== --- main/trunk/src/states_screens/race_setup_screen.cpp 2010-04-08 01:38:10 UTC (rev 5128) +++ main/trunk/src/states_screens/race_setup_screen.cpp 2010-04-08 01:45:57 UTC (rev 5129) @@ -105,7 +105,6 @@ else if (selectedMode == "3strikes") { race_manager->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES); - //FIXME: it's a little weird that the value from the 'AI karts' spinner is ignored race_manager->setNumKarts( race_manager->getNumPlayers() ); // no AI karts; StateManager::get()->pushScreen( ArenasScreen::getInstance() ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-04-20 17:12:16
|
Revision: 5216 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5216&view=rev Author: auria Date: 2010-04-20 17:12:09 +0000 (Tue, 20 Apr 2010) Log Message: ----------- Implemented Todo : In the 3 strikes arena selection screen, groups are not implemented Modified Paths: -------------- main/trunk/src/states_screens/arenas_screen.cpp main/trunk/src/states_screens/arenas_screen.hpp Modified: main/trunk/src/states_screens/arenas_screen.cpp =================================================================== --- main/trunk/src/states_screens/arenas_screen.cpp 2010-04-20 17:12:00 UTC (rev 5215) +++ main/trunk/src/states_screens/arenas_screen.cpp 2010-04-20 17:12:09 UTC (rev 5216) @@ -31,78 +31,155 @@ DEFINE_SCREEN_SINGLETON( ArenasScreen ); +const char* ALL_ARENA_GROUPS_ID = "all"; + + // ------------------------------------------------------------------------------------------------------ ArenasScreen::ArenasScreen() : Screen("arenas.stkgui") { + // Dynamically add tabs + RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups"); + assert( tabs != NULL ); + + tabs->m_children.clearAndDeleteAll(); + + //FIXME: this returns groups for arenas but tracks too. this means that some of them + // may contain only tracks, no arenas, and thus add an empty tab here... + const std::vector<std::string>& groups = track_manager->getAllGroups(); + + const int group_amount = groups.size(); + for (int n=0; n<group_amount; n++) + { + ButtonWidget* item = new ButtonWidget(); + item->m_text = groups[n].c_str(); // FIXME: i18n ? + item->m_properties[PROP_ID] = groups[n]; + tabs->m_children.push_back(item); + } + + if (group_amount > 1) + { + ButtonWidget* item = new ButtonWidget(); + //I18N: name of the tab that will show tracks from all groups + item->m_text = _("All"); + item->m_properties[PROP_ID] = ALL_ARENA_GROUPS_ID; + tabs->m_children.push_back(item); + } + } // ArenasScreen // ------------------------------------------------------------------------------------------------------ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) { - if(name!="tracks") return; + if (name == "tracks") + { + DynamicRibbonWidget* w2 = dynamic_cast<DynamicRibbonWidget*>(widget); + if (w2 == NULL) return; - DynamicRibbonWidget* w2 = dynamic_cast<DynamicRibbonWidget*>(widget); - if(w2==NULL) return; + 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; - 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; + if (selection == "random_track") + { + // TODO: random arena selection + } + else + { + Track* clickedTrack = track_manager->getTrack(selection); + if (clickedTrack != NULL) + { + ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile().c_str() ); - if (selection == "random_track") + new TrackInfoDialog( clickedTrack->getIdent(), clickedTrack->getName().c_str(), + screenshot, 0.8f, 0.7f); + } // clickedTrack != NULL + } // if random_track + + } + else if (name == "trackgroups") { - // TODO: random arena selection + buildTrackList(); } - else - { - Track* clickedTrack = track_manager->getTrack(selection); - if (clickedTrack != NULL) - { - ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile().c_str() ); - - new TrackInfoDialog( clickedTrack->getIdent(), clickedTrack->getName().c_str(), - screenshot, 0.8f, 0.7f); - } // clickedTrack != NULL - } // if random_track + } // eventCallback // ------------------------------------------------------------------------------------------------------ void ArenasScreen::init() { + buildTrackList(); + + // select something by default for the game master DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks"); assert( w != NULL ); + w->setSelection(w->getItems()[0].m_code_name, PLAYER_ID_GAME_MASTER, true); +} // init + +// ------------------------------------------------------------------------------------------------------ + +void ArenasScreen::buildTrackList() +{ + DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks"); + assert( w != NULL ); // Re-build track list everytime (accounts for locking changes, etc.) w->clearItems(); - const int trackAmount = track_manager->getNumberOfTracks(); - //bool hasLockedTracks = false; - for (int n=0; n<trackAmount; n++) + RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups"); + assert( tabs != NULL ); + const std::string curr_group_name = tabs->getSelectionIDString(0); + + if (curr_group_name == ALL_ARENA_GROUPS_ID) { - Track* curr = track_manager->getTrack(n); - if (!curr->isArena()) continue; - - if (unlock_manager->isLocked(curr->getIdent())) + const int trackAmount = track_manager->getNumberOfTracks(); + + for (int n=0; n<trackAmount; n++) { - w->addItem( _("Locked : solve active challenges to gain access to more!"), - "locked", curr->getScreenshotFile(), LOCKED_BADGE ); + Track* curr = track_manager->getTrack(n); + if (!curr->isArena()) continue; + + if (unlock_manager->isLocked(curr->getIdent())) + { + w->addItem( _("Locked : solve active challenges to gain access to more!"), + "locked", curr->getScreenshotFile(), LOCKED_BADGE ); + } + else + { + w->addItem( curr->getName(), curr->getIdent(), curr->getScreenshotFile(), 0, + IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE ); + } } - else + + } + else + { + const std::vector<int>& currArenas = track_manager->getArenasInGroup(curr_group_name); + const int trackAmount = currArenas.size(); + + for (int n=0; n<trackAmount; n++) { - w->addItem( curr->getName(), curr->getIdent(), curr->getScreenshotFile(), 0, - IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE ); + Track* curr = track_manager->getTrack(currArenas[n]); + if (!curr->isArena()) continue; + + if (unlock_manager->isLocked(curr->getIdent())) + { + w->addItem( _("Locked : solve active challenges to gain access to more!"), + "locked", curr->getScreenshotFile(), LOCKED_BADGE ); + } + else + { + w->addItem( curr->getName(), curr->getIdent(), curr->getScreenshotFile(), 0, + IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE ); + } } } w->addItem(_("Random Arena"), "random_track", "/gui/track_random.png"); w->updateItemDisplay(); assert(w->getItems().size() > 0); - - // FIXME: don't hardcode player 0? - w->setSelection(w->getItems()[0].m_code_name, 0, true); -} // init +} // ------------------------------------------------------------------------------------------------------ Modified: main/trunk/src/states_screens/arenas_screen.hpp =================================================================== --- main/trunk/src/states_screens/arenas_screen.hpp 2010-04-20 17:12:00 UTC (rev 5215) +++ main/trunk/src/states_screens/arenas_screen.hpp 2010-04-20 17:12:09 UTC (rev 5216) @@ -28,7 +28,8 @@ friend class GUIEngine::ScreenSingleton<ArenasScreen>; ArenasScreen(); - + void buildTrackList(); + public: void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); void init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-04-21 19:19:48
|
Revision: 5231 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5231&view=rev Author: auria Date: 2010-04-21 19:19:42 +0000 (Wed, 21 Apr 2010) Log Message: ----------- Added support in feature unlocked chest for unlocked GPs Modified Paths: -------------- main/trunk/src/states_screens/feature_unlocked.cpp main/trunk/src/states_screens/feature_unlocked.hpp main/trunk/src/states_screens/main_menu_screen.cpp Modified: main/trunk/src/states_screens/feature_unlocked.cpp =================================================================== --- main/trunk/src/states_screens/feature_unlocked.cpp 2010-04-21 18:14:28 UTC (rev 5230) +++ main/trunk/src/states_screens/feature_unlocked.cpp 2010-04-21 19:19:42 UTC (rev 5231) @@ -8,6 +8,7 @@ #include "karts/kart.hpp" #include "karts/kart_properties_manager.hpp" #include "modes/world.hpp" +#include "race/grand_prix_manager.hpp" #include "states_screens/main_menu_screen.hpp" #include "states_screens/state_manager.hpp" #include "tracks/track.hpp" @@ -52,6 +53,16 @@ // ------------------------------------------------------------------------------------- +void FeatureUnlockedCutScene::addUnlockedPictures(std::vector<irr::video::ITexture*> pictures, + float w, float h, irr::core::stringw msg) +{ + assert(!pictures.empty()); + + m_unlocked_stuff.push_back( new UnlockedThing(pictures, w, h, msg) ); +} + +// ------------------------------------------------------------------------------------- + void FeatureUnlockedCutScene::init() { m_sky_angle = 0.0f; @@ -110,12 +121,12 @@ m_unlocked_stuff[n].m_root_gift_node = kart_node; } - else if (m_unlocked_stuff[n].m_picture != NULL) + else if (!m_unlocked_stuff[n].m_pictures.empty()) { video::SMaterial m; m.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; m.BackfaceCulling = false; - m.setTexture(0, m_unlocked_stuff[n].m_picture); + m.setTexture(0, m_unlocked_stuff[n].m_pictures[0]); m.AmbientColor = video::SColor(255, 255, 255, 255); m.DiffuseColor = video::SColor(255, 255, 255, 255); m.EmissiveColor = video::SColor(255, 255, 255, 255); @@ -255,7 +266,42 @@ 30.0f, sin((1.0f-m_key_angle)*M_PI/8 + M_PI/4)*70.0f) ); } - + + for (int n=0; n<unlockedStuffCount; n++) + { + if (m_unlocked_stuff[n].m_root_gift_node == NULL) continue; + + if (!m_unlocked_stuff[n].m_pictures.empty()) + { + const int pictureCount = m_unlocked_stuff[n].m_pictures.size(); + + if (pictureCount > 1) + { + const int previousTextureID = m_unlocked_stuff[n].m_curr_image; + const int textureID = int(m_global_time/1.2f) % pictureCount; + + if (textureID != previousTextureID) + { + scene::IMeshSceneNode* node = (scene::IMeshSceneNode*)m_unlocked_stuff[n].m_root_gift_node; + scene::IMesh* mesh = node->getMesh(); + + assert(mesh->getMeshBufferCount() == 1); + + scene::IMeshBuffer* mb = mesh->getMeshBuffer(0); + + SMaterial& m = mb->getMaterial(); + m.setTexture(0, m_unlocked_stuff[n].m_pictures[textureID]); + + // FIXME: this mesh is already associated with this node. I'm calling this + // to force irrLicht to refresh the display, now that Material has changed. + node->setMesh(mesh); + + m_unlocked_stuff[n].m_curr_image = textureID; + } + } + } + } + assert(m_unlocked_stuff.size() > 0); if (m_unlocked_stuff[0].m_root_gift_node != NULL) { @@ -322,11 +368,38 @@ } case UNLOCK_GP: { - //TODO: implement gp reward - std::cerr << "OK, I see you unlocked a GP, but this is not supported yet\n"; - - video::ITexture* tex = irr_driver->getTexture( file_manager->getGUIDir() + "/main_help.png"); - addUnlockedPicture( tex, 1.0f, 0.75f, + std::vector<ITexture*> images; + const GrandPrixData* gp = grand_prix_manager->getGrandPrix(unlockedFeatures[i].name); + if (gp == NULL) + { + std::cerr << "ERROR: Unlocked GP does not exist???\n"; + video::ITexture* WTF_image = irr_driver->getTexture( file_manager->getGUIDir() + "/main_help.png"); + images.push_back(WTF_image); + } + else + { + const std::vector<std::string>& gptracks = gp->getTracks(); + const int trackAmount = gptracks.size(); + + if (trackAmount == 0) + { + std::cerr << "ERROR: Unlocked GP is empty???\n"; + video::ITexture* WTF_image = irr_driver->getTexture( file_manager->getGUIDir() + "/main_help.png"); + images.push_back(WTF_image); + } + + for (int t=0; t<trackAmount; t++) + { + Track* track = track_manager->getTrack(gptracks[t]); + + ITexture* tex = irr_driver->getTexture(track != NULL ? + track->getScreenshotFile().c_str() : + file_manager->getDataDir() + "gui/main_help.png"); + images.push_back(tex); + } + } + + addUnlockedPictures(images, 1.0f, 0.75f, unlockedFeatures[i].getUnlockedMessage() ); break; } Modified: main/trunk/src/states_screens/feature_unlocked.hpp =================================================================== --- main/trunk/src/states_screens/feature_unlocked.hpp 2010-04-21 18:14:28 UTC (rev 5230) +++ main/trunk/src/states_screens/feature_unlocked.hpp 2010-04-21 19:19:42 UTC (rev 5231) @@ -20,10 +20,12 @@ /** Will be non-null if this unlocked thing is a kart */ KartProperties* m_unlocked_kart; - /** Will be non-null if this unlocked thing is a picture */ - irr::video::ITexture* m_picture; + /** Will be non-empty if this unlocked thing is one or many pictures */ + std::vector<irr::video::ITexture*> m_pictures; /** Will be set if this unlocked thing is a picture */ float m_w, m_h; + /** used for slideshows */ + int m_curr_image; /** Contains whatever is in the chest */ scene::ISceneNode* m_root_gift_node; @@ -33,17 +35,42 @@ UnlockedThing(KartProperties* kart, irr::core::stringw msg) { m_unlocked_kart = kart; - m_picture = NULL; m_unlock_message = msg; + m_curr_image = -1; } + + /** + * Creates a 'picture' reward. + * \param pict the picture to display as reward. + * \param w width of the picture to display + * \param y height of the picture to display + */ UnlockedThing(irr::video::ITexture* pict, float w, float h, irr::core::stringw msg) { m_unlocked_kart = NULL; - m_picture = pict; + m_pictures.push_back(pict); m_w = w; m_h = h; m_unlock_message = msg; + m_curr_image = -1; } + + /** + * Creates a 'picture slideshow' reward. + * \param picts the pictures to display as reward. + * \param w width of the pictures to display + * \param y height of the pictures to display + */ + UnlockedThing(std::vector<irr::video::ITexture*> picts, float w, float h, irr::core::stringw msg) + { + m_unlocked_kart = NULL; + m_pictures = picts; + m_w = w; + m_h = h; + m_unlock_message = msg; + m_curr_image = 0; + } + ~UnlockedThing() { if (m_root_gift_node != NULL) irr_driver->removeNode(m_root_gift_node); @@ -83,16 +110,24 @@ void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); - /** Call before showing up the screen to make a kart come out of the chest */ + /** Call before showing up the screen to make a kart come out of the chest. + 'addUnlockedThings' will invoke this, so you generally don't need to call this directly. */ void addUnlockedKart(KartProperties* unlocked_kart, irr::core::stringw msg); - /** Call before showing up the screen to make a picture come out of the chest */ + /** Call before showing up the screen to make a picture come out of the chest + 'addUnlockedThings' will invoke this, so you generally don't need to call this directly. */ void addUnlockedPicture(irr::video::ITexture* picture, float w, float h, irr::core::stringw msg); + /** Call before showing up the screen to make a picture slideshow come out of the chest + 'addUnlockedThings' will invoke this, so you generally don't need to call this directly. */ + void addUnlockedPictures(std::vector<irr::video::ITexture*> pictures, + float w, float h, irr::core::stringw msg); + /** Call before showing up the screen to make whatever the passed challenges unlocked * come out of the chest */ void addUnlockedThings(const std::vector<const Challenge*> unlocked); + /** override from base class to handle escape press */ virtual bool onEscapePressed(); }; Modified: main/trunk/src/states_screens/main_menu_screen.cpp =================================================================== --- main/trunk/src/states_screens/main_menu_screen.cpp 2010-04-21 18:14:28 UTC (rev 5230) +++ main/trunk/src/states_screens/main_menu_screen.cpp 2010-04-21 19:19:42 UTC (rev 5231) @@ -88,8 +88,19 @@ } else if (i % 3 == 1) { + std::vector<video::ITexture*> textures; + textures.push_back(irr_driver->getTexture(track_manager->getTrack("lighthouse")->getScreenshotFile().c_str())); + textures.push_back(irr_driver->getTexture(track_manager->getTrack("beach")->getScreenshotFile().c_str())); + textures.push_back(irr_driver->getTexture(track_manager->getTrack("sandtrack")->getScreenshotFile().c_str())); + textures.push_back(irr_driver->getTexture(track_manager->getTrack("snowmountain")->getScreenshotFile().c_str())); + + scene->addUnlockedPictures(textures, 1.0, 0.75, L"You did it"); + + /* scene->addUnlockedPicture( irr_driver->getTexture(track_manager->getTrack("lighthouse")->getScreenshotFile().c_str()), 1.0, 0.75, L"You did it"); + */ + StateManager::get()->pushScreen(scene); } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-04-28 00:07:54
|
Revision: 5298 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5298&view=rev Author: auria Date: 2010-04-28 00:07:48 +0000 (Wed, 28 Apr 2010) Log Message: ----------- Removed scaling parameter from race gui lap Modified Paths: -------------- main/trunk/src/states_screens/race_gui.cpp main/trunk/src/states_screens/race_gui.hpp Modified: main/trunk/src/states_screens/race_gui.cpp =================================================================== --- main/trunk/src/states_screens/race_gui.cpp 2010-04-27 23:30:58 UTC (rev 5297) +++ main/trunk/src/states_screens/race_gui.cpp 2010-04-28 00:07:48 UTC (rev 5298) @@ -282,7 +282,7 @@ drawPowerupIcons (kart, viewport, scaling); drawEnergyMeter (kart, viewport, scaling); drawSpeed (kart, viewport, scaling); - drawLap (info, kart, viewport, scaling); + drawLap (info, kart, viewport); } // renderPlayerView @@ -598,8 +598,7 @@ //----------------------------------------------------------------------------- void RaceGUI::drawLap(const KartIconDisplayInfo* info, const Kart* kart, - const core::recti &viewport, - const core::vector2df &scaling) + const core::recti &viewport) { // Don't display laps in follow the leader mode if(!World::getWorld()->raceHasLaps()) return; @@ -609,14 +608,11 @@ if(lap<0) return; // don't display 'lap 0/...' core::recti pos; - pos.UpperLeftCorner.X = viewport.UpperLeftCorner.X - + (int)(0.15f*UserConfigParams::m_width*scaling.X); + pos.UpperLeftCorner.X = viewport.UpperLeftCorner.X + (int)(0.15f*UserConfigParams::m_width); pos.UpperLeftCorner.Y = viewport.LowerRightCorner.Y; gui::IGUIFont* font = GUIEngine::getFont(); - //FIXME: font height is multiplied by "scaling.Y" here, but the font itself is actually not scaled, - // resulting in overlapping of the two lines - int font_height = (int)(font->getDimension(L"X").Height*scaling.Y); + int font_height = (int)(font->getDimension(L"X").Height); if (kart->hasFinishedRace()) { Modified: main/trunk/src/states_screens/race_gui.hpp =================================================================== --- main/trunk/src/states_screens/race_gui.hpp 2010-04-27 23:30:58 UTC (rev 5297) +++ main/trunk/src/states_screens/race_gui.hpp 2010-04-28 00:07:48 UTC (rev 5298) @@ -173,8 +173,7 @@ void drawSpeed (const Kart* kart, const core::recti &viewport, const core::vector2df &scaling); void drawLap (const KartIconDisplayInfo* info, const Kart* kart, - const core::recti &viewport, - const core::vector2df &scaling); + const core::recti &viewport); void drawGlobalPlayerIcons (const KartIconDisplayInfo* info); /** Display items that are shown once only (for all karts). */ void drawGlobalMiniMap (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-04-28 18:26:29
|
Revision: 5310 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5310&view=rev Author: auria Date: 2010-04-28 18:26:23 +0000 (Wed, 28 Apr 2010) Log Message: ----------- Improved lap count display location calculation to avoid any overlap with minimap. The position is still calculated every frame even though it doesn't change, which is a bit silly, but we can improve that later... Modified Paths: -------------- main/trunk/src/states_screens/race_gui.cpp main/trunk/src/states_screens/race_gui.hpp Modified: main/trunk/src/states_screens/race_gui.cpp =================================================================== --- main/trunk/src/states_screens/race_gui.cpp 2010-04-28 13:17:02 UTC (rev 5309) +++ main/trunk/src/states_screens/race_gui.cpp 2010-04-28 18:26:23 UTC (rev 5310) @@ -47,6 +47,8 @@ */ RaceGUI::RaceGUI() { + m_map_right_side_x = 0; + // Originally m_map_height was 100, and we take 480 as minimum res const float scaling = irr_driver->getFrameSize().Height / 480.0f; // Marker texture has to be power-of-two for (old) OpenGL compliance @@ -57,6 +59,8 @@ m_map_height = (int)(100.0f * scaling); m_map_left = (int)( 10.0f * scaling); m_map_bottom = (int)( 10.0f * scaling); + m_minimap_on_left = true; + // Minimap is also rendered bigger via OpenGL, so find power-of-two again const int map_texture = 2 << ((int) ceil(1.0 + log(128.0 * scaling))); m_map_rendered_width = map_texture; @@ -69,6 +73,7 @@ if (race_manager->getNumLocalPlayers() == 3) { m_map_left = UserConfigParams::m_width - m_map_width; + m_minimap_on_left = false; } m_speed_meter_icon = material_manager->getMaterial("speedback.png"); @@ -329,7 +334,8 @@ m_map_left + m_map_width, lower_y); core::rect<s32> source(core::position2di(0, 0), mini_map->getOriginalSize()); irr_driver->getVideoDriver()->draw2DImage(mini_map, dest, source, 0, 0, true); - + m_map_right_side_x = dest.LowerRightCorner.X; + for(unsigned int i=0; i<world->getNumKarts(); i++) { const Kart *kart = world->getKart(i); @@ -608,8 +614,31 @@ if(lap<0) return; // don't display 'lap 0/...' core::recti pos; - pos.UpperLeftCorner.X = viewport.UpperLeftCorner.X + (int)(0.15f*UserConfigParams::m_width); pos.UpperLeftCorner.Y = viewport.LowerRightCorner.Y; + + // place lap count somewhere on the left of the screen + if (m_minimap_on_left) + { + // check if mini-map is within Y coords of this player. + // if the mini-map is not even in the viewport of this player, don't bother placing + // the lap text at the right of the minimap. + if (UserConfigParams::m_height - m_map_bottom - m_map_height > viewport.LowerRightCorner.Y) + { + pos.UpperLeftCorner.X = viewport.UpperLeftCorner.X + (int)(0.1f*UserConfigParams::m_width); + } + else + { + // place lap text at the right of the mini-map + const int calculated_x = viewport.UpperLeftCorner.X + (int)(0.05f*UserConfigParams::m_width); + pos.UpperLeftCorner.X = std::max(calculated_x, m_map_right_side_x + 15); // don't overlap minimap + } + } + else + { + // mini-map is on the right, and lap text on right, so no overlap possible + pos.UpperLeftCorner.X = viewport.UpperLeftCorner.X + (int)(0.05f*UserConfigParams::m_width); + } + gui::IGUIFont* font = GUIEngine::getFont(); int font_height = (int)(font->getDimension(L"X").Height); Modified: main/trunk/src/states_screens/race_gui.hpp =================================================================== --- main/trunk/src/states_screens/race_gui.hpp 2010-04-28 13:17:02 UTC (rev 5309) +++ main/trunk/src/states_screens/race_gui.hpp 2010-04-28 18:26:23 UTC (rev 5310) @@ -121,9 +121,14 @@ // ------------------------- /** The mini map of the track. */ video::ITexture *m_mini_map; + + /** used to render lap count next to the map without overlap */ + int m_map_right_side_x; + bool m_minimap_on_left; + /** The size of a single marker in pixels, must be a power of 2. */ int m_marker_rendered_size; - + /** The size of a single marker on the screen for AI karts, * need not be a power of 2. */ int m_marker_ai_size; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-04-30 19:54:46
|
Revision: 5325 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5325&view=rev Author: auria Date: 2010-04-30 19:54:39 +0000 (Fri, 30 Apr 2010) Log Message: ----------- Implemented the 'random arena' button Modified Paths: -------------- main/trunk/src/states_screens/arenas_screen.cpp main/trunk/src/states_screens/arenas_screen.hpp Modified: main/trunk/src/states_screens/arenas_screen.cpp =================================================================== --- main/trunk/src/states_screens/arenas_screen.cpp 2010-04-30 18:49:25 UTC (rev 5324) +++ main/trunk/src/states_screens/arenas_screen.cpp 2010-04-30 19:54:39 UTC (rev 5325) @@ -68,6 +68,24 @@ // ------------------------------------------------------------------------------------------------------ +void ArenasScreen::init() +{ + buildTrackList(); + + // select something by default for the game master + DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks"); + assert( w != NULL ); + w->setSelection(w->getItems()[0].m_code_name, PLAYER_ID_GAME_MASTER, true); +} // init + +// ------------------------------------------------------------------------------------------------------ + +void ArenasScreen::tearDown() +{ +} // tearDown + +// ------------------------------------------------------------------------------------------------------ + void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) { if (name == "tracks") @@ -79,10 +97,35 @@ if (UserConfigParams::m_verbosity>=5) std::cout << "Clicked on arena " << selection.c_str() << std::endl; + if (selection == "random_track") { - // TODO: random arena selection + RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups"); + assert( tabs != NULL ); + + const std::vector<int>& curr_group = track_manager->getArenasInGroup( + tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER) ); + + RandomGenerator random; + const int randomID = random.get(curr_group.size()); + + Track* clickedTrack = track_manager->getTrack( curr_group[randomID] ); + if (clickedTrack != NULL) + { + ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile().c_str() ); + + new TrackInfoDialog( clickedTrack->getIdent(), clickedTrack->getName().c_str(), + screenshot, 0.8f, 0.7f); + } + + } + else if (selection == "locked") + { + unlock_manager->playLockSound(); } + else if (selection == DynamicRibbonWidget::NO_ITEM_ID) + { + } else { Track* clickedTrack = track_manager->getTrack(selection); @@ -105,18 +148,6 @@ // ------------------------------------------------------------------------------------------------------ -void ArenasScreen::init() -{ - buildTrackList(); - - // select something by default for the game master - DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks"); - assert( w != NULL ); - w->setSelection(w->getItems()[0].m_code_name, PLAYER_ID_GAME_MASTER, true); -} // init - -// ------------------------------------------------------------------------------------------------------ - void ArenasScreen::buildTrackList() { DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks"); @@ -181,19 +212,12 @@ // ------------------------------------------------------------------------------------------------------ -void ArenasScreen::tearDown() -{ -} // tearDown - -// ------------------------------------------------------------------------------------------------------ - void ArenasScreen::setFocusOnTrack(const std::string& trackName) { DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks"); assert( w != NULL ); - // FIXME: don't hardcode player 0? - w->setSelection(trackName, 0, true); + w->setSelection(trackName, PLAYER_ID_GAME_MASTER, true); } // setFOxuOnTrack // ------------------------------------------------------------------------------------------------------ Modified: main/trunk/src/states_screens/arenas_screen.hpp =================================================================== --- main/trunk/src/states_screens/arenas_screen.hpp 2010-04-30 18:49:25 UTC (rev 5324) +++ main/trunk/src/states_screens/arenas_screen.hpp 2010-04-30 19:54:39 UTC (rev 5325) @@ -35,10 +35,16 @@ void buildTrackList(); public: - void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); - void init(); - void tearDown(); + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void init(); + + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void tearDown(); + + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); + void setFocusOnTrack(const std::string& trackName); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-05-01 23:52:25
|
Revision: 5339 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5339&view=rev Author: auria Date: 2010-05-01 23:52:19 +0000 (Sat, 01 May 2010) Log Message: ----------- Make sure the 'standard' group is listed before the 'add-ons' group, and is selected by default. Modified Paths: -------------- main/trunk/src/states_screens/arenas_screen.cpp main/trunk/src/states_screens/kart_selection.cpp main/trunk/src/states_screens/tracks_screen.cpp Modified: main/trunk/src/states_screens/arenas_screen.cpp =================================================================== --- main/trunk/src/states_screens/arenas_screen.cpp 2010-05-01 23:40:50 UTC (rev 5338) +++ main/trunk/src/states_screens/arenas_screen.cpp 2010-05-01 23:52:19 UTC (rev 5339) @@ -56,14 +56,29 @@ //FIXME: this returns groups for arenas but tracks too. this means that some of them // may contain only tracks, no arenas, and thus add an empty tab here... const std::vector<std::string>& groups = track_manager->getAllGroups(); - const int group_amount = groups.size(); + + // add standard group first for (int n=0; n<group_amount; n++) { - //FIXME: group name not translated - tabs->addTextChild( stringw(groups[n].c_str()).c_str(), groups[n]); + if (groups[n] == DEFAULT_GROUP_NAME) + { + //FIXME: group name not translated + tabs->addTextChild( stringw(groups[n].c_str()).c_str(), groups[n]); + break; + } } + // add others after + for (int n=0; n<group_amount; n++) + { + if (groups[n] != DEFAULT_GROUP_NAME) + { + //FIXME: group name not translated + tabs->addTextChild( stringw(groups[n].c_str()).c_str(), groups[n]); + } + } + if (group_amount > 1) { //I18N: name of the tab that will show arenas from all groups Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2010-05-01 23:40:50 UTC (rev 5338) +++ main/trunk/src/states_screens/kart_selection.cpp 2010-05-01 23:52:19 UTC (rev 5339) @@ -726,15 +726,29 @@ tabs->clearAllChildren(); const std::vector<std::string>& groups = kart_properties_manager->getAllGroups(); - const int group_amount = groups.size(); + // add default group first for (int n=0; n<group_amount; n++) { - //FIXME: group name not translated - tabs->addTextChild( stringw(groups[n].c_str()).c_str() , groups[n]); + if (groups[n] == DEFAULT_GROUP_NAME) + { + //FIXME: group name not translated + tabs->addTextChild( stringw(groups[n].c_str()).c_str() , groups[n]); + break; + } } + // add others after + for (int n=0; n<group_amount; n++) + { + if (groups[n] != DEFAULT_GROUP_NAME) + { + //FIXME: group name not translated + tabs->addTextChild( stringw(groups[n].c_str()).c_str() , groups[n]); + } + } + if (group_amount > 1) { //I18N: name of the tab that will show tracks from all groups Modified: main/trunk/src/states_screens/tracks_screen.cpp =================================================================== --- main/trunk/src/states_screens/tracks_screen.cpp 2010-05-01 23:40:50 UTC (rev 5338) +++ main/trunk/src/states_screens/tracks_screen.cpp 2010-05-01 23:52:19 UTC (rev 5339) @@ -56,14 +56,29 @@ tabs->clearAllChildren(); const std::vector<std::string>& groups = track_manager->getAllGroups(); + const int group_amount = groups.size(); - const int group_amount = groups.size(); + // add standard group first for (int n=0; n<group_amount; n++) { - // FIXME: group name is not translated - tabs->addTextChild( stringw(groups[n].c_str()).c_str(), groups[n] ); + if (groups[n] == DEFAULT_GROUP_NAME) + { + // FIXME: group name is not translated + tabs->addTextChild( stringw(groups[n].c_str()).c_str(), groups[n] ); + break; + } } + // add others after + for (int n=0; n<group_amount; n++) + { + if (groups[n] != DEFAULT_GROUP_NAME) + { + // FIXME: group name is not translated + tabs->addTextChild( stringw(groups[n].c_str()).c_str(), groups[n] ); + } + } + if (group_amount > 1) { //I18N: name of the tab that will show tracks from all groups This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-05-03 17:18:54
|
Revision: 5362 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5362&view=rev Author: auria Date: 2010-05-03 17:18:47 +0000 (Mon, 03 May 2010) Log Message: ----------- Improved behavior when escape is pressed in a device config screen Modified Paths: -------------- main/trunk/src/states_screens/options_screen_input2.cpp main/trunk/src/states_screens/options_screen_input2.hpp Modified: main/trunk/src/states_screens/options_screen_input2.cpp =================================================================== --- main/trunk/src/states_screens/options_screen_input2.cpp 2010-05-03 13:40:32 UTC (rev 5361) +++ main/trunk/src/states_screens/options_screen_input2.cpp 2010-05-03 17:18:47 UTC (rev 5362) @@ -417,3 +417,12 @@ { } +// ----------------------------------------------------------------------------- + +bool OptionsScreenInput2::onEscapePressed() +{ + StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance()); + return false; // don't use standard escape key handler, we handled it differently +} + +// ----------------------------------------------------------------------------- Modified: main/trunk/src/states_screens/options_screen_input2.hpp =================================================================== --- main/trunk/src/states_screens/options_screen_input2.hpp 2010-05-03 13:40:32 UTC (rev 5361) +++ main/trunk/src/states_screens/options_screen_input2.hpp 2010-05-03 17:18:47 UTC (rev 5362) @@ -63,6 +63,9 @@ /** \brief implement callback from parent class GUIEngine::Screen */ virtual void tearDown(); + /** \brief implement optional callback from parent class GUIEngine::Screen */ + virtual bool onEscapePressed(); + /** * \brief invoke in "input sensing" mode, when input was sensed. * Updates the input bindings accordingly with the sensed input. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-05-30 15:48:30
|
Revision: 5455 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5455&view=rev Author: auria Date: 2010-05-30 15:48:24 +0000 (Sun, 30 May 2010) Log Message: ----------- Added files forgotten in previous commit Modified Paths: -------------- main/trunk/src/states_screens/main_menu_screen.cpp Added Paths: ----------- main/trunk/src/states_screens/grand_prix_lose.cpp main/trunk/src/states_screens/grand_prix_lose.hpp main/trunk/src/states_screens/grand_prix_win.cpp main/trunk/src/states_screens/grand_prix_win.hpp Removed Paths: ------------- main/trunk/src/states_screens/grand_prix_over.cpp main/trunk/src/states_screens/grand_prix_over.hpp Added: main/trunk/src/states_screens/grand_prix_lose.cpp =================================================================== --- main/trunk/src/states_screens/grand_prix_lose.cpp (rev 0) +++ main/trunk/src/states_screens/grand_prix_lose.cpp 2010-05-30 15:48:24 UTC (rev 5455) @@ -0,0 +1,250 @@ + +#include "states_screens/grand_prix_lose.hpp" + +#include "audio/music_manager.hpp" +#include "audio/sfx_manager.hpp" +#include "challenges/unlock_manager.hpp" +#include "graphics/irr_driver.hpp" +#include "guiengine/engine.hpp" +#include "guiengine/widgets/label_widget.hpp" +#include "io/file_manager.hpp" +#include "items/item_manager.hpp" +#include "karts/kart_properties_manager.hpp" +#include "states_screens/feature_unlocked.hpp" +#include "states_screens/state_manager.hpp" +#include "utils/translation.hpp" + +#include <SColor.h> +#include <iostream> + +using namespace irr::core; +using namespace irr::gui; +using namespace irr::video; + +const float INITIAL_Y = -3.0f; + +const float DURATION = 20.0f; + +const float CAMERA_END_X = -15.0f; +const float CAMERA_END_Y = 1.5f; +const float CAMERA_END_Z = 5.0f; +const float CAMERA_START_X = -17.0f; +const float CAMERA_START_Y = 2.0f; +const float CAMERA_START_Z = 5.5f; + + +const float KART_START_X = -17.0f; +const float KART_END_X = -5.0f; +const float KART_Y = -3.0f; +const float KART_Z = 0.0f; + +DEFINE_SCREEN_SINGLETON( GrandPrixLose ); + +// ------------------------------------------------------------------------------------- + +GrandPrixLose::GrandPrixLose() : Screen("grand_prix_lose.stkgui") +{ + setNeeds3D(true); + + m_throttle_FPS = false; +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixLose::loadedFromFile() +{ + m_kart_node = NULL; +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixLose::init() +{ + // TODO: change music + music_manager->startMusic(music_manager->getMusicInformation(file_manager->getMusicFile("win_theme.music"))); + + m_phase = 1; + m_sky_angle = 0.0f; + m_global_time = 0.0f; + + m_sky = irr_driver->addSkyDome(file_manager->getTextureFile("clouds.png"), + 16 /* hori_res */, 16 /* vert_res */, + 1.0f /* texture_percent */, 2.0f /* sphere_percent */); + + m_camera = irr_driver->addCameraSceneNode(); + m_camera_x = CAMERA_START_X; + m_camera_y = CAMERA_START_Y; + m_camera_z = CAMERA_START_Z; + m_camera->setPosition( core::vector3df(m_camera_x, m_camera_y, m_camera_z) ); + m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); + + m_camera_target_x = 0.0f; + m_camera_target_z = -2.0f; + m_camera->setTarget( core::vector3df(m_camera_target_x, -2.0f, m_camera_target_z) ); + m_camera->setFOV( DEGREE_TO_RAD*50.0f ); + m_camera->updateAbsolutePosition(); + + + scene::IAnimatedMesh* model_garage_door = irr_driver->getAnimatedMesh( file_manager->getModelFile("gplose_door.b3d") ); + assert(model_garage_door!= NULL); + m_garage_door = irr_driver->addAnimatedMesh(model_garage_door); + m_garage_door->setPosition( core::vector3df(2, INITIAL_Y, 0) ); + m_garage_door->setAnimationSpeed(0); + + scene::IMesh* model_garage = irr_driver->getMesh( file_manager->getModelFile("gplose.b3d") ); + assert(model_garage!= NULL); + m_garage = irr_driver->addMesh(model_garage); + m_garage->setPosition( core::vector3df(2, INITIAL_Y, 0) ); + + scene::ISceneManager* sceneManager = irr_driver->getSceneManager(); + sceneManager->setAmbientLight(video::SColor(255, 120, 120, 120)); + + const core::vector3df &sun_pos = core::vector3df( 0, 200, 100.0f ); + m_light = irr_driver->getSceneManager()->addLightSceneNode(NULL, sun_pos, + video::SColorf(1.0f,1.0f,1.0f), + 300.0f /* radius */); + m_light->getLightData().DiffuseColor = irr::video::SColorf(1.0f, 1.0f, 1.0f, 1.0f); + m_light->getLightData().SpecularColor = irr::video::SColorf(1.0f, 0.0f, 0.0f, 0.0f); +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixLose::tearDown() +{ + irr_driver->removeNode(m_sky); + m_sky = NULL; + + irr_driver->removeCameraSceneNode(m_camera); + m_camera = NULL; + + irr_driver->removeNode(m_light); + m_light = NULL; + + irr_driver->removeNode(m_garage); + m_garage = NULL; + + irr_driver->removeNode(m_kart_node); + + irr_driver->removeNode(m_garage_door); +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixLose::onUpdate(float dt, irr::video::IVideoDriver* driver) +{ + m_global_time += dt; + + m_sky_angle += dt*2; + if (m_sky_angle > 360) m_sky_angle -= 360; + m_sky->setRotation( core::vector3df(0, m_sky_angle, 0) ); + + const int lastFrame = m_garage_door->getEndFrame(); + if (m_global_time < 6.0f) + { + m_garage_door->setCurrentFrame( (m_global_time/10.0f)*lastFrame ); + } + else if (m_global_time > DURATION - 6.0f ) + { + m_garage_door->setCurrentFrame( (1.0f - ((m_global_time - (DURATION - 10.0f))/10.0f))*lastFrame ); + } + //else if (m_global_time < DURATION) + //{ + // m_garage_door->setCurrentFrame( lastFrame ); + //} + + const float kartProgression = m_global_time/(DURATION - 5.0f); + if (kartProgression <= 1.0f) + { + m_kart_x = KART_START_X + (KART_END_X - KART_START_X)*kartProgression; + m_kart_node->setPosition( core::vector3df(m_kart_x, m_kart_y, m_kart_z) ); + } + + const float progression = m_global_time / DURATION; + m_camera_x = CAMERA_START_X + (CAMERA_END_X - CAMERA_START_X)*progression; + m_camera_y = CAMERA_START_Y + (CAMERA_END_Y - CAMERA_START_Y)*progression; + m_camera_z = CAMERA_START_Z + (CAMERA_END_Z - CAMERA_START_Z)*progression; + + m_camera->setPosition( core::vector3df(m_camera_x, m_camera_y, m_camera_z) ); + m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); + m_camera->updateAbsolutePosition(); + + // ---- title + static const int w = irr_driver->getFrameSize().Width; + static const int h = irr_driver->getFrameSize().Height; + const irr::video::SColor color(255, 255, 255, 255); + + static int test_y = 0; + + //I18N: when failing a GP + GUIEngine::getTitleFont()->draw(_("Better luck next time!"), + core::rect< s32 >( 0, test_y, w, h ), + color, + true/* center h */, false /* center v */ ); +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixLose::eventCallback(GUIEngine::Widget* widget, + const std::string& name, + const int playerID) +{ + if (name == "continue") + { + // un-set the GP mode so that after unlocking, it doesn't try to continue the GP + race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE); + + if (unlock_manager->getRecentlyUnlockedFeatures().size() > 0) + { + std::vector<const Challenge*> unlocked = unlock_manager->getRecentlyUnlockedFeatures(); + unlock_manager->clearUnlocked(); + + FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance(); + + assert(unlocked.size() > 0); + scene->addUnlockedThings(unlocked); + + StateManager::get()->replaceTopMostScreen(scene); + } + else + { + // we assume the main menu was pushed before showing this menu + StateManager::get()->popMenu(); + } + } +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixLose::setKart(const std::string ident_arg) +{ + scene::ISceneNode* kart_main_node = NULL; + + const KartProperties* kart = kart_properties_manager->getKart(ident_arg); + if (kart != NULL) + { + KartModel* kartModel = kart->getKartModel(); + + m_kart_x = KART_START_X; + m_kart_y = KART_Y; + m_kart_z = KART_Z; + + kart_main_node = irr_driver->addMesh(kartModel->getModel()); + kart_main_node->setPosition( core::vector3df(m_kart_x, m_kart_y, m_kart_z) ); + //kart_main_node->setScale( core::vector3df(0.4f, 0.4f, 0.4f) ); + kart_main_node->updateAbsolutePosition(); + + for (int wheel=0; wheel<4; wheel++) + { + scene::ISceneNode* wheel_model = irr_driver->getSceneManager()->addMeshSceneNode( + kartModel->getWheelModel(wheel), + kart_main_node); + wheel_model->setPosition( kartModel->getWheelGraphicsPosition(wheel).toIrrVector() ); + wheel_model->updateAbsolutePosition(); + } + kart_main_node->setRotation(vector3df(0, 90, 0)); + } + + m_kart_node = kart_main_node; +} + +// ------------------------------------------------------------------------------------- Property changes on: main/trunk/src/states_screens/grand_prix_lose.cpp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: main/trunk/src/states_screens/grand_prix_lose.hpp =================================================================== --- main/trunk/src/states_screens/grand_prix_lose.hpp (rev 0) +++ main/trunk/src/states_screens/grand_prix_lose.hpp 2010-05-30 15:48:24 UTC (rev 5455) @@ -0,0 +1,65 @@ +#ifndef HEADER_GRAND_PRIX_LOSE_HPP +#define HEADER_GRAND_PRIX_LOSE_HPP + +#include "guiengine/screen.hpp" + +namespace irr { namespace scene { class ISceneNode; class ICameraSceneNode; class ILightSceneNode; } } +class KartProperties; + +/** + * \brief Screen shown at the end of a Grand Prix + * \ingroup states_screens + */ +class GrandPrixLose : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<GrandPrixLose> +{ + friend class GUIEngine::ScreenSingleton<GrandPrixLose>; + + GrandPrixLose(); + + /** sky angle, 0-360 */ + float m_sky_angle; + + /** Global evolution of time */ + double m_global_time; + + irr::scene::IMeshSceneNode* m_garage; + + irr::scene::IAnimatedMeshSceneNode* m_garage_door; + + irr::scene::ISceneNode* m_kart_node; + + irr::scene::ISceneNode* m_sky; + irr::scene::ICameraSceneNode* m_camera; + + irr::scene::ILightSceneNode* m_light; + + int m_phase; + + float m_kart_x, m_kart_y, m_kart_z; + + float m_camera_x, m_camera_y, m_camera_z; + float m_camera_target_x, m_camera_target_z; + +public: + + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void loadedFromFile(); + + /** \brief implement optional callback from parent class GUIEngine::Screen */ + void onUpdate(float dt, irr::video::IVideoDriver*); + + /** \brief implement callback from parent class GUIEngine::Screen */ + void init(); + + /** \brief implement callback from parent class GUIEngine::Screen */ + void tearDown(); + + /** \brief implement callback from parent class GUIEngine::Screen */ + void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); + + void setKart(const std::string ident); + +}; + +#endif + Property changes on: main/trunk/src/states_screens/grand_prix_lose.hpp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Deleted: main/trunk/src/states_screens/grand_prix_over.cpp =================================================================== --- main/trunk/src/states_screens/grand_prix_over.cpp 2010-05-30 15:45:44 UTC (rev 5454) +++ main/trunk/src/states_screens/grand_prix_over.cpp 2010-05-30 15:48:24 UTC (rev 5455) @@ -1,413 +0,0 @@ - -#include "states_screens/grand_prix_over.hpp" - -#include "audio/music_manager.hpp" -#include "audio/sfx_manager.hpp" -#include "challenges/unlock_manager.hpp" -#include "graphics/irr_driver.hpp" -#include "guiengine/engine.hpp" -#include "guiengine/widgets/label_widget.hpp" -#include "io/file_manager.hpp" -#include "items/item_manager.hpp" -#include "karts/kart_properties_manager.hpp" -#include "states_screens/feature_unlocked.hpp" -#include "states_screens/state_manager.hpp" -#include "utils/translation.hpp" - -#include <SColor.h> -#include <iostream> - -using namespace irr::core; -using namespace irr::gui; -using namespace irr::video; - -const float INITIAL_Y = -3.0f; -const float INITIAL_PODIUM_Y = -3.6f; -const float PODIUM_HEIGHT[3] = { 0.325f, 0.5f, 0.15f }; - -DEFINE_SCREEN_SINGLETON( GrandPrixOver ); - -// ------------------------------------------------------------------------------------- - -GrandPrixOver::GrandPrixOver() : Screen("grand_prix_over.stkgui") -{ - setNeeds3D(true); - - m_throttle_FPS = false; -} - -// ------------------------------------------------------------------------------------- - -void GrandPrixOver::loadedFromFile() -{ - m_kart_node[0] = NULL; - m_kart_node[1] = NULL; - m_kart_node[2] = NULL; - - m_podium_x[0] = 1.4f; - m_podium_z[0] = 0.0f; - - m_podium_x[1] = 2.2f; - m_podium_z[1] = 0.5f; - - m_podium_x[2] = 3.0f; - m_podium_z[2] = 0.0f; -} - -// ------------------------------------------------------------------------------------- - -void traverse(scene::ISceneNode* curr, int level=0) -{ - for (int n=0; n<level; n++) std::cout << "| "; - - unsigned int type = curr->getType(); - const char* ptr = (const char*)&type; - - std::cout << "+ " << curr->getName() << " (" - << char(ptr[0]) << char(ptr[1]) - << char(ptr[2]) << char(ptr[3]) << std::endl; - - const core::list< scene::ISceneNode * >& children = curr->getChildren(); - for (core::list<scene::ISceneNode*>::ConstIterator it=children.begin(); it != children.end(); it++) - { - traverse(*it, level+1); - } - -} - -// ------------------------------------------------------------------------------------- - -void GrandPrixOver::init() -{ - if (unlock_manager->getRecentlyUnlockedFeatures().size() > 0) - { - const core::dimension2d<u32>& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize(); - - - core::stringw message = _("You unlocked a new feature!"); - const int message_width = GUIEngine::getFont()->getDimension(message.c_str()).Width + 30; - - const int label_height = GUIEngine::getFontHeight() + 15; - - const int y_from = frame_size.Height - label_height*2; - const int y_to = frame_size.Height - label_height; - - const int label_x_from = frame_size.Width/2 - message_width/2; - const int label_x_to = frame_size.Width/2 + message_width/2; - - // button_h is used in the x coordinates not by mistake, but because the icon is square and - // scaled according to the available height. - core::rect< s32 > iconarea(label_x_from - label_height, y_from, - label_x_from, y_to); - IGUIImage* img = GUIEngine::getGUIEnv()->addImage( iconarea ); - img->setImage( irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") ) ); - img->setScaleImage(true); - img->setTabStop(false); - img->setUseAlphaChannel(true); - - core::rect< s32 > icon2area(label_x_to, y_from, - label_x_to + label_height, y_to); - img = GUIEngine::getGUIEnv()->addImage( icon2area ); - img->setImage( irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") ) ); - img->setScaleImage(true); - img->setTabStop(false); - img->setUseAlphaChannel(true); - - GUIEngine::LabelWidget* unlocked_label = new GUIEngine::LabelWidget(); - unlocked_label->m_properties[GUIEngine::PROP_ID] = "label"; - unlocked_label->m_properties[GUIEngine::PROP_TEXT_ALIGN] = "center"; - unlocked_label->x = label_x_from; - unlocked_label->y = y_from; - unlocked_label->w = message_width; - unlocked_label->h = label_height; - unlocked_label->m_text = message; - //const irr::video::SColor orange(255, 255, 126, 21); - //unlocked_label->setColor(orange); - - unlocked_label->add(); - } - - music_manager->startMusic(music_manager->getMusicInformation(file_manager->getMusicFile("win_theme.music"))); - - m_phase = 1; - m_sky_angle = 0.0f; - m_global_time = 0.0f; - - m_sky = irr_driver->addSkyDome(file_manager->getTextureFile("clouds.png"), - 16 /* hori_res */, 16 /* vert_res */, - 1.0f /* texture_percent */, 2.0f /* sphere_percent */); - - m_camera = irr_driver->addCameraSceneNode(); - m_camera_x = 3.0f; - m_camera_y = 0.0f; - m_camera_z = -5.0f; - m_camera->setPosition( core::vector3df(m_camera_x, m_camera_y, m_camera_z) ); - m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); - - m_camera_target_x = 1.5f; - m_camera_target_z = 0.0f; - m_camera->setTarget( core::vector3df(m_camera_target_x, -2.0f, m_camera_target_z) ); - m_camera->setFOV( DEGREE_TO_RAD*50.0f ); - m_camera->updateAbsolutePosition(); - - - scene::IMesh* model_village = irr_driver->getMesh( file_manager->getModelFile("village.b3d") ); - assert(model_village != NULL); - m_village = irr_driver->addMesh(model_village); - m_village->setPosition( core::vector3df(2, INITIAL_Y, 0) ); - - - scene::IMesh* podium_model = irr_driver->getMesh( file_manager->getModelFile("wood_podium.b3d") ); - assert(podium_model != NULL); - - - m_podium_step[0] = irr_driver->addMesh(podium_model); - m_podium_step[0]->setPosition( core::vector3df(m_podium_x[0], INITIAL_PODIUM_Y, m_podium_z[0]) ); - - m_podium_step[1] = irr_driver->addMesh(podium_model); - m_podium_step[1]->setPosition( core::vector3df(m_podium_x[1], INITIAL_PODIUM_Y, m_podium_z[1]) ); - - m_podium_step[2] = irr_driver->addMesh(podium_model); - m_podium_step[2]->setPosition( core::vector3df(m_podium_x[2], INITIAL_PODIUM_Y, m_podium_z[2]) ); - - scene::ISceneManager* sceneManager = irr_driver->getSceneManager(); - sceneManager->setAmbientLight(video::SColor(255, 120, 120, 120)); - - const core::vector3df &sun_pos = core::vector3df( 0, 200, 100.0f ); - m_light = irr_driver->getSceneManager()->addLightSceneNode(NULL, sun_pos, - video::SColorf(1.0f,1.0f,1.0f), - 300.0f /* radius */); - m_light->getLightData().DiffuseColor = irr::video::SColorf(1.0f, 1.0f, 1.0f, 1.0f); - m_light->getLightData().SpecularColor = irr::video::SColorf(1.0f, 0.0f, 0.0f, 0.0f); - - sfx_manager->quickSound("winner"); -} - -// ------------------------------------------------------------------------------------- - -void GrandPrixOver::tearDown() -{ - irr_driver->removeNode(m_sky); - m_sky = NULL; - - irr_driver->removeCameraSceneNode(m_camera); - m_camera = NULL; - - irr_driver->removeNode(m_light); - m_light = NULL; - - irr_driver->removeNode(m_village); - m_village = NULL; - - for (int n=0; n<3; n++) - { - irr_driver->removeNode(m_podium_step[n]); - m_podium_step[n] = NULL; - if (m_kart_node[n] != NULL) irr_driver->removeNode(m_kart_node[n]); - m_kart_node[n] = NULL; - } - -} - -// ------------------------------------------------------------------------------------- - -void GrandPrixOver::onUpdate(float dt, irr::video::IVideoDriver* driver) -{ - m_global_time += dt; - - m_sky_angle += dt*2; - if (m_sky_angle > 360) m_sky_angle -= 360; - m_sky->setRotation( core::vector3df(0, m_sky_angle, 0) ); - - - // ---- karts move - if (m_phase == 1) - { - int karts_not_yet_done = 0; - for (int k=0; k<3; k++) - { - if (m_kart_node[k] != NULL) - { - - if (fabsf(m_kart_z[k] - m_podium_z[k]) > dt) - { - if (m_kart_z[k] < m_podium_z[k] - dt) - { - m_kart_z[k] += dt; - } - else if (m_kart_z[k] > m_podium_z[k] + dt) - { - m_kart_z[k] -= dt; - } - else - { - m_kart_z[k] = m_podium_z[k]; - } - karts_not_yet_done++; - } - - m_kart_node[k]->setPosition( core::vector3df(m_kart_x[k], m_kart_y[k], m_kart_z[k]) ); - } - } // end for - - if (karts_not_yet_done == 0) - { - m_phase = 2; - } - } - - // ---- Karts Rotate - else if (m_phase == 2) - { - int karts_not_yet_done = 0; - for (int k=0; k<3; k++) - { - if (m_kart_node[k] != NULL) - { - if (m_kart_rotation[k] < 180.f) - { - m_kart_rotation[k] += 25.0f*dt; - m_kart_node[k]->setRotation( core::vector3df(0, m_kart_rotation[k], 0) ); - m_podium_step[k]->setRotation( core::vector3df(0, m_kart_rotation[k], 0) ); - karts_not_yet_done++; - } - } - } // end for - - if (karts_not_yet_done == 0) m_phase = 3; - } - - // ---- Podium Rises - else if (m_phase == 3) - { - for (int k=0; k<3; k++) - { - if (m_kart_node[k] != NULL) - { - const float y_target = INITIAL_Y + PODIUM_HEIGHT[k]; - if (m_kart_y[k] < y_target) - { - m_kart_y[k] += dt*(PODIUM_HEIGHT[k]); - m_kart_node[k]->setPosition( core::vector3df(m_kart_x[k], m_kart_y[k], m_kart_z[k]) ); - m_podium_step[k]->setPosition( core::vector3df(m_podium_x[k], - INITIAL_PODIUM_Y - (INITIAL_Y - m_kart_y[k]), - m_podium_z[k]) ); - - } - } - } // end for - - } - - if (m_phase > 1) - { - //m_camera_x = 3.0f; - if (m_camera_z < -2.0f) m_camera_z += dt*0.2f; - - if (m_camera_x < m_podium_x[1] - dt*0.1f) m_camera_x += dt*0.1f; - else if (m_camera_x > m_podium_x[1] + dt*0.1f) m_camera_x -= dt*0.1f; - else m_camera_x = m_podium_x[1]; - - if (m_camera_target_x < m_podium_x[1]) m_camera_target_x += dt*0.1f; - - if (m_camera_y > -1.8f) m_camera_y -= dt*0.1f; - - - m_camera->setTarget( core::vector3df(m_camera_target_x, -2.0f, m_camera_target_z) ); - - m_camera->setPosition( core::vector3df(m_camera_x, m_camera_y, m_camera_z) ); - m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); - m_camera->updateAbsolutePosition(); - } - - - // ---- title - static const int w = irr_driver->getFrameSize().Width; - static const int h = irr_driver->getFrameSize().Height; - const irr::video::SColor color(255, 255, 255, 255); - - static int test_y = 0; - - GUIEngine::getTitleFont()->draw(_("Grand Prix Results"), - core::rect< s32 >( 0, test_y, w, h/10 ), - color, - true/* center h */, true /* center v */ ); -} - -// ------------------------------------------------------------------------------------- - -void GrandPrixOver::eventCallback(GUIEngine::Widget* widget, - const std::string& name, - const int playerID) -{ - if (name == "continue") - { - // un-set the GP mode so that after unlocking, it doesn't try to continue the GP - race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE); - - if (unlock_manager->getRecentlyUnlockedFeatures().size() > 0) - { - std::vector<const Challenge*> unlocked = unlock_manager->getRecentlyUnlockedFeatures(); - unlock_manager->clearUnlocked(); - - FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance(); - - assert(unlocked.size() > 0); - scene->addUnlockedThings(unlocked); - - StateManager::get()->replaceTopMostScreen(scene); - } - else - { - // we assume the main menu was pushed before showing this menu - StateManager::get()->popMenu(); - } - } -} - -// ------------------------------------------------------------------------------------- - -void GrandPrixOver::setKarts(const std::string idents_arg[3]) -{ - // reorder in "podium order" (i.e. second player to the left, first player in the middle, last at the right) - std::string idents[3]; - idents[0] = idents_arg[1]; - idents[1] = idents_arg[0]; - idents[2] = idents_arg[2]; - - for (int n=0; n<3; n++) - { - if (idents[n].size() == 0) continue; - - scene::ISceneNode* kart_main_node = NULL; - - const KartProperties* kart = kart_properties_manager->getKart(idents[n]); - if (kart != NULL) - { - KartModel* kartModel = kart->getKartModel(); - - m_kart_x[n] = m_podium_x[n]; - m_kart_y[n] = INITIAL_Y; - m_kart_z[n] = -4; - m_kart_rotation[n] = 0.0f; - - kart_main_node = irr_driver->addMesh(kartModel->getModel()); - kart_main_node->setPosition( core::vector3df(m_kart_x[n], m_kart_y[n], m_kart_z[n]) ); - kart_main_node->setScale( core::vector3df(0.4f, 0.4f, 0.4f) ); - kart_main_node->updateAbsolutePosition(); - - for (int wheel=0; wheel<4; wheel++) - { - scene::ISceneNode* wheel_model = irr_driver->getSceneManager()->addMeshSceneNode( - kartModel->getWheelModel(wheel), - kart_main_node); - wheel_model->setPosition( kartModel->getWheelGraphicsPosition(wheel).toIrrVector() ); - wheel_model->updateAbsolutePosition(); - } - } - - m_kart_node[n] = kart_main_node; - } -} - -// ------------------------------------------------------------------------------------- Deleted: main/trunk/src/states_screens/grand_prix_over.hpp =================================================================== --- main/trunk/src/states_screens/grand_prix_over.hpp 2010-05-30 15:45:44 UTC (rev 5454) +++ main/trunk/src/states_screens/grand_prix_over.hpp 2010-05-30 15:48:24 UTC (rev 5455) @@ -1,66 +0,0 @@ -#ifndef HEADER_GRAND_PRIX_OVER_HPP -#define HEADER_GRAND_PRIX_OVER_HPP - -#include "guiengine/screen.hpp" - -namespace irr { namespace scene { class ISceneNode; class ICameraSceneNode; class ILightSceneNode; } } -class KartProperties; - -/** - * \brief Screen shown at the end of a Grand Prix - * \ingroup states_screens - */ -class GrandPrixOver : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<GrandPrixOver> -{ - friend class GUIEngine::ScreenSingleton<GrandPrixOver>; - - GrandPrixOver(); - - /** sky angle, 0-360 */ - float m_sky_angle; - - /** Global evolution of time */ - double m_global_time; - - irr::scene::IMeshSceneNode* m_village; - - irr::scene::IMeshSceneNode* m_podium_step[3]; - irr::scene::ISceneNode* m_kart_node[3]; - - irr::scene::ISceneNode* m_sky; - irr::scene::ICameraSceneNode* m_camera; - - irr::scene::ILightSceneNode* m_light; - - int m_phase; - - float m_kart_x[3], m_kart_y[3], m_kart_z[3]; - float m_podium_x[3], m_podium_z[3]; - float m_kart_rotation[3]; - - float m_camera_x, m_camera_y, m_camera_z; - float m_camera_target_x, m_camera_target_z; - -public: - - /** \brief implement callback from parent class GUIEngine::Screen */ - virtual void loadedFromFile(); - - /** \brief implement optional callback from parent class GUIEngine::Screen */ - void onUpdate(float dt, irr::video::IVideoDriver*); - - /** \brief implement callback from parent class GUIEngine::Screen */ - void init(); - - /** \brief implement callback from parent class GUIEngine::Screen */ - void tearDown(); - - /** \brief implement callback from parent class GUIEngine::Screen */ - void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); - - void setKarts(const std::string idents[3]); - -}; - -#endif - Copied: main/trunk/src/states_screens/grand_prix_win.cpp (from rev 5451, main/trunk/src/states_screens/grand_prix_over.cpp) =================================================================== --- main/trunk/src/states_screens/grand_prix_win.cpp (rev 0) +++ main/trunk/src/states_screens/grand_prix_win.cpp 2010-05-30 15:48:24 UTC (rev 5455) @@ -0,0 +1,422 @@ + +#include "states_screens/grand_prix_win.hpp" + +#include "audio/music_manager.hpp" +#include "audio/sfx_manager.hpp" +#include "challenges/unlock_manager.hpp" +#include "graphics/irr_driver.hpp" +#include "guiengine/engine.hpp" +#include "guiengine/widgets/label_widget.hpp" +#include "io/file_manager.hpp" +#include "items/item_manager.hpp" +#include "karts/kart_properties_manager.hpp" +#include "states_screens/feature_unlocked.hpp" +#include "states_screens/state_manager.hpp" +#include "utils/translation.hpp" + +#include <SColor.h> +#include <iostream> + +using namespace irr::core; +using namespace irr::gui; +using namespace irr::video; + +const float INITIAL_Y = -3.0f; +const float INITIAL_PODIUM_Y = -3.6f; +const float PODIUM_HEIGHT[3] = { 0.325f, 0.5f, 0.15f }; + +DEFINE_SCREEN_SINGLETON( GrandPrixWin ); + +// ------------------------------------------------------------------------------------- + +GrandPrixWin::GrandPrixWin() : Screen("grand_prix_win.stkgui") +{ + setNeeds3D(true); + + m_throttle_FPS = false; +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixWin::loadedFromFile() +{ + m_kart_node[0] = NULL; + m_kart_node[1] = NULL; + m_kart_node[2] = NULL; + + m_podium_x[0] = 1.4f; + m_podium_z[0] = 0.0f; + + m_podium_x[1] = 2.2f; + m_podium_z[1] = 0.5f; + + m_podium_x[2] = 3.0f; + m_podium_z[2] = 0.0f; +} + +// ------------------------------------------------------------------------------------- + +void traverse(scene::ISceneNode* curr, int level=0) +{ + for (int n=0; n<level; n++) std::cout << "| "; + + unsigned int type = curr->getType(); + const char* ptr = (const char*)&type; + + std::cout << "+ " << curr->getName() << " (" + << char(ptr[0]) << char(ptr[1]) + << char(ptr[2]) << char(ptr[3]) << std::endl; + + const core::list< scene::ISceneNode * >& children = curr->getChildren(); + for (core::list<scene::ISceneNode*>::ConstIterator it=children.begin(); it != children.end(); it++) + { + traverse(*it, level+1); + } + +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixWin::init() +{ + if (unlock_manager->getRecentlyUnlockedFeatures().size() > 0) + { + const core::dimension2d<u32>& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize(); + + + core::stringw message = _("You unlocked a new feature!"); + const int message_width = GUIEngine::getFont()->getDimension(message.c_str()).Width + 30; + + const int label_height = GUIEngine::getFontHeight() + 15; + + const int y_from = frame_size.Height - label_height*2; + const int y_to = frame_size.Height - label_height; + + const int label_x_from = frame_size.Width/2 - message_width/2; + const int label_x_to = frame_size.Width/2 + message_width/2; + + // button_h is used in the x coordinates not by mistake, but because the icon is square and + // scaled according to the available height. + core::rect< s32 > iconarea(label_x_from - label_height, y_from, + label_x_from, y_to); + IGUIImage* img = GUIEngine::getGUIEnv()->addImage( iconarea ); + img->setImage( irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") ) ); + img->setScaleImage(true); + img->setTabStop(false); + img->setUseAlphaChannel(true); + + core::rect< s32 > icon2area(label_x_to, y_from, + label_x_to + label_height, y_to); + img = GUIEngine::getGUIEnv()->addImage( icon2area ); + img->setImage( irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") ) ); + img->setScaleImage(true); + img->setTabStop(false); + img->setUseAlphaChannel(true); + + GUIEngine::LabelWidget* unlocked_label = new GUIEngine::LabelWidget(); + unlocked_label->m_properties[GUIEngine::PROP_ID] = "label"; + unlocked_label->m_properties[GUIEngine::PROP_TEXT_ALIGN] = "center"; + unlocked_label->x = label_x_from; + unlocked_label->y = y_from; + unlocked_label->w = message_width; + unlocked_label->h = label_height; + unlocked_label->m_text = message; + //const irr::video::SColor orange(255, 255, 126, 21); + //unlocked_label->setColor(orange); + + unlocked_label->add(); + } + + music_manager->startMusic(music_manager->getMusicInformation(file_manager->getMusicFile("win_theme.music"))); + + m_phase = 1; + m_sky_angle = 0.0f; + m_global_time = 0.0f; + + m_sky = irr_driver->addSkyDome(file_manager->getTextureFile("clouds.png"), + 16 /* hori_res */, 16 /* vert_res */, + 1.0f /* texture_percent */, 2.0f /* sphere_percent */); + + m_camera = irr_driver->addCameraSceneNode(); + m_camera_x = 3.0f; + m_camera_y = 0.0f; + m_camera_z = -5.0f; + m_camera->setPosition( core::vector3df(m_camera_x, m_camera_y, m_camera_z) ); + m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); + + m_camera_target_x = 1.5f; + m_camera_target_z = 0.0f; + m_camera->setTarget( core::vector3df(m_camera_target_x, -2.0f, m_camera_target_z) ); + m_camera->setFOV( DEGREE_TO_RAD*50.0f ); + m_camera->updateAbsolutePosition(); + + + scene::IMesh* model_village = irr_driver->getMesh( file_manager->getModelFile("village.b3d") ); + assert(model_village != NULL); + m_village = irr_driver->addMesh(model_village); + m_village->setPosition( core::vector3df(2, INITIAL_Y, 0) ); + + + scene::IMesh* podium_model = irr_driver->getMesh( file_manager->getModelFile("wood_podium.b3d") ); + assert(podium_model != NULL); + + + m_podium_step[0] = irr_driver->addMesh(podium_model); + m_podium_step[0]->setPosition( core::vector3df(m_podium_x[0], INITIAL_PODIUM_Y, m_podium_z[0]) ); + + m_podium_step[1] = irr_driver->addMesh(podium_model); + m_podium_step[1]->setPosition( core::vector3df(m_podium_x[1], INITIAL_PODIUM_Y, m_podium_z[1]) ); + + m_podium_step[2] = irr_driver->addMesh(podium_model); + m_podium_step[2]->setPosition( core::vector3df(m_podium_x[2], INITIAL_PODIUM_Y, m_podium_z[2]) ); + + scene::ISceneManager* sceneManager = irr_driver->getSceneManager(); + sceneManager->setAmbientLight(video::SColor(255, 120, 120, 120)); + + const core::vector3df &sun_pos = core::vector3df( 0, 200, 100.0f ); + m_light = irr_driver->getSceneManager()->addLightSceneNode(NULL, sun_pos, + video::SColorf(1.0f,1.0f,1.0f), + 300.0f /* radius */); + m_light->getLightData().DiffuseColor = irr::video::SColorf(1.0f, 1.0f, 1.0f, 1.0f); + m_light->getLightData().SpecularColor = irr::video::SColorf(1.0f, 0.0f, 0.0f, 0.0f); + + sfx_manager->quickSound("winner"); +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixWin::tearDown() +{ + irr_driver->removeNode(m_sky); + m_sky = NULL; + + irr_driver->removeCameraSceneNode(m_camera); + m_camera = NULL; + + irr_driver->removeNode(m_light); + m_light = NULL; + + irr_driver->removeNode(m_village); + m_village = NULL; + + for (int n=0; n<3; n++) + { + irr_driver->removeNode(m_podium_step[n]); + m_podium_step[n] = NULL; + if (m_kart_node[n] != NULL) irr_driver->removeNode(m_kart_node[n]); + m_kart_node[n] = NULL; + } + +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixWin::onUpdate(float dt, irr::video::IVideoDriver* driver) +{ + m_global_time += dt; + + m_sky_angle += dt*2; + if (m_sky_angle > 360) m_sky_angle -= 360; + m_sky->setRotation( core::vector3df(0, m_sky_angle, 0) ); + + + // ---- karts move + if (m_phase == 1) + { + assert(m_kart_node[0] != NULL || m_kart_node[1] != NULL || m_kart_node[2] != NULL); + + int karts_not_yet_done = 0; + for (int k=0; k<3; k++) + { + if (m_kart_node[k] != NULL) + { + + if (fabsf(m_kart_z[k] - m_podium_z[k]) > dt) + { + if (m_kart_z[k] < m_podium_z[k] - dt) + { + m_kart_z[k] += dt; + } + else if (m_kart_z[k] > m_podium_z[k] + dt) + { + m_kart_z[k] -= dt; + } + else + { + m_kart_z[k] = m_podium_z[k]; + } + karts_not_yet_done++; + } + + m_kart_node[k]->setPosition( core::vector3df(m_kart_x[k], m_kart_y[k], m_kart_z[k]) ); + } + } // end for + + if (karts_not_yet_done == 0) + { + m_phase = 2; + } + } + + // ---- Karts Rotate + else if (m_phase == 2) + { + int karts_not_yet_done = 0; + for (int k=0; k<3; k++) + { + if (m_kart_node[k] != NULL) + { + if (m_kart_rotation[k] < 180.f) + { + m_kart_rotation[k] += 25.0f*dt; + m_kart_node[k]->setRotation( core::vector3df(0, m_kart_rotation[k], 0) ); + m_podium_step[k]->setRotation( core::vector3df(0, m_kart_rotation[k], 0) ); + karts_not_yet_done++; + } + } + } // end for + + if (karts_not_yet_done == 0) m_phase = 3; + } + + // ---- Podium Rises + else if (m_phase == 3) + { + for (int k=0; k<3; k++) + { + if (m_kart_node[k] != NULL) + { + const float y_target = INITIAL_Y + PODIUM_HEIGHT[k]; + if (m_kart_y[k] < y_target) + { + m_kart_y[k] += dt*(PODIUM_HEIGHT[k]); + m_kart_node[k]->setPosition( core::vector3df(m_kart_x[k], m_kart_y[k], m_kart_z[k]) ); + m_podium_step[k]->setPosition( core::vector3df(m_podium_x[k], + INITIAL_PODIUM_Y - (INITIAL_Y - m_kart_y[k]), + m_podium_z[k]) ); + + } + } + } // end for + + } + + if (m_phase > 1) + { + //m_camera_x = 3.0f; + if (m_camera_z < -2.0f) m_camera_z += dt*0.2f; + + if (m_camera_x < m_podium_x[1] - dt*0.1f) m_camera_x += dt*0.1f; + else if (m_camera_x > m_podium_x[1] + dt*0.1f) m_camera_x -= dt*0.1f; + else m_camera_x = m_podium_x[1]; + + if (m_camera_target_x < m_podium_x[1]) m_camera_target_x += dt*0.1f; + + if (m_camera_y > -1.8f) m_camera_y -= dt*0.1f; + + + m_camera->setTarget( core::vector3df(m_camera_target_x, -2.0f, m_camera_target_z) ); + + m_camera->setPosition( core::vector3df(m_camera_x, m_camera_y, m_camera_z) ); + m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); + m_camera->updateAbsolutePosition(); + } + + + // ---- title + static const int w = irr_driver->getFrameSize().Width; + static const int h = irr_driver->getFrameSize().Height; + const irr::video::SColor color(255, 255, 255, 255); + + static int test_y = 0; + + GUIEngine::getTitleFont()->draw(_("You won the Grand Prix!"), + core::rect< s32 >( 0, test_y, w, h/10 ), + color, + true/* center h */, true /* center v */ ); +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixWin::eventCallback(GUIEngine::Widget* widget, + const std::string& name, + const int playerID) +{ + if (name == "continue") + { + // un-set the GP mode so that after unlocking, it doesn't try to continue the GP + race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE); + + if (unlock_manager->getRecentlyUnlockedFeatures().size() > 0) + { + std::vector<const Challenge*> unlocked = unlock_manager->getRecentlyUnlockedFeatures(); + unlock_manager->clearUnlocked(); + + FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance(); + + assert(unlocked.size() > 0); + scene->addUnlockedThings(unlocked); + + StateManager::get()->replaceTopMostScreen(scene); + } + else + { + // we assume the main menu was pushed before showing this menu + StateManager::get()->popMenu(); + } + } +} + +// ------------------------------------------------------------------------------------- + +void GrandPrixWin::setKarts(const std::string idents_arg[3]) +{ + // reorder in "podium order" (i.e. second player to the left, first player in the middle, last at the right) + std::string idents[3]; + idents[0] = idents_arg[1]; + idents[1] = idents_arg[0]; + idents[2] = idents_arg[2]; + + for (int n=0; n<3; n++) + { + if (idents[n].size() == 0) continue; + + scene::ISceneNode* kart_main_node = NULL; + + const KartProperties* kart = kart_properties_manager->getKart(idents[n]); + if (kart != NULL) + { + KartModel* kartModel = kart->getKartModel(); + assert(kartModel != NULL); + + m_kart_x[n] = m_podium_x[n]; + m_kart_y[n] = INITIAL_Y; + m_kart_z[n] = -4; + m_kart_rotation[n] = 0.0f; + + kart_main_node = irr_driver->addMesh(kartModel->getModel()); + assert(kart_main_node != NULL); + kart_main_node->setPosition( core::vector3df(m_kart_x[n], m_kart_y[n], m_kart_z[n]) ); + kart_main_node->setScale( core::vector3df(0.4f, 0.4f, 0.4f) ); + + for (int wheel=0; wheel<4; wheel++) + { + scene::ISceneNode* wheel_model = irr_driver->getSceneManager()->addMeshSceneNode( + kartModel->getWheelModel(wheel), + kart_main_node); + wheel_model->setPosition( kartModel->getWheelGraphicsPosition(wheel).toIrrVector() ); + wheel_model->updateAbsolutePosition(); + } + } + else + { + std::cerr << "GrandPrixWin : warning : kart '" << idents[n] << "' not found!\n"; + } + + m_kart_node[n] = kart_main_node; + } // end for + + assert(m_kart_node[0] != NULL || m_kart_node[1] != NULL || m_kart_node[2] != NULL); +} + +// ------------------------------------------------------------------------------------- Copied: main/trunk/src/states_screens/grand_prix_win.hpp (from rev 5451, main/trunk/src/states_screens/grand_prix_over.hpp) =================================================================== --- main/trunk/src/states_screens/grand_prix_win.hpp (rev 0) +++ main/trunk/src/states_screens/grand_prix_win.hpp 2010-05-30 15:48:24 UTC (rev 5455) @@ -0,0 +1,67 @@ +#ifndef HEADER_GRAND_PRIX_WIN_HPP +#define HEADER_GRAND_PRIX_WIN_HPP + +#include "guiengine/screen.hpp" + +namespace irr { namespace scene { class ISceneNode; class ICameraSceneNode; class ILightSceneNode; } } +class KartProperties; + +/** + * \brief Screen shown at the end of a Grand Prix + * \ingroup states_screens + */ +class GrandPrixWin : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<GrandPrixWin> +{ + friend class GUIEngine::ScreenSingleton<GrandPrixWin>; + + GrandPrixWin(); + + /** sky angle, 0-360 */ + float m_sky_angle; + + /** Global evolution of time */ + double m_global_time; + + irr::scene::IMeshSceneNode* m_village; + + irr::scene::IMeshSceneNode* m_podium_step[3]; + irr::scene::ISceneNode* m_kart_node[3]; + + irr::scene::ISceneNode* m_sky; + irr::scene::ICameraSceneNode* m_camera; + + irr::scene::ILightSceneNode* m_light; + + int m_phase; + + float m_kart_x[3], m_kart_y[3], m_kart_z[3]; + float m_podium_x[3], m_podium_z[3]; + float m_kart_rotation[3]; + + float m_camera_x, m_camera_y, m_camera_z; + float m_camera_target_x, m_camera_target_z; + +public: + + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void loadedFromFile(); + + /** \brief implement optional callback from parent class GUIEngine::Screen */ + void onUpdate(float dt, irr::video::IVideoDriver*); + + /** \brief implement callback from parent class GUIEngine::Screen */ + void init(); + + /** \brief implement callback from parent class GUIEngine::Screen */ + void tearDown(); + + /** \brief implement callback from parent class GUIEngine::Screen */ + void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); + + /** \pre must be called after pushing the screen, but before onUpdate had the chance to be invoked */ + void setKarts(const std::string idents[3]); + +}; + +#endif + Modified: main/trunk/src/states_screens/main_menu_screen.cpp =================================================================== --- main/trunk/src/states_screens/main_menu_screen.cpp 2010-05-30 15:45:44 UTC (rev 5454) +++ main/trunk/src/states_screens/main_menu_screen.cpp 2010-05-30 15:48:24 UTC (rev 5455) @@ -31,7 +31,8 @@ // FIXME : remove, temporary test #include "states_screens/feature_unlocked.hpp" -#include "states_screens/grand_prix_over.hpp" +#include "states_screens/grand_prix_lose.hpp" +#include "states_screens/grand_prix_win.hpp" #include "tracks/track_manager.hpp" #include "tracks/track.hpp" @@ -82,17 +83,17 @@ { FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance(); - static int i = 0; + static int i = 2; i++; - if (i % 3 == 0) + if (i % 4 == 0) { // the passed kart will not be modified, that's why I allow myself to use const_cast scene->addUnlockedKart( const_cast<KartProperties*>(kart_properties_manager->getKart("gnu")), L"Unlocked"); StateManager::get()->pushScreen(scene); } - else if (i % 3 == 1) + else if (i % 4 == 1) { std::vector<video::ITexture*> textures; textures.push_back(irr_driver->getTexture(track_manager->getTrack("lighthouse")->getScreenshotFile().c_str())); @@ -109,12 +110,18 @@ StateManager::get()->pushScreen(scene); } - else + else if (i % 4 == 2) { - GrandPrixOver* scene = GrandPrixOver::getInstance(); + GrandPrixWin* scene = GrandPrixWin::getInstance(); const std::string winners[] = { "mriceblock", "nolok", "pidgin" }; + StateManager::get()->pushScreen(scene); scene->setKarts( winners ); + } + else + { + GrandPrixLose* scene = GrandPrixLose::getInstance(); StateManager::get()->pushScreen(scene); + scene->setKart( "nolok" ); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-06-24 18:28:26
|
Revision: 5551 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5551&view=rev Author: auria Date: 2010-06-24 18:28:20 +0000 (Thu, 24 Jun 2010) Log Message: ----------- Started fixing kart selections being messed up when a player quit Modified Paths: -------------- main/trunk/src/states_screens/kart_selection.cpp main/trunk/src/states_screens/kart_selection.hpp Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2010-06-24 18:18:30 UTC (rev 5550) +++ main/trunk/src/states_screens/kart_selection.cpp 2010-06-24 18:28:20 UTC (rev 5551) @@ -708,6 +708,7 @@ KartSelectionScreen::KartSelectionScreen() : Screen("karts.stkgui") { + m_removed_widget = NULL; } // ----------------------------------------------------------------------------- @@ -924,8 +925,6 @@ return true; } -PlayerKartWidget* removedWidget = NULL; - // ----------------------------------------------------------------------------- // Returns true if event was handled succesfully bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player) @@ -935,13 +934,16 @@ DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("karts"); if (w == NULL) { - std::cout << "playerQuit() called outside of kart selection screen.\n"; + std::cerr << "ERROR: playerQuit() called outside of kart selection screen, " + << "or the XML file for this screen was changed without adapting the code accordingly\n"; return false; } // If last player quits, return to main menu if (m_kart_widgets.size() <= 1) return false; + std::map<PlayerKartWidget*, std::string> selections; + // Find the player ID associated to this player for (int n=0; n<m_kart_widgets.size(); n++) { @@ -955,8 +957,11 @@ } playerID = n; - break; } + else + { + selections[m_kart_widgets.get(n)] = m_kart_widgets[n].getKartInternalName(); + } } if (playerID == -1) { @@ -974,23 +979,47 @@ GUIEngine::focusNothingForPlayer(playerID); // keep the removed kart a while, for the 'disappear' animation to take place - removedWidget = m_kart_widgets.remove(playerID); + m_removed_widget = m_kart_widgets.remove(playerID); // Tell the StateManager to remove this player StateManager::get()->removeActivePlayer(playerID); - // Karts count changed, maybe order too, so renumber them. Also takes - // care of updating selections. + // Karts count changed, maybe order too, so renumber them. renumberKarts(); // Tell the removed widget to perform the shrinking animation (which will be updated in onUpdate, // and will stop when the widget has disappeared) Widget* fullarea = this->getWidget("playerskarts"); - removedWidget->move( removedWidget->x + removedWidget->w/2, fullarea->y + fullarea->h, 0, 0); + m_removed_widget->move( m_removed_widget->x + m_removed_widget->w/2, fullarea->y + fullarea->h, 0, 0); + // update selections + + const int amount = m_kart_widgets.size(); + for (int n=0; n<amount; n++) + { + const std::string& selectedKart = selections[m_kart_widgets.get(n)]; + if (selectedKart.size() > 0) + { + std::cout << m_kart_widgets[n].getAssociatedPlayer()->getProfile()->getName() << " selected " + << selectedKart.c_str() << "\n"; + const bool success = w->setSelection(selectedKart.c_str(), n, true); + if (!success) + { + // TODO: handle players that lose their kart + } + } + } + + /* + for (std::map<PlayerKartWidget*, std::string>::iterator it = selections.begin(); + it != selectiosn.end(); + it++) + { + } + */ + // check if all players are ready bool allPlayersReady = true; - const int amount = m_kart_widgets.size(); for (int n=0; n<amount; n++) { if (!m_kart_widgets[n].isReady()) @@ -1016,16 +1045,16 @@ } // When a kart widget is removed, it's a kept a while, for the disappear animation to take place - if (removedWidget != NULL) + if (m_removed_widget != NULL) { - removedWidget->onUpdate(delta); + m_removed_widget->onUpdate(delta); - if (removedWidget->w == 0 || removedWidget->h == 0) + if (m_removed_widget->w == 0 || m_removed_widget->h == 0) { // destruct when too small (for "disappear" effects) - this->manualRemoveWidget(removedWidget); - delete removedWidget; - removedWidget = NULL; + this->manualRemoveWidget(m_removed_widget); + delete m_removed_widget; + m_removed_widget = NULL; } } } @@ -1390,7 +1419,7 @@ Widget* fullarea = this->getWidget("playerskarts"); const int splitWidth = fullarea->w / m_kart_widgets.size(); - printf("Renumbering karts..."); + //printf("Renumbering karts..."); for (int n=0; n < m_kart_widgets.size(); n++) { m_kart_widgets[n].setPlayerID(n); @@ -1398,7 +1427,7 @@ } w->updateItemDisplay(); - printf("OK\n"); + //printf("OK\n"); } Modified: main/trunk/src/states_screens/kart_selection.hpp =================================================================== --- main/trunk/src/states_screens/kart_selection.hpp 2010-06-24 18:18:30 UTC (rev 5550) +++ main/trunk/src/states_screens/kart_selection.hpp 2010-06-24 18:28:20 UTC (rev 5551) @@ -52,6 +52,8 @@ */ bool m_player_confirmed; + PlayerKartWidget* m_removed_widget; + /** Called when all players selected their kart */ void allPlayersDone(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <xa...@us...> - 2010-07-02 14:59:28
|
Revision: 5617 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5617&view=rev Author: xapantu Date: 2010-07-02 14:59:21 +0000 (Fri, 02 Jul 2010) Log Message: ----------- code cleanup in addons_loading (remove the use of 'this' for the back button, I am going to remove all 'this') move this->update_status to m_update_status in addons_screen disable the focus on the image in the addon dialog Modified Paths: -------------- main/trunk/src/states_screens/addons_screen.cpp main/trunk/src/states_screens/addons_screen.hpp main/trunk/src/states_screens/dialogs/addons_loading.cpp main/trunk/src/states_screens/dialogs/addons_loading.hpp Modified: main/trunk/src/states_screens/addons_screen.cpp =================================================================== --- main/trunk/src/states_screens/addons_screen.cpp 2010-07-02 09:35:55 UTC (rev 5616) +++ main/trunk/src/states_screens/addons_screen.cpp 2010-07-02 14:59:21 UTC (rev 5617) @@ -93,7 +93,7 @@ } //remove the text from the widget : "Updating list..." (see l164) - this->update_status->setText(""); + m_update_status->setText(""); this->can_load_list = false; } // ------------------------------------------------------------------------------------------------------ @@ -119,7 +119,7 @@ if (name == "category") { std::string selection = ((GUIEngine::RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); - + if (selection == "tab_update") StateManager::get()->replaceTopMostScreen(AddonsUpdateScreen::getInstance()); } } @@ -136,7 +136,7 @@ } void AddonsScreen::init() { - this->update_status = this->getWidget<GUIEngine::LabelWidget>("update_status"); + m_update_status = this->getWidget<GUIEngine::LabelWidget>("update_status"); std::cout << "Addons dir:" + file_manager->getAddonsDir() << std::endl; this->type = "track"; GUIEngine::ListWidget* w_list = this->getWidget<GUIEngine::ListWidget>("list_addons"); @@ -144,6 +144,7 @@ //w_list->clear(); std::cout << "icon bank" << std::endl; this->can_load_list = false; + m_update_status->setText(_("Updating the list...")); pthread_t thread; pthread_create(&thread, NULL, &AddonsScreen::downloadList, this); } @@ -157,7 +158,6 @@ void * AddonsScreen::downloadList( void * pthis) { AddonsScreen * pt = (AddonsScreen*)pthis; - pt->update_status->setText(_("Updating the list...")); //load all karts... pt->addons = new Addons(); pthread_mutex_lock(&(pt->mutex)); Modified: main/trunk/src/states_screens/addons_screen.hpp =================================================================== --- main/trunk/src/states_screens/addons_screen.hpp 2010-07-02 09:35:55 UTC (rev 5616) +++ main/trunk/src/states_screens/addons_screen.hpp 2010-07-02 14:59:21 UTC (rev 5617) @@ -38,15 +38,15 @@ class AddonsScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<AddonsScreen> { friend class GUIEngine::ScreenSingleton<AddonsScreen>; - + AddonsScreen(); Addons * addons; AddonsLoading * load; void loadInformations(); /** For the addons list, a package when it is installed. */ irr::gui::STKModifiedSpriteBank* m_icon_bank; - GUIEngine::LabelWidget* update_status; - + GUIEngine::LabelWidget* m_update_status; + public: bool can_load_list; @@ -55,13 +55,13 @@ void loadList(); /** \brief implement callback from parent class GUIEngine::Screen */ virtual void loadedFromFile(); - + /** \brief implement callback from parent class GUIEngine::Screen */ virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); - + /** \brief implement callback from parent class GUIEngine::Screen */ virtual void init(); - + /** \brief implement callback from parent class GUIEngine::Screen */ virtual void tearDown(); friend void * startInstall(void *); Modified: main/trunk/src/states_screens/dialogs/addons_loading.cpp =================================================================== --- main/trunk/src/states_screens/dialogs/addons_loading.cpp 2010-07-02 09:35:55 UTC (rev 5616) +++ main/trunk/src/states_screens/dialogs/addons_loading.cpp 2010-07-02 14:59:21 UTC (rev 5617) @@ -47,7 +47,7 @@ core::rect< s32 > area_left(m_area.getWidth()/2 + 20, 0, m_area.getWidth(), m_area.getHeight()); /*Init the icon here to be able to load a single image*/ - icon = new IconButtonWidget(); + icon = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO, false, /*focusbale*/ false); /* Next and previous button*/ IconButtonWidget * next_previous = new IconButtonWidget(); @@ -133,20 +133,20 @@ - this->back_button = new ButtonWidget(); - /*this->back_button->setLabel(std::string("Back").c_str());*/ - this->back_button->m_text = _("Back"); - this->back_button->m_properties[PROP_ID] = "cancel"; - this->back_button->x = 20; - this->back_button->y = m_area.getHeight()-45; - this->back_button->setParent(m_irrlicht_window); - m_children.push_back(this->back_button); - this->back_button->w = 150; - this->back_button->h = 35; - this->back_button->add(); + m_back_button = new ButtonWidget(); + /*m_back_button->setLabel(std::string("Back").c_str());*/ + m_back_button->m_text = _("Back"); + m_back_button->m_properties[PROP_ID] = "cancel"; + m_back_button->x = 20; + m_back_button->y = m_area.getHeight()-45; + m_back_button->setParent(m_irrlicht_window); + m_children.push_back(m_back_button); + m_back_button->w = 150; + m_back_button->h = 35; + m_back_button->add(); this->install_button = new ButtonWidget(); - /*this->back_button->setLabel(std::string("Back").c_str());*/ + /*m_back_button->setLabel(std::string("Back").c_str());*/ if(this->addons->IsInstalled() == "yes") this->install_button->m_text = _("Uninstall"); else @@ -183,7 +183,7 @@ } if(eventSource == "install") { - this->back_button->setDeactivated(); + m_back_button->setDeactivated(); this->install_button->setDeactivated(); pthread_t thread; pthread_create(&thread, NULL, &AddonsLoading::startInstall, this); Modified: main/trunk/src/states_screens/dialogs/addons_loading.hpp =================================================================== --- main/trunk/src/states_screens/dialogs/addons_loading.hpp 2010-07-02 09:35:55 UTC (rev 5616) +++ main/trunk/src/states_screens/dialogs/addons_loading.hpp 2010-07-02 14:59:21 UTC (rev 5617) @@ -34,7 +34,7 @@ GUIEngine::LabelWidget * description; GUIEngine::LabelWidget * version; GUIEngine::LabelWidget * author; - GUIEngine::ButtonWidget * back_button; + GUIEngine::ButtonWidget * m_back_button; GUIEngine::ButtonWidget * install_button; GUIEngine::IconButtonWidget * icon; static void * startInstall(void*); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <xa...@us...> - 2010-07-06 16:06:49
|
Revision: 5661 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5661&view=rev Author: xapantu Date: 2010-07-06 16:06:43 +0000 (Tue, 06 Jul 2010) Log Message: ----------- Fix a crash caused by a uninitialized mutex and remove the 'setText' call from the thread because it can caused a crash Modified Paths: -------------- main/trunk/src/states_screens/addons_screen.cpp main/trunk/src/states_screens/main_menu_screen.cpp Modified: main/trunk/src/states_screens/addons_screen.cpp =================================================================== --- main/trunk/src/states_screens/addons_screen.cpp 2010-07-06 14:39:45 UTC (rev 5660) +++ main/trunk/src/states_screens/addons_screen.cpp 2010-07-06 16:06:43 UTC (rev 5661) @@ -136,6 +136,7 @@ } void AddonsScreen::init() { + pthread_mutex_init(&(this->mutex), NULL); m_update_status = this->getWidget<GUIEngine::LabelWidget>("update_status"); std::cout << "Addons dir:" + file_manager->getAddonsDir() << std::endl; this->type = "track"; Modified: main/trunk/src/states_screens/main_menu_screen.cpp =================================================================== --- main/trunk/src/states_screens/main_menu_screen.cpp 2010-07-06 14:39:45 UTC (rev 5660) +++ main/trunk/src/states_screens/main_menu_screen.cpp 2010-07-06 16:06:43 UTC (rev 5661) @@ -86,11 +86,11 @@ // to remove the break line. //info.replace(info.size()-1,1, ""); std::cout << info << std::endl; - w->setText(std::string(info).c_str()); + //w->setText(std::string(info).c_str()); } if(action == "offline") { - w->setText(_("Can't access stkaddons server...")); + //w->setText(_("Can't access stkaddons server...")); } } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-07-17 17:23:39
|
Revision: 5688 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5688&view=rev Author: auria Date: 2010-07-17 17:23:33 +0000 (Sat, 17 Jul 2010) Log Message: ----------- Make sure the right camera is used in 3D cutscenes Modified Paths: -------------- main/trunk/src/states_screens/feature_unlocked.cpp main/trunk/src/states_screens/grand_prix_lose.cpp main/trunk/src/states_screens/grand_prix_win.cpp Modified: main/trunk/src/states_screens/feature_unlocked.cpp =================================================================== --- main/trunk/src/states_screens/feature_unlocked.cpp 2010-07-17 17:11:41 UTC (rev 5687) +++ main/trunk/src/states_screens/feature_unlocked.cpp 2010-07-17 17:23:33 UTC (rev 5688) @@ -147,6 +147,7 @@ m_camera->setTarget( core::vector3df(0, 10, 0.0f) ); m_camera->setFOV( DEGREE_TO_RAD*50.0f ); m_camera->updateAbsolutePosition(); + irr_driver->getSceneManager()->setActiveCamera(m_camera); scene::IAnimatedMesh* model_chest = irr_driver->getAnimatedMesh( file_manager->getModelFile("chest.b3d") ); assert(model_chest != NULL); Modified: main/trunk/src/states_screens/grand_prix_lose.cpp =================================================================== --- main/trunk/src/states_screens/grand_prix_lose.cpp 2010-07-17 17:11:41 UTC (rev 5687) +++ main/trunk/src/states_screens/grand_prix_lose.cpp 2010-07-17 17:23:33 UTC (rev 5688) @@ -78,7 +78,8 @@ m_camera_z = CAMERA_START_Z; m_camera->setPosition( core::vector3df(m_camera_x, m_camera_y, m_camera_z) ); m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); - + irr_driver->getSceneManager()->setActiveCamera(m_camera); + m_camera_target_x = 0.0f; m_camera_target_z = -2.0f; m_camera->setTarget( core::vector3df(m_camera_target_x, -2.0f, m_camera_target_z) ); Modified: main/trunk/src/states_screens/grand_prix_win.cpp =================================================================== --- main/trunk/src/states_screens/grand_prix_win.cpp 2010-07-17 17:11:41 UTC (rev 5687) +++ main/trunk/src/states_screens/grand_prix_win.cpp 2010-07-17 17:23:33 UTC (rev 5688) @@ -145,7 +145,8 @@ m_camera_z = -5.0f; m_camera->setPosition( core::vector3df(m_camera_x, m_camera_y, m_camera_z) ); m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); - + irr_driver->getSceneManager()->setActiveCamera(m_camera); + m_camera_target_x = 1.5f; m_camera_target_z = 0.0f; m_camera->setTarget( core::vector3df(m_camera_target_x, -2.0f, m_camera_target_z) ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-07-20 23:01:53
|
Revision: 5699 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5699&view=rev Author: hikerstk Date: 2010-07-20 23:01:47 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Updated new race result gui (which by default is not shown atm). Modified Paths: -------------- main/trunk/src/states_screens/race_result_gui.cpp main/trunk/src/states_screens/race_result_gui.hpp Modified: main/trunk/src/states_screens/race_result_gui.cpp =================================================================== --- main/trunk/src/states_screens/race_result_gui.cpp 2010-07-20 22:39:54 UTC (rev 5698) +++ main/trunk/src/states_screens/race_result_gui.cpp 2010-07-20 23:01:47 UTC (rev 5699) @@ -28,15 +28,19 @@ */ RaceResultGUI::RaceResultGUI() { - // FIXME: for now disable the new race result display - // by just firing up the old display (which will make sure - // that the rendering for this object is not called anymore). - new RaceOverDialog(0.6f, 0.9f); - return; +#undef USE_NEW_RACE_RESULT - +#ifndef USE_NEW_RACE_RESULT + // FIXME: for now disable the new race result display + // by just firing up the old display (which will make sure + // that the rendering for this object is not called anymore). + new RaceOverDialog(0.6f, 0.9f); + return; +#else determineLayout(); m_timer = 0; + m_animation_state = RR_BEGIN_FIRST_TABLE; +#endif } // RaceResultGUI //----------------------------------------------------------------------------- @@ -63,65 +67,86 @@ */ void RaceResultGUI::determineLayout() { + m_font = dynamic_cast<gui::ScalableFont*>(GUIEngine::getFont()); + assert(m_font); + World *world = World::getWorld(); + world->raceResultOrder(&m_order); + + // Determine the kart to display in the right order, and the maximum + // width for the kart name column + m_max_kart_name_width = 0; + float max_finish_time = 0; + for(unsigned int i=0; i<m_order.size(); i++) + { + if(m_order[i]==-1) continue; + Kart *kart = world->getKart(m_order[i]); + m_kart_names.push_back(kart->getName()); + + video::ITexture *icon = + kart->getKartProperties()->getIconMaterial()->getTexture(); + m_kart_icons.push_back(icon); + + const float time = kart->getFinishTime(); + if(time > max_finish_time) max_finish_time = time; + std::string time_string = StringUtils::timeToString(time); + m_time_strings.push_back(time_string.c_str()); + + core::dimension2d<u32> rect = m_font->getDimension(kart->getName().c_str()); + if(rect.Width > m_max_kart_name_width) + m_max_kart_name_width = rect.Width; + m_new_points.push_back(race_manager->getPositionScore(i+1)); + m_old_overall_points.push_back(race_manager->getKartPrevScore(m_order[i])); + } + + std::string max_time = StringUtils::timeToString(max_finish_time); + core::stringw string_max_time(max_time.c_str()); + core::dimension2du r_time = m_font->getDimension(string_max_time.c_str()); + m_time_width = r_time.Width; + + // Use only the karts that are supposed to be displayed (and + // ignore e.g. the leader in a FTL race). + unsigned int num_karts = m_time_strings.size(); + // Top pixel where to display text unsigned int top = (int)(0.15f*UserConfigParams::m_height); // Height of the result display unsigned int height = (int)(0.7f *UserConfigParams::m_height); + // Setup different timing information for the different phases + // ----------------------------------------------------------- // How much time between consecutive rows m_time_between_rows = 0.5f; - World *world = World::getWorld(); - unsigned int num_karts = world->getNumKarts(); + // How long it takes for one line to scroll from right to left + m_time_single_scroll = 0.5f; + // The time the first phase is being displayed: add the start time + // of the last kart to the duration of the scroll plus some time + // of rest before the next phase starts + m_time_overall_scroll = (num_karts-1)*m_time_between_rows + + m_time_single_scroll + 2.0f; + // Determine text height - m_font = GUIEngine::getFont(); - core::dimension2du text_size = m_font->getDimension(L"a"); + core::dimension2du text_size = m_font->getDimension(L"Y"); m_distance_between_rows = (int)(1.5f*text_size.Height); // If there are too many karts, reduce size between rows if(m_distance_between_rows * num_karts > height) m_distance_between_rows = height / num_karts; - world->raceResultOrder(&m_order); - m_start_at.clear(); for(unsigned int i=0; i<num_karts; i++) { - if(m_order[i]==-1) continue; m_start_at.push_back(m_time_between_rows * i); m_x_pos.push_back((float)UserConfigParams::m_width); - m_y_pos.push_back(m_distance_between_rows+i*m_distance_between_rows); - Kart *kart = world->getKart(m_order[i]); - const core::stringw& kart_name = kart->getName(); - - const float time = kart->getFinishTime(); - std::string time_string = StringUtils::timeToString(time); - core::stringw kart_results_line = StringUtils::insertValues( L"%i. %s %s", - kart->getPosition(), - kart_name.c_str(), - time_string.c_str()); - - m_entry.push_back(core::stringw(kart_results_line.c_str())); + m_y_pos.push_back(top+i*m_distance_between_rows); } m_icon_width = UserConfigParams::m_height<600 ? 27 : (int)(40*(UserConfigParams::m_width/800.0f)); - // Determine the maximum width for the kart name column - unsigned int max_name_width = 0; - float max_finish_time = 0; - for(unsigned int i=0; i<num_karts; i++) - { - const Kart *kart = world->getKart(i); - core::dimension2d<u32> rect = m_font->getDimension(kart->getName().c_str()); - if(rect.Width > max_name_width) max_name_width = rect.Width; - if(kart->getFinishTime() > max_finish_time) - max_finish_time = kart->getFinishTime(); - } // for i<num_karts - // Not all digits have the same width. So to properly align the times // and points, we have to do the layout one digit at a time, and we // need the maximum size of one digit for that: @@ -133,7 +158,10 @@ core::dimension2du r = m_font->getDimension(s); if(r.Width > m_max_digit_width) m_max_digit_width = r.Width; } - m_column_space_size = 20; + core::dimension2du r = m_font->getDimension(L":"); + m_colon_width = r.Width; + + m_column_space_size = 20; } // determineLayout //----------------------------------------------------------------------------- @@ -143,28 +171,43 @@ */ void RaceResultGUI::renderGlobal(float dt) { - + m_timer += dt; + switch(m_animation_state) + { + case RR_BEGIN_FIRST_TABLE: + if(m_timer > m_time_overall_scroll) + { + m_animation_state = RR_INCREASE_POINTS; + m_timer = 0; + } + break; + case RR_INCREASE_POINTS: + if(m_timer > 5) + { + m_animation_state = RR_RESORT_TABLE; + m_timer = 0; + } + break; + case RR_RESORT_TABLE: + break; + case RR_WAIT_TILL_END: + break; + } // switch World *world = World::getWorld(); assert(world->getPhase()==WorldStatus::RESULT_DISPLAY_PHASE); - m_timer += dt; unsigned int num_karts = world->getNumKarts(); - // How long it takes for one line to scroll from right to left - float scroll_duration = 0.5f; - - float v = 0.9f*UserConfigParams::m_width/scroll_duration; - for(unsigned int i=0; i<num_karts; i++) + float v = 0.9f*UserConfigParams::m_width/m_time_single_scroll; + for(unsigned int i=0; i<m_kart_names.size(); i++) { - if(m_order[i]==-1) continue; if(m_start_at[i]>m_timer) continue; m_x_pos[i] -= dt*v; if(m_x_pos[i]<0.1f*UserConfigParams::m_width) m_x_pos[i] = 0.1f*UserConfigParams::m_width; - printf("%d: %f %d\n", i, m_x_pos[i], m_y_pos[i]); displayOneEntry((unsigned int)(m_x_pos[i]), m_y_pos[i], - m_order[i], true); + i, true); } } // renderGlobal @@ -187,15 +230,53 @@ // First draw the icon // ------------------- - video::ITexture *t = kart->getKartProperties()->getIconMaterial()->getTexture(); - core::recti source_rect(core::vector2di(0,0), t->getSize()); + core::recti source_rect(core::vector2di(0,0), m_kart_icons[n]->getSize()); core::recti dest_rect(x, y, x+m_icon_width, y+m_icon_width); - irr_driver->getVideoDriver()->draw2DImage(t, dest_rect, source_rect, - NULL, NULL, true); + irr_driver->getVideoDriver()->draw2DImage(m_kart_icons[n], dest_rect, + source_rect, NULL, NULL, true); // Draw the name // ------------- - core::recti pos(x+m_icon_width+m_column_space_size, y, - UserConfigParams::m_width, y+m_distance_between_rows); + core::recti pos_name(x+m_icon_width+m_column_space_size, y, + UserConfigParams::m_width, y+m_distance_between_rows); - m_font->draw(m_entry[n], pos, color); + m_font->draw(m_kart_names[n], pos_name, color); + + // Draw the time + // ------------- + unsigned int x_time = x + m_icon_width + m_column_space_size + + m_max_kart_name_width + m_column_space_size; + + bool mono = m_font->getMonospaceDigits(); + //m_font->setMonospaceDigits(true); + dest_rect = core::recti(x_time, y, x_time+100, y+10); + m_font->draw(m_time_strings[n], dest_rect, color); + m_font->setMonospaceDigits(mono); + + // Draw the new points + // ------------------- + unsigned int x_point = x + m_icon_width + m_column_space_size + + m_max_kart_name_width + m_column_space_size + + m_time_width + m_column_space_size; + dest_rect = core::recti(x_point, y, x_point+100, y+10); + core::stringw point_string = core::stringw("+")+core::stringw(m_new_points[n]); + while(point_string.size()<3) + point_string = core::stringw(" ")+point_string; + m_font->draw(point_string, dest_rect, color); + } // displayOneEntry + +//----------------------------------------------------------------------------- +void RaceResultGUI::drawNumber(const core::stringw &number_string, + unsigned int *x, unsigned int y, + const video::SColor &color) +{ + for(unsigned int i=0; i<number_string.size(); i++) + { + core::recti p(*x, y, *x+m_max_digit_width, y+10); + m_font->draw(number_string.subString(i,1), p, color); + if(number_string[i]==':') + *x+=m_colon_width; + else + *x+=m_max_digit_width; + } // for i<number_string.size +} // drawNumber Modified: main/trunk/src/states_screens/race_result_gui.hpp =================================================================== --- main/trunk/src/states_screens/race_result_gui.hpp 2010-07-20 22:39:54 UTC (rev 5698) +++ main/trunk/src/states_screens/race_result_gui.hpp 2010-07-20 23:01:47 UTC (rev 5699) @@ -24,6 +24,7 @@ #include <vector> #include "states_screens/race_gui_base.hpp" +#include "guiengine/CGUIFont.h" /** * \brief Displays the results (while the end animation is shown). @@ -32,15 +33,65 @@ class RaceResultGUI : public RaceGUIBase { private: + /** Timer variable for animations. */ float m_timer; + + /** Finite state machine for the animations: + BEGIN_FIRST_TABLE: The rows scroll into place. + INCREASE_POINTS: The overall points are added up + RESORT_TABLE: Resort the table so that it is now sorted by + GP points. + WAIT_TILL_END Some delay to wait for end, after a period it + wii automatically end. */ + enum {RR_BEGIN_FIRST_TABLE, + RR_INCREASE_POINTS, + RR_RESORT_TABLE, + RR_WAIT_TILL_END} + m_animation_state; + + /** Start time for each line of the animation. */ std::vector<float> m_start_at; + + /** Currenct X position. */ std::vector<float> m_x_pos; + + /** Currenct Y position. */ std::vector<int> m_y_pos; - std::vector<core::stringw> m_entry; + /** The order in which to display the karts. */ + std::vector<int> m_order; + + /** The names of all karts in the right order. */ + std::vector<core::stringw> m_kart_names; + + /** Points earned in this race. */ + std::vector<int> m_new_points; + + /** When updating the number of points in the display, this is the + currently displayed number of points, so + m_old_overall_points <= m_current_displayed_points<= + m_old_overall_points+m_new_points. */ + std::vector<int> m_current_displayed_points; + + /** Overall points before this race. */ + std::vector<int> m_old_overall_points; + + /** The kart icons. */ + std::vector<video::ITexture*> m_kart_icons; + + /** The times of all karts in the right order. */ + std::vector<core::stringw> m_time_strings; + /** Time to wait till the next row starts to be animated. */ float m_time_between_rows; + /** The time a single line scrolls into place. */ + float m_time_single_scroll; + + /** The overall time the first phase (scrolling) is displayed. + This includes a small waiting time at the end. */ + float m_time_overall_scroll; + /** Distance between each row of the race results */ unsigned int m_distance_between_rows; @@ -50,26 +101,31 @@ /** The width of the time column. */ unsigned int m_time_width; + /** Width of the kart name column. */ + unsigned int m_max_kart_name_width; + /** The width of the point column. */ unsigned int m_column_width; - /** The order in which to display the karts. */ - std::vector<int> m_order; - /** The width of the largest digit (not all digits * have the same font size) */ - unsigned int m_max_digit_width ; + unsigned int m_max_digit_width ; + /** The width of a ":" (used in time display mm:ss:hh). */ + unsigned int m_colon_width; + /** Size of space between columns. */ unsigned int m_column_space_size; /** The font to use. */ - gui::IGUIFont* m_font; + gui::ScalableFont* m_font; void displayOneEntry(unsigned int x, unsigned int y, unsigned int n, bool display_points); void determineLayout(); - + void drawNumber(const core::stringw &number_string, + unsigned int *x, unsigned int y, + const video::SColor &color); public: RaceResultGUI(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-07-25 22:37:17
|
Revision: 5708 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5708&view=rev Author: hikerstk Date: 2010-07-25 22:37:11 +0000 (Sun, 25 Jul 2010) Log Message: ----------- Added animated display of current GP standings. Modified Paths: -------------- main/trunk/src/states_screens/race_result_gui.cpp main/trunk/src/states_screens/race_result_gui.hpp Modified: main/trunk/src/states_screens/race_result_gui.cpp =================================================================== --- main/trunk/src/states_screens/race_result_gui.cpp 2010-07-25 22:35:53 UTC (rev 5707) +++ main/trunk/src/states_screens/race_result_gui.cpp 2010-07-25 22:37:11 UTC (rev 5708) @@ -29,7 +29,7 @@ */ RaceResultGUI::RaceResultGUI() { -#undef USE_NEW_RACE_RESULT +#define USE_NEW_RACE_RESULT #ifndef USE_NEW_RACE_RESULT // FIXME: for now disable the new race result display @@ -77,21 +77,18 @@ assert(m_font); World *world = World::getWorld(); - world->raceResultOrder(&m_order); - if(race_manager->getMajorMode()==RaceManager::MAJOR_MODE_GRAND_PRIX) - race_manager->computeGPRanks(); + std::vector<int> order; + world->raceResultOrder(&order); // Determine the kart to display in the right order, // and the maximum width for the kart name column // ------------------------------------------------- m_width_kart_name = 0; float max_finish_time = 0; - for(unsigned int i=0; i<m_order.size(); i++) + for(unsigned int i=0; i<order.size(); i++) { - if(m_order[i]==-1) continue; - Kart *kart = world->getKart(m_order[i]); - //JH: work in progress printf("%s: %d\n", - // kart->getIdent().c_str(), race_manager->getKartGPRank(m_order[i])); + if(order[i]==-1) continue; + Kart *kart = world->getKart(order[i]); m_kart_names.push_back(kart->getName()); video::ITexture *icon = @@ -107,10 +104,10 @@ if(rect.Width > m_width_kart_name) m_width_kart_name = rect.Width; m_new_points.push_back(race_manager->getPositionScore(i+1)); - int p = race_manager->getKartPrevScore(m_order[i]); + int p = race_manager->getKartPrevScore(order[i]); m_new_overall_points.push_back(p+m_new_points[i]); m_current_displayed_points.push_back((float)p); - } // for i < m_order.size() + } // for i < order.size() std::string max_time = StringUtils::timeToString(max_finish_time); core::stringw string_max_time(max_time.c_str()); @@ -135,6 +132,9 @@ // How long it takes for one line to scroll from right to left m_time_single_scroll = 0.2f; + // Time to rotate the entries to the proper GP position. + m_time_rotation = 2.0f; + // The time the first phase is being displayed: add the start time // of the last kart to the duration of the scroll plus some time // of rest before the next phase starts @@ -177,12 +177,23 @@ + 2 * m_width_column_space; m_leftmost_column = (UserConfigParams::m_width - table_width)/2; + if(race_manager->getMajorMode()==RaceManager::MAJOR_MODE_GRAND_PRIX) + race_manager->computeGPRanks(); m_start_at.clear(); for(unsigned int i=0; i<num_karts; i++) { m_start_at.push_back(m_time_between_rows * i); m_x_pos.push_back((float)UserConfigParams::m_width); m_y_pos.push_back(top+i*m_distance_between_rows); + + if(race_manager->getMajorMode()==RaceManager::MAJOR_MODE_GRAND_PRIX) + { + int gp_position = race_manager->getKartGPRank(order[i]); + if(gp_position<(int)i) + printf("X"); + m_radius.push_back( (gp_position-(int)i)*(int)m_distance_between_rows*0.5f); + m_centre_point.push_back(top+(gp_position+i)*m_distance_between_rows*0.5f); + } } // i < num_karts @@ -200,54 +211,64 @@ assert(world->getPhase()==WorldStatus::RESULT_DISPLAY_PHASE); unsigned int num_karts = world->getNumKarts(); + switch(m_animation_state) { - case RR_BEGIN_FIRST_TABLE: - { - // Animate the table to move in from the left - // ------------------------------------------ - if(m_timer > m_time_overall_scroll) - { - m_animation_state = RR_INCREASE_POINTS; - m_timer = 0; - } - float v = 0.9f*UserConfigParams::m_width/m_time_single_scroll; - for(unsigned int i=0; i<num_karts; i++) - { - if(m_start_at[i]>m_timer) continue; - m_x_pos[i] -= dt*v; - if(m_x_pos[i]<m_leftmost_column) - m_x_pos[i] = (float)m_leftmost_column; - } - break; - } - case RR_INCREASE_POINTS: - { - // Animate the increase of points - // ------------------------------ - if(m_timer > 5) - { - m_animation_state = RR_RESORT_TABLE; - m_timer = 0; - } - for(unsigned int i=0; i<num_karts; i++) - { - m_current_displayed_points[i] += dt*m_time_for_points; - if(m_current_displayed_points[i]>m_new_overall_points[i]) - m_current_displayed_points[i] = (float)m_new_overall_points[i]; - } - break; - } - case RR_RESORT_TABLE: - break; - case RR_WAIT_TILL_END: - break; + case RR_BEGIN_FIRST_TABLE: if(m_timer > m_time_overall_scroll) + { + m_animation_state = RR_INCREASE_POINTS; + m_timer = 0; + } + break; + case RR_INCREASE_POINTS: if(m_timer > 5) + { + m_animation_state = RR_RESORT_TABLE; + m_timer = 0; + } + break; + case RR_RESORT_TABLE: if(m_timer > m_time_rotation) + { + m_animation_state = RR_WAIT_TILL_END; + // Make the new row permanent. + for(unsigned int i=0; i<num_karts; i++) + m_y_pos[i] = m_centre_point[i] + + m_radius[i]; + } + break; + case RR_WAIT_TILL_END: break; } // switch + float v = 0.9f*UserConfigParams::m_width/m_time_single_scroll; for(unsigned int i=0; i<m_kart_names.size(); i++) { - displayOneEntry((unsigned int)(m_x_pos[i]), m_y_pos[i], - i, true); + float x = m_x_pos[i]; + float y = (float)m_y_pos[i]; + switch(m_animation_state) + { + case RR_BEGIN_FIRST_TABLE: + if(m_timer > m_start_at[i]) + { // if active + m_x_pos[i] -= dt*v; + if(m_x_pos[i]<m_leftmost_column) + m_x_pos[i] = (float)m_leftmost_column; + x = m_x_pos[i]; + } + break; + case RR_INCREASE_POINTS: + m_current_displayed_points[i] += dt*m_time_for_points; + if(m_current_displayed_points[i]>m_new_overall_points[i]) + m_current_displayed_points[i] = (float)m_new_overall_points[i]; + break; + case RR_RESORT_TABLE: + x = m_x_pos[i] +m_radius[i]*sin(m_timer/m_time_rotation*M_PI); + y = m_centre_point[i]+m_radius[i]*cos(m_timer/m_time_rotation*M_PI); + break; + case RR_WAIT_TILL_END: + x = m_x_pos[i]; + y = (float)m_y_pos[i]; + break; + } // switch + displayOneEntry((unsigned int)x, (unsigned int)y, i, true); } } // renderGlobal Modified: main/trunk/src/states_screens/race_result_gui.hpp =================================================================== --- main/trunk/src/states_screens/race_result_gui.hpp 2010-07-25 22:35:53 UTC (rev 5707) +++ main/trunk/src/states_screens/race_result_gui.hpp 2010-07-25 22:37:11 UTC (rev 5708) @@ -65,9 +65,13 @@ /** Currenct Y position. */ std::vector<int> m_y_pos; - /** The order in which to display the karts. */ - std::vector<int> m_order; + /** The center point when sorting the entries. */ + std::vector<float> m_centre_point; + /** The radius to use when sorting the entries. Positive values + will rotate downwards, negatives are upwards. */ + std::vector<float> m_radius; + /** The names of all karts in the right order. */ std::vector<core::stringw> m_kart_names; @@ -79,8 +83,8 @@ /** When updating the number of points in the display, this is the currently displayed number of points, so - m_old_overall_points <= m_current_displayed_points<= - m_old_overall_points+m_new_points. + m_new_overall_points-m_new_points <= m_current_displayed_points <= + m_new_overall_points. This is a floating point number since it stores the increments during increasing the points. */ std::vector<float> m_current_displayed_points; @@ -97,6 +101,9 @@ /** The time a single line scrolls into place. */ float m_time_single_scroll; + /** Time to rotate the GP entries. */ + float m_time_rotation; + /** The time for inreasing the points by one during the point update phase. */ float m_time_for_points; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |