LAB: Use CamelCase, and simplify mouseHandler()
This commit is contained in:
parent
8ebb53948d
commit
f017cb624e
4 changed files with 21 additions and 47 deletions
|
@ -1400,9 +1400,7 @@ void LabEngine::go() {
|
||||||
mem = mem && setUpScreens();
|
mem = mem && setUpScreens();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!initMouse()) {
|
initMouse();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mem = mem && initRoomBuffer() &&
|
mem = mem && initRoomBuffer() &&
|
||||||
initLabText();
|
initLabText();
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
namespace Lab {
|
namespace Lab {
|
||||||
|
|
||||||
extern bool IsHiRes;
|
extern bool IsHiRes;
|
||||||
extern uint32 VGAScreenWidth, VGAScreenHeight;
|
|
||||||
|
|
||||||
static bool LeftClick = false;
|
static bool LeftClick = false;
|
||||||
static bool RightClick = 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_WIDTH 10
|
||||||
#define MOUSE_HEIGHT 15
|
#define MOUSE_HEIGHT 15
|
||||||
|
|
||||||
static bool gadhit = false;
|
|
||||||
static Gadget *hitgad = NULL;
|
static Gadget *hitgad = NULL;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -81,7 +79,6 @@ static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) {
|
||||||
(y <= (gadlist->y + gadlist->Im->Height)) &&
|
(y <= (gadlist->y + gadlist->Im->Height)) &&
|
||||||
!(GADGETOFF & gadlist->GadgetFlags)) {
|
!(GADGETOFF & gadlist->GadgetFlags)) {
|
||||||
if (IsHiRes) {
|
if (IsHiRes) {
|
||||||
gadhit = true;
|
|
||||||
hitgad = gadlist;
|
hitgad = gadlist;
|
||||||
} else {
|
} else {
|
||||||
VGAStorePage();
|
VGAStorePage();
|
||||||
|
@ -116,47 +113,36 @@ void attachGadgetList(Gadget *GadList) {
|
||||||
ScreenGadgetList = 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)
|
if (!IsHiRes)
|
||||||
mouseX /= 2;
|
mouseX /= 2;
|
||||||
|
|
||||||
if (flag & 0x01) { /* mouse Move */
|
if (flag & 0x02) { /* Left mouse button click */
|
||||||
}
|
Gadget *tmp = NULL;
|
||||||
|
|
||||||
if ((flag & 0x02) && (NumHidden < 2)) { /* Left mouse button click */
|
|
||||||
if (ScreenGadgetList)
|
if (ScreenGadgetList)
|
||||||
TempGad = checkGadgetHit(ScreenGadgetList, mouseX, mouseY);
|
tmp = checkGadgetHit(ScreenGadgetList, mouseX, mouseY);
|
||||||
|
|
||||||
|
if (tmp)
|
||||||
|
LastGadgetHit = tmp;
|
||||||
else
|
else
|
||||||
TempGad = NULL;
|
|
||||||
|
|
||||||
if (TempGad) {
|
|
||||||
LastGadgetHit = TempGad;
|
|
||||||
} else {
|
|
||||||
LeftClick = true;
|
LeftClick = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flag & 0x08) && (NumHidden < 2)) { /* Right mouse button click */
|
if (flag & 0x08) /* Right mouse button click */
|
||||||
RightClick = true;
|
RightClick = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void updateMouse() {
|
void updateMouse() {
|
||||||
uint16 counter;
|
uint16 counter;
|
||||||
bool doUpdateDisplay = false;
|
bool doUpdateDisplay = false;
|
||||||
|
|
||||||
if (!MouseHidden) {
|
if (!MouseHidden)
|
||||||
doUpdateDisplay = true;
|
doUpdateDisplay = true;
|
||||||
}
|
|
||||||
|
|
||||||
if (gadhit) {
|
if (hitgad) {
|
||||||
gadhit = false;
|
|
||||||
mouseHide();
|
mouseHide();
|
||||||
drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
|
drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
|
||||||
mouseShow();
|
mouseShow();
|
||||||
|
@ -168,6 +154,7 @@ void updateMouse() {
|
||||||
drawImage(hitgad->Im, hitgad->x, hitgad->y);
|
drawImage(hitgad->Im, hitgad->x, hitgad->y);
|
||||||
mouseShow();
|
mouseShow();
|
||||||
doUpdateDisplay = true;
|
doUpdateDisplay = true;
|
||||||
|
hitgad = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doUpdateDisplay)
|
if (doUpdateDisplay)
|
||||||
|
@ -175,23 +162,17 @@ void updateMouse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Initializes the mouse. */
|
/* Initializes the mouse. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
bool initMouse() {
|
void initMouse() {
|
||||||
g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
|
g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
|
||||||
g_system->showMouse(false);
|
g_system->showMouse(false);
|
||||||
|
|
||||||
mouseMove(0, 0);
|
mouseMove(0, 0);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Shows the mouse. */
|
/* Shows the mouse. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -237,8 +218,6 @@ void mouseXY(uint16 *x, uint16 *y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Moves the mouse to new co-ordinates. */
|
/* Moves the mouse to new co-ordinates. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -248,14 +227,11 @@ void mouseMove(uint16 x, uint16 y) {
|
||||||
|
|
||||||
g_system->warpMouse(x, y);
|
g_system->warpMouse(x, y);
|
||||||
|
|
||||||
if (!MouseHidden) {
|
if (!MouseHidden)
|
||||||
WSDL_ProcessInput(0);
|
WSDL_ProcessInput(0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Checks whether or not the mouse buttons have been pressed, and the last */
|
/* 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 */
|
/* co-ordinates of the button press. leftbutton tells whether to check the */
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Lab {
|
||||||
|
|
||||||
struct Gadget;
|
struct Gadget;
|
||||||
|
|
||||||
bool initMouse();
|
void initMouse();
|
||||||
|
|
||||||
void updateMouse();
|
void updateMouse();
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ Gadget *mouseGadget();
|
||||||
|
|
||||||
void attachGadgetList(Gadget *GadList);
|
void attachGadgetList(Gadget *GadList);
|
||||||
|
|
||||||
void mouse_handler(int32 flag, int32 mouseX, int32 mouseY);
|
void mouseHandler(int32 flag, int32 mouseX, int32 mouseY);
|
||||||
|
|
||||||
} // End of namespace Lab
|
} // End of namespace Lab
|
||||||
|
|
||||||
|
|
|
@ -135,12 +135,12 @@ void WSDL_ProcessInput(bool can_delay) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case Common::EVENT_RBUTTONDOWN:
|
case Common::EVENT_RBUTTONDOWN:
|
||||||
flags |= 8;
|
flags |= 8;
|
||||||
mouse_handler(flags, g_MouseX, g_MouseY);
|
mouseHandler(flags, g_MouseX, g_MouseY);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Common::EVENT_LBUTTONDOWN:
|
case Common::EVENT_LBUTTONDOWN:
|
||||||
flags |= 2;
|
flags |= 2;
|
||||||
mouse_handler(flags, g_MouseX, g_MouseY);
|
mouseHandler(flags, g_MouseX, g_MouseY);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Common::EVENT_MOUSEMOVE:
|
case Common::EVENT_MOUSEMOVE:
|
||||||
|
@ -167,7 +167,7 @@ void WSDL_ProcessInput(bool can_delay) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lastMouseAtEdge || !g_MouseAtEdge)
|
if (!lastMouseAtEdge || !g_MouseAtEdge)
|
||||||
mouse_handler(1, g_MouseX, g_MouseY);
|
mouseHandler(1, g_MouseX, g_MouseY);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue