aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
authorPaul Gilbert2014-04-21 20:50:05 -0400
committerPaul Gilbert2014-04-21 20:50:05 -0400
commit692af23f6f0a698e9089fcef0592fcb20e56efa6 (patch)
tree101e3135a7e22f1e97d40893897b253fbf16d8f1 /engines/mads
parentff70186855bec22fe77043d89917b189218ff856 (diff)
downloadscummvm-rg350-692af23f6f0a698e9089fcef0592fcb20e56efa6.tar.gz
scummvm-rg350-692af23f6f0a698e9089fcef0592fcb20e56efa6.tar.bz2
scummvm-rg350-692af23f6f0a698e9089fcef0592fcb20e56efa6.zip
MADS: Create a Globals base class that the games will derive from
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/game.h6
-rw-r--r--engines/mads/globals.cpp34
-rw-r--r--engines/mads/globals.h50
-rw-r--r--engines/mads/module.mk1
-rw-r--r--engines/mads/nebular/game_nebular.h5
-rw-r--r--engines/mads/nebular/globals_nebular.cpp7
-rw-r--r--engines/mads/nebular/globals_nebular.h16
-rw-r--r--engines/mads/nebular/nebular_scenes.h2
-rw-r--r--engines/mads/user_interface.cpp25
9 files changed, 107 insertions, 39 deletions
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 44aa0dbee5..5bb7b31973 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -27,6 +27,7 @@
#include "common/str-array.h"
#include "mads/scene.h"
#include "mads/game_data.h"
+#include "mads/globals.h"
#include "mads/inventory.h"
#include "mads/player.h"
#include "mads/screen.h"
@@ -150,6 +151,11 @@ public:
Common::StringArray getMessage(uint32 id);
/**
+ * Returns the globals for the game
+ */
+ virtual Globals &globals() = 0;
+
+ /**
* Standard object handling across the game
*/
virtual void doObjectAction() = 0;
diff --git a/engines/mads/globals.cpp b/engines/mads/globals.cpp
new file mode 100644
index 0000000000..68a2cf1970
--- /dev/null
+++ b/engines/mads/globals.cpp
@@ -0,0 +1,34 @@
+/* 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/scummsys.h"
+#include "mads/globals.h"
+
+namespace MADS {
+
+void Globals::reset() {
+ for (uint i = 0; i < _flags.size(); ++i)
+ _flags[i] = 0;
+}
+
+
+} // End of namespace MADS
diff --git a/engines/mads/globals.h b/engines/mads/globals.h
new file mode 100644
index 0000000000..ea327b0045
--- /dev/null
+++ b/engines/mads/globals.h
@@ -0,0 +1,50 @@
+/* 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 MADS_GLOBALS_H
+#define MADS_GLOBALS_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+
+namespace MADS {
+
+class Globals {
+protected:
+ Common::Array<int16> _flags;
+public:
+ Globals() {}
+
+ /**
+ * Square brackets operator for accessing flags
+ */
+ int16 &operator[](int idx) { return _flags[idx]; }
+
+ /*
+ * Resets all the globals to empty
+ */
+ void reset();
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_GLOBALS_H */
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 716521d6ec..43853f5abb 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -21,6 +21,7 @@ MODULE_OBJS := \
font.o \
game.o \
game_data.o \
+ globals.o \
hotspots.o \
inventory.o \
mads.o \
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 4d011c2f4a..7d64e3e49f 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "mads/game.h"
+#include "mads/globals.h"
#include "mads/nebular/globals_nebular.h"
namespace MADS {
@@ -62,9 +63,11 @@ protected:
virtual void checkShowDialog();
public:
- Globals _globals;
+ NebularGlobals _globals;
StoryMode _storyMode;
+ virtual Globals &globals() { return _globals; }
+
virtual void doObjectAction();
virtual void unhandledAction();
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 11c2b81502..3e9a9f7e2f 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -28,7 +28,7 @@ namespace MADS {
namespace Nebular {
-Globals::Globals() {
+NebularGlobals::NebularGlobals(): Globals() {
// Initialize lists
_flags.resize(210);
_spriteIndexes.resize(30);
@@ -53,11 +53,6 @@ Globals::Globals() {
_v84268 = 0;
}
-void Globals::reset() {
- for (uint i = 0; i < _flags.size(); ++i)
- _flags[i] = 0;
-}
-
} // End of namespace Nebular
} // End of namespace MADS
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 242e0d1b7b..b8fe17f333 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -279,9 +279,7 @@ enum {
#define TELEPORTER_WORK_COUNT 6 // Total number that actually work
-class Globals {
-private:
- Common::Array<int16> _flags;
+class NebularGlobals: public Globals {
public:
Common::Array<int> _spriteIndexes;
Common::Array<int> _sequenceIndexes;
@@ -302,17 +300,7 @@ public:
/**
* Constructor
*/
- Globals();
-
- /**
- * Square brackets operator for accessing flags
- */
- int16 &operator[](int idx) { return _flags[idx]; }
-
- /*
- * Resets all the globals to empty
- */
- void reset();
+ NebularGlobals();
};
} // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 56ea52d2c8..a227b7658a 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -111,7 +111,7 @@ public:
*/
class NebularScene : public SceneLogic {
protected:
- Globals &_globals;
+ NebularGlobals &_globals;
GameNebular &_game;
MADSAction &_action;
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index f775e459b5..346ad2d688 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -231,18 +231,14 @@ void Conversation::setup(int globalId, ...) {
if (quoteId < 0) {
// For an ending value of -1, also initial the bitflags for the global
// associated with the conversation entry, which enables all the quote Ids
- assert(_vm->getGameID() == GType_RexNebular);
- Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
- game->_globals[globalId] = (int16)0xffff;
+ _vm->_game->globals()[globalId] = (int16)0xffff;
}
_globalId = globalId;
}
void Conversation::set(int quoteId, ...) {
- assert(_vm->getGameID() == GType_RexNebular);
- Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
- game->_globals[_globalId] = 0;
+ _vm->_game->globals()[_globalId] = 0;
va_list va;
va_start(va, quoteId);
@@ -252,7 +248,7 @@ void Conversation::set(int quoteId, ...) {
for (uint idx = 0; idx < _quotes.size(); ++idx) {
if (_quotes[idx] == quoteId) {
// Found index, so set that bit in the global keeping track of conversation state
- game->_globals[_globalId] |= 1 << idx;
+ _vm->_game->globals()[_globalId] |= 1 << idx;
break;
}
}
@@ -263,18 +259,15 @@ void Conversation::set(int quoteId, ...) {
}
void Conversation::write(int quoteId, bool flag) {
- assert(_vm->getGameID() == GType_RexNebular);
- Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
-
for (uint idx = 0; idx < _quotes.size(); ++idx) {
if (_quotes[idx] == quoteId) {
// Found index, so set or clear the flag
if (flag) {
// Set bit
- game->_globals[_globalId] |= 1 << idx;
+ _vm->_game->globals()[_globalId] |= 1 << idx;
} else {
// Clear bit
- game->_globals[_globalId] &= ~(1 << idx);
+ _vm->_game->globals()[_globalId] &= ~(1 << idx);
}
return;
}
@@ -282,17 +275,15 @@ void Conversation::write(int quoteId, bool flag) {
}
void Conversation::start() {
- assert(_vm->getGameID() == GType_RexNebular);
- Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
- UserInterface &userInterface = game->_scene._userInterface;
+ UserInterface &userInterface = _vm->_game->_scene._userInterface;
userInterface.emptyConversationList();
// Loop through each of the quotes loaded into the conversation
for (uint idx = 0; idx < _quotes.size(); ++idx) {
// Check whether the given quote is enabled or not
- if (game->_globals[_globalId] & (1 << idx)) {
+ if (_vm->_game->globals()[_globalId] & (1 << idx)) {
// Quote enabled, so add it to the list of talk selections
- Common::String msg = game->getQuote(_quotes[idx]);
+ Common::String msg = _vm->_game->getQuote(_quotes[idx]);
userInterface.addConversationMessage(_quotes[idx], msg);
}
}