diff options
-rw-r--r-- | backends/updates/macosx/macosx-updates.h | 4 | ||||
-rw-r--r-- | backends/updates/macosx/macosx-updates.mm | 19 | ||||
-rw-r--r-- | base/main.cpp | 10 | ||||
-rw-r--r-- | common/module.mk | 5 | ||||
-rw-r--r-- | common/updates.cpp | 66 | ||||
-rw-r--r-- | common/updates.h | 34 | ||||
-rw-r--r-- | gui/module.mk | 5 | ||||
-rw-r--r-- | gui/options.cpp | 39 | ||||
-rw-r--r-- | gui/options.h | 5 | ||||
-rw-r--r-- | gui/themes/default.inc | 24 | ||||
-rw-r--r-- | gui/themes/scummclassic.zip | bin | 111410 -> 112109 bytes | |||
-rw-r--r-- | gui/themes/scummclassic/classic_layout.stx | 11 | ||||
-rw-r--r-- | gui/themes/scummclassic/classic_layout_lowres.stx | 13 | ||||
-rw-r--r-- | gui/themes/scummmodern.zip | bin | 1487187 -> 1487883 bytes | |||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout.stx | 11 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout_lowres.stx | 13 | ||||
-rw-r--r-- | gui/updates-dialog.cpp | 148 | ||||
-rw-r--r-- | gui/updates-dialog.h | 54 | ||||
-rw-r--r-- | gui/widget.cpp | 8 | ||||
-rw-r--r-- | gui/widget.h | 5 | ||||
-rw-r--r-- | gui/widgets/popup.cpp | 8 | ||||
-rw-r--r-- | gui/widgets/popup.h | 1 | ||||
-rw-r--r-- | po/POTFILES | 2 |
23 files changed, 465 insertions, 20 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..fc967f8fec 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 <Cocoa/Cocoa.h> #include <Sparkle/Sparkle.h> @@ -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(normalizeInterval(ConfMan.getInt("updates_check"))); + } } MacOSXUpdateManager::~MacOSXUpdateManager() { @@ -103,14 +106,16 @@ Common::UpdateManager::UpdateState MacOSXUpdateManager::getAutomaticallyChecksFo return kUpdateStateDisabled; } -void MacOSXUpdateManager::setUpdateCheckInterval(UpdateInterval interval) { +void MacOSXUpdateManager::setUpdateCheckInterval(int interval) { if (interval == kUpdateIntervalNotSupported) return; + interval = normalizeInterval(interval); + [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/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(); 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..552324ef5a --- /dev/null +++ b/common/updates.cpp @@ -0,0 +1,66 @@ +/* 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; +} + +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: + return _("Never"); + case kUpdateIntervalOneDay: + return _("Daily"); + case kUpdateIntervalOneWeek: + return _("Weekly"); + case kUpdateIntervalOneMonth: + return _("Monthly"); + default: + return _("<Bad value>"); + } +} + +} // End of namespace Common diff --git a/common/updates.h b/common/updates.h index 4c30987c38..65eb5ac095 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) @@ -85,18 +85,42 @@ 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; } + + /** + * 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. + * + * @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 #endif -#endif // BACKENDS_UPDATES_ABSTRACT_H +#endif // COMMON_UPDATES_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/options.cpp b/gui/options.cpp index ba247e5f15..ecd1607e1b 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" @@ -61,7 +62,8 @@ enum { kChooseExtraDirCmd = 'chex', kExtraPathClearCmd = 'clex', kChoosePluginsDirCmd = 'chpl', - kChooseThemeCmd = 'chtf' + kChooseThemeCmd = 'chtf', + kUpdatesCheckCmd = 'updc' }; enum { @@ -1229,6 +1231,22 @@ 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"); + + 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"))); + + new ButtonWidget(tab, "GlobalOptions_Misc.UpdatesCheckManuallyButton", _("Check now"), 0, kUpdatesCheckCmd); +#endif + // Activate the first tab tab->setActiveTab(0); _tabWidget = tab; @@ -1367,6 +1385,19 @@ void GlobalOptionsDialog::close() { } #endif // USE_TRANSLATION +#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 + } OptionsDialog::close(); } @@ -1488,6 +1519,12 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 _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/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/default.inc b/gui/themes/default.inc index e367bcb3c7..a23e2f4c30 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -1076,6 +1076,17 @@ const char *defaultXML1 = "<?xml version = '1.0'?>" "type='PopUp' " "/>" "</layout>" +"<layout type='horizontal' padding='0,0,0,0' spacing='10' center='true'>" +"<widget name='UpdatesPopupDesc' " +"type='OptionsLabel' " +"/>" +"<widget name='UpdatesPopup' " +"type='PopUp' " +"/>" +"<widget name='UpdatesCheckManuallyButton' " +"type='Button' " +"/>" +"</layout>" "<widget name='KeysButton' " "type='Button' " "/>" @@ -2365,6 +2376,19 @@ const char *defaultXML1 = "<?xml version = '1.0'?>" "type='PopUp' " "/>" "</layout>" +"<layout type='horizontal' padding='0,0,0,0' spacing='6' center='true'>" +"<widget name='UpdatesPopupDesc' " +"width='80' " +"height='Globals.Line.Height' " +"textalign='right' " +"/>" +"<widget name='UpdatesPopup' " +"type='PopUp' " +"/>" +"<widget name='UpdatesCheckManuallyButton' " +"type='Button' " +"/>" +"</layout>" "<widget name='KeysButton' " "type='Button' " "/>" diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip Binary files differindex 1d8b8dad05..43fcea12fd 100644 --- a/gui/themes/scummclassic.zip +++ b/gui/themes/scummclassic.zip diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index 18c2a1f889..65724d9faf 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -507,6 +507,17 @@ type = 'PopUp' /> </layout> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'> + <widget name = 'UpdatesPopupDesc' + type = 'OptionsLabel' + /> + <widget name = 'UpdatesPopup' + type = 'PopUp' + /> + <widget name = 'UpdatesCheckManuallyButton' + type = 'Button' + /> + </layout> <widget name='KeysButton' type='Button' /> diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index 6cc9eed6b3..f73f6e864b 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -510,6 +510,19 @@ type = 'PopUp' /> </layout> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'> + <widget name = 'UpdatesPopupDesc' + width = '80' + height = 'Globals.Line.Height' + textalign = 'right' + /> + <widget name = 'UpdatesPopup' + type = 'PopUp' + /> + <widget name = 'UpdatesCheckManuallyButton' + type = 'Button' + /> + </layout> <widget name='KeysButton' type='Button' /> diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip Binary files differindex 43826abf5e..70f7672c57 100644 --- a/gui/themes/scummmodern.zip +++ b/gui/themes/scummmodern.zip diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index fd6a3c5cd2..c73ffa1f08 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -521,6 +521,17 @@ type = 'PopUp' /> </layout> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'> + <widget name = 'UpdatesPopupDesc' + type = 'OptionsLabel' + /> + <widget name = 'UpdatesPopup' + type = 'PopUp' + /> + <widget name = 'UpdatesCheckManuallyButton' + type = 'Button' + /> + </layout> <widget name='KeysButton' type='Button' /> diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index 9d8f79795c..43ec0cdee1 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -508,6 +508,19 @@ type = 'PopUp' /> </layout> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'> + <widget name = 'UpdatesPopupDesc' + width = '80' + height = 'Globals.Line.Height' + textalign = 'right' + /> + <widget name = 'UpdatesPopup' + type = 'PopUp' + /> + <widget name = 'UpdatesCheckManuallyButton' + type = 'Button' + /> + </layout> <widget name='KeysButton' type='Button' /> diff --git a/gui/updates-dialog.cpp b/gui/updates-dialog.cpp new file mode 100644 index 0000000000..960b3f397a --- /dev/null +++ b/gui/updates-dialog.cpp @@ -0,0 +1,148 @@ +/* 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/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" +#include "gui/widgets/popup.h" + +namespace GUI { + +enum { + kYesCmd = 'YES ', + kNoCmd = 'NO ', + kCheckBoxCmd = 'CHK ' +}; + + +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?"); + 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<Common::String> lines, lines2; + 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; + + int lineCount = lines.size() + 1 + lines2.size(); + + _h = 16 + 3 * kLineHeight; + _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; + } + for (int i = 0; i < lines2.size(); i++) { + new StaticTextWidget(this, 10, y, maxlineWidth2, kLineHeight, + lines2[i], Graphics::kTextAlignCenter, 0, ThemeEngine::kFontStyleTooltip); + y += kLineHeight; + } + + y += kLineHeight; + _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)); + + const int *vals = Common::UpdateManager::getUpdateIntervals(); + + while (*vals != -1) { + _updatesPopUp->appendEntry(Common::UpdateManager::updateIntervalToString(*vals), *vals); + vals++; + } + + _updatesPopUp->setSelectedTag(Common::UpdateManager::kUpdateIntervalOneWeek); + + int yesButtonPos = (_w - (buttonWidth * 2)) / 2; + int noButtonPos = ((_w - (buttonWidth * 2)) / 2) + buttonWidth + 10; + + _yesButton = new ButtonWidget(this, yesButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, + _("Proceed"), 0, kYesCmd, Common::ASCII_RETURN); + _noButton = new ButtonWidget(this, noButtonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, + _("Cancel"), 0, kNoCmd, Common::ASCII_ESCAPE); + + _updatesPopUp->setEnabled(false); + _yesButton->setEnabled(false); +} + +void UpdatesDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { + if (cmd == kYesCmd) { + 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(); + } 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); + } +} + +} // End of namespace GUI diff --git a/gui/updates-dialog.h b/gui/updates-dialog.h new file mode 100644 index 0000000000..9c429c960c --- /dev/null +++ b/gui/updates-dialog.h @@ -0,0 +1,54 @@ +/* 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 CheckboxWidget; +class CommandSender; +class ButtonWidget; +class PopUpWidget; + +/** + * Wizard for updates opt-in + */ +class UpdatesDialog : public Dialog { +public: + UpdatesDialog(); + virtual ~UpdatesDialog() {} + + void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); + +private: + PopUpWidget *_updatesPopUp; + ButtonWidget *_yesButton; + ButtonWidget *_noButton; + CheckboxWidget *_updatesCheckbox; +}; + +} // End of namespace GUI + +#endif 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; } 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); 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 |