From 81e0fa37ffaa4d711c7d5727e2b6caa969808bd0 Mon Sep 17 00:00:00 2001 From: David Fioramonti Date: Sat, 7 Jul 2018 02:12:33 -0700 Subject: GUI: Show saveload date/time, or playtime even if thumbnail not enabled Previously, if playtime or date/time support was added it would not be displayed unless thumbnail support was also valid. Now they will be shown even if the thumbnail is not valid. No container is shown if only metainfo support is enabled. --- gui/saveload-dialog.cpp | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'gui') diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 8d59a6318a..2702cbe31b 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -463,13 +463,14 @@ void SaveLoadChooserSimple::handleCommand(CommandSender *sender, uint32 cmd, uin } void SaveLoadChooserSimple::reflowLayout() { - if (g_gui.xmlEval()->getVar("Globals.SaveLoadChooser.ExtInfo.Visible") == 1 && _thumbnailSupport) { + if (g_gui.xmlEval()->getVar("Globals.SaveLoadChooser.ExtInfo.Visible") == 1 && (_thumbnailSupport || _saveDateSupport || _playTimeSupport)) { int16 x, y; uint16 w, h; if (!g_gui.xmlEval()->getWidgetData("SaveLoadChooser.Thumbnail", x, y, w, h)) error("Error when loading position data for Save/Load Thumbnails"); + // Even if there is no thumbnail support, getWidgetData() will provide default thumbnail values int thumbW = kThumbnailWidth; int thumbH = kThumbnailHeight2; int thumbX = x + (w >> 1) - (thumbW >> 1); @@ -483,28 +484,40 @@ void SaveLoadChooserSimple::reflowLayout() { if (textLines > 0) textLines++; // add a line of padding at the bottom - _container->resize(x, y, w, h + (kLineHeight * textLines)); - _gfxWidget->resize(thumbX, thumbY, thumbW, thumbH); + if (_thumbnailSupport) { + _gfxWidget->resize(thumbX, thumbY, thumbW, thumbH); + _gfxWidget->setVisible(true); + } else { + // choose sensible values for displaying playtime and date/time when a thumbnail is not being used + thumbH = 0; + thumbY = y; + h = kLineHeight; + _gfxWidget->setVisible(false); + } int height = thumbY + thumbH + kLineHeight; if (_saveDateSupport) { - _date->resize(thumbX, height, kThumbnailWidth, kLineHeight); + _date->resize(thumbX, height, thumbW, kLineHeight); height += kLineHeight; - _time->resize(thumbX, height, kThumbnailWidth, kLineHeight); + _time->resize(thumbX, height, thumbW, kLineHeight); height += kLineHeight; + _date->setVisible(_saveDateSupport); + _time->setVisible(_saveDateSupport); + } else { + _date->setVisible(false); + _time->setVisible(false); } - if (_playTimeSupport) - _playtime->resize(thumbX, height, kThumbnailWidth, kLineHeight); + if (_playTimeSupport) { + _playtime->resize(thumbX, height, thumbW, kLineHeight); + _playtime->setVisible(_playTimeSupport); + } else { + _playtime->setVisible(false); + } + _container->resize(x, y, w, h + (kLineHeight * textLines)); _container->setVisible(true); - _gfxWidget->setVisible(true); - - _date->setVisible(_saveDateSupport); - _time->setVisible(_saveDateSupport); - - _playtime->setVisible(_playTimeSupport); updateSelection(false); } else { -- cgit v1.2.3