2016-04-26 14:44:01 +02:00
|
|
|
#include "common/scummsys.h"
|
2016-05-02 20:58:55 +02:00
|
|
|
#include "common/system.h"
|
2016-04-26 14:44:01 +02:00
|
|
|
|
|
|
|
#include "common/debug.h"
|
|
|
|
#include "common/debug-channels.h"
|
|
|
|
#include "common/error.h"
|
|
|
|
|
|
|
|
#include "engines/util.h"
|
2016-05-02 20:58:55 +02:00
|
|
|
#include "engines/engine.h"
|
|
|
|
#include "graphics/palette.h"
|
|
|
|
#include "common/file.h"
|
2016-05-21 21:09:09 +02:00
|
|
|
#include "common/events.h"
|
2016-04-26 14:44:01 +02:00
|
|
|
|
|
|
|
#include "dm/dm.h"
|
2016-06-15 22:42:08 +02:00
|
|
|
#include "gfx.h"
|
|
|
|
#include "dungeonman.h"
|
|
|
|
#include "eventman.h"
|
2016-06-17 14:29:05 +02:00
|
|
|
#include "menus.h"
|
2016-04-26 14:44:01 +02:00
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
2016-05-21 21:09:09 +02:00
|
|
|
int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */};
|
|
|
|
int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */};
|
|
|
|
|
|
|
|
void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
|
|
|
|
void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
|
|
|
|
bool isOrientedWestEast(direction dir) { return dir & 1; }
|
|
|
|
|
2016-05-04 12:50:06 +02:00
|
|
|
|
2016-04-26 14:44:01 +02:00
|
|
|
DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
|
|
|
|
// Do not load data files
|
|
|
|
// Do not initialize graphics here
|
|
|
|
// Do not initialize audio devices here
|
|
|
|
// Do these from run
|
|
|
|
|
|
|
|
//Specify all default directories
|
2016-04-26 23:33:03 +02:00
|
|
|
//const Common::FSNode gameDataDir(ConfMan.get("example"));
|
|
|
|
//SearchMan.addSubDirectoryMatching(gameDataDir, "example2");
|
2016-04-26 14:44:01 +02:00
|
|
|
DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc");
|
|
|
|
|
2016-05-04 11:23:52 +02:00
|
|
|
// register random source
|
2016-04-26 14:44:01 +02:00
|
|
|
_rnd = new Common::RandomSource("quux");
|
|
|
|
|
|
|
|
debug("DMEngine::DMEngine");
|
|
|
|
}
|
|
|
|
|
|
|
|
DMEngine::~DMEngine() {
|
|
|
|
debug("DMEngine::~DMEngine");
|
|
|
|
|
|
|
|
// dispose of resources
|
|
|
|
delete _rnd;
|
2016-05-02 20:58:55 +02:00
|
|
|
delete _console;
|
|
|
|
delete _displayMan;
|
2016-05-03 17:55:04 +02:00
|
|
|
delete _dungeonMan;
|
2016-06-15 10:41:33 +02:00
|
|
|
delete _eventMan;
|
2016-06-17 14:29:05 +02:00
|
|
|
delete _menuMan;
|
2016-04-26 14:44:01 +02:00
|
|
|
|
|
|
|
// clear debug channels
|
|
|
|
DebugMan.clearAllDebugChannels();
|
|
|
|
}
|
|
|
|
|
2016-05-03 17:55:04 +02:00
|
|
|
|
2016-04-26 14:44:01 +02:00
|
|
|
Common::Error DMEngine::run() {
|
|
|
|
initGraphics(320, 200, false);
|
|
|
|
_console = new Console(this);
|
2016-05-02 20:58:55 +02:00
|
|
|
_displayMan = new DisplayMan(this);
|
2016-05-03 17:55:04 +02:00
|
|
|
_dungeonMan = new DungeonMan(this);
|
2016-06-15 10:41:33 +02:00
|
|
|
_eventMan = new EventManager(this);
|
2016-06-17 14:29:05 +02:00
|
|
|
_menuMan = new MenuMan(this);
|
2016-05-15 15:53:00 +02:00
|
|
|
|
2016-05-15 17:52:39 +02:00
|
|
|
_displayMan->setUpScreens(320, 200);
|
|
|
|
|
2016-05-15 18:59:55 +02:00
|
|
|
_displayMan->loadGraphics();
|
|
|
|
|
2016-05-15 15:53:00 +02:00
|
|
|
_dungeonMan->loadDungeonFile();
|
2016-05-21 21:09:09 +02:00
|
|
|
int16 dummyMapIndex = 0;
|
|
|
|
_dungeonMan->setCurrentMapAndPartyMap(dummyMapIndex);
|
2016-05-15 17:52:39 +02:00
|
|
|
|
2016-05-15 15:53:00 +02:00
|
|
|
|
|
|
|
_displayMan->loadCurrentMapGraphics();
|
|
|
|
_displayMan->loadPalette(gPalCredits);
|
|
|
|
|
2016-06-15 10:41:33 +02:00
|
|
|
_eventMan->initMouse();
|
2016-06-15 18:22:32 +02:00
|
|
|
_eventMan->showMouse(true);
|
2016-06-15 10:41:33 +02:00
|
|
|
|
2016-06-16 23:48:18 +02:00
|
|
|
startGame();
|
|
|
|
|
|
|
|
|
2016-05-02 20:58:55 +02:00
|
|
|
while (true) {
|
2016-06-17 14:29:05 +02:00
|
|
|
_stopWaitingForPlayerInput = false;
|
|
|
|
//do {
|
|
|
|
_eventMan->processInput();
|
|
|
|
_eventMan->processCommandQueue();
|
|
|
|
//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
|
|
|
|
|
2016-05-06 18:20:30 +02:00
|
|
|
_displayMan->clearScreen(kColorBlack);
|
2016-05-21 21:09:09 +02:00
|
|
|
_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY);
|
2016-06-17 14:29:05 +02:00
|
|
|
// DUMMY CODE:
|
|
|
|
_menuMan->drawMovementArrows();
|
2016-05-02 20:58:55 +02:00
|
|
|
_displayMan->updateScreen();
|
2016-05-21 21:09:09 +02:00
|
|
|
_system->delayMillis(10);
|
2016-05-02 20:58:55 +02:00
|
|
|
}
|
2016-04-26 14:44:01 +02:00
|
|
|
|
2016-05-04 11:16:41 +02:00
|
|
|
|
2016-04-26 14:44:01 +02:00
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
2016-06-16 23:48:18 +02:00
|
|
|
|
|
|
|
void DMEngine::startGame() {
|
|
|
|
_eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface;
|
|
|
|
_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
|
2016-06-17 14:29:05 +02:00
|
|
|
|
|
|
|
_menuMan->drawMovementArrows();
|
|
|
|
_gameTimeTicking = true;
|
2016-06-16 23:48:18 +02:00
|
|
|
}
|
|
|
|
|
2016-04-26 14:44:01 +02:00
|
|
|
} // End of namespace DM
|