Skip to content

Commit

Permalink
FULLPIPE: Implement Scene::initObjectCursors()
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Sep 6, 2013
1 parent 1261cd4 commit 3e4670e
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 4 deletions.
2 changes: 2 additions & 0 deletions engines/fullpipe/fullpipe.cpp
Expand Up @@ -132,6 +132,8 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc)
_inventoryScene = 0;
_inventory = 0;

_minCursorId = 0;

_isSaveAllowed = true;

g_fullpipe = this;
Expand Down
5 changes: 5 additions & 0 deletions engines/fullpipe/fullpipe.h
Expand Up @@ -53,6 +53,7 @@ struct CursorInfo;
class EntranceInfo;
class ExCommand;
class GameProject;
class GameObject;
class GlobalMessageQueueList;
class MessageHandler;
struct MovTable;
Expand Down Expand Up @@ -198,7 +199,11 @@ class FullpipeEngine : public ::Engine {
int (*_updateCursorCallback)();

int _cursorId;
int _minCursorId;
Common::Array<int> _objectIdCursors;

void setCursor(int id);
void updateCursorsCommon();

int getObjectState(const char *objname);
void setObjectState(const char *name, int state);
Expand Down
4 changes: 4 additions & 0 deletions engines/fullpipe/input.cpp
Expand Up @@ -117,4 +117,8 @@ void FullpipeEngine::defHandleKeyDown(int key) {
warning("STUB: FullpipeEngine::defHandleKeyDown(%d)", key);
}

void FullpipeEngine::updateCursorsCommon() {

}

} // End of namespace Fullpipe
49 changes: 46 additions & 3 deletions engines/fullpipe/scene.cpp
Expand Up @@ -26,6 +26,7 @@
#include "fullpipe/ngiarchive.h"
#include "fullpipe/statics.h"
#include "fullpipe/messages.h"
#include "fullpipe/gameloader.h"

#include "fullpipe/constants.h"

Expand Down Expand Up @@ -326,14 +327,23 @@ void Scene::setPictureObjectsFlag4() {
}

PictureObject *Scene::getPictureObjectById(int objId, int flags) {
for (uint i = 1; i < _picObjList.size(); i++) {
for (uint i = 0; i < _picObjList.size(); i++) {
if (((PictureObject *)_picObjList[i])->_id == objId && ((PictureObject *)_picObjList[i])->_okeyCode == flags)
return (PictureObject *)_picObjList[i];
}

return 0;
}

PictureObject *Scene::getPictureObjectByName(const char *objName, int flags) {
for (uint i = 0; i < _picObjList.size(); i++) {
if (!strcmp(((PictureObject *)_picObjList[i])->_objectName, objName) && ((PictureObject *)_picObjList[i])->_okeyCode == flags || flags == -1)
return (PictureObject *)_picObjList[i];
}

return 0;
}

void Scene::deletePictureObject(PictureObject *obj) {
for (uint i = 0; i < _picObjList.size(); i++) {
if (((PictureObject *)_picObjList[i]) == obj) {
Expand Down Expand Up @@ -386,8 +396,41 @@ void Scene::preloadMovements(CGameVar *var) {
}
}

void Scene::initObjectCursors(const char *name) {
warning("STUB: Scene::initObjectCursors(%s)", name);
void Scene::initObjectCursors(const char *varname) {
CGameVar *cursorsVar = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(varname)->getSubVarByName("CURSORS");

if (!cursorsVar || !cursorsVar->_subVars)
return;

int maxId = 0;
int minId = 0xffff;

for (CGameVar *sub = cursorsVar->_subVars; sub; sub = sub->_nextVarObj) {
GameObject *obj = getPictureObjectByName(sub->_varName, -1);

if (obj || (obj = getStaticANIObject1ByName(sub->_varName, -1)) != 0) {
if (obj->_id < minId)
minId = obj->_id;
if (obj->_id > maxId)
maxId = obj->_id;
}
}

g_fullpipe->_minCursorId = minId;

g_fullpipe->_objectIdCursors.resize(maxId - minId + 1);

for (CGameVar *sub = cursorsVar->_subVars; sub; sub = sub->_nextVarObj) {
GameObject *obj = getPictureObjectByName(sub->_varName, -1);

if (!obj)
obj = getStaticANIObject1ByName(sub->_varName, -1);

PictureObject *pic = getGameLoaderInventory()->getScene()->getPictureObjectByName(sub->_value.stringValue, -1);

if (obj && pic)
g_fullpipe->_objectIdCursors[obj->_id - minId] = pic->_id;
}
}

bool Scene::compareObjPriority(const void *p1, const void *p2) {
Expand Down
1 change: 1 addition & 0 deletions engines/fullpipe/scene.h
Expand Up @@ -67,6 +67,7 @@ class Scene : public Background {

void setPictureObjectsFlag4();
PictureObject *getPictureObjectById(int objId, int flags);
PictureObject *getPictureObjectByName(const char *name, int keyCode);
void deletePictureObject(PictureObject *obj);
void preloadMovements(CGameVar *var);

Expand Down
2 changes: 1 addition & 1 deletion engines/fullpipe/scenes.cpp
Expand Up @@ -1137,7 +1137,7 @@ int global_messageHandler4(ExCommand *cmd) {
}

int defaultUpdateCursor() {
warning("STUB: defaultUpdateCursor");
g_fullpipe->updateCursorsCommon();

return g_fullpipe->_cursorId;
}
Expand Down

0 comments on commit 3e4670e

Please sign in to comment.