diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lab/eventman.cpp | 10 | ||||
-rw-r--r-- | engines/lab/eventman.h | 1 | ||||
-rw-r--r-- | engines/lab/lab.h | 5 | ||||
-rw-r--r-- | engines/lab/map.cpp | 58 | ||||
-rw-r--r-- | engines/lab/special.cpp | 62 |
5 files changed, 47 insertions, 89 deletions
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp index 7760ba2085..53361c9e8a 100644 --- a/engines/lab/eventman.cpp +++ b/engines/lab/eventman.cpp @@ -94,6 +94,16 @@ void EventManager::attachGadgetList(GadgetList *gadgetList) { _screenGadgetList = gadgetList; } +Gadget *EventManager::getGadget(uint16 id) { + for (GadgetList::iterator gadgetItr = _screenGadgetList->begin(); gadgetItr != _screenGadgetList->end(); ++gadgetItr) { + Gadget *gadget = *gadgetItr; + if (gadget->_gadgetID == id) + return gadget; + } + + return nullptr; +} + EventManager::EventManager(LabEngine *vm) : _vm(vm) { _leftClick = false; _rightClick = false; diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h index f87d7ee2db..420c7d03df 100644 --- a/engines/lab/eventman.h +++ b/engines/lab/eventman.h @@ -67,6 +67,7 @@ public: bool mouseButton(uint16 *x, uint16 *y, bool leftButton); Gadget *mouseGadget(); void attachGadgetList(GadgetList *gadgetList); + Gadget *getGadget(uint16 id); void mouseHandler(int flag, Common::Point pos); bool keyPress(uint16 *keyCode); bool haveNextChar(); diff --git a/engines/lab/lab.h b/engines/lab/lab.h index 6b2efdae54..2604579ca9 100644 --- a/engines/lab/lab.h +++ b/engines/lab/lab.h @@ -149,6 +149,8 @@ private: CloseDataPtr _cptr; InventoryData *_inventory; Image *_tiles[16]; + GadgetList _journalGadgetList; + GadgetList _mapGadgetList; private: bool from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage * curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode); @@ -161,9 +163,12 @@ public: void decIncInv(uint16 *CurInv, bool dec); Gadget *checkNumGadgetHit(GadgetList *gadgetList, uint16 key); IntuiMessage *getMsg(); + void loadMapData(); void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein); void processMap(uint16 CurRoom); void doMap(uint16 CurRoom); + void freeMapData(); + void loadJournalData(); void drawJournal(uint16 wipenum, bool needFade); void processJournal(); void doJournal(); diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index b09ca506f2..b509039277 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -49,15 +49,6 @@ static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge, static uint16 MaxRooms; static MapData *Maps; -static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105}; - -static Gadget - backgadget = { 8, 105, 0, 0, 0L, NULL, NULL }, - upgadget = { 55, 105, 1, VKEY_UPARROW, 0L, NULL, NULL }, - downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL }; - -static GadgetList *MapGadgetList; - #define LOWERFLOOR 1 #define MIDDLEFLOOR 2 #define UPPERFLOOR 3 @@ -83,14 +74,8 @@ static uint16 mapScaleY(uint16 y) { /** * Loads in the map data. */ -static bool loadMapData() { - uint16 counter; - - MapGadgetList = new GadgetList(); - MapGadgetList->push_back(&backgadget); - MapGadgetList->push_back(&upgadget); - MapGadgetList->push_back(&downgadget); - +void LabEngine::loadMapData() { + Utils *utils = g_lab->_utils; Common::File *mapImages = g_lab->_resource->openDataFile("P:MapImage"); Map = new Image(mapImages); @@ -111,23 +96,12 @@ static bool loadMapData() { Path = new Image(mapImages); Bridge = new Image(mapImages); - backgadget._image = new Image(mapImages); - backgadget._altImage = new Image(mapImages); - upgadget._image = new Image(mapImages); - upgadget._altImage = new Image(mapImages); - downgadget._image = new Image(mapImages); - downgadget._altImage = new Image(mapImages); + _mapGadgetList.push_back(createButton( 8, utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages))); // back + _mapGadgetList.push_back(createButton( 55, utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages))); // up + _mapGadgetList.push_back(createButton(101, utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages))); // down delete mapImages; - counter = 0; - - for (GadgetList::iterator gadget = MapGadgetList->begin(); gadget != MapGadgetList->end(); ++gadget) { - (*gadget)->x = g_lab->_utils->vgaScaleX(MapGadX[counter]); - (*gadget)->y = g_lab->_utils->vgaScaleY(MapGadY[counter]); - counter++; - } - Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0')); g_lab->_music->updateMusic(); if (!g_lab->_music->_doNotFilestopSoundEffect) @@ -144,13 +118,10 @@ static bool loadMapData() { } delete mapFile; - - return true; } -static void freeMapData() { - MapGadgetList->clear(); - delete MapGadgetList; +void LabEngine::freeMapData() { + freeButtonList(&_mapGadgetList); delete[] Maps; Maps = NULL; @@ -406,7 +377,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou _graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1); Map->drawImage(0, 0); - drawGadgetList(MapGadgetList); + drawGadgetList(&_mapGadgetList); for (uint16 i = 1; i <= MaxRooms; i++) { if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) { @@ -424,18 +395,21 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou tempfloor = Floor; getUpFloor(&tempfloor, &noOverlay); + Gadget *upGadget = _event->getGadget(1); + Gadget *downGadget = _event->getGadget(2); + if (noOverlay) - enableGadget(&upgadget); + enableGadget(upGadget); else - disableGadget(&upgadget, 12); + disableGadget(upGadget, 12); tempfloor = Floor; getDownFloor(&tempfloor, &noOverlay); if (noOverlay) - enableGadget(&downgadget); + enableGadget(downGadget); else - disableGadget(&downgadget, 12); + disableGadget(downGadget, 12); // Labyrinth specific code if (Floor == LOWERFLOOR) { @@ -660,9 +634,9 @@ void LabEngine::doMap(uint16 CurRoom) { else if (_direction == WEST) XMark = MapWest; + _event->attachGadgetList(&_mapGadgetList); drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true); _event->mouseShow(); - _event->attachGadgetList(MapGadgetList); _graphics->screenUpdate(); processMap(CurRoom); _event->attachGadgetList(NULL); diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 6395ee9a7c..5aa8db5181 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -51,8 +51,6 @@ static char *journaltext, *journaltexttitle; static uint16 JPage = 0; static bool lastpage = false; static Image JBackImage, ScreenImage; -static uint16 JGadX[3] = { 80, 144, 194 }, JGadY[3] = { 162, 164, 162 }; -static Gadget ForwardG, CancelG, BackG; static bool GotBackImage = false; static uint16 monitorPage; static const char *TextFileName; @@ -150,7 +148,7 @@ void LabEngine::doWestPaper() { /** * Loads in the data for the journal. */ -static bool loadJournalData() { +void LabEngine::loadJournalData() { char filename[20]; bool bridge, dirty, news, clean; @@ -187,40 +185,11 @@ static bool loadJournalData() { journaltexttitle = g_lab->_resource->getText("Lab:Rooms/jt"); Common::File *journalFile = g_lab->_resource->openDataFile("P:JImage"); - - BackG._image = new Image(journalFile); - BackG._altImage = new Image(journalFile); - ForwardG._image = new Image(journalFile); - ForwardG._altImage = new Image(journalFile); - CancelG._image = new Image(journalFile); - CancelG._altImage = new Image(journalFile); - + Utils *utils = g_lab->_utils; + _journalGadgetList.push_back(createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile))); // back + _journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // foward + _journalGadgetList.push_back(createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile), new Image(journalFile))); // cancel delete journalFile; - - BackG._keyEquiv = VKEY_LTARROW; - ForwardG._keyEquiv = VKEY_RTARROW; - - uint16 counter = 0; - - GadgetList journalGadgetList; - journalGadgetList.push_back(&BackG); - journalGadgetList.push_back(&CancelG); - journalGadgetList.push_back(&ForwardG); - - for (GadgetList::iterator gadgetIter = journalGadgetList.begin(); gadgetIter != journalGadgetList.end(); ++gadgetIter) { - Gadget *gadget = *gadgetIter; - gadget->x = g_lab->_utils->vgaScaleX(JGadX[counter]); - - if (counter == 1) - gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) + g_lab->_utils->svgaCord(1); - else - gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) - g_lab->_utils->svgaCord(1); - - gadget->_gadgetID = counter; - counter++; - } - - return true; } /** @@ -302,15 +271,18 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) { else turnPage((bool)(wipenum == 1)); + Gadget *backGadget = _event->getGadget(0); + Gadget *forwardGadget = _event->getGadget(1); + if (JPage == 0) - disableGadget(&BackG, 15); + disableGadget(backGadget, 15); else - enableGadget(&BackG); + enableGadget(backGadget); if (lastpage) - disableGadget(&ForwardG, 15); + disableGadget(forwardGadget, 15); else - enableGadget(&ForwardG); + enableGadget(forwardGadget); if (needFade) @@ -373,11 +345,6 @@ void LabEngine::processJournal() { * Does the journal processing. */ void LabEngine::doJournal() { - GadgetList journalGadgetList; - journalGadgetList.push_back(&BackG); - journalGadgetList.push_back(&CancelG); - journalGadgetList.push_back(&ForwardG); - _graphics->blackAllScreen(); lastpage = false; @@ -395,13 +362,13 @@ void LabEngine::doJournal() { drawJournal(0, true); - _event->attachGadgetList(&journalGadgetList); + _event->attachGadgetList(&_journalGadgetList); _event->mouseShow(); processJournal(); _event->attachGadgetList(NULL); _graphics->fade(false, 0); _event->mouseHide(); - journalGadgetList.clear(); + freeButtonList(&_journalGadgetList); ScreenImage._imageData = _graphics->getCurrentDrawingBuffer(); @@ -445,6 +412,7 @@ bool LabEngine::saveRestoreGame() { } } + //_event->attachGadgetList(&_moveGadgetList); _graphics->screenUpdate(); return isOK; |