GUI: Implement setSelected in Grid and use it in launcher
This commit is contained in:
parent
d2f327921c
commit
b94ad4d8b8
3 changed files with 34 additions and 1 deletions
|
@ -1540,8 +1540,18 @@ void LauncherGrid::updateListing() {
|
||||||
gridList.push_back(GridItemInfo(k++, engineid, gameid, iter->title, iter->description, Common::parseLanguage(language), Common::parsePlatform(platform)));
|
gridList.push_back(GridItemInfo(k++, engineid, gameid, iter->title, iter->description, Common::parseLanguage(language), Common::parsePlatform(platform)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int oldSel = _grid->getSelected();
|
||||||
|
|
||||||
_grid->setEntryList(&gridList);
|
_grid->setEntryList(&gridList);
|
||||||
groupEntries(attrs);
|
groupEntries(attrs);
|
||||||
|
|
||||||
|
if (oldSel < (int)gridList.size() && oldSel >= 0)
|
||||||
|
_grid->setSelected(oldSel); // Restore the old selection
|
||||||
|
else if (oldSel != -1)
|
||||||
|
// Select the last entry if the list has been reduced
|
||||||
|
_grid->setSelected(gridList.size() - 1);
|
||||||
|
updateButtons();
|
||||||
|
|
||||||
// And fill out our structures
|
// And fill out our structures
|
||||||
for (Common::Array<LauncherEntry>::const_iterator iter = domainList.begin(); iter != domainList.end(); ++iter) {
|
for (Common::Array<LauncherEntry>::const_iterator iter = domainList.begin(); iter != domainList.end(); ++iter) {
|
||||||
_domains.push_back(iter->key);
|
_domains.push_back(iter->key);
|
||||||
|
@ -1556,7 +1566,19 @@ void LauncherGrid::updateButtons() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherGrid::selectTarget(const Common::String &target) {}
|
void LauncherGrid::selectTarget(const Common::String &target) {
|
||||||
|
if (!target.empty()) {
|
||||||
|
int itemToSelect = 0;
|
||||||
|
Common::StringArray::const_iterator iter;
|
||||||
|
for (iter = _domains.begin(); iter != _domains.end(); ++iter, ++itemToSelect) {
|
||||||
|
if (target == *iter) {
|
||||||
|
_grid->setSelected(itemToSelect);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int LauncherGrid::getSelected() { return _grid->getSelected(); }
|
int LauncherGrid::getSelected() { return _grid->getSelected(); }
|
||||||
|
|
||||||
void LauncherGrid::build() {
|
void LauncherGrid::build() {
|
||||||
|
|
|
@ -947,4 +947,14 @@ void GridWidget::setFilter(const Common::U32String &filter) {
|
||||||
sortGroups();
|
sortGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GridWidget::setSelected(int id) {
|
||||||
|
for (uint i = 0; i < _sortedEntryList.size(); ++i) {
|
||||||
|
if ((!_sortedEntryList[i]->isHeader) && (_sortedEntryList[i]->entryID == id)) {
|
||||||
|
_selectedEntry = _sortedEntryList[i];
|
||||||
|
scrollToEntry(id, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace GUI
|
} // End of namespace GUI
|
||||||
|
|
|
@ -209,6 +209,7 @@ public:
|
||||||
void openTrayAtSelected();
|
void openTrayAtSelected();
|
||||||
void scrollBarRecalc();
|
void scrollBarRecalc();
|
||||||
|
|
||||||
|
void setSelected(int id);
|
||||||
void setFilter(const Common::U32String &filter);
|
void setFilter(const Common::U32String &filter);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue