Skip to content

Commit

Permalink
GUI: Hide update controls when UpdateManager not set
Browse files Browse the repository at this point in the history
  • Loading branch information
sluicebox authored and lotharsm committed Nov 13, 2021
1 parent 6842e6f commit e82f6c6
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions gui/options.cpp
Expand Up @@ -2399,18 +2399,20 @@ void GlobalOptionsDialog::addMiscControls(GuiObject *boss, const Common::String
}

#ifdef USE_UPDATES
_updatesPopUpDesc = new StaticTextWidget(boss, prefix + "UpdatesPopupDesc", _("Update check:"), _("How often to check ScummVM updates"));
_updatesPopUp = new PopUpWidget(boss, prefix + "UpdatesPopup");
if (g_system->getUpdateManager()) {
_updatesPopUpDesc = new StaticTextWidget(boss, prefix + "UpdatesPopupDesc", _("Update check:"), _("How often to check ScummVM updates"));
_updatesPopUp = new PopUpWidget(boss, prefix + "UpdatesPopup");

const int *vals = Common::UpdateManager::getUpdateIntervals();
while (*vals != -1) {
_updatesPopUp->appendEntry(Common::UpdateManager::updateIntervalToString(*vals), *vals);
vals++;
}
const int *vals = Common::UpdateManager::getUpdateIntervals();
while (*vals != -1) {
_updatesPopUp->appendEntry(Common::UpdateManager::updateIntervalToString(*vals), *vals);
vals++;
}

_updatesPopUp->setSelectedTag(Common::UpdateManager::normalizeInterval(ConfMan.getInt("updates_check")));
_updatesPopUp->setSelectedTag(Common::UpdateManager::normalizeInterval(ConfMan.getInt("updates_check")));

new ButtonWidget(boss, prefix + "UpdatesCheckManuallyButton", _("Check now"), Common::U32String(), kUpdatesCheckCmd);
new ButtonWidget(boss, prefix + "UpdatesCheckManuallyButton", _("Check now"), Common::U32String(), kUpdatesCheckCmd);
}
#endif // USE_UPDATES
}

Expand Down Expand Up @@ -2687,9 +2689,9 @@ void GlobalOptionsDialog::apply() {
_autosavePeriodPopUp->setSelected(0);

#ifdef USE_UPDATES
ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag());

if (g_system->getUpdateManager()) {
ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag());

if (_updatesPopUp->getSelectedTag() == Common::UpdateManager::kUpdateIntervalNotSupported) {
g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateDisabled);
} else {
Expand Down

0 comments on commit e82f6c6

Please sign in to comment.