Work on tutorial

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12373 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2013-01-17 02:20:12 +00:00
parent 14c058a311
commit c44dbf4214
10 changed files with 232 additions and 60 deletions

View File

@ -13,6 +13,7 @@ endif()
option(USE_WIIUSE "Support for wiimote input devices" OFF)
option(USE_FRIBIDI "Support for right-to-left languages" ON)
option(USE_CPP2011 "Activate C++ 2011 mode (GCC only)" OFF)
set(STK_SOURCE_DIR "src")
set(STK_DATA_DIR "${PROJECT_SOURCE_DIR}/data")
@ -72,6 +73,9 @@ if(USE_FRIBIDI)
endif()
endif()
if(USE_CPP2011)
add_definitions("-std=gnu++11")
endif()
# OpenGL
find_package(OpenGL REQUIRED)

View File

@ -176,6 +176,7 @@ src/states_screens/dialogs/race_paused_dialog.cpp
src/states_screens/dialogs/select_challenge.cpp
src/states_screens/dialogs/story_mode_new.cpp
src/states_screens/dialogs/track_info_dialog.cpp
src/states_screens/dialogs/tutorial_message_dialog.cpp
src/states_screens/feature_unlocked.cpp
src/states_screens/grand_prix_lose.cpp
src/states_screens/grand_prix_win.cpp
@ -433,6 +434,7 @@ src/states_screens/dialogs/race_paused_dialog.hpp
src/states_screens/dialogs/select_challenge.hpp
src/states_screens/dialogs/story_mode_new.hpp
src/states_screens/dialogs/track_info_dialog.hpp
src/states_screens/dialogs/tutorial_message_dialog.hpp
src/states_screens/feature_unlocked.hpp
src/states_screens/grand_prix_lose.hpp
src/states_screens/grand_prix_win.hpp

View File

@ -46,8 +46,10 @@ using namespace GUIEngine;
// ----------------------------------------------------------------------------
ModalDialog::ModalDialog(const float percentWidth, const float percentHeight)
ModalDialog::ModalDialog(const float percentWidth, const float percentHeight,
ModalDialogLocation location)
{
m_dialog_location = location;
doInit(percentWidth, percentHeight);
}
@ -100,13 +102,27 @@ void ModalDialog::doInit(const float percentWidth, const float percentHeight)
assert((unsigned int)w <= frame_size.Width);
assert((unsigned int)h <= frame_size.Height);
m_area = core::rect< s32 >( core::position2d< s32 >(frame_size.Width/2 - w/2, frame_size.Height/2 - h/2),
core::dimension2d< s32 >(w, h) );
if (m_dialog_location == MODAL_DIALOG_LOCATION_CENTER)
{
m_area = core::rect<s32>(core::position2d<s32>(frame_size.Width/2 - w/2,
frame_size.Height/2 - h/2),
core::dimension2d<s32>(w, h));
}
else if (m_dialog_location == MODAL_DIALOG_LOCATION_BOTTOM)
{
m_area = core::rect<s32>(core::position2d<s32>(frame_size.Width/2 - w/2,
frame_size.Height - h - 15),
core::dimension2d<s32>(w, h));
}
else
{
assert(false);
}
if (modalWindow != NULL) delete modalWindow;
modalWindow = this;
m_irrlicht_window = GUIEngine::getGUIEnv()->addWindow ( m_area, true /* modal */ );
m_irrlicht_window = GUIEngine::getGUIEnv()->addWindow(m_area, true /* modal */);
GUIEngine::getSkin()->m_dialog = true;
GUIEngine::getSkin()->m_dialog_size = 0.0f;

View File

