aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSupSuper2018-11-19 14:57:50 +0000
committerThierry Crozat2018-12-16 10:48:13 +0000
commit952b12311cfbdc48ddae0dbc7b960cd17c8e2b1e (patch)
treee689fda0423e30ca904497de4fda33c787c9d4d3 /common
parent313cd2315e43bd0d9a052a6486dab36648a98d1b (diff)
downloadscummvm-rg350-952b12311cfbdc48ddae0dbc7b960cd17c8e2b1e.tar.gz
scummvm-rg350-952b12311cfbdc48ddae0dbc7b960cd17c8e2b1e.tar.bz2
scummvm-rg350-952b12311cfbdc48ddae0dbc7b960cd17c8e2b1e.zip
BACKENDS: Add base support for system dialogs
Diffstat (limited to 'common')
-rw-r--r--common/dialogs.h60
-rw-r--r--common/system.cpp9
-rw-r--r--common/system.h23
3 files changed, 92 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.
*