[Scummvm-cvs-logs] SF.net SVN: scummvm:[42839] scummvm/branches/gsoc2009-draci/engines/draci
dkasak13 at users.sourceforge.net
dkasak13 at users.sourceforge.net
Mon Jul 27 06:51:35 CEST 2009
Revision: 42839
http://scummvm.svn.sourceforge.net/scummvm/?rev=42839&view=rev
Author: dkasak13
Date: 2009-07-27 04:51:34 +0000 (Mon, 27 Jul 2009)
Log Message:
-----------
* Added Game::getObjectWithAnimation() which finds the object that owns an animation with a certain ID
* Made GameObjects track their titles as Strings rather than byte *
* Made the engine display the title of the object under the cursor (added a special animation ID for that, kTitleText)
Modified Paths:
--------------
scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
scummvm/branches/gsoc2009-draci/engines/draci/game.h
Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.cpp 2009-07-27 04:47:38 UTC (rev 42838)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.cpp 2009-07-27 04:51:34 UTC (rev 42839)
@@ -153,7 +153,10 @@
void Game::init() {
_loopStatus = kStatusOrdinary;
+ _objUnderCursor = kOverlayImage;
+ _vm->_anims->addText(kTitleText, true);
+
loadObject(kDragonObject);
GameObject *dragon = getObject(kDragonObject);
@@ -173,9 +176,42 @@
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 @@
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;
Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.h 2009-07-27 04:47:38 UTC (rev 42838)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.h 2009-07-27 04:51:34 UTC (rev 42839)
@@ -43,6 +43,10 @@
personSize = sizeof(uint16) * 2 + sizeof(byte)
};
+enum {
+ kNotFound = -1
+};
+
class WalkingMap {
public:
@@ -82,7 +86,7 @@
struct GameObject {
- GameObject() : _title(NULL) {}
+ GameObject() {}
uint _init, _look, _use, _canUse;
bool _imInit, _imLook, _imUse;
@@ -93,7 +97,7 @@
uint16 _absNum;
Common::Array<int> _anims;
GPL2Program _program;
- byte *_title;
+ Common::String _title;
int _location;
bool _visible;
};
@@ -196,6 +200,7 @@
uint getNumObjects();
GameObject *getObject(uint objNum);
+ int getObjectWithAnimation(int animID);
int getVariable(int varNum);
void setVariable(int varNum, int value);
@@ -222,6 +227,8 @@
Room _currentRoom;
LoopStatus _loopStatus;
+ int _objUnderCursor;
+
int _markedAnimationIndex; //!< Used by the Mark GPL command
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list