Skip to content

Commit

Permalink
Merge branch 'master' of github.com:scummvm/scummvm
Browse files Browse the repository at this point in the history
  • Loading branch information
wjp committed Dec 24, 2015
2 parents da20741 + c191efa commit f2194d5
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 206 deletions.
38 changes: 19 additions & 19 deletions engines/lab/dispman.cpp
Expand Up @@ -335,16 +335,16 @@ void DisplayMan::setUpScreens() {
// It's very convenient to have those shortcut, so I added them
// for all versions. (Strangerke)
uint16 y = _vm->_utils->vgaScaleY(173) - _vm->_utils->svgaCord(2);
moveButtonList->push_back(e->createButton( 1, y, 0, 't', moveImages[0], moveImages[1]));
moveButtonList->push_back(e->createButton( 33, y, 1, 'm', moveImages[2], moveImages[3]));
moveButtonList->push_back(e->createButton( 65, y, 2, 'o', moveImages[4], moveImages[5]));
moveButtonList->push_back(e->createButton( 97, y, 3, 'c', moveImages[6], moveImages[7]));
moveButtonList->push_back(e->createButton(129, y, 4, 'l', moveImages[8], moveImages[9]));
moveButtonList->push_back(e->createButton(161, y, 5, 'i', moveImages[12], moveImages[13]));
moveButtonList->push_back(e->createButton(193, y, 6, VKEY_LTARROW, moveImages[14], moveImages[15]));
moveButtonList->push_back(e->createButton(225, y, 7, VKEY_UPARROW, moveImages[16], moveImages[17]));
moveButtonList->push_back(e->createButton(257, y, 8, VKEY_RTARROW, moveImages[18], moveImages[19]));
moveButtonList->push_back(e->createButton(289, y, 9, 'p', moveImages[10], moveImages[11]));
moveButtonList->push_back(e->createButton( 1, y, 0, Common::KEYCODE_t, moveImages[0], moveImages[1]));
moveButtonList->push_back(e->createButton( 33, y, 1, Common::KEYCODE_m, moveImages[2], moveImages[3]));
moveButtonList->push_back(e->createButton( 65, y, 2, Common::KEYCODE_o, moveImages[4], moveImages[5]));
moveButtonList->push_back(e->createButton( 97, y, 3, Common::KEYCODE_c, moveImages[6], moveImages[7]));
moveButtonList->push_back(e->createButton(129, y, 4, Common::KEYCODE_l, moveImages[8], moveImages[9]));
moveButtonList->push_back(e->createButton(161, y, 5, Common::KEYCODE_i, moveImages[12], moveImages[13]));
moveButtonList->push_back(e->createButton(193, y, 6, Common::KEYCODE_LEFT, moveImages[14], moveImages[15]));
moveButtonList->push_back(e->createButton(225, y, 7, Common::KEYCODE_UP, moveImages[16], moveImages[17]));
moveButtonList->push_back(e->createButton(257, y, 8, Common::KEYCODE_RIGHT, moveImages[18], moveImages[19]));
moveButtonList->push_back(e->createButton(289, y, 9, Common::KEYCODE_p, moveImages[10], moveImages[11]));

// TODO: The INV file is not present in the Amiga version
Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
Expand All @@ -355,18 +355,18 @@ void DisplayMan::setUpScreens() {
for (int imgIdx = 0; imgIdx < 6; imgIdx++)
_vm->_invImages[imgIdx] = new Image(invFile, _vm);
}
invButtonList->push_back(e->createButton( 24, y, 0, 'm', invImages[0], invImages[1]));
invButtonList->push_back(e->createButton( 56, y, 1, 'g', invImages[2], invImages[3]));
invButtonList->push_back(e->createButton( 94, y, 2, 'u', invImages[4], invImages[5]));
invButtonList->push_back(e->createButton(126, y, 3, 'l', moveImages[8], moveImages[9]));
invButtonList->push_back(e->createButton(164, y, 4, VKEY_LTARROW, moveImages[14], moveImages[15]));
invButtonList->push_back(e->createButton(196, y, 5, VKEY_RTARROW, moveImages[18], moveImages[19]));
invButtonList->push_back(e->createButton( 24, y, 0, Common::KEYCODE_ESCAPE, invImages[0], invImages[1]));
invButtonList->push_back(e->createButton( 56, y, 1, Common::KEYCODE_g, invImages[2], invImages[3]));
invButtonList->push_back(e->createButton( 94, y, 2, Common::KEYCODE_u, invImages[4], invImages[5]));
invButtonList->push_back(e->createButton(126, y, 3, Common::KEYCODE_l, moveImages[8], moveImages[9]));
invButtonList->push_back(e->createButton(164, y, 4, Common::KEYCODE_LEFT, moveImages[14], moveImages[15]));
invButtonList->push_back(e->createButton(196, y, 5, Common::KEYCODE_RIGHT, moveImages[18], moveImages[19]));

// The windows version has 2 extra buttons for breadcrumb trail
// CHECKME: the game is really hard to play without those, maybe we could add something to enable that.
if (_vm->getPlatform() == Common::kPlatformWindows) {
invButtonList->push_back(e->createButton(234, y, 6, 'b', invImages[6], invImages[7]));
invButtonList->push_back(e->createButton(266, y, 7, 'f', invImages[8], invImages[9]));
invButtonList->push_back(e->createButton(234, y, 6, Common::KEYCODE_b, invImages[6], invImages[7]));
invButtonList->push_back(e->createButton(266, y, 7, Common::KEYCODE_f, invImages[8], invImages[9]));
}

delete invFile;
Expand Down Expand Up @@ -507,7 +507,7 @@ void DisplayMan::checkerboardEffect(uint16 penColor, uint16 x1, uint16 y1, uint1
}
}

