When pressing escape to leave track info dialog, focus is now properly restored on previously selected track

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4316 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2009-12-17 22:18:14 +00:00
parent e77fc3cb0c
commit 5eac1154c2
4 changed files with 29 additions and 2 deletions

View File

@@ -17,6 +17,7 @@
#include "guiengine/engine.hpp"
#include "guiengine/screen.hpp"
#include "guiengine/widget.hpp"
#include "io/file_manager.hpp"
#include "karts/kart_properties_manager.hpp"
@@ -26,6 +27,7 @@
#include "race/race_manager.hpp"
#include "states_screens/dialogs/track_info_dialog.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/tracks_screen.hpp"
#include "tracks/track.hpp"
#include "tracks/track_manager.hpp"
#include "utils/string_utils.hpp"
@@ -195,7 +197,7 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core:
screenshotWidget->y = area_right.UpperLeftCorner.Y;
screenshotWidget->w = area_right.getWidth();
screenshotWidget->h = area_right.getHeight();
std::cout << screenshotWidget->x << ", " << screenshotWidget->y << " : " << screenshotWidget->w << ", " << screenshotWidget->h << std::endl;
//std::cout << screenshotWidget->x << ", " << screenshotWidget->y << " : " << screenshotWidget->w << ", " << screenshotWidget->h << std::endl;
screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png"; // temporary icon, will replace it just after
//screenshotWidget->setScaleImage(true);
@@ -210,6 +212,18 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core:
}
TrackInfoDialog::~TrackInfoDialog()
{
// Place focus back on selected track, in case the dialog was cancelled and we're back to
// the track selection screen after
Screen* curr_screen = GUIEngine::getCurrentScreen();
if (curr_screen->getName() == "tracks.stkgui")
{
((TracksScreen*)curr_screen)->setFocusOnTrack(m_track_ident);
}
}
// ------------------------------------------------------------------------------------------------------
// FIXME : this probably doesn't belong here

View File

@@ -40,7 +40,9 @@ public:
* Creates a modal dialog with given percentage of screen width and height
*/
TrackInfoDialog(const std::string& trackIdent, const irr::core::stringw& trackName,
irr::video::ITexture* screenshot, const float percentWidth, const float percentHeight);
irr::video::ITexture* screenshot, const float percentWidth, const float percentHeight);
virtual ~TrackInfoDialog();
void onEnterPressedInternal();
GUIEngine::EventPropagation processEvent(std::string& eventSource);
};

View File

@@ -112,3 +112,12 @@ void TracksScreen::init()
void TracksScreen::tearDown()
{
}
void TracksScreen::setFocusOnTrack(const std::string& trackName)
{
DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks");
assert( w != NULL );
// FIXME: don't hardcode player 0?
w->setSelection(trackName, 0, true);
}

View File

@@ -33,6 +33,8 @@ public:
void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID);
void init();
void tearDown();
void setFocusOnTrack(const std::string& trackName);
};
#endif