LAB: make takeItem use Common::Point, some refactoring

This commit is contained in:
Strangerke 2015-12-16 15:36:21 +01:00 committed by Willem Jan Palenstijn
parent dd06c83280
commit 9c7e372a21
3 changed files with 6 additions and 11 deletions

View File

@ -630,7 +630,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
uint16 oldDirection = 0;
uint16 lastInv = kItemMap;
CloseDataPtr wrkClosePtr = nullptr;
bool doit;
bool leftButtonClick = false;
bool rightButtonClick = false;
@ -663,7 +662,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
interfaceOff();
_mainDisplay = true;
doit = false;
bool doit = false;
if (_closeDataPtr) {
switch (_closeDataPtr->_closeUpType) {
@ -690,9 +689,9 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
switch (actionMode) {
case 0:
// Take something.
if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &_closeDataPtr))
if (doActionRule(curPos, actionMode, _roomNum, &_closeDataPtr))
_curFileName = _newFileName;
else if (takeItem(curPos.x, curPos.y, &_closeDataPtr))
else if (takeItem(curPos, &_closeDataPtr))
drawStaticMessage(kTextTakeItem);
else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &_closeDataPtr))
_curFileName = _newFileName;
@ -1060,9 +1059,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
_closeDataPtr = nullptr;
_mainDisplay = true;
curInv = kItemMap;
lastInv = kItemMap;
curInv = lastInv = kItemMap;
_nextFileName = getInvName(curInv);
_graphics->drawPanel();
@ -1212,7 +1209,6 @@ int LabEngine::followCrumbs() {
}
int exitDir;
// which direction is last crumb
if (_breadCrumbs[_numCrumbs]._direction == EAST)
exitDir = WEST;

View File

@ -249,7 +249,7 @@ private:
Common::Rect roomCoords(uint16 curRoom);
bool saveRestoreGame();
void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList);
bool takeItem(Common::Point pos, CloseDataPtr *closePtrList);
void turnPage(bool fromLeft);
bool processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code);
void processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode);

View File

@ -240,7 +240,7 @@ void LabEngine::setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, b
/**
* Takes the currently selected item.
*/
bool LabEngine::takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList) {
bool LabEngine::takeItem(Common::Point pos, CloseDataPtr *closePtrList) {
CloseDataPtr closePtr;
if (!*closePtrList) {
@ -251,7 +251,6 @@ bool LabEngine::takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList) {
} else
closePtr = (*closePtrList)->_subCloseUps;
Common::Point pos = Common::Point(x, y);
Common::Rect objRect;
while (closePtr) {
objRect = Common::Rect(_utils->scaleX(closePtr->_x1), _utils->scaleX(closePtr->_y1), _utils->scaleX(closePtr->_x2), _utils->scaleX(closePtr->_y2));