1,079
edits
(→Example: engines/quux/quux.h: update / compilation fixes) |
(→Example: engines/quux/quux.cpp: quux.cpp was badly outdated and broken -- fixed it) |
||
Line 143: | Line 143: | ||
<pre> | <pre> | ||
#include "common/scummsys.h" | #include "common/scummsys.h" | ||
#include "common/events.h" // for getEventManager() | #include "common/events.h" // for getEventManager() | ||
#include "common/config-manager.h" | |||
#include "common/file.h" | |||
#include "common/fs.h" | |||
#include "base/game.h" | |||
#include "base/ | |||
#include "base/plugins.h" | #include "base/plugins.h" | ||
Line 152: | Line 155: | ||
static const | static const PlainGameDescriptor quux_setting[] = { | ||
{ "quux", "Quux the Example Module" | { "quux", "Quux the Example Module" }, | ||
{ "quuxcd", "Quux the Example Module (CD version)" | { "quuxcd", "Quux the Example Module (CD version)" }, | ||
{ | { 0, 0 } | ||
}; | }; | ||
GameList | GameList Engine_QUUX_gameIDList() { | ||
GameList games; | GameList games; | ||
const | const PlainGameDescriptor *g = quux_setting; | ||
while (g->gameid) { | while (g->gameid) { | ||
games.push_back(*g); | games.push_back(*g); | ||
Line 169: | Line 172: | ||
} | } | ||
GameDescriptor Engine_QUUX_findGameID(const char *gameid) { | |||
const PlainGameDescriptor *g = quux_setting; | |||
while (g->gameid) { | |||
if (0 == scumm_stricmp(gameid, g->gameid)) | |||
break; | |||
g++; | |||
} | |||
return GameDescriptor(g->gameid, g->description); | |||
} | |||
GameList Engine_QUUX_detectGames(const FSList &fslist) { | |||
GameList detectedGames; | |||
// Iterate over all files in the given directory | // Iterate over all files in the given directory | ||
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { | for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { | ||
if (!file->isDirectory()) { | if (!file->isDirectory()) { | ||
const char *gameName = file-> | const char *gameName = file->getName().c_str(); | ||
if (0 == scumm_stricmp("README", gameName)) { | if (0 == scumm_stricmp("README", gameName)) { | ||
Line 187: | Line 200: | ||
} | } | ||
PluginError Engine_QUUX_create(OSystem *syst, Engine **engine) { | |||
// At this point you may want to perform | assert(syst); | ||
assert(engine); | |||
// Scan the target directory for files (error out if it does not exist) | |||
FSList fslist; | |||
FilesystemNode dir(ConfMan.get("path")); | |||
if (!dir.getChildren(fslist, FilesystemNode::kListAll)) { | |||
return kInvalidPathError; | |||
} | |||
// Invoke the detector | |||
Common::String gameid = ConfMan.get("gameid"); | |||
GameList detectedGames = Engine_QUUX_detectGames(fslist); | |||
for (uint i = 0; i < detectedGames.size(); i++) { | |||
if (detectedGames[i].gameid() == gameid) { | |||
// At this point you may want to perform additional sanity checks. | |||
*engine = new Quux::QuuxEngine(syst); | |||
return kNoError; | |||
} | |||
} | |||
// Failed to find any game data | |||
return kNoGameDataFoundError; | |||
} | } | ||
REGISTER_PLUGIN(QUUX, "Quux the Example Module"); | REGISTER_PLUGIN(QUUX, "Quux the Example Module", "Copyright (C) Quux Entertainment Ltd."); | ||
Line 208: | Line 243: | ||
// However this is the place to specify all default directories | // However this is the place to specify all default directories | ||
File::addDefaultDirectory(_gameDataPath + "sound/"); | Common::File::addDefaultDirectory(_gameDataPath + "sound/"); | ||
// Here is the right place to set up the engine specific debug levels | // Here is the right place to set up the engine specific debug levels | ||
Line 228: | Line 263: | ||
} | } | ||
int QuuxEngine::init( | int QuuxEngine::init() { | ||
// Initialize graphics using following template | // Initialize graphics using following template | ||
// You have to use transactions | // You have to use transactions | ||
Line 234: | Line 269: | ||
// This is handled by base Engine class and processes command | // This is handled by base Engine class and processes command | ||
// line parameters | // line parameters | ||
initCommonGFX(true); | |||
// Specify dimensions of game graphics window | // Specify dimensions of game graphics window. | ||
_system->initSize( | // In this example: 320x200 | ||
_system->initSize(320, 200); | |||
_system->endGFXTransaction(); | _system->endGFXTransaction(); | ||
Line 260: | Line 296: | ||
return 0; | return 0; | ||
} | } | ||
edits