Fixed exiting a race & starting a new one in a cleaner way
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4138 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
325b7aff3e
commit
584d203aa4
@ -62,6 +62,7 @@ namespace GUIEngine
|
||||
void clear()
|
||||
{
|
||||
g_env->clear();
|
||||
if (g_current_screen != NULL) g_current_screen->elementsWereDeleted();
|
||||
g_current_screen = NULL;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -304,16 +304,16 @@ void Screen::addWidgetsRecursively(ptr_vector<Widget>& widgets, Widget* parent)
|
||||
*/
|
||||
void Screen::elementsWereDeleted(ptr_vector<Widget>* within_vector)
|
||||
{
|
||||
if(within_vector == NULL) within_vector = &m_widgets;
|
||||
if (within_vector == NULL) within_vector = &m_widgets;
|
||||
const unsigned short widgets_amount = within_vector->size();
|
||||
|
||||
for(int n=0; n<widgets_amount; n++)
|
||||
for (int n=0; n<widgets_amount; n++)
|
||||
{
|
||||
Widget& widget = (*within_vector)[n];
|
||||
|
||||
widget.m_element = NULL;
|
||||
widget.elementRemoved();
|
||||
|
||||
if(widget.m_children.size() > 0)
|
||||
if (widget.m_children.size() > 0)
|
||||
{
|
||||
elementsWereDeleted( &(widget.m_children) );
|
||||
}
|
||||
|
@ -293,6 +293,11 @@ namespace GUIEngine
|
||||
* Call after Widget was read from XML file and laid out.
|
||||
*/
|
||||
virtual void add();
|
||||
|
||||
/**
|
||||
* Called when irrLicht widgets cleared. Forget all references to them, they're no more valid.
|
||||
*/
|
||||
virtual void elementRemoved() { m_element = NULL; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -243,17 +243,19 @@ void DynamicRibbonWidget::addItem( const irr::core::stringw& user_name, const st
|
||||
m_items.push_back(desc);
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
void DynamicRibbonWidget::clearItems(bool widgetsToo)
|
||||
void DynamicRibbonWidget::clearItems()
|
||||
{
|
||||
m_items.clear();
|
||||
if (widgetsToo)
|
||||
{
|
||||
m_children.clearWithoutDeleting();
|
||||
m_rows.clearWithoutDeleting();
|
||||
}
|
||||
m_previous_item_count = 0;
|
||||
}
|
||||
|
||||
void DynamicRibbonWidget::elementRemoved()
|
||||
{
|
||||
Widget::elementRemoved();
|
||||
m_previous_item_count = 0;
|
||||
m_rows.clearWithoutDeleting();
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#pragma mark Getters
|
||||
|
@ -151,7 +151,7 @@ namespace GUIEngine
|
||||
|
||||
/** Clears all items added through 'addItem'. You can then add new items with 'addItem' and call
|
||||
'updateItemDisplay' to update the display. */
|
||||
void clearItems(bool widgetsToo=false);
|
||||
void clearItems();
|
||||
|
||||
/** Register a listener to be notified of selection changes within the ribbon */
|
||||
void registerHoverListener(DynamicRibbonHoverListener* listener);
|
||||
@ -180,6 +180,11 @@ namespace GUIEngine
|
||||
const std::vector<ItemDescription>& getItems() const { return m_items; }
|
||||
|
||||
void setSelection(int item_id, const int playerID);
|
||||
|
||||
/**
|
||||
* Called when irrLicht widgets cleared. Forget all references to them, they're no more valid.
|
||||
*/
|
||||
virtual void elementRemoved();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -627,11 +627,6 @@ void KartSelectionScreen::tearDown()
|
||||
{
|
||||
//g_player_karts.clearWithoutDeleting();
|
||||
g_player_karts.clearAndDeleteAll();
|
||||
|
||||
// List is rebuilt everytime.
|
||||
DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("karts");
|
||||
assert(w != NULL);
|
||||
w->clearItems(true);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -653,6 +648,7 @@ void KartSelectionScreen::init()
|
||||
|
||||
// Build kart list
|
||||
// (it is built everytikme, to account for .g. locking)
|
||||
w->clearItems();
|
||||
std::vector<int> group = kart_properties_manager->getKartsInGroup("standard");
|
||||
const int kart_amount = group.size();
|
||||
|
||||
|
@ -66,7 +66,9 @@ void TracksScreen::init()
|
||||
DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks");
|
||||
assert( w != NULL );
|
||||
|
||||
|
||||
// Re-build track list everytime (accounts for locking changes, etc.)
|
||||
w->clearItems();
|
||||
|
||||
const int trackAmount = track_manager->getNumberOfTracks();
|
||||
bool hasLockedTracks = false;
|
||||
for (int n=0; n<trackAmount; n++)
|
||||
@ -90,11 +92,4 @@ void TracksScreen::init()
|
||||
|
||||
void TracksScreen::tearDown()
|
||||
{
|
||||
// List is rebuilt everytime (for instance, locking might change, etc.)
|
||||
DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks");
|
||||
assert(w != NULL);
|
||||
|
||||
// FIXME : the 'true' argument to force deleting references to irrLicht widgets is an ugly hack
|
||||
// Ideally the widget should find out by itself and take care of that.
|
||||
w->clearItems(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user