diff --git a/src/challenges/story_mode_status.cpp b/src/challenges/story_mode_status.cpp index 266f6548d..65ab04976 100644 --- a/src/challenges/story_mode_status.cpp +++ b/src/challenges/story_mode_status.cpp @@ -31,6 +31,7 @@ StoryModeStatus::StoryModeStatus(const XMLNode *node) { m_points = 0; + m_points_before = 0; m_next_unlock_points = 0; m_first_time = true; m_easy_challenges = 0; @@ -79,6 +80,7 @@ bool StoryModeStatus::isLocked(const std::string& feature) //----------------------------------------------------------------------------- void StoryModeStatus::computeActive() { + int old_points = m_points; m_points = 0; m_next_unlock_points = 0; m_easy_challenges = 0; @@ -182,6 +184,9 @@ void StoryModeStatus::computeActive() // now we have the number of points. + if (old_points != m_points) + m_points_before = old_points; + unlockFeatureByList(); //Actually lock the tracks diff --git a/src/challenges/story_mode_status.hpp b/src/challenges/story_mode_status.hpp index 94a7ee1c2..5f1da7423 100644 --- a/src/challenges/story_mode_status.hpp +++ b/src/challenges/story_mode_status.hpp @@ -62,6 +62,7 @@ private: const ChallengeStatus *m_current_challenge; int m_points; + int m_points_before; // used for unlocks int m_next_unlock_points; /** Set to false after the initial stuff (intro, select kart, etc.) */ @@ -101,6 +102,9 @@ public: /** Returns the number of points accumulated. */ int getPoints () const { return m_points; } // ------------------------------------------------------------------------ + /** Returns the number of points before the previous point increase */ + int getPointsBefore () const { return m_points_before; } + // ------------------------------------------------------------------------ /** Returns the number of points needed by the next unlockable. 0 if none. */ int getNextUnlockPoints () const { return m_next_unlock_points; } // ------------------------------------------------------------------------ diff --git a/src/config/player_profile.hpp b/src/config/player_profile.hpp index 519f5f5c3..5f20c9dda 100644 --- a/src/config/player_profile.hpp +++ b/src/config/player_profile.hpp @@ -230,6 +230,8 @@ public: // ------------------------------------------------------------------------ unsigned int getPoints() const { return m_story_mode_status->getPoints(); } // ------------------------------------------------------------------------ + unsigned int getPointsBefore() const { return m_story_mode_status->getPointsBefore(); } + // ------------------------------------------------------------------------ unsigned int getNextUnlockPoints() const { return m_story_mode_status->getNextUnlockPoints(); } // ------------------------------------------------------------------------ void setFirstTime(bool b) { m_story_mode_status->setFirstTime(b); } diff --git a/src/states_screens/feature_unlocked.cpp b/src/states_screens/feature_unlocked.cpp index 06664f7da..591a5f5f9 100644 --- a/src/states_screens/feature_unlocked.cpp +++ b/src/states_screens/feature_unlocked.cpp @@ -165,10 +165,6 @@ FeatureUnlockedCutScene::FeatureUnlockedCutScene() : CutsceneScreen("feature_unlocked.stkgui") { m_key_angle = 0; - -#ifdef USE_IRRLICHT_BUG_WORKAROUND - m_avoid_irrlicht_bug = NULL; -#endif } // FeatureUnlockedCutScene // ---------------------------------------------------------------------------- @@ -181,12 +177,6 @@ void FeatureUnlockedCutScene::loadedFromFile() void FeatureUnlockedCutScene::onCutsceneEnd() { -#ifdef USE_IRRLICHT_BUG_WORKAROUND - if (m_avoid_irrlicht_bug) - irr_driver->removeNode(m_avoid_irrlicht_bug); - m_avoid_irrlicht_bug = NULL; -#endif - m_unlocked_stuff.clearAndDeleteAll(); #ifndef SERVER_ONLY if (CVS->isGLSL()) @@ -205,8 +195,10 @@ void FeatureUnlockedCutScene::onCutsceneEnd() void FeatureUnlockedCutScene::findWhatWasUnlocked(RaceManager::Difficulty difficulty,std::vector& unlocked) { PlayerProfile *player = PlayerManager::getCurrentPlayer(); - int points_before = player->getPoints(); - int points_now = points_before + CHALLENGE_POINTS[difficulty]; + + // The number of points is updated before this function is called + int points_before = player->getPointsBefore(); + int points_now = player->getPoints(); std::vector tracks; std::vector gps; @@ -362,18 +354,6 @@ void FeatureUnlockedCutScene::init() #ifdef DEBUG m_unlocked_stuff[n].m_root_gift_node->setName("unlocked kart"); -#endif -#ifdef USE_IRRLICHT_BUG_WORKAROUND - // If a mesh with this material is added, irrlicht will - // display the 'continue' text (otherwise the text is - // not visible). This is a terrible work around, but allows - // stk to be released without waiting for the next - // irrlicht version. - video::SMaterial m; - m.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - scene::IMesh* mesh = - irr_driver->createTexturedQuadMesh(&m, 0, 0); - m_avoid_irrlicht_bug = irr_driver->addMesh(mesh); #endif } #ifndef SERVER_ONLY @@ -475,6 +455,7 @@ void FeatureUnlockedCutScene::onUpdate(float dt) m_global_time += dt; const int unlockedStuffCount = m_unlocked_stuff.size(); + // When the chest has opened but the items are not yet at their final position if (m_global_time > GIFT_EXIT_FROM && m_global_time < GIFT_EXIT_TO) { float progress_factor = (m_global_time - GIFT_EXIT_FROM) / (GIFT_EXIT_TO - GIFT_EXIT_FROM); @@ -489,30 +470,21 @@ void FeatureUnlockedCutScene::onUpdate(float dt) // when there are more than 1 unlocked items, make sure they each // have their own path when they move - if (unlockedStuffCount > 1) - { - if (n == 1) pos.X -= 1.0f*dt*float( int((n + 1)/2) ); - else if (n > 1) pos.X += 1.0f*dt*(n - 0.3f); + // and that they won't end offscreen in usual situations - //else pos.X += 6.2f*dt*float( int((n + 1)/2) ); - //Log::info("FeatureUnlockedCutScene", "Object %d moving by %f", n, - // (n % 2 == 0 ? -4.0f : 4.0f)*float( n/2 + 1 )); - } - else - { - //pos.X -= 2.0f*dt; - } - - //if (m_global_time > GIFT_EXIT_FROM + 2.0f) pos.Z -= 2.0f*dt; + // Put the trophy in center + float pos_value = (n == 0) ? unlockedStuffCount/2 : + (n == unlockedStuffCount/2) ? 0 : n; + float offset = (float) pos_value - ((float) unlockedStuffCount)/2.0f + 0.5f; + offset *= (unlockedStuffCount <= 3) ? 1.4f : + (unlockedStuffCount <= 5) ? 1.2f : 1.0f; + pos.X += offset*dt; pos.Z = smoothed_progress_factor * -4.0f; m_unlocked_stuff[n].m_root_gift_node->setPosition(pos); } } - else if (m_global_time < GIFT_EXIT_FROM) - { - } for (int n=0; n