From 39765b0d19fd8409cf4e0e96c9edc2ad5b25f247 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 28 Mar 2004 20:31:18 +0000 Subject: Remove explicit OSystem parameter from StackLock constructor; added OSystem::displayMessageOnOSD (not yet used; default implementation provided) svn-id: r13413 --- common/system.cpp | 21 +++++++++++++-------- common/system.h | 24 ++++++++++++++++++------ 2 files changed, 31 insertions(+), 14 deletions(-) (limited to 'common') diff --git a/common/system.cpp b/common/system.cpp index ce9ba67c3c..b9cfb8de8f 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -26,6 +26,8 @@ #include "base/gameDetector.h" +#include "gui/message.h" + #include "common/config-manager.h" #include "common/system.h" @@ -84,15 +86,20 @@ bool OSystem::setGraphicsMode(const char *name) { return false; } +void OSystem::displayMessageOnOSD(const char *msg) { + // Display the message for 1.5 seconds + GUI::TimedMessageDialog dialog(msg, 1500); + dialog.runModal(); +} + + #pragma mark - namespace Common { -StackLock::StackLock(OSystem::MutexRef mutex, OSystem *syst, const char *mutexName) - : _mutex(mutex), _syst(syst), _mutexName(mutexName) { - if (syst == 0) - _syst = g_system; +StackLock::StackLock(OSystem::MutexRef mutex, const char *mutexName) + : _mutex(mutex), _mutexName(mutexName) { lock(); } @@ -101,19 +108,17 @@ StackLock::~StackLock() { } void StackLock::lock() { - assert(_syst); if (_mutexName != NULL) debug(6, "Locking mutex %s", _mutexName); - _syst->lockMutex(_mutex); + g_system->lockMutex(_mutex); } void StackLock::unlock() { - assert(_syst); if (_mutexName != NULL) debug(6, "Unlocking mutex %s", _mutexName); - _syst->unlockMutex(_mutex); + g_system->unlockMutex(_mutex); } } // End of namespace Common diff --git a/common/system.h b/common/system.h index 8f9b5a7464..2039085fdb 100644 --- a/common/system.h +++ b/common/system.h @@ -602,12 +602,25 @@ public: virtual void quit() = 0; /** - * Set a window caption or any other comparable status display to the - * given value. - * @param caption the window caption to use from now on + * Set a window caption or any other comparable status display to the + * given value. + * @param caption the window caption to use from now on */ virtual void setWindowCaption(const char *caption) {} - + + /** + * Display a message in an 'on screen display'. That is, display it in a + * fashion where it is visible on or near the screen (e.g. in a transparent + * rectangle over the regular screen content; or in a message box beneath + * it; etc.). + * + * @note There is a default implementation which uses a TimedMessageDialog + * to display the message. Hence implementing this is optional. + * + * @param msg the message to display on screen + */ + virtual void displayMessageOnOSD(const char *msg); + /** Savefile management. */ virtual SaveFileManager *get_savefile_manager() { return new SaveFileManager(); @@ -626,13 +639,12 @@ namespace Common { */ class StackLock { OSystem::MutexRef _mutex; - OSystem *_syst; const char *_mutexName; void lock(); void unlock(); public: - StackLock(OSystem::MutexRef mutex, OSystem *syst = 0, const char *mutexName = NULL); + StackLock(OSystem::MutexRef mutex, const char *mutexName = NULL); ~StackLock(); }; -- cgit v1.2.3