mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-16 14:50:17 +00:00
FULLPIPE: Implement CMovGraph_messageHandler()
This commit is contained in:
parent
32d28c9f7a
commit
eeac2c0c4f
@ -28,6 +28,7 @@
|
||||
|
||||
#include "fullpipe/objects.h"
|
||||
#include "fullpipe/motion.h"
|
||||
#include "fullpipe/messages.h"
|
||||
|
||||
namespace Fullpipe {
|
||||
|
||||
@ -104,13 +105,17 @@ bool CMctlCompoundArray::load(MfcArchive &file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int CMovGraph_messageHandler(ExCommand *cmd);
|
||||
|
||||
CMovGraph::CMovGraph() {
|
||||
warning("STUB: CMovGraph::CMovGraph()");
|
||||
_itemsCount = 0;
|
||||
_items = 0;
|
||||
//_callback1 = CMovGraphCallback1; // TODO
|
||||
_field_44 = 0;
|
||||
// insertMessageHandler(CMovGraph_messageHandler, getMessageHandlersCount() - 1, 129);
|
||||
insertMessageHandler(CMovGraph_messageHandler, getMessageHandlersCount() - 1, 129);
|
||||
|
||||
_objtype = kObjTypeMovGraph;
|
||||
}
|
||||
|
||||
bool CMovGraph::load(MfcArchive &file) {
|
||||
@ -126,6 +131,19 @@ void CMovGraph::addObject(StaticANIObject *obj) {
|
||||
warning("STUB: CMovGraph::addObject()");
|
||||
}
|
||||
|
||||
double CMovGraph::calcDistance(Common::Point *point, CMovGraphLink *link, int flag) {
|
||||
warning("STUB: CMovGraph::calcDistance()");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CMovGraphNode *CMovGraph::calcOffset(int ox, int oy) {
|
||||
warning("STUB: CMovGraph::calcOffset()");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
CMovGraphLink::CMovGraphLink() {
|
||||
_distance = 0;
|
||||
_angle = 0;
|
||||
|
@ -77,6 +77,7 @@ class Unk2 : public CObject {
|
||||
};
|
||||
|
||||
class CMovGraphNode : public CObject {
|
||||
public:
|
||||
int _x;
|
||||
int _y;
|
||||
int _distance;
|
||||
@ -137,6 +138,7 @@ class CReactPolygonal : public CMovGraphReact {
|
||||
};
|
||||
|
||||
class CMovGraphLink : public CObject {
|
||||
public:
|
||||
CMovGraphNode *_movGraphNode1;
|
||||
CMovGraphNode *_movGraphNode2;
|
||||
CDWordArray _dwordArray1;
|
||||
@ -155,6 +157,7 @@ class CMovGraphLink : public CObject {
|
||||
};
|
||||
|
||||
class CMovGraph : public CMotionController {
|
||||
public:
|
||||
CObList _nodes;
|
||||
CObList _links;
|
||||
int _field_44;
|
||||
@ -168,6 +171,9 @@ class CMovGraph : public CMotionController {
|
||||
virtual bool load(MfcArchive &file);
|
||||
|
||||
virtual void addObject(StaticANIObject *obj);
|
||||
|
||||
double calcDistance(Common::Point *point, CMovGraphLink *link, int flag);
|
||||
CMovGraphNode *calcOffset(int ox, int oy);
|
||||
};
|
||||
|
||||
class CMctlConnectionPoint : public CObject {
|
||||
|
@ -1313,6 +1313,63 @@ int global_messageHandler4(ExCommand *cmd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CMovGraph_messageHandler(ExCommand *cmd) {
|
||||
if (cmd->_messageKind != 17)
|
||||
return 0;
|
||||
|
||||
if (cmd->_messageNum != 33)
|
||||
return 0;
|
||||
|
||||
StaticANIObject *ani = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_gameLoader->_field_FA, -1);
|
||||
|
||||
if (!getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId))
|
||||
return 0;
|
||||
|
||||
if (getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->_objtype != kObjTypeMovGraph || !ani)
|
||||
return 0;
|
||||
|
||||
CMovGraph *gr = (CMovGraph *)getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId);
|
||||
|
||||
CMovGraphLink *link = 0;
|
||||
double mindistance = 1.0e10;
|
||||
Common::Point point;
|
||||
|
||||
for (CObList::iterator i = gr->_links.begin(); i != gr->_links.end(); ++i) {
|
||||
point.x = ani->_ox;
|
||||
point.y = ani->_oy;
|
||||
|
||||
double dst = gr->calcDistance(&point, (CMovGraphLink *)(*i), 0);
|
||||
if (dst >= 0.0 && dst < mindistance) {
|
||||
mindistance = dst;
|
||||
link = (CMovGraphLink *)(*i);
|
||||
}
|
||||
}
|
||||
|
||||
int top;
|
||||
|
||||
if (link) {
|
||||
CMovGraphNode *node = link->_movGraphNode1;
|
||||
|
||||
double sq = (ani->_oy - node->_y) * (ani->_oy - node->_y) + (ani->_ox - node->_x) * (ani->_ox - node->_x);
|
||||
int off = (node->_field_14 >> 16) & 0xFF;
|
||||
double off2 = (link->_movGraphNode2->_field_14 >> 8) & 0xff - off;
|
||||
|
||||
top = off + (int)(sqrt(sq) * off2 / link->_distance);
|
||||
} else {
|
||||
top = (gr->calcOffset(ani->_ox, ani->_oy)->_field_14 >> 8) & 0xff;
|
||||
}
|
||||
|
||||
if (ani->_movement) {
|
||||
ani->_movement->_currDynamicPhase->_rect->top = 255 - top;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ani->_statics)
|
||||
ani->_statics->_rect->top = 255 - top;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int defaultUpdateCursor() {
|
||||
g_fullpipe->updateCursorsCommon();
|
||||
|
||||
|
@ -396,6 +396,8 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) {
|
||||
if (_objectMap.size() < obTag) {
|
||||
error("Object index too big: %d at 0x%08x", obTag, pos() - 2);
|
||||
}
|
||||
debug(7, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag]));
|
||||
|
||||
res = _objectMap[obTag];
|
||||
|
||||
*isCopyReturned = true;
|
||||
|
@ -68,7 +68,8 @@ enum ObjType {
|
||||
kObjTypeDefault,
|
||||
kObjTypeObjstateCommand,
|
||||
kObjTypeStaticANIObject,
|
||||
kObjTypePictureObject
|
||||
kObjTypePictureObject,
|
||||
kObjTypeMovGraph
|
||||
};
|
||||
|
||||
class CObject {
|
||||
|
Loading…
Reference in New Issue
Block a user