GOB: use EventManager::getMousePos and some cleanup

svn-id: r26220
This commit is contained in:
Max Horn 2007-03-18 18:10:34 +00:00
parent 139608f451
commit 8ba2a5bb83
3 changed files with 12 additions and 37 deletions

View file

@ -69,7 +69,6 @@ void Init::cleanup(void) {
warning("cleanup: Allocated sprites left: %d", _vm->_global->_sprAllocated); warning("cleanup: Allocated sprites left: %d", _vm->_global->_sprAllocated);
_vm->_snd->stopSound(0); _vm->_snd->stopSound(0);
_vm->_util->keyboard_release();
} }
void Init::initGame(char *totName) { void Init::initGame(char *totName) {

View file

@ -33,8 +33,6 @@
namespace Gob { namespace Gob {
Util::Util(GobEngine *vm) : _vm(vm) { Util::Util(GobEngine *vm) : _vm(vm) {
_mouseX = 0;
_mouseY = 0;
_mouseButtons = 0; _mouseButtons = 0;
for (int i = 0; i < KEYBUFSIZE; i++) for (int i = 0; i < KEYBUFSIZE; i++)
_keyBuffer[i] = 0; _keyBuffer[i] = 0;
@ -67,7 +65,7 @@ bool Util::getKeyFromBuffer(int16& key) {
void Util::initInput(void) { void Util::initInput(void) {
_mouseX = _mouseY = _mouseButtons = 0; _mouseButtons = 0;
_keyBufferHead = _keyBufferTail = 0; _keyBufferHead = _keyBufferTail = 0;
} }
@ -144,10 +142,6 @@ void Util::processInput() {
Common::EventManager *eventMan = g_system->getEventManager(); Common::EventManager *eventMan = g_system->getEventManager();
while (eventMan->pollEvent(event)) { while (eventMan->pollEvent(event)) {
switch (event.type) { switch (event.type) {
case Common::EVENT_MOUSEMOVE:
_mouseX = event.mouse.x;
_mouseY = event.mouse.y;
break;
case Common::EVENT_LBUTTONDOWN: case Common::EVENT_LBUTTONDOWN:
_mouseButtons |= 1; _mouseButtons |= 1;
break; break;
@ -175,8 +169,9 @@ void Util::processInput() {
} }
void Util::getMouseState(int16 *pX, int16 *pY, int16 *pButtons) { void Util::getMouseState(int16 *pX, int16 *pY, int16 *pButtons) {
*pX = _mouseX; Common::Point mouse = g_system->getEventManager()->getMousePos();
*pY = _mouseY; *pX = mouse.x;
*pY = mouse.y;
if (pButtons != 0) if (pButtons != 0)
*pButtons = _mouseButtons; *pButtons = _mouseButtons;
@ -211,27 +206,17 @@ uint32 Util::getTimeKey(void) {
} }
void Util::waitMouseUp(void) { void Util::waitMouseUp(void) {
int16 x;
int16 y;
int16 buttons;
do { do {
processInput(); processInput();
getMouseState(&x, &y, &buttons); if (_mouseButtons != 0) delay(10);
if (buttons != 0) delay(10); } while (_mouseButtons != 0);
} while (buttons != 0);
} }
void Util::waitMouseDown(void) { void Util::waitMouseDown(void) {
int16 x;
int16 y;
int16 buttons;
do { do {
processInput(); processInput();
getMouseState(&x, &y, &buttons); if (_mouseButtons == 0) delay(10);
if (buttons == 0) delay(10); } while (_mouseButtons == 0);
} while (buttons == 0);
} }
/* NOT IMPLEMENTED */ /* NOT IMPLEMENTED */
@ -437,11 +422,11 @@ void Util::deleteList(List * list) {
delete list; delete list;
} }
const char Util::trStr1[] = static const char trStr1[] =
" ' + - :0123456789: <=> abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz "; " ' + - :0123456789: <=> abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz ";
const char Util::trStr2[] = static const char trStr2[] =
" ueaaaaceeeiii ooouu aioun "; " ueaaaaceeeiii ooouu aioun ";
const char Util::trStr3[] = " "; static const char trStr3[] = " ";
void Util::prepareStr(char *str) { void Util::prepareStr(char *str) {
uint16 i; uint16 i;
@ -490,8 +475,6 @@ void Util::waitMouseRelease(char drawMouse) {
} while (buttons != 0); } while (buttons != 0);
} }
void Util::keyboard_release(void) {;}
void Util::forceMouseUp(void) { void Util::forceMouseUp(void) {
_vm->_game->_mouseButtons = 0; _vm->_game->_mouseButtons = 0;
_mouseButtons = 0; _mouseButtons = 0;

View file

@ -61,9 +61,6 @@ public:
void waitMouseUp(void); void waitMouseUp(void);
void waitMouseDown(void); void waitMouseDown(void);
void keyboard_init(void);
void keyboard_release(void);
void clearPalette(void); void clearPalette(void);
void asm_setPaletteBlock(char *tmpPalBuffer, int16 start, int16 end); void asm_setPaletteBlock(char *tmpPalBuffer, int16 start, int16 end);
@ -86,14 +83,10 @@ public:
void forceMouseUp(void); void forceMouseUp(void);
void setScrollOffset(int16 x = -1, int16 y = -1); void setScrollOffset(int16 x = -1, int16 y = -1);
static const char trStr1[];
static const char trStr2[];
static const char trStr3[];
Util(GobEngine *vm); Util(GobEngine *vm);
protected: protected:
int16 _mouseX, _mouseY, _mouseButtons; int16 _mouseButtons;
int16 _keyBuffer[KEYBUFSIZE], _keyBufferHead, _keyBufferTail; int16 _keyBuffer[KEYBUFSIZE], _keyBufferHead, _keyBufferTail;
GobEngine *_vm; GobEngine *_vm;