aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/draci/game.cpp42
-rw-r--r--engines/draci/game.h11
2 files changed, 50 insertions, 3 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 46c7887e46..09bcf4cf13 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -153,6 +153,9 @@ Game::Game(DraciEngine *vm) : _vm(vm) {
void Game::init() {
_loopStatus = kStatusOrdinary;
+ _objUnderCursor = kOverlayImage;
+
+ _vm->_anims->addText(kTitleText, true);
loadObject(kDragonObject);
@@ -173,9 +176,42 @@ void Game::loop() {
if (_vm->_mouse->lButtonPressed() && _currentRoom._walkingMap.isWalkable(x, y)) {
walkHero(x, y);
}
+
+ int animUnderCursor = _vm->_anims->getTopAnimationID(x, y);
+
+ int curObject = getObjectWithAnimation(animUnderCursor);
+
+ Animation *atitle = _vm->_anims->getAnimation(kTitleText);
+
+ // TODO: Handle displaying title in the proper location
+
+ atitle->deleteFrames();
+ if (curObject != kNotFound) {
+ GameObject *obj = &_objects[curObject];
+ Text *title = new Text (obj->_title, _vm->_bigFont, kFontColour1, 0, 0);
+ atitle->addFrame(title);
+ }
+
+ debugC(2, kDraciAnimationDebugLevel, "Anim under cursor: %d", animUnderCursor);
+
+
}
}
+int Game::getObjectWithAnimation(int animID) {
+ for (uint i = 0; i < _info._numObjects; ++i) {
+ GameObject *obj = &_objects[i];
+
+ for (uint j = 0; j < obj->_anims.size(); ++j) {
+ if (obj->_anims[j] == animID) {
+ return i;
+ }
+ }
+ }
+
+ return kNotFound;
+}
+
void Game::walkHero(int x, int y) {
// Fetch dragon's animation ID
// FIXME: Need to add proper walking (this only warps the dragon to position)
@@ -441,8 +477,12 @@ void Game::loadObject(uint objNum) {
obj->_absNum = objNum;
file = _vm->_objectsArchive->getFile(objNum * 3 + 1);
- obj->_title = file->_data;
+ // The first byte of the file is the length of the string (without the length)
+ assert(file->_length - 1 == file->_data[0]);
+
+ obj->_title = Common::String((char *)(file->_data+1), file->_length-1);
+
file = _vm->_objectsArchive->getFile(objNum * 3 + 2);
obj->_program._bytecode = file->_data;
obj->_program._length = file->_length;
diff --git a/engines/draci/game.h b/engines/draci/game.h
index d8e0d137b7..fbc1d3283e 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -43,6 +43,10 @@ enum StructSizes {
personSize = sizeof(uint16) * 2 + sizeof(byte)
};
+enum {
+ kNotFound = -1
+};
+
class WalkingMap {
public:
@@ -82,7 +86,7 @@ private:
struct GameObject {
- GameObject() : _title(NULL) {}
+ GameObject() {}
uint _init, _look, _use, _canUse;
bool _imInit, _imLook, _imUse;
@@ -93,7 +97,7 @@ struct GameObject {
uint16 _absNum;
Common::Array<int> _anims;
GPL2Program _program;
- byte *_title;
+ Common::String _title;
int _location;
bool _visible;
};
@@ -196,6 +200,7 @@ public:
uint getNumObjects();
GameObject *getObject(uint objNum);
+ int getObjectWithAnimation(int animID);
int getVariable(int varNum);
void setVariable(int varNum, int value);
@@ -222,6 +227,8 @@ private:
Room _currentRoom;
LoopStatus _loopStatus;
+ int _objUnderCursor;
+
int _markedAnimationIndex; //!< Used by the Mark GPL command
};