GUI: Add overlay to show demo status on thumbnails
This commit is contained in:
parent
cf88e250ef
commit
2b7dee23b6
4 changed files with 45 additions and 3 deletions
|
@ -1547,11 +1547,13 @@ void LauncherGrid::updateListing() {
|
|||
Common::String engineid = "UNK";
|
||||
Common::String language = "XX";
|
||||
Common::String platform;
|
||||
Common::String extra;
|
||||
iter->domain->tryGetVal("engineid", engineid);
|
||||
iter->domain->tryGetVal("language", language);
|
||||
iter->domain->tryGetVal("platform", platform);
|
||||
iter->domain->tryGetVal("extra", extra);
|
||||
attrs.push_back(iter->domain);
|
||||
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, extra, Common::parseLanguage(language), Common::parsePlatform(platform)));
|
||||
}
|
||||
|
||||
const int oldSel = _grid->getSelected();
|
||||
|
|
Binary file not shown.
|
@ -136,6 +136,13 @@ void GridItemWidget::drawWidget() {
|
|||
g_gui.theme()->drawSurface(p, *flagGfx, true);
|
||||
}
|
||||
|
||||
// Draw Demo Overlay
|
||||
const Graphics::ManagedSurface *demoGfx = _grid->demoToSurface(_activeEntry->extra);
|
||||
if (demoGfx) {
|
||||
Common::Point p(_x + ((thumbWidth - demoGfx->w)/2) , _y + (thumbHeight - demoGfx->h - 10));
|
||||
g_gui.theme()->drawSurface(p, *demoGfx, true);
|
||||
}
|
||||
|
||||
// Draw Title
|
||||
if (_grid->_isTitlesVisible) {
|
||||
// TODO: Currently title is fixed to two lines at all times, we may want
|
||||
|
@ -345,6 +352,8 @@ GridWidget::GridWidget(GuiObject *boss, const Common::String &name)
|
|||
_flagIconWidth = 0;
|
||||
_platformIconHeight = 0;
|
||||
_platformIconWidth = 0;
|
||||
_extraIconHeight = 0;
|
||||
_extraIconWidth = 0;
|
||||
_minGridXSpacing = 0;
|
||||
_minGridYSpacing = 0;
|
||||
_isTitlesVisible = 0;
|
||||
|
@ -381,6 +390,7 @@ GridWidget::GridWidget(GuiObject *boss, const Common::String &name)
|
|||
GridWidget::~GridWidget() {
|
||||
unloadSurfaces(_platformIcons);
|
||||
unloadSurfaces(_languageIcons);
|
||||
unloadSurfaces(_extraIcons);
|
||||
unloadSurfaces(_loadedSurfaces);
|
||||
_gridItems.clear();
|
||||
_dataEntryList.clear();
|
||||
|
@ -415,6 +425,12 @@ const Graphics::ManagedSurface *GridWidget::platformToSurface(Common::Platform p
|
|||
return _platformIcons[platformCode];
|
||||
}
|
||||
|
||||
const Graphics::ManagedSurface *GridWidget::demoToSurface(const Common::String extraString) {
|
||||
if (! extraString.contains("Demo") )
|
||||
return nullptr;
|
||||
return _extraIcons[0];
|
||||
}
|
||||
|
||||
void GridWidget::setEntryList(Common::Array<GridItemInfo> *list) {
|
||||
_dataEntryList.clear();
|
||||
_headerEntryList.clear();
|
||||
|
@ -671,6 +687,21 @@ void GridWidget::loadPlatformIcons() {
|
|||
}
|
||||
}
|
||||
|
||||
void GridWidget::loadExtraIcons() { // for now only the demo icon is available
|
||||
Graphics::ManagedSurface *gfx = loadSurfaceFromFile("icons/extra/demo.png");
|
||||
if (gfx) {
|
||||
const Graphics::ManagedSurface *scGfx = scaleGfx(gfx, _extraIconWidth, _extraIconHeight, true);
|
||||
_extraIcons[0] = scGfx;
|
||||
if (gfx != scGfx) {
|
||||
gfx->free();
|
||||
delete gfx;
|
||||
}
|
||||
} else {
|
||||
_extraIcons[0] = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GridWidget::destroyItems() {
|
||||
for (Common::Array<GridItemWidget *>::iterator i = _gridItems.begin(), end = _gridItems.end(); i != end; ++i) {
|
||||
removeWidget((*i));
|
||||
|
@ -891,12 +922,15 @@ void GridWidget::reflowLayout() {
|
|||
_flagIconWidth = _thumbnailWidth / 4;
|
||||
_flagIconHeight = _flagIconWidth / 2;
|
||||
_platformIconHeight = _platformIconWidth = _thumbnailWidth / 6;
|
||||
_extraIconWidth = _thumbnailWidth / 2;
|
||||
_extraIconHeight = _extraIconWidth / 4;
|
||||
|
||||
if ((oldThumbnailHeight != _thumbnailHeight) || (oldThumbnailWidth != _thumbnailWidth)) {
|
||||
unloadSurfaces(_loadedSurfaces);
|
||||
reloadThumbnails();
|
||||
loadFlagIcons();
|
||||
loadPlatformIcons();
|
||||
loadExtraIcons();
|
||||
}
|
||||
|
||||
_trayHeight = kLineHeight * 3;
|
||||
|
|
|
@ -54,6 +54,7 @@ struct GridItemInfo {
|
|||
Common::String gameid;
|
||||
Common::String title;
|
||||
Common::String description;
|
||||
Common::String extra;
|
||||
Common::String thumbPath;
|
||||
// Generic attribute value, may be any piece of metadata
|
||||
Common::String attribute;
|
||||
|
@ -63,8 +64,8 @@ struct GridItemInfo {
|
|||
int32 x, y, w, h;
|
||||
|
||||
GridItemInfo(int id, const Common::String &eid, const Common::String &gid, const Common::String &t,
|
||||
const Common::String &d, Common::Language l, Common::Platform p)
|
||||
: entryID(id), gameid(gid), engineid(eid), title(t), description(d), language(l), platform(p), isHeader(false) {
|
||||
const Common::String &d, const Common::String &e, Common::Language l, Common::Platform p)
|
||||
: entryID(id), gameid(gid), engineid(eid), title(t), description(d), extra(e), language(l), platform(p), isHeader(false) {
|
||||
thumbPath = Common::String::format("icons/%s-%s.png", engineid.c_str(), gameid.c_str());
|
||||
}
|
||||
|
||||
|
@ -99,6 +100,7 @@ class GridWidget : public ContainerWidget, public CommandSender {
|
|||
protected:
|
||||
Common::HashMap<int, const Graphics::ManagedSurface *> _platformIcons;
|
||||
Common::HashMap<int, const Graphics::ManagedSurface *> _languageIcons;
|
||||
Common::HashMap<int, const Graphics::ManagedSurface *> _extraIcons;
|
||||
|
||||
// Images are mapped by filename -> surface.
|
||||
Common::HashMap<Common::String, const Graphics::ManagedSurface *> _loadedSurfaces;
|
||||
|
@ -134,6 +136,8 @@ protected:
|
|||
int _flagIconWidth;
|
||||
int _platformIconHeight;
|
||||
int _platformIconWidth;
|
||||
int _extraIconHeight;
|
||||
int _extraIconWidth;
|
||||
int _minGridXSpacing;
|
||||
int _minGridYSpacing;
|
||||
int _rows;
|
||||
|
@ -169,6 +173,7 @@ public:
|
|||
const Graphics::ManagedSurface *filenameToSurface(const Common::String &name);
|
||||
const Graphics::ManagedSurface *languageToSurface(Common::Language languageCode);
|
||||
const Graphics::ManagedSurface *platformToSurface(Common::Platform platformCode);
|
||||
const Graphics::ManagedSurface *demoToSurface(const Common::String extraString);
|
||||
|
||||
/// Update _visibleEntries from _allEntries and returns true if reload is required.
|
||||
bool calcVisibleEntries();
|
||||
|
@ -187,6 +192,7 @@ public:
|
|||
void reloadThumbnails();
|
||||
void loadFlagIcons();
|
||||
void loadPlatformIcons();
|
||||
void loadExtraIcons();
|
||||
|
||||
void destroyItems();
|
||||
void calcInnerHeight();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue