Started implementing challenges menu (for some reason, many challenge files are not found/loaded, didn't figure why yet)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4141 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
22
data/gui/challenges.stkgui
Normal file
22
data/gui/challenges.stkgui
Normal file
@@ -0,0 +1,22 @@
|
||||
<stkgui>
|
||||
|
||||
<div x="5%" y="2%" width="90%" height="96%" layout="vertical-row" >
|
||||
|
||||
<label I18N="Title for challenges screen" text="Challenges : Trophy Room" text_align="center" width="100%" />
|
||||
|
||||
<box id="animated_area" width="100%" proportion="1" layout="vertical-row">
|
||||
|
||||
<ribbon_grid id="challenges" proportion="3" width="100%" square_items="true"
|
||||
I18N="Ignore" text="bottom" align="center" child_width="128" child_height="128" />
|
||||
|
||||
<spacer proportion="1" width="100%"/>
|
||||
|
||||
</box>
|
||||
|
||||
<spacer width="100%" height="45"/>
|
||||
|
||||
</div>
|
||||
|
||||
<button id="back" x="20" y="-40" width="250" height="35" align="left" text="Back to main menu"/>
|
||||
|
||||
</stkgui>
|
||||
@@ -49,19 +49,17 @@ private:
|
||||
CH_ACTIVE, // challenge possible, but not yet solved
|
||||
CH_SOLVED} m_state; // challenge was solved
|
||||
std::string m_Id; // short, internal name for this challenge
|
||||
std::string m_Name; // name used in menu for this challenge
|
||||
std::string m_challenge_description; // Message the user gets when the feature is not yet unlocked
|
||||
irr::core::stringw m_Name; // name used in menu for this challenge
|
||||
irr::core::stringw m_challenge_description; // Message the user gets when the feature is not yet unlocked
|
||||
std::vector<UnlockableFeature> m_feature; // Features to unlock
|
||||
std::vector<std::string> m_prerequisites; // what needs to be done before accessing this challenge
|
||||
public:
|
||||
Challenge(const std::string &id, const std::string &name);
|
||||
Challenge() {m_Id=""; m_Name="";m_state=CH_INACTIVE;}
|
||||
virtual ~Challenge() {};
|
||||
const std::string
|
||||
&getId() const { return m_Id; }
|
||||
const std::string
|
||||
&getName() const { return m_Name; }
|
||||
void setName(const std::string& s) { m_Name = s; }
|
||||
const std::string &getId() const { return m_Id; }
|
||||
const irr::core::stringw &getName() const { return m_Name; }
|
||||
void setName(const irr::core::stringw & s) { m_Name = s; }
|
||||
void setId(const std::string& s) { m_Id = s; }
|
||||
void addUnlockTrackReward(const std::string &track_name);
|
||||
void addUnlockModeReward(const std::string &internal_mode_name,
|
||||
@@ -75,9 +73,9 @@ public:
|
||||
const irr::core::stringw getUnlockedMessage() const;
|
||||
const std::vector<UnlockableFeature>&
|
||||
getFeatures() const { return m_feature; }
|
||||
void setChallengeDescription(const std::string& d)
|
||||
void setChallengeDescription(const irr::core::stringw& d)
|
||||
{m_challenge_description=d; }
|
||||
const std::string&
|
||||
const irr::core::stringw&
|
||||
getChallengeDescription() const {return m_challenge_description; }
|
||||
void addDependency(const std::string id) {m_prerequisites.push_back(id); }
|
||||
bool isSolved() const {return m_state==CH_SOLVED; }
|
||||
|
||||
@@ -77,13 +77,13 @@ ChallengeData::ChallengeData(const std::string& filename)
|
||||
|
||||
std::string s;
|
||||
if(!root->get("name", &s) ) error("name");
|
||||
setName(s);
|
||||
setName( _(s.c_str()) );
|
||||
|
||||
if(!root->get("id", &s) ) error("id");
|
||||
setId(s);
|
||||
|
||||
if(!root->get("description", &s) ) error("description");
|
||||
setChallengeDescription(s);
|
||||
setChallengeDescription( _(s.c_str()) );
|
||||
|
||||
if(!root->get("karts", &m_num_karts) ) error("karts");
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
9507E9D10FC1CDCE00BD2B92 /* Ogg.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7F90FC1B63C00DB481B /* Ogg.framework */; };
|
||||
9507E9D20FC1CDCE00BD2B92 /* OpenAL.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7FA0FC1B63C00DB481B /* OpenAL.framework */; };
|
||||
9507E9DB0FC1CDD500BD2B92 /* Vorbis.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7FB0FC1B63C00DB481B /* Vorbis.framework */; };
|
||||
951B7D19108E52C900BC03AE /* challenges.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 951B7D18108E52C900BC03AE /* challenges.cpp */; };
|
||||
951BC65E0FFAF290006B5FF1 /* ipo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 951BC65C0FFAF290006B5FF1 /* ipo.cpp */; };
|
||||
9522F125107948AD0067ECF5 /* main_menu_screen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9522F124107948AD0067ECF5 /* main_menu_screen.cpp */; };
|
||||
9522F15B107949780067ECF5 /* race_setup_screen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9522F15A107949780067ECF5 /* race_setup_screen.cpp */; };
|
||||
@@ -327,6 +328,8 @@
|
||||
9507E9500FC1C8C200BD2B92 /* RenderTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderTexture.cpp; path = ../../bullet/Demos/OpenGL/RenderTexture.cpp; sourceTree = SOURCE_ROOT; };
|
||||
9507E9510FC1C8C200BD2B92 /* RenderTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RenderTexture.h; path = games/supertuxkart/src/bullet/Demos/OpenGL/RenderTexture.h; sourceTree = SYSTEM_DEVELOPER_DIR; };
|
||||
9507E9B60FC1CCE900BD2B92 /* stk.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = stk.icns; sourceTree = SOURCE_ROOT; };
|
||||
951B7D17108E52C900BC03AE /* challenges.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = challenges.hpp; path = ../../states_screens/challenges.hpp; sourceTree = SOURCE_ROOT; };
|
||||
951B7D18108E52C900BC03AE /* challenges.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = challenges.cpp; path = games/supertuxkart/src/states_screens/challenges.cpp; sourceTree = SYSTEM_DEVELOPER_DIR; };
|
||||
951BC65C0FFAF290006B5FF1 /* ipo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ipo.cpp; path = ../../animations/ipo.cpp; sourceTree = SOURCE_ROOT; };
|
||||
951BC65D0FFAF290006B5FF1 /* ipo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ipo.hpp; path = ../../animations/ipo.hpp; sourceTree = SOURCE_ROOT; };
|
||||
951C357D0FC05BF400A48379 /* quad_set.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = quad_set.hpp; path = ../../tracks/quad_set.hpp; sourceTree = SOURCE_ROOT; };
|
||||
@@ -1250,6 +1253,8 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
95833236101243ED00C5137E /* dialogs */,
|
||||
951B7D18108E52C900BC03AE /* challenges.cpp */,
|
||||
951B7D17108E52C900BC03AE /* challenges.hpp */,
|
||||
958330C210122B4A00C5137E /* credits.cpp */,
|
||||
958330C310122B4A00C5137E /* credits.hpp */,
|
||||
95D2343E1078227A00625256 /* feature_unlocked.cpp */,
|
||||
@@ -2546,6 +2551,7 @@
|
||||
9522F1EF107961560067ECF5 /* options_screen_av.cpp in Sources */,
|
||||
9522F1F0107961560067ECF5 /* options_screen_input.cpp in Sources */,
|
||||
9522F1F1107961560067ECF5 /* options_screen_players.cpp in Sources */,
|
||||
951B7D19108E52C900BC03AE /* challenges.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
91
src/states_screens/challenges.cpp
Normal file
91
src/states_screens/challenges.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2009 Marianne Gagnon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// 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/challenges.hpp"
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "irrString.h"
|
||||
using irr::core::stringw;
|
||||
using irr::core::stringc;
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
|
||||
ChallengesScreen::ChallengesScreen() : Screen("challenges.stkgui")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ChallengesScreen::onUpdate(float elapsed_time, irr::video::IVideoDriver*)
|
||||
{
|
||||
}
|
||||
|
||||
void ChallengesScreen::init()
|
||||
{
|
||||
DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("challenges");
|
||||
assert( w != NULL );
|
||||
|
||||
// Re-build track list everytime (accounts for locking changes, etc.)
|
||||
w->clearItems();
|
||||
|
||||
const std::vector<const Challenge*>& challenges = unlock_manager->getActiveChallenges();
|
||||
const std::vector<const Challenge*>& solvedChallenges = unlock_manager->getUnlockedFeatures();
|
||||
|
||||
const int challengeAmount = challenges.size();
|
||||
const int solvedChallengeAmount = solvedChallenges.size();
|
||||
char buffer[64];
|
||||
for (int n=0; n<challengeAmount; n++)
|
||||
{
|
||||
// TODO : temporary icon until we have a 'unsolved challenge' icon
|
||||
sprintf(buffer, "challenge%i", n);
|
||||
w->addItem(challenges[n]->getName() + L"\n" + challenges[n]->getChallengeDescription(),
|
||||
buffer, file_manager->getTextureFile("speedback.png"));
|
||||
}
|
||||
for (int n=0; n<solvedChallengeAmount; n++)
|
||||
{
|
||||
// TODO : add bronze/silver/gold difficulties to challenges
|
||||
sprintf(buffer, "solved%i", n);
|
||||
w->addItem(solvedChallenges[n]->getName(), buffer, file_manager->getTextureFile("cup_gold.png"));
|
||||
}
|
||||
|
||||
w->updateItemDisplay();
|
||||
}
|
||||
|
||||
void ChallengesScreen::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void ChallengesScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name)
|
||||
{
|
||||
if(name == "back")
|
||||
{
|
||||
StateManager::get()->escapePressed();
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
43
src/states_screens/challenges.hpp
Normal file
43
src/states_screens/challenges.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2009 Marianne Gagnon
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
#ifndef HEADER_CHALLENGES_HPP
|
||||
#define HEADER_CHALLENGES_HPP
|
||||
|
||||
#include "irrlicht.h"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
|
||||
class ChallengesScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<ChallengesScreen>
|
||||
{
|
||||
friend class GUIEngine::ScreenSingleton<ChallengesScreen>;
|
||||
ChallengesScreen();
|
||||
|
||||
public:
|
||||
|
||||
void onUpdate(float dt, irr::video::IVideoDriver*);
|
||||
|
||||
void init();
|
||||
void tearDown();
|
||||
void eventCallback(GUIEngine::Widget* widget, const std::string& name);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "main_loop.hpp"
|
||||
#include "states_screens/challenges.hpp"
|
||||
#include "states_screens/credits.hpp"
|
||||
#include "states_screens/kart_selection.hpp"
|
||||
#include "states_screens/help_screen_1.hpp"
|
||||
@@ -78,6 +79,10 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name)
|
||||
{
|
||||
StateManager::get()->pushScreen(HelpScreen1::getInstance());
|
||||
}
|
||||
else if (selection == "challenges")
|
||||
{
|
||||
StateManager::get()->pushScreen(ChallengesScreen::getInstance());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user