mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-20 17:03:05 +00:00
CGE: Fix naming of touch() virtual methods, and fixed keyboard handling
This commit is contained in:
parent
bb3d61b137
commit
72ae475c97
@ -552,7 +552,7 @@ void WALK::reach(Sprite *spr, int mode) {
|
||||
class SQUARE : public Sprite {
|
||||
public:
|
||||
SQUARE(CGEEngine *vm);
|
||||
void Touch(uint16 mask, int x, int y);
|
||||
virtual void touch(uint16 mask, int x, int y);
|
||||
private:
|
||||
CGEEngine *_vm;
|
||||
};
|
||||
@ -565,7 +565,7 @@ SQUARE::SQUARE(CGEEngine *vm)
|
||||
}
|
||||
|
||||
|
||||
void SQUARE::Touch(uint16 mask, int x, int y) {
|
||||
void SQUARE::touch(uint16 mask, int x, int y) {
|
||||
Sprite::touch(mask, x, y);
|
||||
if (mask & L_UP) {
|
||||
XZ(_x + x, _y + y).cell() = 0;
|
||||
@ -822,7 +822,7 @@ SYSTEM::SYSTEM(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
|
||||
Tick();
|
||||
}
|
||||
|
||||
void SYSTEM::Touch(uint16 mask, int x, int y) {
|
||||
void SYSTEM::touch(uint16 mask, int x, int y) {
|
||||
static int pp = 0;
|
||||
|
||||
FunTouch();
|
||||
|
@ -122,7 +122,7 @@ public:
|
||||
|
||||
void SetPal();
|
||||
void FunTouch();
|
||||
void Touch(uint16 mask, int x, int y);
|
||||
virtual void touch(uint16 mask, int x, int y);
|
||||
void Tick();
|
||||
private:
|
||||
CGEEngine *_vm;
|
||||
|
@ -247,55 +247,6 @@ void MOUSE::ClrEvt(Sprite *spr) {
|
||||
EvtTail = EvtHead;
|
||||
}
|
||||
|
||||
|
||||
void MOUSE::Tick(void) {
|
||||
step();
|
||||
while (EvtTail != EvtHead) {
|
||||
CGEEvent e = Evt[EvtTail];
|
||||
if (e._msk) {
|
||||
if (Hold && e._ptr != Hold)
|
||||
Hold->touch(e._msk | ATTN, e._x - Hold->_x, e._y - Hold->_y);
|
||||
|
||||
// update mouse cursor position
|
||||
if (e._msk & ROLL)
|
||||
gotoxy(e._x, e._y);
|
||||
|
||||
// activate current touched SPRITE
|
||||
if (e._ptr) {
|
||||
if (e._msk & KEYB)
|
||||
e._ptr->touch(e._msk, e._x, e._y);
|
||||
else
|
||||
e._ptr->touch(e._msk, e._x - e._ptr->_x, e._y - e._ptr->_y);
|
||||
} else if (Sys)
|
||||
Sys->touch(e._msk, e._x, e._y);
|
||||
|
||||
if (e._msk & L_DN) {
|
||||
Hold = e._ptr;
|
||||
if (Hold) {
|
||||
Hold->_flags._hold = true;
|
||||
hx = e._x - Hold->_x;
|
||||
hy = e._y - Hold->_y;
|
||||
}
|
||||
}
|
||||
|
||||
if (e._msk & L_UP) {
|
||||
if (Hold) {
|
||||
Hold->_flags._hold = false;
|
||||
Hold = NULL;
|
||||
}
|
||||
}
|
||||
///Touched = e.Ptr;
|
||||
|
||||
// discard Text if button released
|
||||
if (e._msk & (L_UP | R_UP))
|
||||
KillText();
|
||||
}
|
||||
EvtTail = (EvtTail + 1) % EVT_MAX;
|
||||
}
|
||||
if (Hold)
|
||||
Hold->gotoxy(_x - hx, _y - hy);
|
||||
}
|
||||
|
||||
/*----------------- EventManager interface -----------------*/
|
||||
|
||||
EventManager::EventManager() {
|
||||
@ -311,9 +262,66 @@ void EventManager::poll() {
|
||||
case Common::EVENT_KEYDOWN:
|
||||
case Common::EVENT_KEYUP:
|
||||
_keyboard->NewKeyboard(_event);
|
||||
handleEvents();
|
||||
break;
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
case Common::EVENT_RBUTTONDOWN:
|
||||
case Common::EVENT_RBUTTONUP:
|
||||
// TODO: Handle mouse events
|
||||
//_mouse->NewMouse(event);
|
||||
handleEvents();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EventManager::handleEvents(void) {
|
||||
while (EvtTail != EvtHead) {
|
||||
CGEEvent e = Evt[EvtTail];
|
||||
if (e._msk) {
|
||||
if (_mouse->Hold && e._ptr != _mouse->Hold)
|
||||
_mouse->Hold->touch(e._msk | ATTN, e._x - _mouse->Hold->_x, e._y - _mouse->Hold->_y);
|
||||
|
||||
// update mouse cursor position
|
||||
if (e._msk & ROLL)
|
||||
_mouse->gotoxy(e._x, e._y);
|
||||
|
||||
// activate current touched SPRITE
|
||||
if (e._ptr) {
|
||||
if (e._msk & KEYB)
|
||||
e._ptr->touch(e._msk, e._x, e._y);
|
||||
else
|
||||
e._ptr->touch(e._msk, e._x - e._ptr->_x, e._y - e._ptr->_y);
|
||||
} else if (Sys)
|
||||
Sys->touch(e._msk, e._x, e._y);
|
||||
|
||||
if (e._msk & L_DN) {
|
||||
_mouse->Hold = e._ptr;
|
||||
if (_mouse->Hold) {
|
||||
_mouse->Hold->_flags._hold = true;
|
||||
_mouse->hx = e._x - _mouse->Hold->_x;
|
||||
_mouse->hy = e._y - _mouse->Hold->_y;
|
||||
}
|
||||
}
|
||||
|
||||
if (e._msk & L_UP) {
|
||||
if (_mouse->Hold) {
|
||||
_mouse->Hold->_flags._hold = false;
|
||||
_mouse->Hold = NULL;
|
||||
}
|
||||
}
|
||||
///Touched = e.Ptr;
|
||||
|
||||
// discard Text if button released
|
||||
if (e._msk & (L_UP | R_UP))
|
||||
KillText();
|
||||
}
|
||||
EvtTail = (EvtTail + 1) % EVT_MAX;
|
||||
}
|
||||
if (_mouse->Hold)
|
||||
_mouse->Hold->gotoxy(_mouse->_x - _mouse->hx, _mouse->_y - _mouse->hy);
|
||||
}
|
||||
|
||||
} // End of namespace CGE
|
||||
|
@ -98,11 +98,11 @@ class MOUSE : public Sprite {
|
||||
static MOUSE_FUN *OldMouseFun;
|
||||
static MOUSE_FUN NewMouseFun;
|
||||
static uint16 OldMouseMask;
|
||||
Sprite *Hold;
|
||||
int hx, hy;
|
||||
//void SetFun (void);
|
||||
//void ResetFun (void);
|
||||
public:
|
||||
Sprite *Hold;
|
||||
int hx, hy;
|
||||
bool Exist;
|
||||
int Buttons;
|
||||
Sprite *Busy;
|
||||
@ -122,6 +122,7 @@ private:
|
||||
class EventManager {
|
||||
private:
|
||||
Common::Event _event;
|
||||
void handleEvents();
|
||||
public:
|
||||
bool _quitFlag;
|
||||
|
||||
|
@ -125,7 +125,7 @@ VMENU::~VMENU(void) {
|
||||
}
|
||||
|
||||
|
||||
void VMENU::Touch(uint16 mask, int x, int y) {
|
||||
void VMENU::touch(uint16 mask, int x, int y) {
|
||||
uint16 h = FONT_HIG + TEXT_LS;
|
||||
bool ok = false;
|
||||
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
MENU_BAR *Bar;
|
||||
VMENU(CGEEngine *vm, CHOICE *list, int x, int y);
|
||||
~VMENU();
|
||||
void Touch(uint16 mask, int x, int y);
|
||||
virtual void touch(uint16 mask, int x, int y);
|
||||
private:
|
||||
CGEEngine *_vm;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user