From f017cb624e219aa7ace135b4c2d6a3b262202f12 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 17 Jul 2015 10:24:34 +0300 Subject: LAB: Use CamelCase, and simplify mouseHandler() --- engines/lab/mouse.cpp | 54 ++++++++++++++------------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) (limited to 'engines/lab/mouse.cpp') diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp index 591014c595..8636ad7733 100644 --- a/engines/lab/mouse.cpp +++ b/engines/lab/mouse.cpp @@ -37,7 +37,6 @@ namespace Lab { extern bool IsHiRes; -extern uint32 VGAScreenWidth, VGAScreenHeight; static bool LeftClick = false; static bool RightClick = false; @@ -65,7 +64,6 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, #define MOUSE_WIDTH 10 #define MOUSE_HEIGHT 15 -static bool gadhit = false; static Gadget *hitgad = NULL; /*****************************************************************************/ @@ -81,7 +79,6 @@ static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) { (y <= (gadlist->y + gadlist->Im->Height)) && !(GADGETOFF & gadlist->GadgetFlags)) { if (IsHiRes) { - gadhit = true; hitgad = gadlist; } else { VGAStorePage(); @@ -116,47 +113,36 @@ void attachGadgetList(Gadget *GadList) { ScreenGadgetList = GadList; } -static Gadget *TempGad; +void mouseHandler(int32 flag, int32 mouseX, int32 mouseY) { + if (NumHidden >= 2) + return; - -void mouse_handler(int32 flag, int32 mouseX, int32 mouseY) { if (!IsHiRes) mouseX /= 2; - if (flag & 0x01) { /* mouse Move */ - } - - if ((flag & 0x02) && (NumHidden < 2)) { /* Left mouse button click */ + if (flag & 0x02) { /* Left mouse button click */ + Gadget *tmp = NULL; if (ScreenGadgetList) - TempGad = checkGadgetHit(ScreenGadgetList, mouseX, mouseY); - else - TempGad = NULL; + tmp = checkGadgetHit(ScreenGadgetList, mouseX, mouseY); - if (TempGad) { - LastGadgetHit = TempGad; - } else { + if (tmp) + LastGadgetHit = tmp; + else LeftClick = true; - } } - if ((flag & 0x08) && (NumHidden < 2)) { /* Right mouse button click */ + if (flag & 0x08) /* Right mouse button click */ RightClick = true; - } } - - - void updateMouse() { uint16 counter; bool doUpdateDisplay = false; - if (!MouseHidden) { + if (!MouseHidden) doUpdateDisplay = true; - } - if (gadhit) { - gadhit = false; + if (hitgad) { mouseHide(); drawImage(hitgad->ImAlt, hitgad->x, hitgad->y); mouseShow(); @@ -168,6 +154,7 @@ void updateMouse() { drawImage(hitgad->Im, hitgad->x, hitgad->y); mouseShow(); doUpdateDisplay = true; + hitgad = NULL; } if (doUpdateDisplay) @@ -175,23 +162,17 @@ void updateMouse() { } - - /*****************************************************************************/ /* Initializes the mouse. */ /*****************************************************************************/ -bool initMouse() { +void initMouse() { g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0); g_system->showMouse(false); mouseMove(0, 0); - - return true; } - - /*****************************************************************************/ /* Shows the mouse. */ /*****************************************************************************/ @@ -237,8 +218,6 @@ void mouseXY(uint16 *x, uint16 *y) { } - - /*****************************************************************************/ /* Moves the mouse to new co-ordinates. */ /*****************************************************************************/ @@ -248,14 +227,11 @@ void mouseMove(uint16 x, uint16 y) { g_system->warpMouse(x, y); - if (!MouseHidden) { + if (!MouseHidden) WSDL_ProcessInput(0); - } } - - /*****************************************************************************/ /* Checks whether or not the mouse buttons have been pressed, and the last */ /* co-ordinates of the button press. leftbutton tells whether to check the */ -- cgit v1.2.3