void DisplayMan::closeFont(TextFont **font) {
void DisplayMan::freeFont(TextFont **font) {
if (*font) {
if ((*font)->_data)
delete[] (*font)->_data;
Expand Down
2 changes: 1 addition & 1 deletion engines/lab/dispman.h
Expand Up @@ -239,7 +239,7 @@ class DisplayMan {
/**
* Closes a font and frees all memory associated with it.
*/
void closeFont(TextFont **font);
void freeFont(TextFont **font);

/**
* Returns the length of a text in the specified font.
Expand Down
62 changes: 17 additions & 45 deletions engines/lab/engine.cpp
Expand Up @@ -77,19 +77,6 @@ enum Monitors {
//kMonitorLevers = 82
};

enum MainButtons {
kButtonPickup,
kButtonUse,
kButtonOpen,
kButtonClose,
kButtonLook,
kButtonInventory,
kButtonLeft,
kButtonForward,
kButtonRight,
kButtonMap
};

enum AltButtons {
kButtonMainDisplay,
kButtonSaveLoad,
Expand Down Expand Up @@ -505,24 +492,9 @@ void LabEngine::mainGameLoop() {
_anim->diffNextFrame();

if (_followingCrumbs) {
int result = followCrumbs();

if (result != 0) {
uint16 code = 0;
switch (result) {
case VKEY_UPARROW:
code = kButtonForward;
break;
case VKEY_LTARROW:
code = kButtonLeft;
break;
case VKEY_RTARROW:
code = kButtonRight;
break;
default:
break;
}
MainButton code = followCrumbs();

if (code == kButtonForward || code == kButtonLeft || code == kButtonRight) {
gotMessage = true;
mayShowCrumbIndicator();
_graphics->screenUpdate();
Expand Down Expand Up @@ -638,7 +610,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo

mayShowCrumbIndicator();
_graphics->screenUpdate();
} else if (msgClass == kMessageDeltaMove) {
} else if (msgClass == kMessageMoveCursorToCloseup) {
CloseDataPtr tmpClosePtr = _closeDataPtr;

// get next close-up in list after the one pointed to by curPos
Expand Down Expand Up @@ -737,7 +709,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
forceDraw = true;
interfaceOn();
} else if (code == Common::KEYCODE_TAB)
msgClass = kMessageDeltaMove;
msgClass = kMessageMoveCursorToCloseup;
else if (code == Common::KEYCODE_ESCAPE)
_closeDataPtr = nullptr;

Expand Down Expand Up @@ -1071,7 +1043,7 @@ void LabEngine::go() {

_event->initMouse();
if (_msgFont)
_graphics->closeFont(&_msgFont);
_graphics->freeFont(&_msgFont);

if (getPlatform() != Common::kPlatformAmiga)
_msgFont = _resource->getFont("F:AvanteG.12");
Expand All @@ -1086,26 +1058,26 @@ void LabEngine::go() {
_event->mouseShow();
mainGameLoop();

_graphics->closeFont(&_msgFont);
_graphics->freeFont(&_msgFont);
_graphics->freePict();

freeScreens();

_music->freeMusic();
}

int LabEngine::followCrumbs() {
MainButton LabEngine::followCrumbs() {
// kDirectionNorth, kDirectionSouth, kDirectionEast, kDirectionWest
int movement[4][4] = {
{ VKEY_UPARROW, VKEY_RTARROW, VKEY_RTARROW, VKEY_LTARROW },
{ VKEY_RTARROW, VKEY_UPARROW, VKEY_LTARROW, VKEY_RTARROW },
{ VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW, VKEY_RTARROW },
{ VKEY_RTARROW, VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW }
MainButton movement[4][4] = {
{ kButtonForward, kButtonRight, kButtonRight, kButtonLeft },
{ kButtonRight, kButtonForward, kButtonLeft, kButtonRight },
{ kButtonLeft, kButtonRight, kButtonForward, kButtonRight },
{ kButtonRight, kButtonLeft, kButtonRight, kButtonForward }
};

if (_isCrumbWaiting) {
if (_system->getMillis() <= _crumbTimestamp)
return 0;
return kButtonNone;

_isCrumbWaiting = false;
}
Expand All @@ -1119,10 +1091,10 @@ int LabEngine::followCrumbs() {
_breadCrumbs[0]._roomNum = 0;
_droppingCrumbs = false;
_followingCrumbs = false;
return 0;
return kButtonNone;
}

int exitDir;
Direction exitDir;
// which direction is last crumb
if (_breadCrumbs[_numCrumbs]._direction == kDirectionEast)
exitDir = kDirectionWest;
Expand All @@ -1133,15 +1105,15 @@ int LabEngine::followCrumbs() {
else
exitDir = kDirectionNorth;

int moveDir = movement[_direction][exitDir];
MainButton moveDir = movement[_direction][exitDir];

if (_numCrumbs == 0) {
_isCrumbTurning = false;
_breadCrumbs[0]._roomNum = 0;
_droppingCrumbs = false;
_followingCrumbs = false;
} else {
_isCrumbTurning = (moveDir != VKEY_UPARROW);
_isCrumbTurning = (moveDir != kButtonForward);
_isCrumbWaiting = true;

int theDelay = (_followCrumbsFast ? 1000 / 4 : 1000);
Expand Down
110 changes: 27 additions & 83 deletions engines/lab/eventman.cpp
Expand Up @@ -59,6 +59,17 @@ static const byte mouseData[] = {
#define MOUSE_WIDTH 10
#define MOUSE_HEIGHT 15

EventManager::EventManager(LabEngine *vm) : _vm(vm) {
_leftClick = false;
_rightClick = false;

_lastButtonHit = nullptr;
_screenButtonList = nullptr;
_hitButton = nullptr;
_mousePos = Common::Point(0, 0);
_keyPressed = Common::KEYCODE_INVALID;
}

Button *EventManager::checkButtonHit(ButtonList *buttonList, Common::Point pos) {
for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) {
Button *button = *buttonItr;
Expand Down Expand Up @@ -104,47 +115,22 @@ Button *EventManager::getButton(uint16 id) {
return nullptr;
}

EventManager::EventManager(LabEngine *vm) : _vm(vm) {
_leftClick = false;
_rightClick = false;

_mouseHidden = true;
_lastButtonHit = nullptr;
_screenButtonList = nullptr;
_hitButton = nullptr;
_mousePos = Common::Point(0, 0);

_nextKeyIn = 0;
_nextKeyOut = 0;

for (int i = 0; i < 64; i++)
_keyBuf[i] = Common::KEYCODE_INVALID;

}

void EventManager::updateMouse() {
bool doUpdateDisplay = false;

if (!_mouseHidden)
doUpdateDisplay = true;
if (!_hitButton)
return;

if (_hitButton) {
mouseHide();
_hitButton->_altImage->drawImage(_hitButton->_x, _hitButton->_y);
mouseShow();
mouseHide();
_hitButton->_altImage->drawImage(_hitButton->_x, _hitButton->_y);
mouseShow();

for (int i = 0; i < 3; i++)
_vm->waitTOF();
for (int i = 0; i < 3; i++)
_vm->waitTOF();

mouseHide();
_hitButton->_image->drawImage(_hitButton->_x, _hitButton->_y);
mouseShow();
doUpdateDisplay = true;
_hitButton = nullptr;
}

if (doUpdateDisplay)
_vm->_graphics->screenUpdate();
mouseHide();
_hitButton->_image->drawImage(_hitButton->_x, _hitButton->_y);
mouseShow();
_hitButton = nullptr;
_vm->_graphics->screenUpdate();
}

void EventManager::initMouse() {
Expand All @@ -155,20 +141,11 @@ void EventManager::initMouse() {
}

void EventManager::mouseShow() {
if (_mouseHidden) {
processInput();
_mouseHidden = false;
}

_vm->_system->showMouse(true);
}

void EventManager::mouseHide() {
if (!_mouseHidden) {
_mouseHidden = true;

_vm->_system->showMouse(false);
}
_vm->_system->showMouse(false);
}

Common::Point EventManager::getMousePos() {
Expand All @@ -183,23 +160,6 @@ void EventManager::setMousePos(Common::Point pos) {
_vm->_system->warpMouse(pos.x, pos.y);
else
_vm->_system->warpMouse(pos.x * 2, pos.y);

if (!_mouseHidden)
processInput();
}

bool EventManager::keyPress(Common::KeyCode *keyCode) {
if (haveNextChar()) {
*keyCode = getNextChar();
return true;
}

return false;
}

bool EventManager::haveNextChar() {
processInput();
return _nextKeyIn != _nextKeyOut;
}

void EventManager::processInput() {
Expand Down Expand Up @@ -241,13 +201,9 @@ void EventManager::processInput() {
continue;
}
// Intentional fall through
default: {
int n = (_nextKeyIn + 1) % 64;
if (n != _nextKeyOut) {
_keyBuf[_nextKeyIn] = event.kbd.keycode;
_nextKeyIn = n;
}
}
default:
_keyPressed = event.kbd;
break;
}
break;
case Common::EVENT_QUIT:
Expand All @@ -262,18 +218,6 @@ void EventManager::processInput() {
_vm->_system->updateScreen();
}

Common::KeyCode EventManager::getNextChar() {
Common::KeyCode chr = Common::KEYCODE_INVALID;

processInput();
if (_nextKeyIn != _nextKeyOut) {
chr = _keyBuf[_nextKeyOut];
_nextKeyOut = (_nextKeyOut + 1) % 64;
}

return chr;
}

Common::Point EventManager::updateAndGetMousePos() {
processInput();

Expand Down

0 comments on commit f2194d5

Please sign in to comment.