Start work on starting challenges from overworld. Note that it does NOT yet fully work.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10668 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
d7eff73234
commit
cd6185c2ee
@ -140,6 +140,7 @@ void LODNode::OnRegisterSceneNode()
|
||||
{
|
||||
scene::IMeshBuffer* mb = mesh->getMeshBuffer(n);
|
||||
video::ITexture* t = mb->getMaterial().getTexture(0);
|
||||
if (t == NULL) continue;
|
||||
Material* m = material_manager->getMaterialFor(t, mb);
|
||||
if (m != NULL)
|
||||
{
|
||||
|
@ -68,6 +68,7 @@ std::set<scene::IMeshBuffer*> g_processed;
|
||||
Material* MaterialManager::getMaterialFor(video::ITexture* t,
|
||||
scene::IMeshBuffer *mb)
|
||||
{
|
||||
assert(t != NULL);
|
||||
const std::string image = StringUtils::getBasename(core::stringc(t->getName()).c_str());
|
||||
// Search backward so that temporary (track) textures are found first
|
||||
for(int i = (int)m_materials.size()-1; i>=0; i-- )
|
||||
|
@ -176,6 +176,10 @@ void PlayerController::action(PlayerAction action, int value)
|
||||
break;
|
||||
case PA_FIRE:
|
||||
m_controls->m_fire = (value!=0);
|
||||
if (value > 0)
|
||||
{
|
||||
World::getWorld()->onFirePressed(this);
|
||||
}
|
||||
break;
|
||||
case PA_LOOK_BACK:
|
||||
m_controls->m_look_back = (value!=0);
|
||||
|
@ -15,9 +15,15 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "karts/kart.hpp"
|
||||
#include "modes/overworld.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "states_screens/race_gui_overworld.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
OverWorld::OverWorld() : LinearWorld()
|
||||
@ -71,3 +77,63 @@ void OverWorld::createRaceGUI()
|
||||
{
|
||||
m_race_gui = new RaceGUIOverworld();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void OverWorld::onFirePressed(Controller* who)
|
||||
{
|
||||
const std::vector<OverworldChallenge>& challenges = m_track->getChallengeList();
|
||||
|
||||
Vec3 kart_xyz = getKart(0)->getXYZ();
|
||||
for (unsigned int n=0; n<challenges.size(); n++)
|
||||
{
|
||||
if ((kart_xyz - Vec3(challenges[n].m_position)).length2_2d() < 20)
|
||||
{
|
||||
core::rect<s32> pos(15,
|
||||
10,
|
||||
15 + UserConfigParams::m_width/2,
|
||||
10 + GUIEngine::getTitleFontHeight());
|
||||
|
||||
const ChallengeData* challenge = unlock_manager->getChallenge(challenges[n].m_challenge_id);
|
||||
|
||||
if (challenge == NULL)
|
||||
{
|
||||
fprintf(stderr, "[RaceGUIOverworld] ERROR: Cannot find challenge <%s>\n",
|
||||
challenges[n].m_challenge_id.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
race_manager->exitRace();
|
||||
|
||||
// Use latest used device
|
||||
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
|
||||
|
||||
int id = StateManager::get()->createActivePlayer( unlock_manager->getCurrentPlayer(), device );
|
||||
input_manager->getDeviceList()->setSinglePlayer( StateManager::get()->getActivePlayer(id) );
|
||||
|
||||
// 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();
|
||||
|
||||
// Initialise global data - necessary even in local games to avoid
|
||||
// many if tests in other places (e.g. if network_game call
|
||||
// network_manager else call race_manager).
|
||||
network_manager->initCharacterDataStructures();
|
||||
|
||||
// Launch challenge
|
||||
challenge->setRace();
|
||||
|
||||
// Sets up kart info, including random list of kart for AI
|
||||
network_manager->setupPlayerKartInfo();
|
||||
race_manager->startNew();
|
||||
return;
|
||||
} // end if
|
||||
} // end for
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,10 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Override base class method */
|
||||
virtual bool shouldDrawTimer() const { return false; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Override base class method */
|
||||
virtual void onFirePressed(Controller* who);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -274,6 +274,8 @@ public:
|
||||
void setClearbackBufferColor(irr::video::SColor color)
|
||||
{ m_clear_color = color; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Override if you want to know when a kart presses fire */
|
||||
virtual void onFirePressed(Controller* who) {}
|
||||
|
||||
}; // World
|
||||
|
||||
|
@ -371,6 +371,14 @@ void RaceGUIOverworld::drawGlobalMiniMap()
|
||||
GUIEngine::getFont()->draw(challenge->getChallengeDescription().c_str(),
|
||||
pos, video::SColor(255,255,255,255),
|
||||
false, false /* vcenter */, NULL);
|
||||
|
||||
core::rect<s32> pos2(0,
|
||||
UserConfigParams::m_height - GUIEngine::getFontHeight()*2,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height);
|
||||
GUIEngine::getFont()->draw(_("Press fire to start the challenge"), pos2,
|
||||
video::SColor(255,255,150,60),
|
||||
true, true /* vcenter */, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user