Fix focus lost when opening and closing dialog in players screen

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8434 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-04-23 20:56:57 +00:00
parent c1f992231e
commit a4229e4cdb
6 changed files with 33 additions and 0 deletions

View File

@ -159,6 +159,15 @@ irr::core::stringw ListWidget::getSelectionLabel() const
// -----------------------------------------------------------------------------
void ListWidget::selectItemWithLabel(const irr::core::stringw& name)
{
IGUIListBox* list = getIrrlichtElement<IGUIListBox>();
assert(list != NULL);
return list->setSelected( name.c_str() );
}
// -----------------------------------------------------------------------------
void ListWidget::unfocused(const int playerID)
{
IGUIListBox* list = getIrrlichtElement<IGUIListBox>();

View File

@ -113,6 +113,8 @@ namespace GUIEngine
irr::core::stringw getSelectionLabel() const;
void selectItemWithLabel(const irr::core::stringw& name);
/**
* \brief Finds the ID of the item that has a given internal name
*/

View File

@ -39,6 +39,14 @@ PlayerInfoDialog::PlayerInfoDialog(PlayerProfile* player, const float w, const f
showRegularDialog();
}
// ------------------------------------------------------------------------------------------------------
PlayerInfoDialog::~PlayerInfoDialog()
{
OptionsScreenPlayers::getInstance()->selectPlayer( translations->fribidize(m_player->getName()) );
}
// ------------------------------------------------------------------------------------------------------
void PlayerInfoDialog::showRegularDialog()
{

View File

@ -44,6 +44,9 @@ public:
*/
PlayerInfoDialog(PlayerProfile* PlayerInfoDialog,
const float percentWidth, const float percentHeight);
virtual ~PlayerInfoDialog();
void onEnterPressedInternal();
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
};

View File

@ -199,3 +199,12 @@ void OptionsScreenPlayers::eventCallback(Widget* widget, const std::string& name
} // eventCallback
// -----------------------------------------------------------------------------
void OptionsScreenPlayers::selectPlayer(const irr::core::stringw& name)
{
ListWidget* players = this->getWidget<ListWidget>("players");
assert(players != NULL);
players->selectItemWithLabel(name);
players->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}

View File

@ -53,6 +53,8 @@ public:
bool gotNewPlayerName(const irr::core::stringw& newName, PlayerProfile* player=NULL);
void deletePlayer(PlayerProfile* player);
void selectPlayer(const irr::core::stringw& name);
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void init();