mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
MM: Create common engine base engine class
This commit is contained in:
parent
a05dfc9cd8
commit
a3550a9cb0
53
engines/mm/mm.cpp
Normal file
53
engines/mm/mm.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mm/mm.h"
|
||||
|
||||
namespace MM {
|
||||
|
||||
MMEngine::MMEngine(OSystem *syst, const MM::MightAndMagicGameDescription *gameDesc) :
|
||||
Engine(syst), _gameDescription(gameDesc), _randomSource("MightAndMagic") {
|
||||
}
|
||||
|
||||
bool MMEngine::hasFeature(EngineFeature f) const {
|
||||
return
|
||||
(f == kSupportsReturnToLauncher) ||
|
||||
(f == kSupportsLoadingDuringRuntime) ||
|
||||
(f == kSupportsSavingDuringRuntime);
|
||||
}
|
||||
|
||||
uint32 MMEngine::getGameID() const {
|
||||
return _gameDescription->gameID;
|
||||
}
|
||||
|
||||
uint32 MMEngine::getFeatures() const {
|
||||
return _gameDescription->desc.flags;
|
||||
}
|
||||
|
||||
Common::Language MMEngine::getLanguage() const {
|
||||
return _gameDescription->desc.language;
|
||||
}
|
||||
|
||||
Common::Platform MMEngine::getPlatform() const {
|
||||
return _gameDescription->desc.platform;
|
||||
}
|
||||
|
||||
} // namespace MM
|
@ -22,6 +22,9 @@
|
||||
#ifndef MM_MM_H
|
||||
#define MM_MM_H
|
||||
|
||||
#include "common/random.h"
|
||||
#include "mm/detection.h"
|
||||
|
||||
namespace MM {
|
||||
|
||||
enum MightAndMagicDebugChannels {
|
||||
@ -31,6 +34,41 @@ enum MightAndMagicDebugChannels {
|
||||
kDebugSound = 1 << 3
|
||||
};
|
||||
|
||||
class MMEngine : public Engine {
|
||||
protected:
|
||||
const MightAndMagicGameDescription *_gameDescription;
|
||||
Common::RandomSource _randomSource;
|
||||
public:
|
||||
MMEngine(OSystem *syst, const MM::MightAndMagicGameDescription *gameDesc);
|
||||
~MMEngine() override {}
|
||||
|
||||
/**
|
||||
* Checks for feature flag
|
||||
*/
|
||||
bool hasFeature(EngineFeature f) const override;
|
||||
|
||||
/**
|
||||
* Returns the features
|
||||
*/
|
||||
uint32 getFeatures() const;
|
||||
|
||||
/**
|
||||
* Returns the game language
|
||||
*/
|
||||
Common::Language getLanguage() const;
|
||||
|
||||
/**
|
||||
* Returns the game's platform
|
||||
*/
|
||||
Common::Platform getPlatform() const;
|
||||
|
||||
/**
|
||||
* Gets the game Id
|
||||
*/
|
||||
uint32 getGameID() const;
|
||||
|
||||
};
|
||||
|
||||
} // namespace MM
|
||||
|
||||
#endif // MM_MM_H
|
||||
|
@ -40,8 +40,7 @@ namespace MM1 {
|
||||
MM1Engine *g_engine = nullptr;
|
||||
|
||||
MM1Engine::MM1Engine(OSystem *syst, const MightAndMagicGameDescription *gameDesc)
|
||||
: Engine(syst), Events(gameDesc->features & GF_ENHANCED),
|
||||
_gameDescription(gameDesc), _randomSource("MM1") {
|
||||
: MMEngine(syst, gameDesc), Events(gameDesc->features & GF_ENHANCED) {
|
||||
g_engine = this;
|
||||
}
|
||||
|
||||
@ -118,13 +117,6 @@ bool MM1Engine::setupEnhanced() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MM1Engine::hasFeature(EngineFeature f) const {
|
||||
return
|
||||
(f == kSupportsReturnToLauncher) ||
|
||||
(f == kSupportsLoadingDuringRuntime) ||
|
||||
(f == kSupportsSavingDuringRuntime);
|
||||
}
|
||||
|
||||
bool MM1Engine::canSaveGameStateCurrently() {
|
||||
if (!g_events)
|
||||
return false;
|
||||
|
@ -35,10 +35,7 @@
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
|
||||
class MM1Engine : public Engine, public Events {
|
||||
private:
|
||||
const MightAndMagicGameDescription *_gameDescription;
|
||||
Common::RandomSource _randomSource;
|
||||
class MM1Engine : public MMEngine, public Events {
|
||||
private:
|
||||
// Engine APIs
|
||||
Common::Error run() override;
|
||||
@ -51,8 +48,6 @@ public:
|
||||
MM1Engine(OSystem *syst, const MightAndMagicGameDescription *gameDesc);
|
||||
~MM1Engine() override;
|
||||
|
||||
bool hasFeature(EngineFeature f) const override;
|
||||
|
||||
bool isEnhanced() const;
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ MODULE := engines/mm
|
||||
|
||||
MODULE_OBJS := \
|
||||
metaengine.o \
|
||||
mm.o \
|
||||
utils/bitmap_font.o \
|
||||
utils/engine_data.o \
|
||||
utils/strings.o \
|
||||
|
@ -34,8 +34,7 @@ namespace Xeen {
|
||||
XeenEngine *g_vm = nullptr;
|
||||
|
||||
XeenEngine::XeenEngine(OSystem *syst, const MightAndMagicGameDescription *gameDesc)
|
||||
: Engine(syst), _gameDescription(gameDesc), _randomSource("Xeen") {
|
||||
|
||||
: MMEngine(syst, gameDesc) {
|
||||
_combat = nullptr;
|
||||
_debugger = nullptr;
|
||||
_events = nullptr;
|
||||
@ -118,13 +117,6 @@ bool XeenEngine::initialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool XeenEngine::hasFeature(EngineFeature f) const {
|
||||
return
|
||||
(f == kSupportsReturnToLauncher) ||
|
||||
(f == kSupportsLoadingDuringRuntime) ||
|
||||
(f == kSupportsSavingDuringRuntime);
|
||||
}
|
||||
|
||||
void XeenEngine::loadSettings() {
|
||||
_gameWon[0] = ConfMan.hasKey("game_won") && ConfMan.getBool("game_won");
|
||||
_gameWon[1] = ConfMan.hasKey("game_won2") && ConfMan.getBool("game_won2");
|
||||
@ -335,10 +327,6 @@ void XeenEngine::GUIError(const Common::U32String &msg) {
|
||||
}
|
||||
|
||||
|
||||
uint32 XeenEngine::getGameID() const {
|
||||
return _gameDescription->gameID;
|
||||
}
|
||||
|
||||
uint32 XeenEngine::getSpecificGameId() const {
|
||||
uint gameId = g_vm->getGameID();
|
||||
if (gameId == GType_WorldOfXeen)
|
||||
@ -351,18 +339,6 @@ uint32 XeenEngine::getGameFeatures() const {
|
||||
return _gameDescription->features;
|
||||
}
|
||||
|
||||
uint32 XeenEngine::getFeatures() const {
|
||||
return _gameDescription->desc.flags;
|
||||
}
|
||||
|
||||
Common::Language XeenEngine::getLanguage() const {
|
||||
return _gameDescription->desc.language;
|
||||
}
|
||||
|
||||
Common::Platform XeenEngine::getPlatform() const {
|
||||
return _gameDescription->desc.platform;
|
||||
}
|
||||
|
||||
bool XeenEngine::getIsCD() const {
|
||||
return getFeatures() & ADGF_CD;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ enum GameMode {
|
||||
|
||||
#define XEEN_SAVEGAME_VERSION 2
|
||||
|
||||
class XeenEngine : public Engine {
|
||||
class XeenEngine : public MMEngine {
|
||||
/**
|
||||
* Container to a set of options newly introduced under ScummVM
|
||||
*/
|
||||
@ -101,9 +101,6 @@ class XeenEngine : public Engine {
|
||||
ExtendedOptions() : _showItemCosts(false), _durableArmor(false) {
|
||||
}
|
||||
};
|
||||
private:
|
||||
const MightAndMagicGameDescription *_gameDescription;
|
||||
Common::RandomSource _randomSource;
|
||||
private:
|
||||
/**
|
||||
* Initializes all the engine sub-objects
|
||||
@ -117,7 +114,6 @@ private:
|
||||
|
||||
// Engine APIs
|
||||
Common::Error run() override;
|
||||
bool hasFeature(EngineFeature f) const override;
|
||||
|
||||
/**
|
||||
* Outer gameplay loop responsible for dispatching control to game-specific
|
||||
@ -185,26 +181,6 @@ public:
|
||||
XeenEngine(OSystem *syst, const MM::MightAndMagicGameDescription *gameDesc);
|
||||
~XeenEngine() override;
|
||||
|
||||
/**
|
||||
* Returns the features
|
||||
*/
|
||||
uint32 getFeatures() const;
|
||||
|
||||
/**
|
||||
* Returns the game language
|
||||
*/
|
||||
Common::Language getLanguage() const;
|
||||
|
||||
/**
|
||||
* Returns the game's platform
|
||||
*/
|
||||
Common::Platform getPlatform() const;
|
||||
|
||||
/**
|
||||
* Gets the game Id
|
||||
*/
|
||||
uint32 getGameID() const;
|
||||
|
||||
/**
|
||||
* Returns the game Id, but with a reuslt of Clouds or Dark Side for World of Xeen,
|
||||
* depending on which side the player is currently on
|
||||
|
Loading…
Reference in New Issue
Block a user