Started implementing clicking on a challenge to start it
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4870 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
fb35d4a390
commit
6f278f6d1e
@ -97,7 +97,10 @@ public:
|
||||
// the feature remains locked.
|
||||
virtual bool raceFinished() {return false;} // end of a race
|
||||
virtual bool grandPrixFinished() {return false;} // end of a GP
|
||||
virtual void setRace() const = 0; // set race to use
|
||||
|
||||
/** sets the right parameters in RaceManager to try this challenge */
|
||||
virtual void setRace() const = 0;
|
||||
|
||||
/** Checks if a challenge is valid. */
|
||||
virtual void check() const = 0;
|
||||
};
|
||||
|
@ -54,7 +54,10 @@ public:
|
||||
#else
|
||||
ChallengeData(const std::string& filename) throw(std::runtime_error);
|
||||
#endif
|
||||
|
||||
/** sets the right parameters in RaceManager to try this challenge */
|
||||
void setRace() const;
|
||||
|
||||
virtual void check() const;
|
||||
virtual bool raceFinished();
|
||||
virtual bool grandPrixFinished();
|
||||
|
@ -210,7 +210,7 @@ std::vector<const Challenge*> UnlockManager::getActiveChallenges()
|
||||
} // getActiveChallenges
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Challenge* UnlockManager::getChallenge(const std::string& id)
|
||||
const Challenge* UnlockManager::getChallenge(const std::string& id)
|
||||
{
|
||||
if(m_all_challenges.find(id)==m_all_challenges.end()) return NULL;
|
||||
return m_all_challenges[id];
|
||||
|
@ -36,7 +36,6 @@ private:
|
||||
AllChallengesType m_all_challenges;
|
||||
std::map<std::string, bool> m_locked_features;
|
||||
std::vector<const Challenge*> m_unlocked_features;
|
||||
Challenge *getChallenge (const std::string& id);
|
||||
void computeActive ();
|
||||
void load ();
|
||||
|
||||
@ -65,6 +64,8 @@ public:
|
||||
/** Returns the list of currently inaccessible (locked) challenges */
|
||||
const std::vector<const Challenge*> getLockedChallenges();
|
||||
|
||||
const Challenge *getChallenge (const std::string& id);
|
||||
|
||||
void raceFinished ();
|
||||
void grandPrixFinished ();
|
||||
void lockFeature (Challenge* challenge);
|
||||
|
@ -18,7 +18,15 @@
|
||||
|
||||
#include "states_screens/challenges.hpp"
|
||||
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
@ -28,11 +36,6 @@
|
||||
using irr::core::stringw;
|
||||
using irr::core::stringc;
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
|
||||
@ -62,28 +65,20 @@ namespace GUIEngine
|
||||
const int solvedChallengeAmount = solvedChallenges.size();
|
||||
const int lockedChallengeAmount = lockedChallenges.size();
|
||||
|
||||
char buffer[64];
|
||||
for (int n=0; n<activeChallengeAmount; n++)
|
||||
{
|
||||
sprintf(buffer, "challenge%i", n);
|
||||
std::cout << "// Adding challenge " << buffer << " : <" << activeChallenges[n]->getId().c_str() << ">\n";
|
||||
w->addItem(activeChallenges[n]->getName() + L"\n" + activeChallenges[n]->getChallengeDescription(),
|
||||
buffer, "/gui/challenge.png");
|
||||
activeChallenges[n]->getId(), "/gui/challenge.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, "/textures/cup_gold.png");
|
||||
std::cout << "// Adding challenge " << buffer << " : <" << solvedChallenges[n]->getId().c_str() << ">\n";
|
||||
|
||||
w->addItem(solvedChallenges[n]->getName(), solvedChallenges[n]->getId(), "/textures/cup_gold.png");
|
||||
}
|
||||
for (int n=0; n<lockedChallengeAmount; n++)
|
||||
{
|
||||
w->addItem( _("Locked : solve active challenges to gain access to more!"), "locked",
|
||||
"/gui/challenge.png", true);
|
||||
std::cout << "// Adding locked challenge <" << lockedChallenges[n]->getId().c_str() << ">\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -114,6 +109,33 @@ namespace GUIEngine
|
||||
{
|
||||
unlock_manager->playLockSound();
|
||||
}
|
||||
else
|
||||
{
|
||||
//FIXME: simplify and centralize race start sequence!!
|
||||
|
||||
// Use latest used device
|
||||
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
|
||||
|
||||
// Create player and associate player with device (FIXME: ask for player ident)
|
||||
StateManager::get()->createActivePlayer( UserConfigParams::m_all_players.get(0), device );
|
||||
|
||||
// Set up race manager appropriately
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
|
||||
|
||||
// ASSIGN should make sure that only input from assigned devices is read.
|
||||
input_manager->getDeviceList()->setAssignMode(ASSIGN);
|
||||
|
||||
// Go straight to the race
|
||||
StateManager::get()->enterGameState();
|
||||
|
||||
network_manager->initCharacterDataStructures();
|
||||
network_manager->setupPlayerKartInfo();
|
||||
|
||||
// Launch challenge
|
||||
unlock_manager->getChallenge(selection)->setRace();
|
||||
race_manager->startNew();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,13 +185,7 @@ void startGPGame(const GrandPrixData* gp)
|
||||
assert(gp != NULL);
|
||||
ModalDialog::dismiss();
|
||||
|
||||
IVideoDriver* driver = GUIEngine::getDriver();
|
||||
|
||||
//TODO?: draw a loading screen
|
||||
driver->endScene();
|
||||
driver->beginScene(true, false);
|
||||
driver->endScene();
|
||||
|
||||
//FIXME: simplify and centralize race start sequence!!
|
||||
|
||||
StateManager::get()->enterGameState();
|
||||
//race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
|
@ -407,7 +407,7 @@ void RaceOverDialog::renderThreeStrikesGraph(const int x, const int y, const int
|
||||
irr_driver->getVideoDriver()->draw2DLine( core::position2d<s32>(x + w, y + h),
|
||||
core::position2d<s32>(x + w - 13, y + h + 7), black);
|
||||
irr_driver->getVideoDriver()->draw2DLine( core::position2d<s32>(x + w, y + h),
|
||||
core::position2d<s32>(x + w - 13, y + h - 7), black);
|
||||
core::position2d<s32>(x + w - 13, y + h - 7), black);
|
||||
float lastEventTime = 0.0f;
|
||||
int max_life_count = 0;
|
||||
|
||||
|
@ -274,16 +274,10 @@ void TrackInfoDialog::updateHighScores()
|
||||
*/
|
||||
void startGame(const std::string trackIdent, const int num_laps)
|
||||
{
|
||||
//FIXME: simplify and centralize race start sequence!!
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
IVideoDriver* driver = GUIEngine::getDriver();
|
||||
|
||||
//TODO?: draw a loading screen
|
||||
driver->endScene();
|
||||
driver->beginScene(true, false);
|
||||
driver->endScene();
|
||||
|
||||
|
||||
StateManager::get()->enterGameState();
|
||||
//race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
race_manager->setTrack(trackIdent.c_str());
|
||||
|
@ -128,7 +128,11 @@ void RaceGUI::createMarkerTexture()
|
||||
for(unsigned int i=0; i<num_karts; i++)
|
||||
{
|
||||
const std::string& kart_ident = race_manager->getKartIdent(i);
|
||||
assert(kart_ident.size() > 0);
|
||||
|
||||
const KartProperties *kp = kart_properties_manager->getKart(kart_ident);
|
||||
assert(kp != NULL);
|
||||
|
||||
core::vector2df center((float)((m_marker_rendered_size>>1)+i*m_marker_rendered_size),
|
||||
(float)(m_marker_rendered_size>>1) );
|
||||
int count = kp->getShape();
|
||||
|
Loading…
Reference in New Issue
Block a user