Back to index

supertuxkart  0.5+dfsg1
feature_unlocked.cpp
Go to the documentation of this file.
00001 //  $Id: feature_unlocked.cpp 1305 2007-11-26 14:28:15Z hiker $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2008 Joerg Henrichs
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #include "gui/feature_unlocked.hpp"
00021 #include "widget_manager.hpp"
00022 #include "menu_manager.hpp"
00023 #include "unlock_manager.hpp"
00024 #include "translation.hpp"
00025 
00026 enum WidgetTokens
00027 {
00028     WTOK_TITLE,
00029     WTOK_CONTINUE,
00030     WTOK_DESCRIPTION
00031 };
00032 
00033 FeatureUnlocked::FeatureUnlocked()
00034 {
00035     widget_manager->switchOrder();
00036     widget_manager->addTitleWgt( WTOK_TITLE, 60, 10,
00037         _("New Feature Unlocked"));
00038 
00039     m_new_features=unlock_manager->getUnlockedFeatures();
00040     assert(m_new_features.size()>0);
00041     unlock_manager->clearUnlocked();
00042 
00043     widget_manager->addTextWgt( WTOK_DESCRIPTION, 60, 30,
00044         m_new_features[0]->getUnlockedMessage());
00045 
00046     widget_manager->addTextButtonWgt(WTOK_CONTINUE, 50, 7,
00047         _("Continue"));
00048 
00049     widget_manager->layout(WGT_AREA_ALL);
00050 }   // FeatureUnlocked
00051 
00052 //-----------------------------------------------------------------------------
00053 FeatureUnlocked::~FeatureUnlocked()
00054 {
00055     widget_manager->reset();
00056 }   // ~FeatureUnlocked
00057 
00058 //-----------------------------------------------------------------------------
00059 
00060 void FeatureUnlocked::select()
00061 {
00062     assert(widget_manager->getSelectedWgt()==WTOK_CONTINUE);
00063     m_new_features.erase(m_new_features.begin());
00064     if(m_new_features.size()>0)
00065     {
00066         widget_manager->setWgtText( WTOK_DESCRIPTION, m_new_features[0]->getUnlockedMessage() );
00067     }
00068     else
00069     {
00070         menu_manager->popMenu();
00071     }
00072 }   // select