Fix restarting tutorial

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@13086 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2013-07-05 00:02:50 +00:00
parent af09c253a7
commit 8e2ccb7762
2 changed files with 17 additions and 12 deletions

View File

@ -574,6 +574,8 @@ TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(const
xml_node.get("action", &m_action); xml_node.get("action", &m_action);
m_action_active = true;
if (m_action.size() == 0) if (m_action.size() == 0)
{ {
fprintf(stderr, "[TrackObject] WARNING: action-trigger has no action defined\n"); fprintf(stderr, "[TrackObject] WARNING: action-trigger has no action defined\n");
@ -584,6 +586,8 @@ TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(const
void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who) void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
{ {
if (!m_action_active) return;
if (m_action == "garage") if (m_action == "garage")
{ {
new RacePausedDialog(0.8f, 0.6f); new RacePausedDialog(0.8f, 0.6f);
@ -593,7 +597,7 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
{ {
//if (World::getWorld()->getPhase() == World::RACE_PHASE) //if (World::getWorld()->getPhase() == World::RACE_PHASE)
{ {
m_action = "__disabled__"; m_action_active = false;
//World::getWorld()->getRaceGUI()->clearAllMessages(); //World::getWorld()->getRaceGUI()->clearAllMessages();
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
@ -608,13 +612,13 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
} }
else if (m_action == "tutorial_bananas") else if (m_action == "tutorial_bananas")
{ {
m_action = "__disabled__"; m_action_active = false;
new TutorialMessageDialog(_("Avoid bananas!"), true); new TutorialMessageDialog(_("Avoid bananas!"), true);
} }
else if (m_action == "tutorial_giftboxes") else if (m_action == "tutorial_giftboxes")
{ {
m_action = "__disabled__"; m_action_active = false;
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration(); DeviceConfig* config = device->getConfiguration();
irr::core::stringw fire = config->getBindingAsString(PA_FIRE); irr::core::stringw fire = config->getBindingAsString(PA_FIRE);
@ -624,14 +628,14 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
} }
else if (m_action == "tutorial_nitro_collect") else if (m_action == "tutorial_nitro_collect")
{ {
m_action = "__disabled__"; m_action_active = false;
new TutorialMessageDialog(_("Collect nitro bottles (we will use them after the curve)"), new TutorialMessageDialog(_("Collect nitro bottles (we will use them after the curve)"),
true); true);
} }
else if (m_action == "tutorial_nitro_use") else if (m_action == "tutorial_nitro_use")
{ {
m_action = "__disabled__"; m_action_active = false;
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration(); DeviceConfig* config = device->getConfiguration();
irr::core::stringw nitro = config->getBindingAsString(PA_NITRO); irr::core::stringw nitro = config->getBindingAsString(PA_NITRO);
@ -641,7 +645,7 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
} }
else if (m_action == "tutorial_rescue") else if (m_action == "tutorial_rescue")
{ {
m_action = "__disabled__"; m_action_active = false;
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration(); DeviceConfig* config = device->getConfiguration();
irr::core::stringw rescue = config->getBindingAsString(PA_RESCUE); irr::core::stringw rescue = config->getBindingAsString(PA_RESCUE);
@ -651,7 +655,7 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
} }
else if (m_action == "tutorial_skidding") else if (m_action == "tutorial_skidding")
{ {
m_action = "__disabled__"; m_action_active = false;
//World::getWorld()->getRaceGUI()->clearAllMessages(); //World::getWorld()->getRaceGUI()->clearAllMessages();
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
@ -664,7 +668,7 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
} }
else if (m_action == "tutorial_skidding2") else if (m_action == "tutorial_skidding2")
{ {
m_action = "__disabled__"; m_action_active = false;
World::getWorld()->getRaceGUI()->clearAllMessages(); World::getWorld()->getRaceGUI()->clearAllMessages();
new TutorialMessageDialog(_("Note that if you manage to skid for several seconds, you will receive a bonus speedup as a reward!"), new TutorialMessageDialog(_("Note that if you manage to skid for several seconds, you will receive a bonus speedup as a reward!"),
@ -672,7 +676,7 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
} }
else if (m_action == "tutorial_endmessage") else if (m_action == "tutorial_endmessage")
{ {
m_action = "__disabled__"; m_action_active = false;
World::getWorld()->getRaceGUI()->clearAllMessages(); World::getWorld()->getRaceGUI()->clearAllMessages();
new TutorialMessageDialog(_("You are now ready to race. Good luck!"), new TutorialMessageDialog(_("You are now ready to race. Good luck!"),
@ -683,9 +687,6 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
World::getWorld()->scheduleExitRace(); World::getWorld()->scheduleExitRace();
return; return;
} }
else if (m_action == "__disabled__")
{
}
else else
{ {
fprintf(stderr, "[TrackObject] WARNING: unknown action <%s>\n", fprintf(stderr, "[TrackObject] WARNING: unknown action <%s>\n",

View File

@ -253,6 +253,8 @@ private:
/** For action trigger objects */ /** For action trigger objects */
std::string m_action; std::string m_action;
bool m_action_active;
public: public:
@ -260,6 +262,8 @@ public:
virtual ~TrackObjectPresentationActionTrigger() {} virtual ~TrackObjectPresentationActionTrigger() {}
virtual void onTriggerItemApproached(Item* who) OVERRIDE; virtual void onTriggerItemApproached(Item* who) OVERRIDE;
virtual void reset() OVERRIDE { m_action_active = true; }
}; };