mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-24 13:13:58 +00:00
UPDATES: Implement and use method for normalizing interval value to accepted values
This commit is contained in:
parent
14478a65f1
commit
a743ec2e07
@ -80,7 +80,7 @@ MacOSXUpdateManager::MacOSXUpdateManager() {
|
||||
setAutomaticallyChecksForUpdates(kUpdateStateDisabled);
|
||||
} else {
|
||||
setAutomaticallyChecksForUpdates(kUpdateStateEnabled);
|
||||
setUpdateCheckInterval(ConfMan.getInt("updates_check"));
|
||||
setUpdateCheckInterval(normalizeInterval(ConfMan.getInt("updates_check")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,16 +110,7 @@ void MacOSXUpdateManager::setUpdateCheckInterval(int interval) {
|
||||
if (interval == kUpdateIntervalNotSupported)
|
||||
return;
|
||||
|
||||
const int *vals = getUpdateIntervals();
|
||||
|
||||
while (*vals != -1) {
|
||||
if (interval == *vals)
|
||||
break;
|
||||
vals++;
|
||||
}
|
||||
|
||||
if (*vals == -1)
|
||||
interval = kUpdateIntervalOneDay;
|
||||
interval = normalizeInterval(interval);
|
||||
|
||||
[sparkleUpdater setUpdateCheckInterval:(NSTimeInterval)interval];
|
||||
}
|
||||
|
@ -38,6 +38,16 @@ const int *UpdateManager::getUpdateIntervals() {
|
||||
return updateIntervals;
|
||||
}
|
||||
|
||||
int UpdateManager::normalizeInterval(int interval) {
|
||||
const int *val = updateIntervals;
|
||||
|
||||
while (*val != -1)
|
||||
if (*val > interval)
|
||||
return *val;
|
||||
|
||||
return val[-1]; // Return maximal acceptable value
|
||||
}
|
||||
|
||||
const char *UpdateManager::updateIntervalToString(int interval) {
|
||||
switch (interval) {
|
||||
case kUpdateIntervalNotSupported:
|
||||
|
@ -105,9 +105,18 @@ public:
|
||||
/**
|
||||
* Returns string representation of a given interval.
|
||||
*
|
||||
* @param interval The interval.
|
||||
* @return pointer to localized string of given interval.
|
||||
*/
|
||||
static const char *updateIntervalToString(int interval);
|
||||
|
||||
/**
|
||||
* Rounds up the given interval to acceptable value.
|
||||
*
|
||||
* @param interval The interval.
|
||||
* @return rounded up interval
|
||||
*/
|
||||
static int normalizeInterval(int interval);
|
||||
};
|
||||
|
||||
} // End of namespace Common
|
||||
|
@ -1243,7 +1243,7 @@ GlobalOptionsDialog::GlobalOptionsDialog()
|
||||
}
|
||||
|
||||
if (ConfMan.hasKey("updates_check"))
|
||||
_updatesPopUp->setSelectedTag(ConfMan.getInt("updates_check"));
|
||||
_updatesPopUp->setSelectedTag(Common::UpdateManager::normalizeInterval(ConfMan.getInt("updates_check")));
|
||||
else
|
||||
_updatesPopUp->setSelectedTag(Common::UpdateManager::kUpdateIntervalNotSupported);
|
||||
|
||||
@ -1397,8 +1397,6 @@ void GlobalOptionsDialog::close() {
|
||||
} else {
|
||||
g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateEnabled);
|
||||
g_system->getUpdateManager()->setUpdateCheckInterval(_updatesPopUp->getSelectedTag());
|
||||
|
||||
ConfMan.setInt("updates_check", g_system->getUpdateManager()->getUpdateCheckInterval());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user