LAB: Move mouse code in separate class, move some functions to LabEngine. (WIP)

This commit is contained in:
Strangerke 2015-11-29 18:10:06 +01:00 committed by Willem Jan Palenstijn
parent 8d70f33efe
commit d96484d81c
14 changed files with 174 additions and 173 deletions

View file

@ -132,7 +132,7 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
/* Draws the control panel display. */
/******************************************************************************/
void LabEngine::drawPanel() {
mouseHide();
_event->mouseHide();
setAPen(3); /* Clear Area */
rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
@ -178,7 +178,7 @@ void LabEngine::drawPanel() {
drawGadgetList(InvGadgetList);
}
mouseShow();
_event->mouseShow();
}
@ -192,7 +192,7 @@ static bool LastTooLong = false;
/******************************************************************************/
/* Draws the message for the room. */
/******************************************************************************/
static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
void LabEngine::drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
if (LastTooLong) {
LastTooLong = false;
return;
@ -360,9 +360,9 @@ void LabEngine::perFlipGadget(uint16 GadID) {
TopGad->ImAlt = Temp;
if (!Alternate) {
mouseHide();
_event->mouseHide();
drawImage(TopGad->Im, TopGad->x, TopGad->y);
mouseShow();
_event->mouseShow();
}
return;
@ -376,7 +376,7 @@ void LabEngine::perFlipGadget(uint16 GadID) {
/******************************************************************************/
/* Eats all the available messages. */
/******************************************************************************/
void eatMessages() {
void LabEngine::eatMessages() {
IntuiMessage *Msg;
do {
@ -479,49 +479,39 @@ static const char *getInvName(uint16 CurInv) {
return Inventory[CurInv].BInvName;
}
static bool interfaceisoff = false;
/******************************************************************************/
/* Turns the interface off. */
/******************************************************************************/
static void interfaceOff() {
void LabEngine::interfaceOff() {
if (!interfaceisoff) {
attachGadgetList(NULL);
mouseHide();
_event->attachGadgetList(NULL);
_event->mouseHide();
interfaceisoff = true;
}
}
/******************************************************************************/
/* Turns the interface on. */
/******************************************************************************/
static void interfaceOn() {
void LabEngine::interfaceOn() {
if (interfaceisoff) {
interfaceisoff = false;
mouseShow();
_event->mouseShow();
}
if (LongWinInFront)
attachGadgetList(NULL);
_event->attachGadgetList(NULL);
else if (Alternate)
attachGadgetList(InvGadgetList);
_event->attachGadgetList(InvGadgetList);
else
attachGadgetList(MoveGadgetList);
_event->attachGadgetList(MoveGadgetList);
}
static const char *Test;
/******************************************************************************/
/* If the user hits the "Use" gadget; things that can get used on themselves. */
/******************************************************************************/
@ -590,7 +580,7 @@ bool LabEngine::doUse(uint16 CurInv) {
/******************************************************************************/
/* Decrements the current inventory number. */
/******************************************************************************/
static void decIncInv(uint16 *CurInv, bool dec) {
void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
interfaceOff();
if (dec)
@ -792,7 +782,7 @@ from_crumbs:
if (code == 13) { /* The return key */
Class = MOUSEBUTTONS;
Qualifier = IEQUALIFIER_LEFTBUTTON;
curPos = getMousePos();
curPos = _event->getMousePos();
} else if (g_lab->getPlatform() == Common::kPlatformWindows &&
(code == 'b' || code == 'B')) { /* Start bread crumbs */
BreadCrumbs[0].RoomNum = 0;
@ -1254,7 +1244,7 @@ from_crumbs:
}
if (HCPtr)
setMousePos(Common::Point(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2)));
_event->setMousePos(Common::Point(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2)));
} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
eatMessages();
Alternate = !Alternate;
@ -1325,7 +1315,7 @@ void LabEngine::go() {
mem = mem && setUpScreens();
}
initMouse();
_event->initMouse();
mem = mem && initRoomBuffer();
@ -1334,7 +1324,7 @@ void LabEngine::go() {
MsgFont = g_resource->getFont("P:AvanteG.12");
mouseHide();
_event->mouseHide();
if (dointro && mem) {
Intro intro;
@ -1343,7 +1333,7 @@ void LabEngine::go() {
DoBlack = true;
if (mem) {
mouseShow();
_event->mouseShow();
mainGameLoop();
} else
debug("\n\nNot enough memory to start game.\n\n");
@ -1454,9 +1444,9 @@ void LabEngine::mayShowCrumbIndicator() {
return;
if (DroppingCrumbs && MainDisplay) {
mouseHide();
_event->mouseHide();
drawMaskImage(&DropCrumbsImage, 612, 4);
mouseShow();
_event->mouseShow();
}
}
@ -1465,9 +1455,9 @@ void LabEngine::mayShowCrumbIndicatorOff() {
return;
if (MainDisplay) {
mouseHide();
_event->mouseHide();
drawMaskImage(&DropCrumbsOffImage, 612, 4);
mouseShow();
_event->mouseShow();
}
}

View file

@ -338,14 +338,14 @@ void createBox(uint16 y2) {
bool LastMessageLong = false;
int32 longDrawMessage(const char *str) {
int32 LabEngine::longDrawMessage(const char *str) {
char NewText[512];
if (str == NULL)
return 0;
attachGadgetList(NULL);
mouseHide();
_event->attachGadgetList(NULL);
_event->mouseHide();
strcpy(NewText, str);
if (!LongWinInFront) {
@ -355,21 +355,19 @@ int32 longDrawMessage(const char *str) {
}
createBox(198);
mouseShow();
_event->mouseShow();
return flowText(MsgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
}
void drawStaticMessage(byte index) {
void LabEngine::drawStaticMessage(byte index) {
drawMessage(g_resource->getStaticText((StaticText)index).c_str());
}
/******************************************************************************/
/* Draws a message to the message box. */
/******************************************************************************/
void drawMessage(const char *str) {
void LabEngine::drawMessage(const char *str) {
if (DoNotDrawMessage) {
DoNotDrawMessage = false;
return;
@ -385,10 +383,10 @@ void drawMessage(const char *str) {
g_lab->drawPanel();
}
mouseHide();
_event->mouseHide();
createBox(168);
text(MsgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
mouseShow();
_event->mouseShow();
LastMessageLong = false;
}
}
@ -412,14 +410,14 @@ void drawMessage(const char *str) {
/*****************************************************************************/
/* Scrolls the display to black. */
/*****************************************************************************/
static void doScrollBlack() {
void LabEngine::doScrollBlack() {
byte *mem, *tempmem;
Image Im;
uint16 width, height, by, nheight;
uint32 size, copysize;
uint32 *BaseAddr;
mouseHide();
_event->mouseHide();
width = VGAScaleX(320);
height = VGAScaleY(149) + SVGACord(2);
@ -481,18 +479,12 @@ static void doScrollBlack() {
}
freeAllStolenMem();
mouseShow();
_event->mouseShow();
}
extern BitMap RawDiffBM;
extern DIFFHeader headerdata;
static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
uint32 size, OffSet, copysize;
uint16 CurPage;
@ -524,11 +516,11 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
/*****************************************************************************/
/* Scrolls the display to a new picture from a black screen. */
/*****************************************************************************/
static void doScrollWipe(char *filename) {
void LabEngine::doScrollWipe(char *filename) {
byte *mem;
uint16 width, height, by, nheight, startline = 0, onrow = 0;
mouseHide();
_event->mouseHide();
width = VGAScaleX(320);
height = VGAScaleY(149) + SVGACord(2);
@ -576,16 +568,13 @@ static void doScrollWipe(char *filename) {
by = VGAScaleX(3);
}
mouseShow();
_event->mouseShow();
}
/*****************************************************************************/
/* Does the scroll bounce. Assumes bitmap already in memory. */
/*****************************************************************************/
static void doScrollBounce() {
void LabEngine::doScrollBounce() {
const uint16 *newby, *newby1;
const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
@ -600,7 +589,7 @@ static void doScrollBounce() {
}
mouseHide();
_event->mouseHide();
int width = VGAScaleX(320);
int height = VGAScaleY(149) + SVGACord(2);
byte *mem = RawDiffBM.Planes[0];
@ -627,15 +616,13 @@ static void doScrollBounce() {
}
mouseShow();
_event->mouseShow();
}
/*****************************************************************************/
/* Does the transporter wipe. */
/*****************************************************************************/
static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
void LabEngine::doTransWipe(CloseDataPtr *CPtr, char *filename) {
uint16 LastY, CurY, linesdone = 0, lineslast;
Image ImSource, ImDest;
@ -743,12 +730,10 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
}
}
/*****************************************************************************/
/* Does a certain number of pre-programmed wipes. */
/*****************************************************************************/
void doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename) {
void LabEngine::doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename) {
if ((WipeType == TRANSWIPE) || (WipeType == TRANSPORTER))
doTransWipe(CPtr, filename);
else if (WipeType == SCROLLWIPE)

View file

@ -125,20 +125,20 @@ uint16 makeGadgetKeyEquiv(uint16 key) {
/* Checks whether or not the cords fall within one of the gadgets in a list */
/* of gadgets. */
/*****************************************************************************/
static Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key) {
Gadget *LabEngine::checkNumGadgetHit(Gadget *gadlist, uint16 key) {
uint16 gkey = key - '0';
while (gadlist != NULL) {
if ((gkey - 1 == gadlist->GadgetID || (gkey == 0 && gadlist->GadgetID == 9) ||
(gadlist->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadlist->KeyEquiv))
&& !(GADGETOFF & gadlist->GadgetFlags)) {
mouseHide();
_event->mouseHide();
g_lab->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
mouseShow();
_event->mouseShow();
g_system->delayMillis(80);
mouseHide();
_event->mouseHide();
g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
mouseShow();
_event->mouseShow();
return gadlist;
} else {
@ -163,30 +163,29 @@ static bool keyPress(uint16 *KeyCode) {
return false;
}
IntuiMessage IMessage;
extern Gadget *ScreenGadgetList;
IntuiMessage *getMsg() {
IntuiMessage *LabEngine::getMsg() {
Gadget *curgad;
int Qualifiers;
updateMouse();
_event->updateMouse();
Qualifiers = _keyPressed.flags;
if ((curgad = mouseGadget()) != NULL) {
updateMouse();
if ((curgad = _event->mouseGadget()) != NULL) {
_event->updateMouse();
IMessage.msgClass = GADGETUP;
IMessage.code = curgad->GadgetID;
IMessage.gadgetID = curgad->GadgetID;
IMessage.qualifier = Qualifiers;
return &IMessage;
} else if (mouseButton(&IMessage.mouseX, &IMessage.mouseY, true)) { /* Left Button */
} else if (_event->mouseButton(&IMessage.mouseX, &IMessage.mouseY, true)) { /* Left Button */
IMessage.qualifier = IEQUALIFIER_LEFTBUTTON | Qualifiers;
IMessage.msgClass = MOUSEBUTTONS;
return &IMessage;
} else if (mouseButton(&IMessage.mouseX, &IMessage.mouseY, false)) { /* Right Button */
} else if (_event->mouseButton(&IMessage.mouseX, &IMessage.mouseY, false)) { /* Right Button */
IMessage.qualifier = IEQUALIFIER_RBUTTON | Qualifiers;
IMessage.msgClass = MOUSEBUTTONS;
return &IMessage;

View file

@ -52,7 +52,7 @@ Intro::Intro() {
/******************************************************************************/
void Intro::introEatMessages() {
while (1) {
IntuiMessage *msg = getMsg();
IntuiMessage *msg = g_lab->getMsg();
if (g_engine->shouldQuit()) {
_quitIntro = true;
@ -121,7 +121,7 @@ void Intro::doPictText(const char *filename, bool isscreen) {
Drawn = flowText(_msgfont, (!IsHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
fade(true, 0);
} else {
Drawn = longDrawMessage((char *)curplace);
Drawn = g_lab->longDrawMessage((char *)curplace);
}
curplace += Drawn;
@ -141,12 +141,11 @@ void Intro::doPictText(const char *filename, bool isscreen) {
g_lab->getTime(&lastsecs, &lastmicros);
}
msg = getMsg();
msg = g_lab->getMsg();
if (msg == NULL) {
g_music->updateMusic();
diffNextFrame();
g_lab->diffNextFrame();
g_lab->getTime(&secs, &micros);
g_lab->anyTimeDiff(lastsecs, lastmicros, secs, micros, &secs, &micros);

View file

@ -90,6 +90,8 @@ Common::Error LabEngine::run() {
else
initGraphics(640, 480, true);
_event = new EventManager(this);
g_music = new Music();
g_resource = new Resource();

View file

@ -36,6 +36,8 @@
#include "engines/engine.h"
#include "lab/labfun.h"
#include "lab/interface.h"
#include "lab/mouse.h"
struct ADGameDescription;
@ -96,6 +98,7 @@ private:
byte _curapen;
public:
EventManager *_event;
byte *_currentDsplayBuffer;
Common::Point _mousePos;
@ -137,6 +140,32 @@ public:
void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);
void drawPanel();
void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr);
void interfaceOff();
void interfaceOn();
void decIncInv(uint16 *CurInv, bool dec);
int32 longDrawMessage(const char *str);
void drawMessage(const char *str);
void doScrollBlack();
void doScrollWipe(char *filename);
void doScrollBounce();
void doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename);
void doTransWipe(CloseDataPtr *CPtr, char *filename);
Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key);
IntuiMessage *getMsg();
void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein);
void processMap(uint16 CurRoom);
void doMap(uint16 CurRoom);
void diffNextFrame();
void drawJournal(uint16 wipenum, bool needFade);
void processJournal();
void doJournal();
void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive);
void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void eatMessages();
void drawStaticMessage(byte index);
void drawDirection(CloseDataPtr LCPtr);
private:
void quickWaitTOF();

View file

@ -73,7 +73,7 @@ Music::Music() {
void Music::updateMusic() {
g_lab->WSDL_ProcessInput(0);
updateMouse();
g_lab->_event->updateMouse();
if (_musicOn && getPlayingBufferCount() < MAXBUFFERS) {
// NOTE: We need to use malloc(), cause this will be freed with free()

View file

@ -553,13 +553,13 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) {
/*****************************************************************************/
/* Draws the map */
/*****************************************************************************/
static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) {
void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) {
char *sptr;
uint16 tempfloor;
bool noghoast;
mouseHide();
_event->mouseHide();
if (fadeout)
fade(false, 0);
@ -652,13 +652,13 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
if (fadein)
fade(true, 0);
mouseShow();
_event->mouseShow();
}
/*****************************************************************************/
/* Processes the map. */
/*****************************************************************************/
void processMap(uint16 CurRoom) {
void LabEngine::processMap(uint16 CurRoom) {
uint32 Class, place = 1;
uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, x1, y1, x2, y2;
char *sptr;
@ -688,13 +688,13 @@ void processMap(uint16 CurRoom) {
g_lab->waitTOF();
g_lab->writeColorReg(newcolor, 1);
updateMouse();
_event->updateMouse();
g_lab->waitTOF();
updateMouse();
_event->updateMouse();
g_lab->waitTOF();
updateMouse();
_event->updateMouse();
g_lab->waitTOF();
updateMouse();
_event->updateMouse();
place++;
@ -799,7 +799,7 @@ void processMap(uint16 CurRoom) {
g_resource->readViews(CurMsg);
if ((sptr = _rooms[CurMsg]._roomMsg)) {
mouseHide();
_event->mouseHide();
g_lab->setAPen(3);
g_lab->rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186));
flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
@ -816,7 +816,7 @@ void processMap(uint16 CurRoom) {
g_lab->rectFill(x1 - 1, y1, x1, y1);
}
mouseShow();
_event->mouseShow();
}
}
}
@ -831,7 +831,7 @@ void processMap(uint16 CurRoom) {
/*****************************************************************************/
/* Does the map processing. */
/*****************************************************************************/
void doMap(uint16 CurRoom) {
void LabEngine::doMap(uint16 CurRoom) {
FadePalette = AmigaMapPalette;
g_music->updateMusic();
@ -848,19 +848,19 @@ void doMap(uint16 CurRoom) {
XMark = MapWest;
drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
mouseShow();
attachGadgetList(MapGadgetList);
_event->mouseShow();
_event->attachGadgetList(MapGadgetList);
g_lab->WSDL_UpdateScreen();
processMap(CurRoom);
attachGadgetList(NULL);
_event->attachGadgetList(NULL);
fade(false, 0);
blackAllScreen();
mouseHide();
_event->mouseHide();
g_lab->setAPen(0);
g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
freeMapData();
blackAllScreen();
mouseShow();
_event->mouseShow();
g_lab->WSDL_UpdateScreen();
}

View file

@ -69,7 +69,7 @@ static Gadget *hitgad = NULL;
/* Checks whether or not the cords fall within one of the gadgets in a list */
/* of gadgets. */
/*****************************************************************************/
static Gadget *checkGadgetHit(Gadget *gadlist, Common::Point pos) {
Gadget *EventManager::checkGadgetHit(Gadget *gadlist, Common::Point pos) {
while (gadlist != NULL) {
if ((pos.x >= gadlist->x) && (pos.y >= gadlist->y) &&
(pos.x <= (gadlist->x + gadlist->Im->Width)) &&
@ -101,14 +101,17 @@ static Gadget *checkGadgetHit(Gadget *gadlist, Common::Point pos) {
void attachGadgetList(Gadget *GadList) {
void EventManager::attachGadgetList(Gadget *GadList) {
if (ScreenGadgetList != GadList)
LastGadgetHit = NULL;
ScreenGadgetList = GadList;
}
void mouseHandler(int flag, Common::Point pos) {
EventManager::EventManager(LabEngine *vm) : _vm(vm) {
}
void EventManager::mouseHandler(int flag, Common::Point pos) {
if (NumHidden >= 2)
return;
@ -127,7 +130,7 @@ void mouseHandler(int flag, Common::Point pos) {
RightClick = true;
}
void updateMouse() {
void EventManager::updateMouse() {
bool doUpdateDisplay = false;
if (!MouseHidden)
@ -156,7 +159,7 @@ void updateMouse() {
/*****************************************************************************/
/* Initializes the mouse. */
/*****************************************************************************/
void initMouse() {
void EventManager::initMouse() {
g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
g_system->showMouse(false);
@ -167,7 +170,7 @@ void initMouse() {
/*****************************************************************************/
/* Shows the mouse. */
/*****************************************************************************/
void mouseShow() {
void EventManager::mouseShow() {
if (NumHidden)
NumHidden--;
@ -182,7 +185,7 @@ void mouseShow() {
/*****************************************************************************/
/* Hides the mouse. */
/*****************************************************************************/
void mouseHide() {
void EventManager::mouseHide() {
NumHidden++;
if (NumHidden && !MouseHidden) {
@ -196,7 +199,7 @@ void mouseHide() {
/* Gets the current mouse co-ordinates. NOTE: On IBM version, will scale */
/* from virtual to screen co-ordinates automatically. */
/*****************************************************************************/
Common::Point getMousePos() {
Common::Point EventManager::getMousePos() {
if (IsHiRes)
return g_lab->_mousePos;
else
@ -207,7 +210,7 @@ Common::Point getMousePos() {
/*****************************************************************************/
/* Moves the mouse to new co-ordinates. */
/*****************************************************************************/
void setMousePos(Common::Point pos) {
void EventManager::setMousePos(Common::Point pos) {
if (IsHiRes)
g_system->warpMouse(pos.x, pos.y);
else
@ -223,7 +226,7 @@ void setMousePos(Common::Point pos) {
/* co-ordinates of the button press. leftbutton tells whether to check the */
/* left or right button. */
/*****************************************************************************/
bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
if (leftbutton) {
if (LeftClick) {
*x = (!IsHiRes) ? (uint16)g_lab->_mousePos.x / 2 : (uint16)g_lab->_mousePos.x;
@ -243,10 +246,7 @@ bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
return false;
}
Gadget *mouseGadget() {
Gadget *EventManager::mouseGadget() {
Gadget *Temp = LastGadgetHit;
LastGadgetHit = NULL;

View file

@ -38,25 +38,27 @@ namespace Lab {
struct Gadget;
class LabEngine;
class EventManager {
private:
LabEngine *_vm;
public:
EventManager (LabEngine *vm);
Gadget *checkGadgetHit(Gadget *gadlist, Common::Point pos);
void initMouse();
void updateMouse();
void mouseShow();
void mouseHide();
Common::Point getMousePos();
void setMousePos(Common::Point pos);
bool mouseButton(uint16 *x, uint16 *y, bool leftbutton);
Gadget *mouseGadget();
void attachGadgetList(Gadget *GadList);
void mouseHandler(int flag, Common::Point pos);
};
} // End of namespace Lab

View file

@ -188,7 +188,7 @@ char *getPictName(CloseDataPtr *LCPtr) {
/*****************************************************************************/
/* Draws the current direction to the screen. */
/*****************************************************************************/
void drawDirection(CloseDataPtr LCPtr) {
void LabEngine::drawDirection(CloseDataPtr LCPtr) {
if (LCPtr != NULL && LCPtr->Message) {
drawMessage(LCPtr->Message);
return;
@ -375,7 +375,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
break;
case WIPECMD:
doWipe(APtr->Param1, LCPtr, (char *)APtr->Data);
g_lab->doWipe(APtr->Param1, LCPtr, (char *)APtr->Data);
break;
case NOUPDATE:
@ -409,9 +409,9 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
DoNotDrawMessage = false;
if (LongWinInFront)
longDrawMessage((char *)APtr->Data);
g_lab->longDrawMessage((char *)APtr->Data);
else
drawMessage((char *)APtr->Data);
g_lab->drawMessage((char *)APtr->Data);
DoNotDrawMessage = true;
break;
@ -419,7 +419,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
case CSHOWMESSAGE:
if (*LCPtr == NULL) {
DoNotDrawMessage = false;
drawMessage((char *)APtr->Data);
g_lab->drawMessage((char *)APtr->Data);
DoNotDrawMessage = true;
}
@ -428,7 +428,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
case SHOWMESSAGES:
str = (char **)APtr->Data;
DoNotDrawMessage = false;
drawMessage(str[getRandom(APtr->Param1)]);
g_lab->drawMessage(str[getRandom(APtr->Param1)]);
DoNotDrawMessage = true;
break;
@ -486,7 +486,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
while (1) {
g_music->updateMusic();
diffNextFrame();
g_lab->diffNextFrame();
g_lab->getTime(&CurSecs, &CurMicros);
if ((CurSecs > StartSecs) || ((CurSecs == StartSecs) &&
@ -521,7 +521,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
case WAITSOUND:
while (g_music->isSoundEffectActive()) {
g_music->updateMusic();
diffNextFrame();
g_lab->diffNextFrame();
g_lab->waitTOF();
}
@ -596,7 +596,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
} else {
while (g_music->isSoundEffectActive()) {
g_music->updateMusic();
diffNextFrame();
g_lab->diffNextFrame();
g_lab->waitTOF();
}
}

View file

@ -113,8 +113,7 @@ void blackAllScreen() {
g_system->delayMillis(32);
}
void diffNextFrame() {
void LabEngine::diffNextFrame() {
if (header == 65535) /* Already done. */
return;
@ -126,11 +125,11 @@ void diffNextFrame() {
DispBitMap->Planes[4] = DispBitMap->Planes[3] + 0x10000;
}
mouseHide();
_event->mouseHide();
while (1) {
if (CurBit >= numchunks) {
mouseShow();
_event->mouseShow();
if (!IsBM) {
if (headerdata.fps) {
@ -264,7 +263,7 @@ void diffNextFrame() {
}
IsPlaying = false;
mouseShow();
_event->mouseShow();
if (!didTOF)
g_lab->WSDL_UpdateScreen();
@ -283,8 +282,6 @@ void diffNextFrame() {
}
}
/*****************************************************************************/
/* A separate task launched by readDiff. Plays the DIFF. */
/*****************************************************************************/
@ -306,11 +303,9 @@ void playDiff() {
blackScreen();
}
start = *startoffile; /* Make a copy of the pointer to the start of the file */
*difffile = start; /* Now can modify the file without modifying the original */
if (start == NULL) {
IsPlaying = false;
return;
@ -373,9 +368,9 @@ void playDiff() {
if (PlayOnce) {
while (header != 65535)
diffNextFrame();
g_lab->diffNextFrame();
} else
diffNextFrame();
g_lab->diffNextFrame();
}
@ -399,7 +394,7 @@ void stopDiffEnd() {
if (IsPlaying) {
while (IsPlaying) {
g_music->updateMusic();
diffNextFrame();
g_lab->diffNextFrame();
}
}
}

View file

@ -682,8 +682,8 @@ static void turnPage(bool FromLeft) {
/*****************************************************************************/
/* Draws the journal from page x. */
/*****************************************************************************/
static void drawJournal(uint16 wipenum, bool needFade) {
mouseHide();
void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
_event->mouseHide();
g_music->updateMusic();
@ -718,7 +718,7 @@ static void drawJournal(uint16 wipenum, bool needFade) {
GotBackImage = true;
eatMessages();
mouseShow();
_event->mouseShow();
nopalchange = false;
}
@ -726,14 +726,14 @@ static void drawJournal(uint16 wipenum, bool needFade) {
/*****************************************************************************/
/* Processes user input. */
/*****************************************************************************/
static void processJournal() {
void LabEngine::processJournal() {
IntuiMessage *Msg;
uint32 Class;
uint16 Qualifier, GadID;
while (1) {
g_music->updateMusic(); /* Make sure we check the music at least after every message */
Msg = (IntuiMessage *)getMsg();
Msg = getMsg();
if (Msg == NULL) {
g_music->updateMusic();
@ -768,7 +768,7 @@ static void processJournal() {
/*****************************************************************************/
/* Does the journal processing. */
/*****************************************************************************/
void doJournal() {
void LabEngine::doJournal() {
resetBuffer();
blackAllScreen();
@ -790,12 +790,12 @@ void doJournal() {
drawJournal(0, true);
attachGadgetList(&BackG);
mouseShow();
_event->attachGadgetList(&BackG);
_event->mouseShow();
processJournal();
attachGadgetList(NULL);
_event->attachGadgetList(NULL);
fade(false, 0);
mouseHide();
_event->mouseHide();
ScreenImage.ImageData = g_lab->getVGABaseAddr();
@ -869,12 +869,12 @@ static void getMonImages() {
/*****************************************************************************/
/* Draws the text for the monitor. */
/*****************************************************************************/
static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight;
int32 CharsDrawn = 0L;
char *CurText = text;
mouseHide();
_event->mouseHide();
if (*text == '%') {
text++;
@ -923,13 +923,13 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2,
CurText += CharsDrawn;
lastpage = lastpage || (*CurText == 0);
mouseShow();
_event->mouseShow();
}
/*****************************************************************************/
/* Processes user input. */
/*****************************************************************************/
static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
IntuiMessage *Msg;
uint32 Class;
uint16 Qualifier, Code, MouseX, MouseY;
@ -1022,7 +1022,7 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1
/*****************************************************************************/
/* Does what's necessary for the monitor. */
/*****************************************************************************/
void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
char *ntext;
x1 = VGAScaleX(x1);
@ -1064,11 +1064,11 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1,
drawMonText(ntext, x1, y1, x2, y2, isinteractive);
mouseShow();
_event->mouseShow();
fade(true, 0);
processMonitor(ntext, isinteractive, x1, y1, x2, y2);
fade(false, 0);
mouseHide();
_event->mouseHide();
freeAllStolenMem();

View file

@ -90,12 +90,12 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
switch (event.type) {
case Common::EVENT_RBUTTONDOWN:
flags |= 8;
mouseHandler(flags, _mousePos);
_event->mouseHandler(flags, _mousePos);
break;
case Common::EVENT_LBUTTONDOWN:
flags |= 2;
mouseHandler(flags, _mousePos);
_event->mouseHandler(flags, _mousePos);
break;
case Common::EVENT_MOUSEMOVE: {
@ -122,7 +122,7 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
}
if (!lastMouseAtEdge || !_mouseAtEdge)
mouseHandler(1, _mousePos);
_event->mouseHandler(1, _mousePos);
}
break;