Skip to content

Commit

Permalink
Fixed|Ring Zero: Folded Saved Games title always shows 0 games initially
Browse files Browse the repository at this point in the history
The content widget of a fold panel does not receive updates when
closed, so now SavegameSelectionWidget employs a better mechanism for
deferring item updates.
  • Loading branch information
skyjake committed Mar 30, 2014
1 parent 4582b78 commit f22c2d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
3 changes: 0 additions & 3 deletions doomsday/client/include/ui/widgets/savegameselectionwidget.h
Expand Up @@ -64,9 +64,6 @@ class SavegameSelectionWidget : public de::MenuWidget

de::game::SavedSession const &savedSession(de::ui::DataPos pos) const;

// Events.
void update();

signals:
void availabilityChanged();
void gameSelected();
Expand Down
28 changes: 14 additions & 14 deletions doomsday/client/src/ui/widgets/savegameselectionwidget.cpp
Expand Up @@ -39,6 +39,7 @@ DENG_GUI_PIMPL(SavegameSelectionWidget)
, DENG2_OBSERVES(App, StartupComplete)
, DENG2_OBSERVES(SavedSessionRepository, AvailabilityUpdate)
, DENG2_OBSERVES(ButtonWidget, Press)
, DENG2_OBSERVES(Loop, Iteration) // deferred refresh
, public ChildWidgetOrganizer::IWidgetFactory
{
/**
Expand Down Expand Up @@ -112,12 +113,10 @@ DENG_GUI_PIMPL(SavegameSelectionWidget)
};

bool loadWhenSelected;
bool needUpdateFromRepository;

Instance(Public *i)
: Base(i)
, loadWhenSelected(true)
, needUpdateFromRepository(false)
{
self.organizer().setWidgetFactory(*this);

Expand Down Expand Up @@ -225,18 +224,29 @@ DENG_GUI_PIMPL(SavegameSelectionWidget)
if(!App::inMainThread())
{
// We'll have to defer the update for now.
needUpdateFromRepository = true;
deferUpdate();
return;
}
updateItemsFromRepository();
}

void deferUpdate()
{
Loop::appLoop().audienceForIteration() += this;
}

void loopIteration()
{
Loop::appLoop().audienceForIteration() -= this;
updateItemsFromRepository();
}
};

SavegameSelectionWidget::SavegameSelectionWidget()
: MenuWidget("savegame-selection"), d(new Instance(this))
{
setGridSize(3, ui::Filled, 0, ui::Expand);
d->needUpdateFromRepository = true;
d->updateItemsFromRepository();
}

void SavegameSelectionWidget::setLoadGameWhenSelected(bool enableLoad)
Expand All @@ -252,16 +262,6 @@ void SavegameSelectionWidget::setColumns(int numberOfColumns)
}
}

void SavegameSelectionWidget::update()
{
if(d->needUpdateFromRepository)
{
d->needUpdateFromRepository = false;
d->updateItemsFromRepository();
}
MenuWidget::update();
}

SavedSession const &SavegameSelectionWidget::savedSession(ui::DataPos pos) const
{
DENG2_ASSERT(pos < items().size());
Expand Down

0 comments on commit f22c2d9

Please sign in to comment.