Handle better locked GPs

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4703 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2010-02-13 01:53:16 +00:00
parent 6d4078d3c7
commit 219cc77c1e
2 changed files with 44 additions and 37 deletions

View File

@@ -1184,54 +1184,57 @@ void Skin::process3DPane(IGUIElement *element, const core::rect< s32 > &rect, co
// -----------------------------------------------------------------------------
void Skin::drawBadgeOn(const Widget* widget, const core::rect<s32>& rect)
void doDrawBadge(ITexture* texture, const core::rect<s32>& rect, float max_icon_size, bool badge_at_left)
{
video::ITexture* texture = NULL;
float max_icon_size = 0.35f;
bool badge_at_left = true;
if (widget->m_badges & LOCKED_BADGE)
{
texture = irr_driver->getTexture(file_manager->getTextureFile("gui_lock.png"));
max_icon_size = 0.5f; // Lock badge can be quite big
}
if (widget->m_badges & OK_BADGE)
{
texture = irr_driver->getTexture(file_manager->getTextureFile("green_check.png"));
}
if (widget->m_badges & BAD_BADGE)
{
texture = irr_driver->getTexture(file_manager->getTextureFile("red_mark.png"));
badge_at_left = false;
}
if (widget->m_badges & TROPHY_BADGE)
{
texture = irr_driver->getTexture(file_manager->getTextureFile("cup_bronze.png"));
badge_at_left = false;
}
const core::dimension2d<u32>& texture_size = texture->getSize();
const float aspectRatio = (float)texture_size.Width / (float)texture_size.Height;
const int h = rect.getHeight() <= 50 ?
rect.getHeight() :
std::min( (int)(rect.getHeight()*max_icon_size), (int)(texture_size.Height) );
rect.getHeight() :
std::min( (int)(rect.getHeight()*max_icon_size), (int)(texture_size.Height) );
int w = (int)(aspectRatio*h);
const core::rect<s32> source_area = core::rect<s32>(0, 0, texture_size.Width, texture_size.Height);
const core::rect< s32 > rect2 = core::rect< s32 >(badge_at_left ?
rect.UpperLeftCorner.X :
rect.LowerRightCorner.X - w,
rect.UpperLeftCorner.X :
rect.LowerRightCorner.X - w,
rect.LowerRightCorner.Y - h,
badge_at_left ?
rect.UpperLeftCorner.X + w :
rect.LowerRightCorner.X,
rect.UpperLeftCorner.X + w :
rect.LowerRightCorner.X,
rect.LowerRightCorner.Y);
GUIEngine::getDriver()->draw2DImage(texture, rect2, source_area,
0 /* no clipping */, 0, true /* alpha */);
}
void Skin::drawBadgeOn(const Widget* widget, const core::rect<s32>& rect)
{
if (widget->m_badges & LOCKED_BADGE)
{
video::ITexture* texture = irr_driver->getTexture(file_manager->getTextureFile("gui_lock.png"));
float max_icon_size = 0.5f; // Lock badge can be quite big
doDrawBadge(texture, rect, max_icon_size, true);
}
if (widget->m_badges & OK_BADGE)
{
video::ITexture* texture = irr_driver->getTexture(file_manager->getTextureFile("green_check.png"));
float max_icon_size = 0.35f;
doDrawBadge(texture, rect, max_icon_size, true);
}
if (widget->m_badges & BAD_BADGE)
{
video::ITexture* texture = irr_driver->getTexture(file_manager->getTextureFile("red_mark.png"));
float max_icon_size = 0.35f;
doDrawBadge(texture, rect, max_icon_size, false);
}
if (widget->m_badges & TROPHY_BADGE)
{
float max_icon_size = 0.43f;
video::ITexture* texture = irr_driver->getTexture(file_manager->getTextureFile("cup_bronze.png"));
doDrawBadge(texture, rect, max_icon_size, false);
}
}
// -----------------------------------------------------------------------------
void Skin::draw3DButtonPanePressed (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip)

View File

@@ -105,11 +105,16 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const
DynamicRibbonWidget* gps_widget = dynamic_cast<DynamicRibbonWidget*>(widget);
if (gps_widget != NULL)
{
std::cout << "Clicked on GrandPrix "
<< gps_widget->getSelectionIDString(GUI_PLAYER_ID).c_str()
<< std::endl;
std::string selection = gps_widget->getSelectionIDString(GUI_PLAYER_ID);
new GPInfoDialog( gps_widget->getSelectionIDString(GUI_PLAYER_ID), 0.8f, 0.7f );
if (selection == "locked")
{
unlock_manager->playLockSound();
}
else
{
new GPInfoDialog( selection, 0.8f, 0.7f );
}
}
else
{
@@ -140,7 +145,6 @@ void TracksScreen::init()
for (int n=0; n<gpAmount; n++)
{
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(n);
std::cout << "Got GP : " << gp->getId() << std::endl;
std::vector<std::string> tracks = gp->getTracks();
@@ -169,7 +173,7 @@ void TracksScreen::init()
if (unlock_manager->isLocked(gp->getId()))
{
gps_widget->addAnimatedItem( _("Locked : solve active challenges to gain access to more!"),
"locked", sshot_files, 1.5f, TROPHY_BADGE,
"locked", sshot_files, 1.5f, LOCKED_BADGE | TROPHY_BADGE,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
}
else