GUI: Disable download button when no item is selected in DLC browsing dialog

This commit is contained in:
Ankush Dutt 2023-08-03 13:22:26 +05:30 committed by Eugene Sandulenko
parent dd87960fe8
commit a4329e21b9
2 changed files with 20 additions and 1 deletions

View File

@ -54,7 +54,7 @@ DLCsDialog::DLCsDialog() : Dialog("DownloadGames") {
new ButtonWidget(this, "DownloadGames.Back", _("Back"), Common::U32String(), kCloseCmd);
new ButtonWidget(this, "DownloadGames.AllDownloads", _("All Downloads"), Common::U32String(), kAllDownloadsCmd);
new ButtonWidget(this, "DownloadGames.Download", _("Download"), Common::U32String(), kDownloadSelectedCmd);
_downloadButton = new ButtonWidget(this, "DownloadGames.Download", _("Download"), Common::U32String(), kDownloadSelectedCmd);
}
DLCsDialog::~DLCsDialog() {
@ -83,6 +83,23 @@ void DLCsDialog::refreshDLCList() {
g_gui.scheduleTopDialogRedraw();
}
void DLCsDialog::handleTickle() {
// enable download button only when a list item is selected
if (_gamesList->getSelected() == -1) {
if (_downloadButton->isEnabled()) {
_downloadButton->setEnabled(false);
g_gui.scheduleTopDialogRedraw();
}
} else {
if (!_downloadButton->isEnabled()) {
_downloadButton->setEnabled(true);
g_gui.scheduleTopDialogRedraw();
}
}
Dialog::handleTickle();
}
void DLCsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kAllDownloadsCmd: {

View File

@ -39,12 +39,14 @@ public:
DLCsDialog();
~DLCsDialog() override;
void handleTickle() override;
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
void refreshDLCList();
private:
ListWidget *_gamesList;
ButtonWidget *_downloadButton;
};
} // End of namespace GUI