Skip to content

Commit

Permalink
GUI: Disable load button in Grid Launcher when no savegame can be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
criezy committed Dec 23, 2024
1 parent 38eb164 commit d236a24
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gui/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,7 @@ void LauncherGrid::build() {
_gridItemSizeLabel->setValue(ConfMan.getInt("grid_items_per_row"));

// Add list with game titles
_grid = new GridWidget(this, "LauncherGrid.IconArea");
_grid = new GridWidget(this, "LauncherGrid.IconArea", this);
// Populate the list
updateListing();

Expand Down
10 changes: 7 additions & 3 deletions gui/widgets/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "gui/gui-manager.h"
#include "gui/widgets/grid.h"
#include "gui/launcher.h"

#include "gui/ThemeEval.h"

Expand Down Expand Up @@ -264,7 +265,7 @@ void GridItemWidget::handleMouseDown(int x, int y, int button, int clickCount) {

#pragma mark -

GridItemTray::GridItemTray(GuiObject *boss, int x, int y, int w, int h, int entryID, GridWidget *grid)
GridItemTray::GridItemTray(GuiObject *boss, int x, int y, int w, int h, int entryID, GridWidget *grid, LauncherDialog *launcher)
: Dialog(x, y, w, h), CommandSender(boss) {

_entryID = entryID;
Expand All @@ -286,6 +287,8 @@ GridItemTray::GridItemTray(GuiObject *boss, int x, int y, int w, int h, int entr
_loadButton = new PicButtonWidget(this, trayPaddingX, trayPaddingY + buttonHeight + buttonSpacingY,
buttonWidth, buttonHeight,
_("Saves"), kLoadButtonCmd);
if (launcher)
_loadButton->setEnabled(launcher->canLoadSavegames(entryID));
_editButton = new PicButtonWidget(this, trayPaddingX + buttonWidth + buttonSpacingX, trayPaddingY + buttonHeight + buttonSpacingY,
buttonWidth, buttonHeight,
_("Edit"), kEditButtonCmd);
Expand Down Expand Up @@ -400,9 +403,10 @@ Graphics::ManagedSurface *loadSurfaceFromFile(const Common::String &name, int re

#pragma mark -

GridWidget::GridWidget(GuiObject *boss, const Common::String &name)
GridWidget::GridWidget(GuiObject *boss, const Common::String &name, LauncherDialog *launcher)
: ContainerWidget(boss, name), CommandSender(boss) {

_launcher = launcher;
_thumbnailHeight = 0;
_thumbnailWidth = 0;
_flagIconHeight = 0;
Expand Down Expand Up @@ -1115,7 +1119,7 @@ void GridWidget::reflowLayout() {
void GridWidget::openTrayAtSelected() {
if (_selectedEntry) {
GridItemTray *tray = new GridItemTray(this, _x + _selectedEntry->x - _gridXSpacing / 3, _y + _selectedEntry->y + _selectedEntry->h - _scrollPos,
_gridItemWidth + 2 * (_gridXSpacing / 3), _trayHeight, _selectedEntry->entryID, this);
_gridItemWidth + 2 * (_gridXSpacing / 3), _trayHeight, _selectedEntry->entryID, this, _launcher);
tray->runModal();
delete tray;
}
Expand Down
6 changes: 4 additions & 2 deletions gui/widgets/grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace GUI {
class ScrollBarWidget;
class GridItemWidget;
class GridWidget;
class LauncherDialog;

enum {
kPlayButtonCmd = 'PLAY',
Expand Down Expand Up @@ -84,7 +85,7 @@ class GridItemTray: public Dialog, public CommandSender {
PicButtonWidget *_loadButton;
PicButtonWidget *_editButton;
public:
GridItemTray(GuiObject *boss, int x, int y, int w, int h, int entryID, GridWidget *grid);
GridItemTray(GuiObject *boss, int x, int y, int w, int h, int entryID, GridWidget *grid, LauncherDialog *launcher);

void reflowLayout() override;

Expand Down Expand Up @@ -126,6 +127,7 @@ class GridWidget : public ContainerWidget, public CommandSender {
Common::Array<GridItemWidget *> _gridItems;

ScrollBarWidget *_scrollBar;
LauncherDialog *_launcher;

int _scrollBarWidth;
int _scrollWindowHeight;
Expand Down Expand Up @@ -169,7 +171,7 @@ class GridWidget : public ContainerWidget, public CommandSender {

Common::U32String _filter;

GridWidget(GuiObject *boss, const Common::String &name);
GridWidget(GuiObject *boss, const Common::String &name, LauncherDialog *launcher);
~GridWidget();

template<typename T>
Expand Down

0 comments on commit d236a24

Please sign in to comment.