void LabEngine::turnPage(bool fromLeft) { if (fromLeft) { for (int i = 0; i < _graphics->_screenWidth; i += 8) { updateEvents(); waitTOF(); _journalBackImage->blitBitmap(i, 0, nullptr, i, 0, 8, _graphics->_screenHeight, false); } } else { for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) { updateEvents(); waitTOF(); _journalBackImage->blitBitmap(i, 0, nullptr, i, 0, 8, _graphics->_screenHeight, false); } } }
void LabEngine::doActions(const ActionList &actionList) { ActionList::const_iterator action; for (action = actionList.begin(); action != actionList.end(); ++action) { updateEvents(); if (_quitLab || shouldQuit()) return; switch (action->_actionType) { case kActionPlaySound: _music->loadSoundEffect(action->_messages[0], false, true); break; case kActionPlaySoundNoWait: // only used in scene 7 (street, when teleporting to the surreal maze) _music->loadSoundEffect(action->_messages[0], false, false); break; case kActionPlaySoundLooping: _music->loadSoundEffect(action->_messages[0], true, false); break; case kActionShowDiff: _graphics->readPict(action->_messages[0], true); break; case kActionShowDiffLooping: // used in scene 44 (heart of the labyrinth, minotaur) _graphics->readPict(action->_messages[0], false); break; case kActionLoadDiff: if (!action->_messages[0].empty()) // Puts a file into memory _graphics->loadPict(action->_messages[0]); break; case kActionLoadBitmap: error("Unused opcode kActionLoadBitmap has been called"); case kActionShowBitmap: error("Unused opcode kActionShowBitmap has been called"); case kActionTransition: _graphics->doTransition((TransitionType)action->_param1, action->_messages[0].c_str()); break; case kActionNoUpdate: _noUpdateDiff = true; _anim->_doBlack = false; break; case kActionForceUpdate: _curFileName = " "; break; case kActionShowCurPict: { Common::String test = getPictName(true); if (test != _curFileName) { _curFileName = test; _graphics->readPict(_curFileName); } } break; case kActionSetElement: _conditions->inclElement(action->_param1); break; case kActionUnsetElement: _conditions->exclElement(action->_param1); break; case kActionShowMessage: if (_graphics->_longWinInFront) _graphics->longDrawMessage(action->_messages[0], true); else _graphics->drawMessage(action->_messages[0], true); break; case kActionCShowMessage: if (!_closeDataPtr) _graphics->drawMessage(action->_messages[0], true); break; case kActionShowMessages: _graphics->drawMessage(action->_messages[_utils->getRandom(action->_param1)], true); break; case kActionChangeRoom: if (action->_param1 & 0x8000) { // This is a Wyrmkeep Windows trial version, thus stop at this // point, since we can't check for game payment status _graphics->readPict(getPictName(true)); GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep"); trialMessage.runModal(); break; } _music->checkRoomMusic(_roomNum, action->_param1); _roomNum = action->_param1; _direction = action->_param2 - 1; _closeDataPtr = nullptr; _anim->_doBlack = true; break; case kActionSetCloseup: { Common::Point curPos = Common::Point(_utils->scaleX(action->_param1), _utils->scaleY(action->_param2)); const CloseData *tmpClosePtr = getObject(curPos, _closeDataPtr); if (tmpClosePtr) _closeDataPtr = tmpClosePtr; } break; case kActionMainView: _closeDataPtr = nullptr; break; case kActionSubInv: if (_inventory[action->_param1]._quantity) (_inventory[action->_param1]._quantity)--; if (_inventory[action->_param1]._quantity == 0) _conditions->exclElement(action->_param1); break; case kActionAddInv: (_inventory[action->_param1]._quantity) += action->_param2; _conditions->inclElement(action->_param1); break; case kActionShowDir: _graphics->setActionMessage(false); break; case kActionWaitSecs: { uint32 targetMillis = _system->getMillis() + action->_param1 * 1000; _graphics->screenUpdate(); while (_system->getMillis() < targetMillis) { updateEvents(); if (_quitLab || shouldQuit()) return; _anim->diffNextFrame(); } } break; case kActionStopMusic: // used in scene 44 (heart of the labyrinth, minotaur) _music->freeMusic(); break; case kActionStartMusic: // unused error("Unused opcode kActionStartMusic has been called"); break; case kActionChangeMusic: // used in scene 46 (museum exhibit, for the alarm) _music->changeMusic(action->_messages[0], true, false); break; case kActionResetMusic: // used in scene 45 (sheriff's office, after museum) _music->resetMusic(true); break; case kActionFillMusic: error("Unused opcode kActionFillMusic has been called"); break; case kActionWaitSound: // used in scene 44 (heart of the labyrinth / ending) while (_music->isSoundEffectActive()) { updateEvents(); if (_quitLab || shouldQuit()) return; _anim->diffNextFrame(); waitTOF(); } break; case kActionClearSound: _music->stopSoundEffect(); break; case kActionWinMusic: // used in scene 44 (heart of the labyrinth / ending) _music->freeMusic(); _music->changeMusic("Music:WinGame", false, false); break; case kActionWinGame: // used in scene 44 (heart of the labyrinth / ending) _quitLab = true; showLab2Teaser(); break; case kActionLostGame: error("Unused opcode kActionLostGame has been called"); case kActionResetBuffer: _graphics->freePict(); break; case kActionSpecialCmd: if (action->_param1 == 0) _anim->_doBlack = true; else if (action->_param1 == 1) _anim->_doBlack = (_closeDataPtr == nullptr); else if (action->_param1 == 2) _anim->_doBlack = (_closeDataPtr != nullptr); else if (action->_param1 == 5) { // inverse the palette for (int idx = (8 * 3); idx < (255 * 3); idx++) _anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx]; waitTOF(); _graphics->setPalette(_anim->_diffPalette, 256); waitTOF(); waitTOF(); } else if (action->_param1 == 4) { // white the palette _graphics->whiteScreen(); waitTOF(); waitTOF(); } else if (action->_param1 == 6) { // Restore the palette waitTOF(); _graphics->setPalette(_anim->_diffPalette, 256); waitTOF(); waitTOF(); } else if (action->_param1 == 7) { // Quick pause waitTOF(); waitTOF(); waitTOF(); } break; } } _music->stopSoundEffect(); }
void LabEngine::processMap(uint16 curRoom) { byte place = 1; uint16 curMsg = curRoom; uint16 curFloor = _maps[curRoom]._pageNumber; while (1) { IntuiMessage *msg = _event->getMsg(); if (shouldQuit()) { _quitLab = true; return; } updateEvents(); _graphics->screenUpdate(); _system->delayMillis(10); if (!msg) { updateEvents(); byte newcolor[3]; if (place <= 14) { newcolor[0] = 14 << 2; newcolor[1] = place << 2; newcolor[2] = newcolor[1]; } else { newcolor[0] = 14 << 2; newcolor[1] = (28 - place) << 2; newcolor[2] = newcolor[1]; } waitTOF(); _graphics->writeColorRegs(newcolor, 1, 1); _interface->handlePressedButton(); waitTOF(); place++; if (place >= 28) place = 1; } else { uint32 msgClass = msg->_msgClass; uint16 msgCode = msg->_code; uint16 mouseX = msg->_mouse.x; uint16 mouseY = msg->_mouse.y; if ((msgClass == kMessageRightClick) || ((msgClass == kMessageRawKey) && (msgCode == Common::KEYCODE_ESCAPE))) return; if (msgClass == kMessageButtonUp) { if (msgCode == 0) { // Quit menu button return; } else if (msgCode == 1) { // Up arrow uint16 upperFloor = getUpperFloor(curFloor); if (upperFloor != kFloorNone) { curFloor = upperFloor; _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } } else if (msgCode == 2) { // Down arrow uint16 lowerFloor = getLowerFloor(curFloor); if (lowerFloor != kFloorNone) { curFloor = lowerFloor; _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } } } else if (msgClass == kMessageLeftClick) { if ((curFloor == kFloorLower) && _utils->mapRectScale(538, 277, 633, 352).contains(mouseX, mouseY) && floorVisited(kFloorSurMaze)) { curFloor = kFloorSurMaze; _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(358, 71, 452, 147).contains(mouseX, mouseY) && floorVisited(kFloorCarnival)) { curFloor = kFloorCarnival; _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(557, 325, 653, 401).contains(mouseX, mouseY) && floorVisited(kFloorMedMaze)) { curFloor = kFloorMedMaze; _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } else if ((curFloor == kFloorUpper) && _utils->mapRectScale(524, 97, 645, 207).contains(mouseX, mouseY) && floorVisited(kFloorHedgeMaze)) { curFloor = kFloorHedgeMaze; _graphics->fade(false); drawMap(curRoom, curMsg, curFloor, false); _graphics->fade(true); } else if (mouseX > _utils->mapScaleX(314)) { uint16 oldMsg = curMsg; Common::Rect curCoords; for (int i = 1; i <= _maxRooms; i++) { curCoords = roomCoords(i); if ((_maps[i]._pageNumber == curFloor) && _roomsFound->in(i) && curCoords.contains(Common::Point(mouseX, mouseY))) { curMsg = i; } } if (oldMsg != curMsg) { if (!_rooms[curMsg]._roomMsg.empty()) _resource->readViews(curMsg); const char *sptr; if ((sptr = _rooms[curMsg]._roomMsg.c_str())) { _graphics->rectFillScaled(13, 148, 135, 186, 3); _graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), sptr); if (_maps[oldMsg]._pageNumber == curFloor) drawRoomMap(oldMsg, (bool)(oldMsg == curRoom)); curCoords = roomCoords(curMsg); int right = (curCoords.left + curCoords.right) / 2; int left = right - 1; int top, bottom; top = bottom = (curCoords.top + curCoords.bottom) / 2; if ((curMsg != curRoom) && (_maps[curMsg]._pageNumber == curFloor)) _graphics->rectFill(left, top, right, bottom, 1); } } } } _graphics->screenUpdate(); } } // while }