aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Page2008-07-08 05:21:05 +0000
committerChristopher Page2008-07-08 05:21:05 +0000
commit94beb3037e55803dd45e5720af8320f0ebccb9ac (patch)
tree69a157ac4096149d6f128c43729b9b212098c265
parentb97f39019cff74f7211152c78e4777ca0e31826e (diff)
downloadscummvm-rg350-94beb3037e55803dd45e5720af8320f0ebccb9ac.tar.gz
scummvm-rg350-94beb3037e55803dd45e5720af8320f0ebccb9ac.tar.bz2
scummvm-rg350-94beb3037e55803dd45e5720af8320f0ebccb9ac.zip
Improved GMM implementation by adding unified quit() and quitGame() methods for all engines. Also implemented a Queue class before and forgot to svn add, common/queue.h is added here.
svn-id: r32958
-rw-r--r--common/queue.h75
-rw-r--r--engines/engine.h16
2 files changed, 86 insertions, 5 deletions
diff --git a/common/queue.h b/common/queue.h
new file mode 100644
index 0000000000..56f0b70415
--- /dev/null
+++ b/common/queue.h
@@ -0,0 +1,75 @@
+/* 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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/gsoc2008-rtl/common/stack.h $
+ * $Id$
+ */
+
+#ifndef COMMON_QUEUE_H
+#define COMMON_QUEUE_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+
+namespace Common {
+
+/**
+ * Variable size Queue class, implemented using our Array class.
+ */
+template<class T>
+class Queue {
+protected:
+ Array<T> _queue;
+public:
+ Queue<T>() {}
+ Queue<T>(const Array<T> &queueContent) : _queue(queueContent) {}
+
+ bool empty() const {
+ return _queue.empty();
+ }
+ void clear() {
+ _queue.clear();
+ }
+ void push(const T &x) {
+ _queue.push_back(x);
+ }
+ T back() const {
+ const int s = size();
+ return _queue[s - 1];
+ }
+ T front() const {
+ return _queue[0];
+ }
+ T pop() {
+ T tmp = front();
+ _queue.remove_at(0);
+ return tmp;
+ }
+ int size() const {
+ return _queue.size();
+ }
+ T operator[](int i) {
+ return _queue[i];
+ }
+};
+
+} // End of namespace Common
+
+#endif
diff --git a/engines/engine.h b/engines/engine.h
index 02eea82618..d84ef2bbf8 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -25,6 +25,7 @@
#ifndef ENGINES_ENGINE_H
#define ENGINES_ENGINE_H
+#include "common/events.h"
#include "common/scummsys.h"
#include "common/str.h"
@@ -50,11 +51,7 @@ public:
Audio::Mixer *_mixer;
Common::TimerManager * _timer;
- /** We keep running until this is set to true. */
- bool _quit;
-
- /** This is used when returning from go() to specifiy if we return to the launcher (true), or quit (false). */
- bool _rtl;
+ bool _quit, _rtl;
protected:
Common::EventManager *_eventMan;
@@ -121,10 +118,19 @@ public:
void pauseEngine(bool pause);
/**
+ * Quit the engine, sends a Quit event to the Event Manager
+ */
+ void quitGame() { _eventMan->pushEvent(Common::EVENT_QUIT); };
+
+ /**
* Return whether the engine is currently paused or not.
*/
bool isPaused() const { return _pauseLevel != 0; }
+ /**
+ * Return whether or not the engine should quit
+ */
+ bool quit() const { return _eventMan->shouldQuit(); }
/** Run the Global Main Menu Dialog
*/