@ -39,6 +39,12 @@ namespace GUIEngine
class TextBoxWidget;
class ButtonWidget;
enum ModalDialogLocation
{
MODAL_DIALOG_LOCATION_CENTER = 0,
MODAL_DIALOG_LOCATION_BOTTOM = 1
};
/**
* \brief Abstract base class representing a modal dialog.
* Only once instance at a time (if you create a 2nd the first will be destroyed).
@ -52,6 +58,9 @@ namespace GUIEngine
/** Because C++ doesn't support constructor delegation... */
void doInit(const float percentWidth, const float percentHeight);
ModalDialogLocation m_dialog_location;
protected:
irr::gui::IGUIWindow* m_irrlicht_window;
irr::core::rect< irr::s32 > m_area;
@ -61,7 +70,8 @@ namespace GUIEngine
/**
* \brief Creates a modal dialog with given percentage of screen width and height
*/
ModalDialog(const float percentWidth, const float percentHeight);
ModalDialog(const float percentWidth, const float percentHeight,
ModalDialogLocation location = MODAL_DIALOG_LOCATION_CENTER);
/** \brief Load a XML file to create the dialog from
* \note This method automatically calls Widget::add() on each widget

View File

@ -169,7 +169,9 @@ void WorldStatus::update(const float dt)
m_auxiliary_timer += dt;
// In artist debug mode, when without opponents, skip the ready/set/go counter faster
if (UserConfigParams::m_artist_debug_mode && race_manager->getNumberOfKarts() == 1)
if (UserConfigParams::m_artist_debug_mode &&
race_manager->getNumberOfKarts() == 1 &&
race_manager->getTrackName() != "tutorial")
m_auxiliary_timer += dt*6;
return;
case SET_PHASE :
@ -187,7 +189,9 @@ void WorldStatus::update(const float dt)
m_auxiliary_timer += dt;
// In artist debug mode, when without opponents, skip the ready/set/go counter faster
if (UserConfigParams::m_artist_debug_mode && race_manager->getNumberOfKarts() == 1)
if (UserConfigParams::m_artist_debug_mode &&
race_manager->getNumberOfKarts() == 1 &&
race_manager->getTrackName() != "tutorial")
m_auxiliary_timer += dt*6;
return;
case GO_PHASE :

View File

@ -21,6 +21,7 @@
#include "guiengine/screen.hpp"
#include "guiengine/widgets/button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "modes/world.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
@ -44,9 +45,27 @@ MessageDialog::MessageDialog(irr::core::stringw msg) :
// ------------------------------------------------------------------------------------------------------
MessageDialog::~MessageDialog()
{
if (m_own_listener) delete m_listener; m_listener = NULL;
if (StateManager::get()->getGameState() == GUIEngine::GAME)
{
World::getWorld()->scheduleUnpause();
}
}
// ------------------------------------------------------------------------------------------------------
void MessageDialog::doInit(irr::core::stringw msg, MessageDialogType type,
IConfirmDialogListener* listener, bool own_listener)
{
if (StateManager::get()->getGameState() == GUIEngine::GAME)
{
World::getWorld()->schedulePause(World::IN_GAME_MENU_PHASE);
}
loadFromFile("confirm_dialog.stkgui");
m_listener = listener;

View File

@ -87,7 +87,7 @@ public:
MessageDialog(irr::core::stringw msg);
~MessageDialog() { if (m_own_listener) delete m_listener; m_listener = NULL; }
~MessageDialog();
virtual void onEnterPressedInternal();
virtual void onUpdate(float dt);

View File

@ -0,0 +1,86 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2010 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/dialogs/tutorial_message_dialog.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/screen.hpp"
#include "guiengine/widgets/button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "modes/world.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
using namespace GUIEngine;
// ------------------------------------------------------------------------------------------------------
TutorialMessageDialog::TutorialMessageDialog(irr::core::stringw msg, bool stopGame) :
ModalDialog(0.85f, 0.25f, MODAL_DIALOG_LOCATION_BOTTOM)
{
m_stop_game = stopGame;
if (stopGame && StateManager::get()->getGameState() == GUIEngine::GAME)
{
World::getWorld()->schedulePause(World::IN_GAME_MENU_PHASE);
}
loadFromFile("tutorial_message_dialog.stkgui");
LabelWidget* message = getWidget<LabelWidget>("title");
message->setText( msg.c_str(), false );
ButtonWidget* cancelbtn = getWidget<ButtonWidget>("continue");
cancelbtn->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
// ------------------------------------------------------------------------------------------------------
TutorialMessageDialog::~TutorialMessageDialog()
{
if (m_stop_game && StateManager::get()->getGameState() == GUIEngine::GAME)
{
World::getWorld()->scheduleUnpause();
}
}
// ------------------------------------------------------------------------------------------------------
void TutorialMessageDialog::onEnterPressedInternal()
{
}
// ------------------------------------------------------------------------------------------------------
GUIEngine::EventPropagation TutorialMessageDialog::processEvent(const std::string& eventSource)
{
if (eventSource == "continue")
{
ModalDialog::dismiss();
return GUIEngine::EVENT_BLOCK;
}
return GUIEngine::EVENT_LET;
}
// ------------------------------------------------------------------------------------------------------
void TutorialMessageDialog::onUpdate(float dt)
{
}

View File

@ -0,0 +1,52 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2010 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_TUTORIAL_DIALOG_HPP
#define HEADER_TUTORIAL_DIALOG_HPP
#include "config/player.hpp"
#include "guiengine/modaldialog.hpp"
#include "utils/cpp2011.h"
#include "utils/leak_check.hpp"
/**
* \brief Messages shown during tutorial
* \ingroup states_screens
*/
class TutorialMessageDialog : public GUIEngine::ModalDialog
{
private:
bool m_stop_game;
public:
TutorialMessageDialog(irr::core::stringw msg, bool stopGame);
~TutorialMessageDialog();
virtual void onEnterPressedInternal() OVERRIDE;
virtual void onUpdate(float dt) OVERRIDE;
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
};
#endif

