aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/dialogs.h60
-rw-r--r--common/system.cpp9
-rw-r--r--common/system.h23
-rwxr-xr-xconfigure29
-rw-r--r--devtools/create_project/create_project.cpp1
5 files changed, 122 insertions, 0 deletions
diff --git a/common/dialogs.h b/common/dialogs.h
new file mode 100644
index 0000000000..70c4837aa5
--- /dev/null
+++ b/common/dialogs.h
@@ -0,0 +1,60 @@
+/* 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 COMMON_DIALOG_MANAGER_H
+#define COMMON_DIALOG_MANAGER_H
+
+#include "common/scummsys.h"
+#include "common/str.h"
+
+#if defined(USE_SYSDIALOGS)
+
+namespace Common {
+
+/**
+ * The DialogManager allows GUI code to interact with native system dialogs.
+ */
+class DialogManager {
+public:
+ /**
+ * Values representing the user response to a dialog
+ */
+ enum DialogResult {
+ kDialogError = -1, ///< Dialog couldn't be displayed
+ kDialogCancel = 0, ///< User cancelled the dialog (Cancel/No/Close buttons)
+ kDialogOk = 1 ///< User confirmed the dialog (OK/Yes buttons)
+ };
+
+ DialogManager() {}
+ virtual ~DialogManager() {}
+
+ /**
+ * Displays a dialog for selecting a file or folder.
+ */
+ virtual DialogResult showFileBrowser() { return kDialogError; }
+};
+
+} // End of namespace Common
+
+#endif
+
+#endif // COMMON_DIALOG_MANAGER_H
diff --git a/common/system.cpp b/common/system.cpp
index c8023c8ec2..93cf98c08e 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -29,6 +29,7 @@
#include "common/str.h"
#include "common/taskbar.h"
#include "common/updates.h"
+#include "common/dialogs.h"
#include "common/textconsole.h"
#include "backends/audiocd/default/default-audiocd.h"
@@ -48,6 +49,9 @@ OSystem::OSystem() {
#if defined(USE_UPDATES)
_updateManager = nullptr;
#endif
+#if defined(USE_SYSDIALOGS)
+ _dialogManager = nullptr;
+#endif
_fsFactory = nullptr;
_backendInitialized = false;
}
@@ -72,6 +76,11 @@ OSystem::~OSystem() {
_updateManager = nullptr;
#endif
+#if defined(USE_SYSDIALOGS)
+ delete _dialogManager;
+ _dialogManager = nullptr;
+#endif
+
delete _savefileManager;
_savefileManager = nullptr;
diff --git a/common/system.h b/common/system.h
index 405d6a90a8..01d436e5df 100644
--- a/common/system.h
+++ b/common/system.h
@@ -49,6 +49,9 @@ class TaskbarManager;
#if defined(USE_UPDATES)
class UpdateManager;
#endif
+#if defined(USE_SYSDIALOGS)
+class DialogManager;
+#endif
class TimerManager;
class SeekableReadStream;
class WriteStream;
@@ -179,6 +182,15 @@ protected:
Common::UpdateManager *_updateManager;
#endif
+#if defined(USE_SYSDIALOGS)
+ /**
+ * No default value is provided for _dialogManager by OSystem.
+ *
+ * @note _dialogManager is deleted by the OSystem destructor.
+ */
+ Common::DialogManager *_dialogManager;
+#endif
+
/**
* No default value is provided for _fsFactory by OSystem.
*
@@ -1305,6 +1317,17 @@ public:
}
#endif
+#if defined(USE_SYSDIALOGS)
+ /**
+ * Returns the DialogManager, used to handle system dialogs.
+ *
+ * @return the DialogManager for the current architecture
+ */
+ virtual Common::DialogManager *getDialogManager() {
+ return _dialogManager;
+ }
+#endif
+
/**
* Returns the FilesystemFactory object, depending on the current architecture.
*
diff --git a/configure b/configure
index 7a066169c5..44c7c09621 100755
--- a/configure
+++ b/configure
@@ -163,6 +163,7 @@ _freetype2=auto
_taskbar=auto
_updates=no
_libunity=auto
+_dialogs=auto
# Default option behavior yes/no
_debug_build=auto
_release_build=auto
@@ -1003,6 +1004,7 @@ Optional Features:
--disable-translation don't build support for translated messages
--disable-taskbar don't build support for taskbar and launcher integration
--disable-cloud don't build cloud support
+ --disable-system-dialogs don't build support for system dialogs
--enable-vkeybd build virtual keyboard support
--enable-keymapper build key mapper support
--enable-eventrecorder enable event recording functionality
@@ -1197,6 +1199,8 @@ for ac_option in $@; do
--disable-freetype2) _freetype2=no ;;
--enable-taskbar) _taskbar=yes ;;
--disable-taskbar) _taskbar=no ;;
+ --enable-system-dialogs) _dialogs=yes ;;
+ --disable-system-dialogs) _dialogs=no ;;
--enable-sdlnet) _sdlnet=yes ;;
--disable-sdlnet) _sdlnet=no ;;
--enable-libcurl) _libcurl=yes ;;
@@ -5139,6 +5143,31 @@ fi
define_in_config_if_yes $_taskbar 'USE_TASKBAR'
#
+# Check whether to build system dialogs support
+#
+echo_n "Building system dialogs support... "
+if test "$_dialogs" = "no"; then
+ echo "no"
+else
+ case $_host_os in
+ mingw*)
+ append_var LIBS "-lole32 -luuid"
+ echo "win32"
+ _dialogs=yes
+ ;;
+ darwin*)
+ echo "osx"
+ _dialogs=yes
+ ;;
+ *)
+ echo "no"
+ _dialogs=no
+ ;;
+ esac
+fi
+define_in_config_if_yes $_dialogs 'USE_SYSDIALOGS'
+
+#
# Check whether to build Bink video support
#
echo_n "Building Bink video support... "
diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp
index 3dab08a0b3..dd7eeba895 100644
--- a/devtools/create_project/create_project.cpp
+++ b/devtools/create_project/create_project.cpp
@@ -1063,6 +1063,7 @@ const Feature s_features[] = {
{ "keymapper", "ENABLE_KEYMAPPER", "", false, "Keymapper support"},
{ "eventrecorder", "ENABLE_EVENTRECORDER", "", false, "Event recorder support"},
{ "updates", "USE_UPDATES", "", false, "Updates support"},
+ { "dialogs", "USE_SYSDIALOGS", "", true, "System dialogs support"},
{ "langdetect", "USE_DETECTLANG", "", true, "System language detection support" } // This feature actually depends on "translation", there
// is just no current way of properly detecting this...
};