Notify player when he unlocked a feature by completing a GP

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4957 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2010-03-08 16:44:09 +00:00
parent 9606ee9ab6
commit 5239b62e0d
4 changed files with 68 additions and 2 deletions

View File

@@ -53,7 +53,7 @@ ModalDialog::ModalDialog(const float percentWidth, const float percentHeight)
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) );
core::dimension2d< s32 >(w, h) );
if (modalWindow != NULL) delete modalWindow;
modalWindow = this;

View File

@@ -23,8 +23,9 @@ using namespace irr::gui;
LabelWidget::LabelWidget(bool title)
{
m_type = WTYPE_LABEL;
m_type = WTYPE_LABEL;
m_title_font = title;
m_has_color = false;
}
// -----------------------------------------------------------------------------
void LabelWidget::add()
@@ -42,6 +43,11 @@ void LabelWidget::add()
m_element = irrwidget;
irrwidget->setTextAlignment( align, valign );
if (m_has_color)
{
irrwidget->setOverrideColor(m_color);
}
if (m_title_font)
{
irrwidget->setOverrideColor( video::SColor(255,255,255,255) );

View File

@@ -30,6 +30,9 @@ namespace GUIEngine
/** A simple label widget. See guiengine/engine.hpp for a detailed overview. */
class LabelWidget : public Widget
{
bool m_has_color;
irr::video::SColor m_color;
public:
LabelWidget(bool title=false);
virtual ~LabelWidget() {}
@@ -38,6 +41,13 @@ namespace GUIEngine
/** Change the text in the label */
void setText(irr::core::stringw newText);
void setColor(const irr::video::SColor& color)
{
m_color = color;
m_has_color = true;
}
};
}

View File

@@ -3,8 +3,10 @@
#include "audio/sound_manager.hpp"
#include "audio/sfx_manager.hpp"
#include "challenges/unlock_manager.hpp"
#include "graphics/irr_driver.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "io/file_manager.hpp"
#include "items/item_manager.hpp"
#include "karts/kart_properties_manager.hpp"
@@ -69,6 +71,54 @@ void traverse(scene::ISceneNode* curr, int level=0)
void GrandPrixOver::init()
{
if (unlock_manager->getRecentlyUnlockedFeatures().size() > 0)
{
const core::dimension2d<u32>& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize();
core::stringw message = _("You unlocked a new feature!");
const int message_width = GUIEngine::getFont()->getDimension(message.c_str()).Width + 30;
const int label_height = GUIEngine::getFontHeight() + 15;
const int y_from = frame_size.Height - label_height*2;
const int y_to = frame_size.Height - label_height;
const int label_x_from = frame_size.Width/2 - message_width/2;
const int label_x_to = frame_size.Width/2 + message_width/2;
// button_h is used in the x coordinates not by mistake, but because the icon is square and
// scaled according to the available height.
core::rect< s32 > iconarea(label_x_from - label_height, y_from,
label_x_from, y_to);
IGUIImage* img = GUIEngine::getGUIEnv()->addImage( iconarea );
img->setImage( irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") ) );
img->setScaleImage(true);
img->setTabStop(false);
img->setUseAlphaChannel(true);
core::rect< s32 > icon2area(label_x_to, y_from,
label_x_to + label_height, y_to);
img = GUIEngine::getGUIEnv()->addImage( icon2area );
img->setImage( irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") ) );
img->setScaleImage(true);
img->setTabStop(false);
img->setUseAlphaChannel(true);
GUIEngine::LabelWidget* unlocked_label = new GUIEngine::LabelWidget();
unlocked_label->m_properties[GUIEngine::PROP_ID] = "label";
unlocked_label->m_properties[GUIEngine::PROP_TEXT_ALIGN] = "center";
unlocked_label->x = label_x_from;
unlocked_label->y = y_from;
unlocked_label->w = message_width;
unlocked_label->h = label_height;
unlocked_label->m_text = message;
//const irr::video::SColor orange(255, 255, 126, 21);
//unlocked_label->setColor(orange);
unlocked_label->add();
}
sound_manager->startMusic(sound_manager->getMusicInformation(file_manager->getMusicFile("win_theme.music")));
m_phase = 1;