View File

@ -31,6 +31,7 @@
#include "items/item_manager.hpp"
#include "modes/overworld.hpp"
#include "modes/world.hpp"
#include "states_screens/dialogs/tutorial_message_dialog.hpp"
#include "states_screens/dialogs/race_paused_dialog.hpp"
#include "tracks/track.hpp"
@ -470,27 +471,26 @@ void TrackObject::onTriggerItemApproached(Item* who)
}
else if (m_action == "tutorial_drive")
{
m_action = "__disabled__";
World::getWorld()->getRaceGUI()->clearAllMessages();
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration();
irr::core::stringw accel = config->getBindingAsString(PA_ACCEL);
irr::core::stringw left = config->getBindingAsString(PA_STEER_LEFT);
irr::core::stringw right = config->getBindingAsString(PA_STEER_RIGHT);
World::getWorld()->getRaceGUI()->addMessage(_("Accelerate with <%s> and steer with <%s> and <%s>",
accel, left, right), NULL, 5.0f,
video::SColor(255, 255,255,255),
false, true);
//if (World::getWorld()->getPhase() == World::RACE_PHASE)
{
m_action = "__disabled__";
//World::getWorld()->getRaceGUI()->clearAllMessages();
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration();
irr::core::stringw accel = config->getBindingAsString(PA_ACCEL);
irr::core::stringw left = config->getBindingAsString(PA_STEER_LEFT);
irr::core::stringw right = config->getBindingAsString(PA_STEER_RIGHT);
new TutorialMessageDialog(_("Accelerate with <%s> and steer with <%s> and <%s>", accel, left, right),
false);
}
}
else if (m_action == "tutorial_bananas")
{
m_action = "__disabled__";
World::getWorld()->getRaceGUI()->clearAllMessages();
World::getWorld()->getRaceGUI()->addMessage(_("Avoid bananas!"), NULL, 5.0f,
video::SColor(255, 255,255,255),
false, true);
new TutorialMessageDialog(_("Avoid bananas!"), true);
}
else if (m_action == "tutorial_giftboxes")
{
@ -499,24 +499,15 @@ void TrackObject::onTriggerItemApproached(Item* who)
DeviceConfig* config = device->getConfiguration();
irr::core::stringw fire = config->getBindingAsString(PA_FIRE);
World::getWorld()->getRaceGUI()->clearAllMessages();
core::stringw msg = _("Collect gift boxes, and fire the weapon with <%s> to blow away these boxes!", fire);
std::vector<core::stringw> parts = StringUtils::split(msg, '\n', false);
for (unsigned int i = 0; i < parts.size(); i++)
{
World::getWorld()->getRaceGUI()->addMessage(parts[i], NULL, 7.0f,
video::SColor(255, 255,255,255),
false, false);
}
new TutorialMessageDialog(_("Collect gift boxes, and fire the weapon with <%s> to blow away these boxes!", fire),
true);
}
else if (m_action == "tutorial_nitro_collect")
{
m_action = "__disabled__";
World::getWorld()->getRaceGUI()->clearAllMessages();
World::getWorld()->getRaceGUI()->addMessage(_("Collect nitro bottles (we will use them after the curve)"),
NULL, 5.0f, video::SColor(255, 255,255,255),
false, false);
new TutorialMessageDialog(_("Collect nitro bottles (we will use them after the curve)"),
true);
}
else if (m_action == "tutorial_nitro_use")
{
@ -525,10 +516,8 @@ void TrackObject::onTriggerItemApproached(Item* who)
DeviceConfig* config = device->getConfiguration();
irr::core::stringw nitro = config->getBindingAsString(PA_NITRO);
World::getWorld()->getRaceGUI()->clearAllMessages();
World::getWorld()->getRaceGUI()->addMessage(_("Use the nitro you collected by pressing <%s>!", nitro),
NULL, 5.0f, video::SColor(255, 255,255,255),
false, false);
new TutorialMessageDialog(_("Use the nitro you collected by pressing <%s>!", nitro),
true);
}
else if (m_action == "tutorial_rescue")
{
@ -537,39 +526,29 @@ void TrackObject::onTriggerItemApproached(Item* who)
DeviceConfig* config = device->getConfiguration();
irr::core::stringw rescue = config->getBindingAsString(PA_RESCUE);
World::getWorld()->getRaceGUI()->clearAllMessages();
World::getWorld()->getRaceGUI()->addMessage(_("Oops! When you're in trouble, press <%s> to be rescued", rescue),
NULL, 5.0f, video::SColor(255, 255,255,255),
false, false);
new TutorialMessageDialog(_("Oops! When you're in trouble, press <%s> to be rescued", rescue),
false);
}
else if (m_action == "tutorial_skidding")
{
m_action = "__disabled__";
World::getWorld()->getRaceGUI()->clearAllMessages();
//World::getWorld()->getRaceGUI()->clearAllMessages();
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration();
irr::core::stringw skid = config->getBindingAsString(PA_DRIFT);
World::getWorld()->getRaceGUI()->addMessage(_("Skidding for a short while can help you turn faster to take sharp turns"),
NULL, 10.0f, video::SColor(255, 255,255,255),
false, false);
World::getWorld()->getRaceGUI()->addMessage(_("Accelerate and press the <%s> key while turning to skid.", skid),
NULL, 10.0f, video::SColor(255, 255,255,255),
false, false);
new TutorialMessageDialog(_("Accelerate and press the <%s> key while turning to skid. Skidding for a short while can help you turn faster to take sharp turns.", skid),
true);
}
else if (m_action == "tutorial_skidding2")
{
m_action = "__disabled__";
World::getWorld()->getRaceGUI()->clearAllMessages();
World::getWorld()->getRaceGUI()->addMessage(_("you will receive a bonus speedup as a reward!"), NULL, 10.0f,
video::SColor(255, 255,255,255),
false, false);
World::getWorld()->getRaceGUI()->addMessage(_("If you manage to skid for several seconds,"), NULL, 10.0f,
video::SColor(255, 255,255,255),
false, false);
new TutorialMessageDialog(_("Note that if you manage to skid for several seconds, you will receive a bonus speedup as a reward!"),
true);
}
else if (m_action == "__disabled__")
{