From 7b768043548d8086b52edbd334999ee2b3dd3277 Mon Sep 17 00:00:00 2001 From: Deve Date: Fri, 23 Dec 2016 23:36:39 +0100 Subject: [PATCH] Allow to unlock all tracks in config.xml. Can be used on android when only some tracks are included in the apk. --- src/challenges/story_mode_status.cpp | 4 ++++ src/config/user_config.hpp | 4 ++++ src/modes/overworld.cpp | 4 ++++ src/scriptengine/script_challenges.cpp | 21 ++++++++++++++------- src/states_screens/race_gui_overworld.cpp | 7 +++++++ 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/challenges/story_mode_status.cpp b/src/challenges/story_mode_status.cpp index fcefad1dd..bd1b83b4a 100644 --- a/src/challenges/story_mode_status.cpp +++ b/src/challenges/story_mode_status.cpp @@ -23,6 +23,7 @@ #include "challenges/challenge_data.hpp" #include "challenges/unlock_manager.hpp" #include "config/player_manager.hpp" +#include "config/user_config.hpp" #include "io/utf_writer.hpp" #include "io/xml_node.hpp" @@ -67,6 +68,9 @@ void StoryModeStatus::addStatus(ChallengeStatus *cs) //----------------------------------------------------------------------------- bool StoryModeStatus::isLocked(const std::string& feature) { + if (UserConfigParams::m_everything_unlocked) + return false; + return m_locked_features.find(feature)!=m_locked_features.end(); } // featureIsLocked diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index d71292b4b..a8621c700 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -891,6 +891,10 @@ namespace UserConfigParams PARAM_PREFIX BoolUserConfigParam m_artist_debug_mode PARAM_DEFAULT( BoolUserConfigParam(false, "artist_debug_mode", "Whether to enable track debugging features") ); + + PARAM_PREFIX BoolUserConfigParam m_everything_unlocked + PARAM_DEFAULT( BoolUserConfigParam(false, "everything_unlocked", + "Enable all karts and tracks") ); // TODO? implement blacklist for new irrlicht device and GUI PARAM_PREFIX std::vector m_blacklist_res; diff --git a/src/modes/overworld.cpp b/src/modes/overworld.cpp index 47a8c5046..674c5049d 100644 --- a/src/modes/overworld.cpp +++ b/src/modes/overworld.cpp @@ -244,6 +244,10 @@ void OverWorld::onFirePressed(Controller* who) const unsigned int val = challenge->getNumTrophies(); bool unlocked = (PlayerManager::getCurrentPlayer()->getPoints() >= val); + + if (UserConfigParams::m_everything_unlocked) + unlocked = true; + if (unlocked) { race_manager->setKartLastPositionOnOverworld(kart_xyz); diff --git a/src/scriptengine/script_challenges.cpp b/src/scriptengine/script_challenges.cpp index 5c391cd15..792b21697 100644 --- a/src/scriptengine/script_challenges.cpp +++ b/src/scriptengine/script_challenges.cpp @@ -20,6 +20,7 @@ #include "animations/three_d_animation.hpp" #include "challenges/unlock_manager.hpp" +#include "config/user_config.hpp" #include "graphics/central_settings.hpp" #include "graphics/irr_driver.hpp" #include "guiengine/engine.hpp" @@ -48,13 +49,6 @@ namespace Scripting * @{ */ - // -------------------------------------------------------------------- - /** Get number of challenges that were completed at any difficulty */ - int getCompletedChallengesCount() - { - return ::Track::getCurrentTrack()->getNumOfCompletedChallenges(); - } // getCompletedChallengesCount - // -------------------------------------------------------------------- /** Get total number of challenges */ int getChallengeCount() @@ -62,6 +56,16 @@ namespace Scripting return ::Track::getCurrentTrack()->getChallengeList().size(); } // getChallengeCount + // -------------------------------------------------------------------- + /** Get number of challenges that were completed at any difficulty */ + int getCompletedChallengesCount() + { + if (UserConfigParams::m_everything_unlocked) + return getChallengeCount(); + + return ::Track::getCurrentTrack()->getNumOfCompletedChallenges(); + } // getCompletedChallengesCount + // -------------------------------------------------------------------- int getChallengeRequiredPoints(std::string* challenge_name) { @@ -81,6 +85,9 @@ namespace Scripting // -------------------------------------------------------------------- bool isChallengeUnlocked(std::string* challenge_name) { + if (UserConfigParams::m_everything_unlocked) + return true; + const ChallengeData* challenge = unlock_manager->getChallengeData(*challenge_name); if (challenge == NULL) diff --git a/src/states_screens/race_gui_overworld.cpp b/src/states_screens/race_gui_overworld.cpp index 1c6106dba..e20452024 100644 --- a/src/states_screens/race_gui_overworld.cpp +++ b/src/states_screens/race_gui_overworld.cpp @@ -431,6 +431,9 @@ void RaceGUIOverworld::drawGlobalMiniMap() const unsigned int val = challenge->getNumTrophies(); bool unlocked = (PlayerManager::getCurrentPlayer()->getPoints() >= val); int state = (unlocked ? OPEN : LOCKED); + + if (UserConfigParams::m_everything_unlocked) + state = OPEN; const ChallengeStatus* c = PlayerManager::getCurrentPlayer() ->getChallengeStatus(challenges[n].m_challenge_id); @@ -475,6 +478,10 @@ void RaceGUIOverworld::drawGlobalMiniMap() const ChallengeData* challenge = unlock_manager->getChallengeData(challenges[n].m_challenge_id); const unsigned int val = challenge->getNumTrophies(); bool unlocked = (PlayerManager::getCurrentPlayer()->getPoints() >= val); + + if (UserConfigParams::m_everything_unlocked) + unlocked = true; + if (!unlocked) continue; }