From 12b0313d92cea9105477e644fb4fdcb592c30abb Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 29 Mar 2016 10:44:46 +0200 Subject: GUI: Added stub for Update frequency check widgets. --- gui/options.cpp | 11 +++++++++++ gui/options.h | 5 +++++ gui/themes/scummclassic.zip | Bin 111410 -> 111931 bytes gui/themes/scummclassic/classic_layout.stx | 8 ++++++++ gui/themes/scummclassic/classic_layout_lowres.stx | 10 ++++++++++ gui/themes/scummmodern.zip | Bin 1487187 -> 1487717 bytes gui/themes/scummmodern/scummmodern_layout.stx | 8 ++++++++ .../scummmodern/scummmodern_layout_lowres.stx | 10 ++++++++++ 8 files changed, 52 insertions(+) diff --git a/gui/options.cpp b/gui/options.cpp index ba247e5f15..832f793b9f 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -36,6 +36,7 @@ #include "common/system.h" #include "common/textconsole.h" #include "common/translation.h" +#include "common/updates.h" #include "audio/mididrv.h" #include "audio/musicplugin.h" @@ -1229,6 +1230,16 @@ GlobalOptionsDialog::GlobalOptionsDialog() #endif // USE_TRANSLATION +#ifdef USE_UPDATES + _updatesPopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Misc.UpdatesPopupDesc", _("Update check:"), _("How often to check ScummVM updates")); + _updatesPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.UpdatesPopup"); + + _updatesPopUp->appendEntry(_("Never"), Common::UpdateManager::kUpdateIntervalNotSupported); + _updatesPopUp->appendEntry(_("Daily"), Common::UpdateManager::kUpdateIntervalOneDay); + _updatesPopUp->appendEntry(_("Weekly"), Common::UpdateManager::kUpdateIntervalOneWeek); + _updatesPopUp->appendEntry(_("Monthly"), Common::UpdateManager::kUpdateIntervalOneMonth); +#endif + // Activate the first tab tab->setActiveTab(0); _tabWidget = tab; diff --git a/gui/options.h b/gui/options.h index 1e65bfd134..6f4046381d 100644 --- a/gui/options.h +++ b/gui/options.h @@ -236,6 +236,11 @@ protected: PopUpWidget *_autosavePeriodPopUp; StaticTextWidget *_guiLanguagePopUpDesc; PopUpWidget *_guiLanguagePopUp; + +#ifdef USE_UPDATES + StaticTextWidget *_updatesPopUpDesc; + PopUpWidget *_updatesPopUp; +#endif }; } // End of namespace GUI diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip index 1d8b8dad05..028e5f23c7 100644 Binary files a/gui/themes/scummclassic.zip and b/gui/themes/scummclassic.zip differ diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index 18c2a1f889..b8b0d9a85d 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -507,6 +507,14 @@ type = 'PopUp' /> + + + + diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index 6cc9eed6b3..7481f9ef54 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -510,6 +510,16 @@ type = 'PopUp' /> + + + + diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip index 43826abf5e..52655a510e 100644 Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index fd6a3c5cd2..8ce9a0007e 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -521,6 +521,14 @@ type = 'PopUp' /> + + + + diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index 9d8f79795c..7de2c48c60 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -508,6 +508,16 @@ type = 'PopUp' /> + + + + -- cgit v1.2.3 From 3efae7e799851f7288266e3bd91c783168d16eb3 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 29 Mar 2016 10:53:50 +0200 Subject: GUI: Store secelcted update frequency in config --- gui/options.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gui/options.cpp b/gui/options.cpp index 832f793b9f..0dd5d95651 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -1238,6 +1238,11 @@ GlobalOptionsDialog::GlobalOptionsDialog() _updatesPopUp->appendEntry(_("Daily"), Common::UpdateManager::kUpdateIntervalOneDay); _updatesPopUp->appendEntry(_("Weekly"), Common::UpdateManager::kUpdateIntervalOneWeek); _updatesPopUp->appendEntry(_("Monthly"), Common::UpdateManager::kUpdateIntervalOneMonth); + + if (ConfMan.hasKey("updates_check")) + _updatesPopUp->setSelectedTag(ConfMan.getInt("updates_check")); + else + _updatesPopUp->setSelectedTag(Common::UpdateManager::kUpdateIntervalNotSupported); #endif // Activate the first tab @@ -1378,6 +1383,10 @@ void GlobalOptionsDialog::close() { } #endif // USE_TRANSLATION +#ifdef USE_UPDATES + ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag()); +#endif + } OptionsDialog::close(); } -- cgit v1.2.3 From 0db4c879f2d5fa1c7aad2d478f0c0af0a7b2b042 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 29 Mar 2016 20:22:45 +0200 Subject: GUI: Added initial implementation for Updates opt-in wizard --- gui/module.mk | 5 +++ gui/updates-dialog.cpp | 101 +++++++++++++++++++++++++++++++++++++++++++++++++ gui/updates-dialog.h | 44 +++++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 gui/updates-dialog.cpp create mode 100644 gui/updates-dialog.h diff --git a/gui/module.mk b/gui/module.mk index bbb3def96d..9e821e71a7 100644 --- a/gui/module.mk +++ b/gui/module.mk @@ -65,5 +65,10 @@ MODULE_OBJS += \ fluidsynth-dialog.o endif +ifdef USE_UPDATES +MODULE_OBJS += \ + updates-dialog.o +endif + # Include common rules include $(srcdir)/rules.mk diff --git a/gui/updates-dialog.cpp b/gui/updates-dialog.cpp new file mode 100644 index 0000000000..23d5db95d6 --- /dev/null +++ b/gui/updates-dialog.cpp @@ -0,0 +1,101 @@ +/* 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/str.h" +#include "common/system.h" +#include "common/translation.h" +#include "gui/updates-dialog.h" +#include "gui/gui-manager.h" +#include "gui/ThemeEval.h" +#include "gui/widget.h" + +namespace GUI { + +enum { + kOkCmd = 'OK ', + kCancelCmd = 'CNCL' +}; + + +UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) { + + const int screenW = g_system->getOverlayWidth(); + const int screenH = g_system->getOverlayHeight(); + + int buttonWidth = g_gui.xmlEval()->getVar("Globals.Button.Width", 0); + int buttonHeight = g_gui.xmlEval()->getVar("Globals.Button.Height", 0); + + const char *message = _( + "ScummVM now supports automatic check for updates\n" + "which requires access to the Internet.\n" + "\n" + "Would you like to enable this feature?\n" + "(You can always enable it in the options\n" + "dialog on the Misc tab)"); + + // First, determine the size the dialog needs. For this we have to break + // down the string into lines, and taking the maximum of their widths. + // Using this, and accounting for the space the button(s) need, we can set + // the real size of the dialog + Common::Array lines; + int lineCount, okButtonPos, cancelButtonPos; + int maxlineWidth = g_gui.getFont().wordWrapText(message, screenW - 2 * 20, lines); + + _w = MAX(maxlineWidth, (2 * buttonWidth) + 10) + 20; + + lineCount = lines.size(); + + _h = 16; + _h += buttonHeight + 8; + + _h += lineCount * kLineHeight; + + // Center the dialog + _x = (screenW - _w) / 2; + _y = (screenH - _h) / 2; + + // Each line is represented by one static text item. + int y = 10; + for (int i = 0; i < lines.size(); i++) { + new StaticTextWidget(this, 10, y, maxlineWidth, kLineHeight, + lines[i], Graphics::kTextAlignCenter); + y += kLineHeight; + } + + okButtonPos = (_w - (buttonWidth * 2)) / 2; + cancelButtonPos = ((_w - (buttonWidth * 2)) / 2) + buttonWidth + 10; + + new ButtonWidget(this, okButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, "OK", 0, kOkCmd, Common::ASCII_RETURN); // Confirm dialog + new ButtonWidget(this, cancelButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, "Cancel", 0, kCancelCmd, Common::ASCII_ESCAPE); // Cancel dialog +} + +void UpdatesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { + if (cmd == kOkCmd) { + close(); + } else if (cmd == kCancelCmd) { + close(); + } else { + Dialog::handleCommand(sender, cmd, data); + } +} + +} // End of namespace GUI diff --git a/gui/updates-dialog.h b/gui/updates-dialog.h new file mode 100644 index 0000000000..fa46057229 --- /dev/null +++ b/gui/updates-dialog.h @@ -0,0 +1,44 @@ +/* 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. + * + */ + +#ifndef GUI_UPDATES_DIALOG_H +#define GUI_UPDATES_DIALOG_H + +#include "gui/dialog.h" + +namespace GUI { + +class CommandSender; + +/** + * Wizard for updates opt-in + */ +class UpdatesDialog : public Dialog { +public: + UpdatesDialog(); + + void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); +}; + +} // End of namespace GUI + +#endif -- cgit v1.2.3 From 17a8f0baddec3e0c3057a86c9f7e7d70c52e6b8e Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 30 Mar 2016 10:58:57 +0200 Subject: UPDATES: Plug updates dialog in. Launched when ScummVM is run first time with updates feature. --- base/main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/base/main.cpp b/base/main.cpp index ff441df49c..587e32804f 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -75,6 +75,9 @@ #include "gui/launcher.h" #endif +#ifdef USE_UPDATES +#include "gui/updates-dialog.h" +#endif static bool launcherDialog() { @@ -458,6 +461,13 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { // Now as the event manager is created, setup the keymapper setupKeymapper(system); +#ifdef USE_UPDATES + if (!ConfMan.hasKey("updates_check")) { + GUI::UpdatesDialog dlg; + dlg.runModal(); + } +#endif + // Unless a game was specified, show the launcher dialog if (0 == ConfMan.getActiveDomain()) launcherDialog(); -- cgit v1.2.3 From 3c4ccfc52c1843529d4570eec358e7183fa903d6 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 30 Mar 2016 11:09:32 +0200 Subject: GUI: Enhanced StaticTextWidget with font style --- gui/widget.cpp | 8 +++++--- gui/widget.h | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gui/widget.cpp b/gui/widget.cpp index e4afea0c36..11b1ed66f0 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -229,20 +229,22 @@ Common::String Widget::cleanupHotkey(const Common::String &label) { #pragma mark - -StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align, const char *tooltip) +StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align, const char *tooltip, ThemeEngine::FontStyle font) : Widget(boss, x, y, w, h, tooltip), _align(align) { setFlags(WIDGET_ENABLED); _type = kStaticTextWidget; _label = text; + _font = font; } -StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text, const char *tooltip) +StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text, const char *tooltip, ThemeEngine::FontStyle font) : Widget(boss, name, tooltip) { setFlags(WIDGET_ENABLED); _type = kStaticTextWidget; _label = text; _align = g_gui.xmlEval()->getWidgetTextHAlign(name); + _font = font; } void StaticTextWidget::setValue(int value) { @@ -270,7 +272,7 @@ void StaticTextWidget::setAlign(Graphics::TextAlign align) { void StaticTextWidget::drawWidget() { - g_gui.theme()->drawText(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, _align); + g_gui.theme()->drawText(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, _align, ThemeEngine::kTextInversionNone, 0, true, _font); } #pragma mark - diff --git a/gui/widget.h b/gui/widget.h index 7c1437de0a..4f181954b5 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -168,9 +168,10 @@ class StaticTextWidget : public Widget { protected: Common::String _label; Graphics::TextAlign _align; + ThemeEngine::FontStyle _font; public: - StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align, const char *tooltip = 0); - StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text, const char *tooltip = 0); + StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align, const char *tooltip = 0, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold); + StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text, const char *tooltip = 0, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold); void setValue(int value); void setLabel(const Common::String &label); const Common::String &getLabel() const { return _label; } -- cgit v1.2.3 From cb51af0d6d2fccc72571149a8ff15a416ca6e701 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 30 Mar 2016 11:15:57 +0200 Subject: UPDATES: Improve update dialog message --- gui/updates-dialog.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/gui/updates-dialog.cpp b/gui/updates-dialog.cpp index 23d5db95d6..7b98e4f942 100644 --- a/gui/updates-dialog.cpp +++ b/gui/updates-dialog.cpp @@ -31,8 +31,8 @@ namespace GUI { enum { - kOkCmd = 'OK ', - kCancelCmd = 'CNCL' + kYesCmd = 'YES ', + kNoCmd = 'NO ' }; @@ -48,21 +48,21 @@ UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) { "ScummVM now supports automatic check for updates\n" "which requires access to the Internet.\n" "\n" - "Would you like to enable this feature?\n" - "(You can always enable it in the options\n" - "dialog on the Misc tab)"); + "Would you like to enable this feature?"); + const char *message2 = _("(You can always enable it in the options dialog on the Misc tab)"); // First, determine the size the dialog needs. For this we have to break // down the string into lines, and taking the maximum of their widths. // Using this, and accounting for the space the button(s) need, we can set // the real size of the dialog - Common::Array lines; + Common::Array lines, lines2; int lineCount, okButtonPos, cancelButtonPos; int maxlineWidth = g_gui.getFont().wordWrapText(message, screenW - 2 * 20, lines); + int maxlineWidth2 = g_gui.getFont(ThemeEngine::kFontStyleTooltip).wordWrapText(message2, screenW - 2 * 20, lines2); - _w = MAX(maxlineWidth, (2 * buttonWidth) + 10) + 20; + _w = MAX(MAX(maxlineWidth, maxlineWidth2), (2 * buttonWidth) + 10) + 20; - lineCount = lines.size(); + lineCount = lines.size() + 1 + lines2.size(); _h = 16; _h += buttonHeight + 8; @@ -80,18 +80,23 @@ UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) { lines[i], Graphics::kTextAlignCenter); y += kLineHeight; } + for (int i = 0; i < lines2.size(); i++) { + new StaticTextWidget(this, 10, y, maxlineWidth2, kLineHeight, + lines2[i], Graphics::kTextAlignCenter, 0, ThemeEngine::kFontStyleTooltip); + y += kLineHeight; + } okButtonPos = (_w - (buttonWidth * 2)) / 2; cancelButtonPos = ((_w - (buttonWidth * 2)) / 2) + buttonWidth + 10; - new ButtonWidget(this, okButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, "OK", 0, kOkCmd, Common::ASCII_RETURN); // Confirm dialog - new ButtonWidget(this, cancelButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, "Cancel", 0, kCancelCmd, Common::ASCII_ESCAPE); // Cancel dialog + new ButtonWidget(this, okButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("Yes"), 0, kYesCmd, Common::ASCII_RETURN); // Confirm dialog + new ButtonWidget(this, cancelButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("No"), 0, kNoCmd, Common::ASCII_ESCAPE); // Cancel dialog } void UpdatesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { - if (cmd == kOkCmd) { + if (cmd == kYesCmd) { close(); - } else if (cmd == kCancelCmd) { + } else if (cmd == kNoCmd) { close(); } else { Dialog::handleCommand(sender, cmd, data); -- cgit v1.2.3 From f58b43b38a8f13c90df41bf1202f48b551b2edd5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 30 Mar 2016 14:28:25 +0200 Subject: UPDATES: Beginnings of the update frequency control --- gui/updates-dialog.cpp | 23 ++++++++++++++++------- gui/updates-dialog.h | 7 +++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gui/updates-dialog.cpp b/gui/updates-dialog.cpp index 7b98e4f942..b08f317618 100644 --- a/gui/updates-dialog.cpp +++ b/gui/updates-dialog.cpp @@ -23,10 +23,11 @@ #include "common/str.h" #include "common/system.h" #include "common/translation.h" +#include "common/updates.h" #include "gui/updates-dialog.h" #include "gui/gui-manager.h" #include "gui/ThemeEval.h" -#include "gui/widget.h" +#include "gui/widgets/popup.h" namespace GUI { @@ -56,13 +57,12 @@ UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) { // Using this, and accounting for the space the button(s) need, we can set // the real size of the dialog Common::Array lines, lines2; - int lineCount, okButtonPos, cancelButtonPos; int maxlineWidth = g_gui.getFont().wordWrapText(message, screenW - 2 * 20, lines); int maxlineWidth2 = g_gui.getFont(ThemeEngine::kFontStyleTooltip).wordWrapText(message2, screenW - 2 * 20, lines2); _w = MAX(MAX(maxlineWidth, maxlineWidth2), (2 * buttonWidth) + 10) + 20; - lineCount = lines.size() + 1 + lines2.size(); + int lineCount = lines.size() + 1 + lines2.size(); _h = 16; _h += buttonHeight + 8; @@ -86,11 +86,20 @@ UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) { y += kLineHeight; } - okButtonPos = (_w - (buttonWidth * 2)) / 2; - cancelButtonPos = ((_w - (buttonWidth * 2)) / 2) + buttonWidth + 10; + _updatesPopUpDesc = new StaticTextWidget(this, "GlobalOptions_Misc.UpdatesPopupDesc", _("Update check:"), _("How often to check ScummVM updates")); + _updatesPopUp = new PopUpWidget(this, "GlobalOptions_Misc.UpdatesPopup"); - new ButtonWidget(this, okButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("Yes"), 0, kYesCmd, Common::ASCII_RETURN); // Confirm dialog - new ButtonWidget(this, cancelButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("No"), 0, kNoCmd, Common::ASCII_ESCAPE); // Cancel dialog + _updatesPopUp->appendEntry(_("Never"), Common::UpdateManager::kUpdateIntervalNotSupported); + _updatesPopUp->appendEntry(_("Daily"), Common::UpdateManager::kUpdateIntervalOneDay); + _updatesPopUp->appendEntry(_("Weekly"), Common::UpdateManager::kUpdateIntervalOneWeek); + _updatesPopUp->appendEntry(_("Monthly"), Common::UpdateManager::kUpdateIntervalOneMonth); + + + int yesButtonPos = (_w - (buttonWidth * 2)) / 2; + int noButtonPos = ((_w - (buttonWidth * 2)) / 2) + buttonWidth + 10; + + new ButtonWidget(this, yesButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("Yes"), 0, kYesCmd, Common::ASCII_RETURN); // Confirm dialog + new ButtonWidget(this, noButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("No"), 0, kNoCmd, Common::ASCII_ESCAPE); // Cancel dialog } void UpdatesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { diff --git a/gui/updates-dialog.h b/gui/updates-dialog.h index fa46057229..8f89a8fcaf 100644 --- a/gui/updates-dialog.h +++ b/gui/updates-dialog.h @@ -28,6 +28,8 @@ namespace GUI { class CommandSender; +class PopUpWidget; +class StaticTextWidget; /** * Wizard for updates opt-in @@ -35,8 +37,13 @@ class CommandSender; class UpdatesDialog : public Dialog { public: UpdatesDialog(); + virtual ~UpdatesDialog() {} void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); + +private: + StaticTextWidget *_updatesPopUpDesc; + PopUpWidget *_updatesPopUp; }; } // End of namespace GUI -- cgit v1.2.3 From 35a44edca18cdec6c2dd484715a72d469cd0f1c3 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 30 Mar 2016 19:02:02 +0200 Subject: GUI: Implement immediate coordinate mode for PopUp widget --- gui/widgets/popup.cpp | 8 ++++++++ gui/widgets/popup.h | 1 + 2 files changed, 9 insertions(+) diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp index 6186492339..b10b4fb5fe 100644 --- a/gui/widgets/popup.cpp +++ b/gui/widgets/popup.cpp @@ -382,6 +382,14 @@ PopUpWidget::PopUpWidget(GuiObject *boss, const String &name, const char *toolti _selectedItem = -1; } +PopUpWidget::PopUpWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip) + : Widget(boss, x, y, w, h, tooltip), CommandSender(boss) { + setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_IGNORE_DRAG); + _type = kPopUpWidget; + + _selectedItem = -1; +} + void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) { if (isEnabled()) { PopUpDialog popupDialog(this, x + getAbsX(), y + getAbsY()); diff --git a/gui/widgets/popup.h b/gui/widgets/popup.h index 102c7fd258..37ddc276ad 100644 --- a/gui/widgets/popup.h +++ b/gui/widgets/popup.h @@ -58,6 +58,7 @@ protected: public: PopUpWidget(GuiObject *boss, const String &name, const char *tooltip = 0); + PopUpWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip = 0); void handleMouseDown(int x, int y, int button, int clickCount); void handleMouseWheel(int x, int y, int direction); -- cgit v1.2.3 From bd249ee32489140d4556e9107adfaaa695a84f4a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 30 Mar 2016 19:02:23 +0200 Subject: UPDATES: Made dialog functional --- gui/updates-dialog.cpp | 35 +++++++++++++++++++++++++++++------ gui/updates-dialog.h | 5 +++++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/gui/updates-dialog.cpp b/gui/updates-dialog.cpp index b08f317618..fe963e8623 100644 --- a/gui/updates-dialog.cpp +++ b/gui/updates-dialog.cpp @@ -24,6 +24,7 @@ #include "common/system.h" #include "common/translation.h" #include "common/updates.h" +#include "common/config-manager.h" #include "gui/updates-dialog.h" #include "gui/gui-manager.h" #include "gui/ThemeEval.h" @@ -64,7 +65,7 @@ UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) { int lineCount = lines.size() + 1 + lines2.size(); - _h = 16; + _h = 16 + 3 * kLineHeight; _h += buttonHeight + 8; _h += lineCount * kLineHeight; @@ -86,26 +87,48 @@ UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) { y += kLineHeight; } - _updatesPopUpDesc = new StaticTextWidget(this, "GlobalOptions_Misc.UpdatesPopupDesc", _("Update check:"), _("How often to check ScummVM updates")); - _updatesPopUp = new PopUpWidget(this, "GlobalOptions_Misc.UpdatesPopup"); + y += kLineHeight; + _updatesPopUpDesc = new StaticTextWidget(this, 10, y, _w, kLineHeight, _("How often you would like to check for updates?"), Graphics::kTextAlignCenter); + y += kLineHeight + 3; + + _updatesPopUp = new PopUpWidget(this, 10, y, _w - 20, g_gui.xmlEval()->getVar("Globals.PopUp.Height", kLineHeight)); _updatesPopUp->appendEntry(_("Never"), Common::UpdateManager::kUpdateIntervalNotSupported); _updatesPopUp->appendEntry(_("Daily"), Common::UpdateManager::kUpdateIntervalOneDay); _updatesPopUp->appendEntry(_("Weekly"), Common::UpdateManager::kUpdateIntervalOneWeek); _updatesPopUp->appendEntry(_("Monthly"), Common::UpdateManager::kUpdateIntervalOneMonth); + _updatesPopUp->setSelectedTag(Common::UpdateManager::kUpdateIntervalOneWeek); + + _updatesPopUp->setVisible(false); + _updatesPopUpDesc->setVisible(false); int yesButtonPos = (_w - (buttonWidth * 2)) / 2; int noButtonPos = ((_w - (buttonWidth * 2)) / 2) + buttonWidth + 10; - new ButtonWidget(this, yesButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("Yes"), 0, kYesCmd, Common::ASCII_RETURN); // Confirm dialog - new ButtonWidget(this, noButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("No"), 0, kNoCmd, Common::ASCII_ESCAPE); // Cancel dialog + _yesButton = new ButtonWidget(this, yesButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("Yes"), 0, kYesCmd, Common::ASCII_RETURN); + _noButton = new ButtonWidget(this, noButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("No"), 0, kNoCmd, Common::ASCII_ESCAPE); + + _state = 0; } void UpdatesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { if (cmd == kYesCmd) { - close(); + if (_state == 0) { + _yesButton->setLabel(_("Proceed")); + _noButton->setLabel(_("Cancel")); + _updatesPopUp->setVisible(true); + _updatesPopUpDesc->setVisible(true); + + _state = 1; + + draw(); + } else { + ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag()); + close(); + } } else if (cmd == kNoCmd) { + ConfMan.setInt("updates_check", Common::UpdateManager::kUpdateIntervalNotSupported); close(); } else { Dialog::handleCommand(sender, cmd, data); diff --git a/gui/updates-dialog.h b/gui/updates-dialog.h index 8f89a8fcaf..b0626dfd5f 100644 --- a/gui/updates-dialog.h +++ b/gui/updates-dialog.h @@ -28,6 +28,7 @@ namespace GUI { class CommandSender; +class ButtonWidget; class PopUpWidget; class StaticTextWidget; @@ -44,6 +45,10 @@ public: private: StaticTextWidget *_updatesPopUpDesc; PopUpWidget *_updatesPopUp; + ButtonWidget *_yesButton; + ButtonWidget *_noButton; + + int _state; }; } // End of namespace GUI -- cgit v1.2.3 From 73784c6a8488fef1ca7e6971a12868735d606de7 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 30 Mar 2016 19:27:59 +0200 Subject: UPDATES: Made interval set/get functions accept normal integers --- backends/updates/macosx/macosx-updates.h | 4 ++-- backends/updates/macosx/macosx-updates.mm | 4 ++-- common/updates.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backends/updates/macosx/macosx-updates.h b/backends/updates/macosx/macosx-updates.h index fd2d1f46f5..9f541ad02a 100644 --- a/backends/updates/macosx/macosx-updates.h +++ b/backends/updates/macosx/macosx-updates.h @@ -39,8 +39,8 @@ public: virtual void setAutomaticallyChecksForUpdates(UpdateState state); virtual UpdateState getAutomaticallyChecksForUpdates(); - virtual void setUpdateCheckInterval(UpdateInterval interval); - virtual UpdateInterval getUpdateCheckInterval(); + virtual void setUpdateCheckInterval(int interval); + virtual int getUpdateCheckInterval(); }; #endif diff --git a/backends/updates/macosx/macosx-updates.mm b/backends/updates/macosx/macosx-updates.mm index a94f1c21fd..c13f05f1c6 100644 --- a/backends/updates/macosx/macosx-updates.mm +++ b/backends/updates/macosx/macosx-updates.mm @@ -103,14 +103,14 @@ Common::UpdateManager::UpdateState MacOSXUpdateManager::getAutomaticallyChecksFo return kUpdateStateDisabled; } -void MacOSXUpdateManager::setUpdateCheckInterval(UpdateInterval interval) { +void MacOSXUpdateManager::setUpdateCheckInterval(int interval) { if (interval == kUpdateIntervalNotSupported) return; [sparkleUpdater setUpdateCheckInterval:(NSTimeInterval)interval]; } -Common::UpdateManager::UpdateInterval MacOSXUpdateManager::getUpdateCheckInterval() { +int MacOSXUpdateManager::getUpdateCheckInterval() { // This is kind of a hack but necessary, as the value stored by Sparkle // might have been changed outside of ScummVM (in which case we return the // default interval of one day) diff --git a/common/updates.h b/common/updates.h index 4c30987c38..8863a58931 100644 --- a/common/updates.h +++ b/common/updates.h @@ -85,14 +85,14 @@ public: * * @param interval The interval. */ - virtual void setUpdateCheckInterval(UpdateInterval interval) {} + virtual void setUpdateCheckInterval(int interval) {} /** * Gets the update check interval. * * @return the update check interval. */ - virtual UpdateInterval getUpdateCheckInterval() { return kUpdateIntervalNotSupported; } + virtual int getUpdateCheckInterval() { return kUpdateIntervalNotSupported; } }; } // End of namespace Common -- cgit v1.2.3 From 47985debe12a77513843f672df912d340cca5c7c Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 30 Mar 2016 19:28:24 +0200 Subject: UPDATES: Hook dialogs to UpdateManager --- gui/options.cpp | 9 +++++++++ gui/updates-dialog.cpp | 19 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gui/options.cpp b/gui/options.cpp index 0dd5d95651..96db1d74ce 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -1385,6 +1385,15 @@ void GlobalOptionsDialog::close() { #ifdef USE_UPDATES ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag()); + + if (g_system->getUpdateManager()) { + if (_updatesPopUp->getSelectedTag() == Common::UpdateManager::kUpdateIntervalNotSupported) { + g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateDisabled); + } else { + g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateEnabled); + g_system->getUpdateManager()->setUpdateCheckInterval(_updatesPopUp->getSelectedTag()); + } + } #endif } diff --git a/gui/updates-dialog.cpp b/gui/updates-dialog.cpp index fe963e8623..56d8085c31 100644 --- a/gui/updates-dialog.cpp +++ b/gui/updates-dialog.cpp @@ -20,11 +20,11 @@ * */ -#include "common/str.h" #include "common/system.h" #include "common/translation.h" #include "common/updates.h" #include "common/config-manager.h" + #include "gui/updates-dialog.h" #include "gui/gui-manager.h" #include "gui/ThemeEval.h" @@ -106,8 +106,10 @@ UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) { int yesButtonPos = (_w - (buttonWidth * 2)) / 2; int noButtonPos = ((_w - (buttonWidth * 2)) / 2) + buttonWidth + 10; - _yesButton = new ButtonWidget(this, yesButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("Yes"), 0, kYesCmd, Common::ASCII_RETURN); - _noButton = new ButtonWidget(this, noButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("No"), 0, kNoCmd, Common::ASCII_ESCAPE); + _yesButton = new ButtonWidget(this, yesButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, + _("Yes"), 0, kYesCmd, Common::ASCII_RETURN); + _noButton = new ButtonWidget(this, noButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, + _("No"), 0, kNoCmd, Common::ASCII_ESCAPE); _state = 0; } @@ -125,10 +127,21 @@ void UpdatesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data draw(); } else { ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag()); + + if (g_system->getUpdateManager()) { + if (_updatesPopUp->getSelectedTag() == Common::UpdateManager::kUpdateIntervalNotSupported) { + g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateDisabled); + } else { + g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateEnabled); + g_system->getUpdateManager()->setUpdateCheckInterval(_updatesPopUp->getSelectedTag()); + } + } close(); } } else if (cmd == kNoCmd) { ConfMan.setInt("updates_check", Common::UpdateManager::kUpdateIntervalNotSupported); + g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateDisabled); + close(); } else { Dialog::handleCommand(sender, cmd, data); -- cgit v1.2.3 From 556b7ffa29fc7f98904fce4e2fdeb07a5369558d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 31 Mar 2016 09:09:23 +0200 Subject: UPDATES: Merge two steps into one --- gui/updates-dialog.cpp | 51 +++++++++++++++++++++++--------------------------- gui/updates-dialog.h | 6 ++---- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/gui/updates-dialog.cpp b/gui/updates-dialog.cpp index 56d8085c31..260bc590d6 100644 --- a/gui/updates-dialog.cpp +++ b/gui/updates-dialog.cpp @@ -34,7 +34,8 @@ namespace GUI { enum { kYesCmd = 'YES ', - kNoCmd = 'NO ' + kNoCmd = 'NO ', + kCheckBoxCmd = 'CHK ' }; @@ -88,7 +89,8 @@ UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) { } y += kLineHeight; - _updatesPopUpDesc = new StaticTextWidget(this, 10, y, _w, kLineHeight, _("How often you would like to check for updates?"), Graphics::kTextAlignCenter); + _updatesCheckbox = new CheckboxWidget(this, 10, y, _w, kLineHeight, _("Check for updates automatically"), 0, kCheckBoxCmd); + y += kLineHeight + 3; _updatesPopUp = new PopUpWidget(this, 10, y, _w - 20, g_gui.xmlEval()->getVar("Globals.PopUp.Height", kLineHeight)); @@ -100,49 +102,42 @@ UpdatesDialog::UpdatesDialog() : Dialog(30, 20, 260, 124) { _updatesPopUp->setSelectedTag(Common::UpdateManager::kUpdateIntervalOneWeek); - _updatesPopUp->setVisible(false); - _updatesPopUpDesc->setVisible(false); - int yesButtonPos = (_w - (buttonWidth * 2)) / 2; int noButtonPos = ((_w - (buttonWidth * 2)) / 2) + buttonWidth + 10; _yesButton = new ButtonWidget(this, yesButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, - _("Yes"), 0, kYesCmd, Common::ASCII_RETURN); + _("Proceed"), 0, kYesCmd, Common::ASCII_RETURN); _noButton = new ButtonWidget(this, noButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, - _("No"), 0, kNoCmd, Common::ASCII_ESCAPE); + _("Cancel"), 0, kNoCmd, Common::ASCII_ESCAPE); - _state = 0; + _updatesPopUp->setEnabled(false); + _yesButton->setEnabled(false); } void UpdatesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { if (cmd == kYesCmd) { - if (_state == 0) { - _yesButton->setLabel(_("Proceed")); - _noButton->setLabel(_("Cancel")); - _updatesPopUp->setVisible(true); - _updatesPopUpDesc->setVisible(true); - - _state = 1; - - draw(); - } else { - ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag()); - - if (g_system->getUpdateManager()) { - if (_updatesPopUp->getSelectedTag() == Common::UpdateManager::kUpdateIntervalNotSupported) { - g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateDisabled); - } else { - g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateEnabled); - g_system->getUpdateManager()->setUpdateCheckInterval(_updatesPopUp->getSelectedTag()); - } + ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag()); + + if (g_system->getUpdateManager()) { + if (_updatesCheckbox->getState() == false || + _updatesPopUp->getSelectedTag() == Common::UpdateManager::kUpdateIntervalNotSupported) { + g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateDisabled); + } else { + g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateEnabled); + g_system->getUpdateManager()->setUpdateCheckInterval(_updatesPopUp->getSelectedTag()); } - close(); } + close(); } else if (cmd == kNoCmd) { ConfMan.setInt("updates_check", Common::UpdateManager::kUpdateIntervalNotSupported); g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateDisabled); close(); + } else if (cmd == kCheckBoxCmd) { + _updatesPopUp->setEnabled(_updatesCheckbox->getState()); + _yesButton->setEnabled(_updatesCheckbox->getState()); + + draw(); } else { Dialog::handleCommand(sender, cmd, data); } diff --git a/gui/updates-dialog.h b/gui/updates-dialog.h index b0626dfd5f..9c429c960c 100644 --- a/gui/updates-dialog.h +++ b/gui/updates-dialog.h @@ -27,10 +27,10 @@ namespace GUI { +class CheckboxWidget; class CommandSender; class ButtonWidget; class PopUpWidget; -class StaticTextWidget; /** * Wizard for updates opt-in @@ -43,12 +43,10 @@ public: void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); private: - StaticTextWidget *_updatesPopUpDesc; PopUpWidget *_updatesPopUp; ButtonWidget *_yesButton; ButtonWidget *_noButton; - - int _state; + CheckboxWidget *_updatesCheckbox; }; } // End of namespace GUI -- cgit v1.2.3 From 08e7f0ab9179691fe869bab8fee5585364c846c7 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 31 Mar 2016 09:31:57 +0200 Subject: UPDATES: Got rid of hardcoded update intervals list --- common/module.mk | 5 +++++ common/updates.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ common/updates.h | 9 +++++--- gui/options.cpp | 10 +++++---- gui/updates-dialog.cpp | 10 +++++---- 5 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 common/updates.cpp diff --git a/common/module.mk b/common/module.mk index 67c498df00..570040c8e1 100644 --- a/common/module.mk +++ b/common/module.mk @@ -56,5 +56,10 @@ MODULE_OBJS += \ recorderfile.o endif +ifdef USE_UPDATES +MODULE_OBJS += \ + updates.o +endif + # Include common rules include $(srcdir)/rules.mk diff --git a/common/updates.cpp b/common/updates.cpp new file mode 100644 index 0000000000..0318864881 --- /dev/null +++ b/common/updates.cpp @@ -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 _(""); + } +} + +} // End of namespace Common diff --git a/common/updates.h b/common/updates.h index 8863a58931..986d56ce24 100644 --- a/common/updates.h +++ b/common/updates.h @@ -20,8 +20,8 @@ * */ -#ifndef BACKENDS_UPDATES_ABSTRACT_H -#define BACKENDS_UPDATES_ABSTRACT_H +#ifndef COMMON_UPDATES_H +#define COMMON_UPDATES_H #if defined(USE_UPDATES) @@ -93,10 +93,13 @@ public: * @return the update check interval. */ virtual int getUpdateCheckInterval() { return kUpdateIntervalNotSupported; } + + static const int *getUpdateIntervals(); + static const char *updateIntervalToString(int interval); }; } // End of namespace Common #endif -#endif // BACKENDS_UPDATES_ABSTRACT_H +#endif // COMMON_UPDATES_H diff --git a/gui/options.cpp b/gui/options.cpp index 96db1d74ce..06f79e94b7 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -1234,10 +1234,12 @@ GlobalOptionsDialog::GlobalOptionsDialog() _updatesPopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Misc.UpdatesPopupDesc", _("Update check:"), _("How often to check ScummVM updates")); _updatesPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.UpdatesPopup"); - _updatesPopUp->appendEntry(_("Never"), Common::UpdateManager::kUpdateIntervalNotSupported); - _updatesPopUp->appendEntry(_("Daily"), Common::UpdateManager::kUpdateIntervalOneDay); - _updatesPopUp->appendEntry(_("Weekly"), Common::UpdateManager::kUpdateIntervalOneWeek); - _updatesPopUp->appendEntry(_("Monthly"), Common::UpdateManager::kUpdateIntervalOneMonth); + const int *vals = Common::UpdateManager::getUpdateIntervals(); + + while (*vals != -1) { + _updatesPopUp->appendEntry(Common::UpdateManager::updateIntervalToString(*vals), *vals); + vals++; + } if (ConfMan.hasKey("updates_check")) _updatesPopUp->setSelectedTag(ConfMan.getInt("updates_check")); diff --git a/gui/updates-dialog.cpp b/gui/updates-dialog.cpp index 260bc590d6..960b3f397a 100644 --- a/gui/updates-dialog.cpp +++ b/gui/updates-dialog.cpp @@ -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->appendEntry(_("Never"), Common::UpdateManager::kUpdateIntervalNotSupported); - _updatesPopUp->appendEntry(_("Daily"), Common::UpdateManager::kUpdateIntervalOneDay); - _updatesPopUp->appendEntry(_("Weekly"), Common::UpdateManager::kUpdateIntervalOneWeek); - _updatesPopUp->appendEntry(_("Monthly"), Common::UpdateManager::kUpdateIntervalOneMonth); + const int *vals = Common::UpdateManager::getUpdateIntervals(); + + while (*vals != -1) { + _updatesPopUp->appendEntry(Common::UpdateManager::updateIntervalToString(*vals), *vals); + vals++; + } _updatesPopUp->setSelectedTag(Common::UpdateManager::kUpdateIntervalOneWeek); -- cgit v1.2.3 From 82963f7446f336fe71e71f35fa39768aed059541 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 31 Mar 2016 09:38:28 +0200 Subject: UPDATES: Read values from config file in MacOS X update manager --- backends/updates/macosx/macosx-updates.mm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backends/updates/macosx/macosx-updates.mm b/backends/updates/macosx/macosx-updates.mm index c13f05f1c6..6f99e71ccf 100644 --- a/backends/updates/macosx/macosx-updates.mm +++ b/backends/updates/macosx/macosx-updates.mm @@ -27,6 +27,7 @@ #ifdef USE_SPARKLE #include "common/translation.h" +#include "common/config-manager.h" #include #include @@ -74,11 +75,13 @@ MacOSXUpdateManager::MacOSXUpdateManager() { // Finally give up our references to the objects [menuItem release]; - // Enable automatic update checking once a day (alternatively use - // checkForUpdates() here to check for updates on every startup) - // TODO: Should be removed when an update settings gui is implemented - setAutomaticallyChecksForUpdates(kUpdateStateEnabled); - setUpdateCheckInterval(kUpdateIntervalOneDay); + if (!ConfMan.hasKey("updates_check") + || ConfMan.getInt("updates_check") == Common::UpdateManager::kUpdateIntervalNotSupported) { + setAutomaticallyChecksForUpdates(kUpdateStateDisabled); + } else { + setAutomaticallyChecksForUpdates(kUpdateStateEnabled); + setUpdateCheckInterval(ConfMan.getInt("updates_check")); + } } MacOSXUpdateManager::~MacOSXUpdateManager() { -- cgit v1.2.3 From 2cde45fe6d94211d005cd32e7368769f8524bdec Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 31 Mar 2016 13:59:01 +0200 Subject: UPDATES: Implement Check now button in Options --- gui/options.cpp | 11 ++++++++++- gui/themes/scummclassic.zip | Bin 111931 -> 112109 bytes gui/themes/scummclassic/classic_layout.stx | 3 +++ gui/themes/scummclassic/classic_layout_lowres.stx | 3 +++ gui/themes/scummmodern.zip | Bin 1487717 -> 1487883 bytes gui/themes/scummmodern/scummmodern_layout.stx | 3 +++ .../scummmodern/scummmodern_layout_lowres.stx | 3 +++ 7 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gui/options.cpp b/gui/options.cpp index 06f79e94b7..c4a82982b2 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -62,7 +62,8 @@ enum { kChooseExtraDirCmd = 'chex', kExtraPathClearCmd = 'clex', kChoosePluginsDirCmd = 'chpl', - kChooseThemeCmd = 'chtf' + kChooseThemeCmd = 'chtf', + kUpdatesCheckCmd = 'updc' }; enum { @@ -1245,6 +1246,8 @@ GlobalOptionsDialog::GlobalOptionsDialog() _updatesPopUp->setSelectedTag(ConfMan.getInt("updates_check")); else _updatesPopUp->setSelectedTag(Common::UpdateManager::kUpdateIntervalNotSupported); + + new ButtonWidget(tab, "GlobalOptions_Misc.UpdatesCheckManuallyButton", _("Check now"), 0, kUpdatesCheckCmd); #endif // Activate the first tab @@ -1518,6 +1521,12 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 case kFluidSynthSettingsCmd: _fluidSynthSettingsDialog->runModal(); break; +#endif +#ifdef USE_UPDATES + case kUpdatesCheckCmd: + if (g_system->getUpdateManager()) + g_system->getUpdateManager()->checkForUpdates(); + break; #endif default: OptionsDialog::handleCommand(sender, cmd, data); diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip index 028e5f23c7..43fcea12fd 100644 Binary files a/gui/themes/scummclassic.zip and b/gui/themes/scummclassic.zip differ diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index b8b0d9a85d..65724d9faf 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -514,6 +514,9 @@ + + + + " "" +"" +"" +"" +"" +"" "" @@ -2365,6 +2376,19 @@ const char *defaultXML1 = "" "type='PopUp' " "/>" "" +"" +"" +"" +"" +"" "" -- cgit v1.2.3 From 33dc840d2f580ac9bd9d4634279294621692bafd Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 31 Mar 2016 15:34:50 +0200 Subject: UPDATES: Normalize update intervals at setting --- backends/updates/macosx/macosx-updates.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backends/updates/macosx/macosx-updates.mm b/backends/updates/macosx/macosx-updates.mm index 6f99e71ccf..6c7ed03b52 100644 --- a/backends/updates/macosx/macosx-updates.mm +++ b/backends/updates/macosx/macosx-updates.mm @@ -110,6 +110,17 @@ 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; + [sparkleUpdater setUpdateCheckInterval:(NSTimeInterval)interval]; } -- cgit v1.2.3 From a4bf64fecde9ee3ce6d0f1ef785151f6489f7643 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 31 Mar 2016 15:38:00 +0200 Subject: UPDATES: Normalize updates_check value --- gui/options.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gui/options.cpp b/gui/options.cpp index c4a82982b2..9e8036b68f 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -1397,6 +1397,8 @@ 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 -- cgit v1.2.3 From 8d6fdaa46fce3090d7b381a231174f6929802788 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 1 Apr 2016 21:10:28 +0200 Subject: I18N: Add update files to POTFILES --- po/POTFILES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/po/POTFILES b/po/POTFILES index 49f3b6c372..dc4a19da2e 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -19,12 +19,14 @@ gui/recorderdialog.cpp gui/saveload-dialog.cpp gui/themebrowser.cpp gui/ThemeEngine.cpp +gui/updates-dialog.cpp gui/widget.cpp base/main.cpp common/error.cpp common/rendermode.cpp +common/updates.cpp engines/advancedDetector.cpp engines/dialogs.cpp -- cgit v1.2.3 From 14478a65f179318f0e269f10d8bfd77174d73cb1 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 1 Apr 2016 21:19:15 +0200 Subject: UPDATES: Added documentation to new methods --- common/updates.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/updates.h b/common/updates.h index 986d56ce24..fa6f79fb91 100644 --- a/common/updates.h +++ b/common/updates.h @@ -94,7 +94,19 @@ public: */ virtual int getUpdateCheckInterval() { return kUpdateIntervalNotSupported; } + /** + * Returns list of supported uptate intervals. + * Ending with '-1' which is not acceptable value. + * + * @return list of integer values representing update intervals in seconds. + */ static const int *getUpdateIntervals(); + + /** + * Returns string representation of a given interval. + * + * @return pointer to localized string of given interval. + */ static const char *updateIntervalToString(int interval); }; -- cgit v1.2.3 From a743ec2e07ccada0286085ecec54f4d87ed49d44 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 1 Apr 2016 21:29:29 +0200 Subject: UPDATES: Implement and use method for normalizing interval value to accepted values --- backends/updates/macosx/macosx-updates.mm | 13 ++----------- common/updates.cpp | 10 ++++++++++ common/updates.h | 9 +++++++++ gui/options.cpp | 4 +--- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/backends/updates/macosx/macosx-updates.mm b/backends/updates/macosx/macosx-updates.mm index 6c7ed03b52..fc967f8fec 100644 --- a/backends/updates/macosx/macosx-updates.mm +++ b/backends/updates/macosx/macosx-updates.mm @@ -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]; } diff --git a/common/updates.cpp b/common/updates.cpp index 0318864881..552324ef5a 100644 --- a/common/updates.cpp +++ b/common/updates.cpp @@ -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: diff --git a/common/updates.h b/common/updates.h index fa6f79fb91..65eb5ac095 100644 --- a/common/updates.h +++ b/common/updates.h @@ -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 diff --git a/gui/options.cpp b/gui/options.cpp index 9e8036b68f..c6bbde7abf 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -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 -- cgit v1.2.3 From 5baa657f2586ec9596768920861f1645dd5a4856 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 1 Apr 2016 21:32:16 +0200 Subject: UPDATES: Remove an unneeded check --- gui/options.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gui/options.cpp b/gui/options.cpp index c6bbde7abf..ecd1607e1b 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -1242,10 +1242,7 @@ GlobalOptionsDialog::GlobalOptionsDialog() vals++; } - if (ConfMan.hasKey("updates_check")) - _updatesPopUp->setSelectedTag(Common::UpdateManager::normalizeInterval(ConfMan.getInt("updates_check"))); - else - _updatesPopUp->setSelectedTag(Common::UpdateManager::kUpdateIntervalNotSupported); + _updatesPopUp->setSelectedTag(Common::UpdateManager::normalizeInterval(ConfMan.getInt("updates_check"))); new ButtonWidget(tab, "GlobalOptions_Misc.UpdatesCheckManuallyButton", _("Check now"), 0, kUpdatesCheckCmd); #endif -- cgit v1.2.3