UPDATES: Got rid of hardcoded update intervals list
This commit is contained in:
parent
556b7ffa29
commit
08e7f0ab91
5 changed files with 79 additions and 11 deletions
|
@ -56,5 +56,10 @@ MODULE_OBJS += \
|
||||||
recorderfile.o
|
recorderfile.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef USE_UPDATES
|
||||||
|
MODULE_OBJS += \
|
||||||
|
updates.o
|
||||||
|
endif
|
||||||
|
|
||||||
# Include common rules
|
# Include common rules
|
||||||
include $(srcdir)/rules.mk
|
include $(srcdir)/rules.mk
|
||||||
|
|
56
common/updates.cpp
Normal file
56
common/updates.cpp
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* file distributed with this source distribution.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "common/system.h"
|
||||||
|
#include "common/updates.h"
|
||||||
|
#include "common/translation.h"
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
static const int updateIntervals[] = {
|
||||||
|
UpdateManager::kUpdateIntervalNotSupported,
|
||||||
|
UpdateManager::kUpdateIntervalOneDay,
|
||||||
|
UpdateManager::kUpdateIntervalOneWeek,
|
||||||
|
UpdateManager::kUpdateIntervalOneMonth,
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
|
||||||
|
const int *UpdateManager::getUpdateIntervals() {
|
||||||
|
return updateIntervals;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *UpdateManager::updateIntervalToString(int interval) {
|
||||||
|
switch (interval) {
|
||||||
|
case kUpdateIntervalNotSupported:
|
||||||
|
return _("Never");
|
||||||
|
case kUpdateIntervalOneDay:
|
||||||
|
return _("Daily");
|
||||||
|
case kUpdateIntervalOneWeek:
|
||||||
|
return _("Weekly");
|
||||||
|
case kUpdateIntervalOneMonth:
|
||||||
|
return _("Monthly");
|
||||||
|
default:
|
||||||
|
return _("<Bad value>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End of namespace Common
|
|
@ -20,8 +20,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BACKENDS_UPDATES_ABSTRACT_H
|
#ifndef COMMON_UPDATES_H
|
||||||
#define BACKENDS_UPDATES_ABSTRACT_H
|
#define COMMON_UPDATES_H
|
||||||
|
|
||||||
#if defined(USE_UPDATES)
|
#if defined(USE_UPDATES)
|
||||||
|
|
||||||
|
@ -93,10 +93,13 @@ public:
|
||||||
* @return the update check interval.
|
* @return the update check interval.
|
||||||
*/
|
*/
|
||||||
virtual int getUpdateCheckInterval() { return kUpdateIntervalNotSupported; }
|
virtual int getUpdateCheckInterval() { return kUpdateIntervalNotSupported; }
|
||||||
|
|
||||||
|
static const int *getUpdateIntervals();
|
||||||
|
static const char *updateIntervalToString(int interval);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Common
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // BACKENDS_UPDATES_ABSTRACT_H
|
#endif // COMMON_UPDATES_H
|
||||||
|
|
|
@ -1234,10 +1234,12 @@ GlobalOptionsDialog::GlobalOptionsDialog()
|
||||||
_updatesPopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Misc.UpdatesPopupDesc", _("Update check:"), _("How often to check ScummVM updates"));
|
_updatesPopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Misc.UpdatesPopupDesc", _("Update check:"), _("How often to check ScummVM updates"));
|
||||||
_updatesPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.UpdatesPopup");
|
_updatesPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.UpdatesPopup");
|
||||||
|
|
||||||
_updatesPopUp->appendEntry(_("Never"), Common::UpdateManager::kUpdateIntervalNotSupported);
|
const int *vals = Common::UpdateManager::getUpdateIntervals();
|
||||||
_updatesPopUp->appendEntry(_("Daily"), Common::UpdateManager::kUpdateIntervalOneDay);
|
|
||||||
_updatesPopUp->appendEntry(_("Weekly"), Common::UpdateManager::kUpdateIntervalOneWeek);
|
while (*vals != -1) {
|
||||||
_updatesPopUp->appendEntry(_("Monthly"), Common::UpdateManager::kUpdateIntervalOneMonth);
|
_updatesPopUp->appendEntry(Common::UpdateManager::updateIntervalToString(*vals), *vals);
|
||||||
|
vals++;
|
||||||
|
}
|
||||||
|
|
||||||
if (ConfMan.hasKey("updates_check"))
|
if (ConfMan.hasKey("updates_check"))
|
||||||
_updatesPopUp->setSelectedTag(ConfMan.getInt("updates_check"));
|
_updatesPopUp->setSelectedTag(ConfMan.getInt("updates_check"));
|
||||||
|
|
|
@ -95,10 +95,12 @@ UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) {
|
||||||
|
|
||||||
_updatesPopUp = new PopUpWidget(this, 10, y, _w - 20, g_gui.xmlEval()->getVar("Globals.PopUp.Height", kLineHeight));
|
_updatesPopUp = new PopUpWidget(this, 10, y, _w - 20, g_gui.xmlEval()->getVar("Globals.PopUp.Height", kLineHeight));
|
||||||
|
|
||||||
_updatesPopUp->appendEntry(_("Never"), Common::UpdateManager::kUpdateIntervalNotSupported);
|
const int *vals = Common::UpdateManager::getUpdateIntervals();
|
||||||
_updatesPopUp->appendEntry(_("Daily"), Common::UpdateManager::kUpdateIntervalOneDay);
|
|
||||||
_updatesPopUp->appendEntry(_("Weekly"), Common::UpdateManager::kUpdateIntervalOneWeek);
|
while (*vals != -1) {
|
||||||
_updatesPopUp->appendEntry(_("Monthly"), Common::UpdateManager::kUpdateIntervalOneMonth);
|
_updatesPopUp->appendEntry(Common::UpdateManager::updateIntervalToString(*vals), *vals);
|
||||||
|
vals++;
|
||||||
|
}
|
||||||
|
|
||||||
_updatesPopUp->setSelectedTag(Common::UpdateManager::kUpdateIntervalOneWeek);
|
_updatesPopUp->setSelectedTag(Common::UpdateManager::kUpdateIntervalOneWeek);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue