Unlock cutscene improvements (#3298)

* Don't display unlocked features out of screen when there are 4 to 6-7

And more regular spacing between them

* Remove outdated workaround

* Store the previous number of story mode point

* Allow to get the previous points from player profile

* Fix points estimation for finding unlocked tracks

- Updated to reflect that the player's points are now updated before this function
- Use the real previous number of points rather than trying to estimate the point change (otherwise, the points computation method would have to be duplicated here to not have a bug with GPs who give more points than single race challenges).
This commit is contained in:
Alayan-stk-2 2018-06-13 02:36:33 +02:00 committed by auriamg
parent 7d9adf5b93
commit aee9e7ffa1
5 changed files with 24 additions and 45 deletions

View File

@ -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

View File

@ -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; }
// ------------------------------------------------------------------------

View File

@ -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); }

View File

@ -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<const ChallengeData*>& 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<std::string> tracks;
std::vector<std::string> 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<unlockedStuffCount; n++)
{

View File

@ -116,10 +116,6 @@ class FeatureUnlockedCutScene : public GUIEngine::CutsceneScreen, public GUIEngi
/** Angle of the key (from 0 to 1, simply traces progression) */
float m_key_angle;
#ifdef USE_IRRLICHT_BUG_WORKAROUND
scene::IMeshSceneNode *m_avoid_irrlicht_bug;
#endif
void continueButtonPressed();
public: