Allowed deleting players
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3666 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
fc826538f6
commit
23192bfe21
@ -403,8 +403,15 @@ void PlayerInfoDialog::processEvent(std::string& eventSource)
|
||||
}
|
||||
if(eventSource == "removeplayer")
|
||||
{
|
||||
// TODO
|
||||
dismiss();
|
||||
StateManager::deletePlayer( m_player );
|
||||
|
||||
// irrLicht is too stupid to remove focus from deleted widgets
|
||||
// so do it by hand
|
||||
GUIEngine::getGUIEnv()->removeFocus( textCtrl->m_element );
|
||||
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -548,6 +548,24 @@ namespace StateManager
|
||||
// TODO : need to re-save user config here?
|
||||
}
|
||||
|
||||
void deletePlayer(Player* player)
|
||||
{
|
||||
UserConfigParams::m_player.erase(player);
|
||||
|
||||
// refresh list display
|
||||
ListWidget* players = getCurrentScreen()->getWidget<ListWidget>("players");
|
||||
if(players == NULL) return;
|
||||
players->clear();
|
||||
|
||||
const int playerAmount = UserConfigParams::m_player.size();
|
||||
for(int n=0; n<playerAmount; n++)
|
||||
{
|
||||
players->addItem(UserConfigParams::m_player[n].getName());
|
||||
}
|
||||
|
||||
// TODO : need to re-save user config here?
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// main call (from StateManager); dispatches the call to a specialissed function as needed
|
||||
void menuEventOptions(Widget* widget, const std::string& name)
|
||||
|
@ -31,11 +31,11 @@ struct Input;
|
||||
|
||||
namespace StateManager
|
||||
{
|
||||
|
||||
void menuEventOptions(GUIEngine::Widget* widget, const std::string& name);
|
||||
|
||||
void gotSensedInput(Input* sensedInput);
|
||||
void gotNewPlayerName(const irr::core::stringw& newName, Player* player=NULL);
|
||||
|
||||
void deletePlayer(Player* player);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -191,6 +191,9 @@ void clearWithoutDeleting()
|
||||
contentsVector.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes without deleting
|
||||
*/
|
||||
void remove(TYPE* obj)
|
||||
{
|
||||
for(unsigned int n=0; n<contentsVector.size(); n++)
|
||||
@ -204,7 +207,24 @@ void remove(TYPE* obj)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes and deletes
|
||||
*/
|
||||
void erase(TYPE* obj)
|
||||
{
|
||||
for(unsigned int n=0; n<contentsVector.size(); n++)
|
||||
{
|
||||
TYPE * pointer = contentsVector[n];
|
||||
if(pointer == obj)
|
||||
{
|
||||
contentsVector.erase(contentsVector.begin()+n);
|
||||
delete pointer;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user