1 // 2 // SuperTuxKart - a fun racing game with go-kart 3 // Copyright (C) 2010-2015 SuperTuxKart-Team 4 // 5 // This program is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU General Public License 7 // as published by the Free Software Foundation; either version 3 8 // of the License, or (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 #ifndef HEADER_FEATURE_UNLOCKED_HPP 20 #define HEADER_FEATURE_UNLOCKED_HPP 21 22 #include "graphics/irr_driver.hpp" 23 #include "guiengine/screen.hpp" 24 #include "race/race_manager.hpp" 25 #include "utils/ptr_vector.hpp" 26 27 #include <memory> 28 29 namespace irr { 30 namespace scene { class ISceneNode; class ICameraSceneNode; 31 class ILightSceneNode; } 32 } 33 34 namespace SP 35 { 36 class SPTexture; 37 } 38 39 class KartModel; 40 class KartProperties; 41 class ChallengeData; 42 43 /** 44 * \brief Screen shown when a feature has been unlocked 45 * \ingroup states_screens 46 */ 47 class FeatureUnlockedCutScene : public GUIEngine::CutsceneScreen, 48 public GUIEngine::ScreenSingleton<FeatureUnlockedCutScene> 49 { 50 friend class GUIEngine::ScreenSingleton<FeatureUnlockedCutScene>; 51 52 FeatureUnlockedCutScene(); 53 54 /** Whichever of these is non-null decides what comes out of the chest */ 55 struct UnlockedThing 56 { 57 /** Will be non-null if this unlocked thing is a kart */ 58 const KartProperties* m_unlocked_kart; 59 60 std::string m_unlock_model; 61 62 /** Will be non-empty if this unlocked thing is one or many pictures */ 63 std::vector<irr::video::ITexture*> m_pictures; 64 65 std::vector<std::shared_ptr<SP::SPTexture> > m_sp_pictures; 66 67 /** Will be set if this unlocked thing is a picture */ 68 float m_w, m_h; 69 /** used for slideshows */ 70 int m_curr_image; 71 72 /** Contains whatever is in the chest */ 73 scene::ISceneNode* m_root_gift_node; 74 75 scene::ISceneNode* m_side_1; 76 scene::ISceneNode* m_side_2; 77 78 float m_scale; 79 80 irr::core::stringw m_unlock_message; 81 82 UnlockedThing(const std::string &model, const irr::core::stringw &msg); 83 84 UnlockedThing(const KartProperties* kart, const irr::core::stringw &msg); 85 86 /** 87 * Creates a 'picture' reward. 88 * \param pict the picture to display as reward. 89 * \param w width of the picture to display 90 * \param y height of the picture to display 91 */ 92 UnlockedThing(irr::video::ITexture* pict, float w, float h, 93 const irr::core::stringw &msg); 94 95 /** 96 * Creates a 'picture slideshow' reward. 97 * \param picts the pictures to display as reward. 98 * \param w width of the pictures to display 99 * \param y height of the pictures to display 100 */ 101 UnlockedThing(std::vector<irr::video::ITexture*> picts, float w, float h, 102 const irr::core::stringw &msg); 103 104 ~UnlockedThing(); 105 }; 106 107 /** The list of all unlocked things. */ 108 PtrVector<UnlockedThing, HOLD> m_unlocked_stuff; 109 110 /** To store the copy of the KartModel for each unlocked kart. */ 111 PtrVector<KartModel> m_all_kart_models; 112 113 /** Global evolution of time */ 114 float m_global_time; 115 116 /** Key position from origin (where the chest is) */ 117 float m_key_pos; 118 119 /** Angle of the key (from 0 to 1, simply traces progression) */ 120 float m_key_angle; 121 122 void continueButtonPressed(); 123 124 public: 125 126 virtual void onCutsceneEnd() OVERRIDE; 127 128 /** \brief implement optional callback from parent class GUIEngine::Screen */ 129 void onUpdate(float dt) OVERRIDE; 130 131 /** \brief implement callback from parent class GUIEngine::Screen */ 132 virtual void loadedFromFile() OVERRIDE; 133 134 /** \brief implement callback from parent class GUIEngine::Screen */ 135 void init() OVERRIDE; 136 137 /** \brief implement callback from parent class GUIEngine::Screen */ 138 void tearDown() OVERRIDE; 139 140 void eventCallback(GUIEngine::Widget* widget, const std::string& name, 141 const int playerID) OVERRIDE; 142 143 void findWhatWasUnlocked(RaceManager::Difficulty difficulty, 144 std::vector<const ChallengeData*>& unlocked); 145 146 /** Call before showing up the screen to make a kart come out of the chest. 147 * 'addUnlockedThings' will invoke this, so you generally don't need to 148 * call this directly. */ 149 void addUnlockedKart(const KartProperties* unlocked_kart); 150 151 /** Call before showing up the screen to make a picture come out of the 152 * chest 'addUnlockedThings' will invoke this, so you generally don't 153 * need to call this directly. */ 154 void addUnlockedPicture(irr::video::ITexture* picture, float w, float h, 155 const irr::core::stringw &msg); 156 157 /** Call before showing up the screen to make a picture slideshow come out 158 * of the chest 'addUnlockedThings' will invoke this, so you generally 159 * don't need to call this directly. */ 160 void addUnlockedPictures(std::vector<irr::video::ITexture*> pictures, 161 float w, float h, irr::core::stringw msg); 162 163 void addUnlockedTrack(const Track* track); 164 void addUnlockedGP(const GrandPrixData* gp); 165 166 /** Call before showing up the screen to make whatever the passed challenges unlocked 167 * come out of the chest */ 168 // unused for now... maybe this could could useful later? 169 /* 170 void addUnlockedThings(const std::vector<const ChallengeData*> unlocked); 171 */ 172 173 void addTrophy(RaceManager::Difficulty difficulty, bool is_grandprix); 174 175 /** override from base class to handle escape press */ 176 virtual bool onEscapePressed() OVERRIDE; 177 178 virtual MusicInformation* getInGameMenuMusic() const OVERRIDE; 179 }; 180 181 #endif 182