[Scummvm-cvs-logs] scummvm master -> 9c749c7d2e9c60b30274ba63fac44f886574e668

bluegr bluegr at gmail.com
Thu Dec 24 17:13:37 CET 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9c749c7d2e LAB: Start to untangle the mess in the event code


Commit: 9c749c7d2e9c60b30274ba63fac44f886574e668
    https://github.com/scummvm/scummvm/commit/9c749c7d2e9c60b30274ba63fac44f886574e668
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-24T18:12:57+02:00

Commit Message:
LAB: Start to untangle the mess in the event code

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 4947991..5dbe60f 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -108,7 +108,6 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 	_leftClick = false;
 	_rightClick = false;
 
-	_mouseHidden = true;
 	_lastButtonHit = nullptr;
 	_screenButtonList = nullptr;
 	_hitButton = nullptr;
@@ -123,28 +122,21 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 }
 
 void EventManager::updateMouse() {
-	bool doUpdateDisplay = false;
+	if (!_hitButton)
+		return;
 
-	if (!_mouseHidden)
-		doUpdateDisplay = true;
+	mouseHide();
+	_hitButton->_altImage->drawImage(_hitButton->_x, _hitButton->_y);
+	mouseShow();
 
-	if (_hitButton) {
-		mouseHide();
-		_hitButton->_altImage->drawImage(_hitButton->_x, _hitButton->_y);
-		mouseShow();
+	for (int i = 0; i < 3; i++)
+		_vm->waitTOF();
 
-		for (int i = 0; i < 3; i++)
-			_vm->waitTOF();
-
-		mouseHide();
-		_hitButton->_image->drawImage(_hitButton->_x, _hitButton->_y);
-		mouseShow();
-		doUpdateDisplay = true;
-		_hitButton = nullptr;
-	}
-
-	if (doUpdateDisplay)
-		_vm->_graphics->screenUpdate();
+	mouseHide();
+	_hitButton->_image->drawImage(_hitButton->_x, _hitButton->_y);
+	mouseShow();
+	_hitButton = nullptr;
+	_vm->_graphics->screenUpdate();
 }
 
 void EventManager::initMouse() {
@@ -155,20 +147,11 @@ void EventManager::initMouse() {
 }
 
 void EventManager::mouseShow() {
-	if (_mouseHidden) {
-		processInput();
-		_mouseHidden = false;
-	}
-
 	_vm->_system->showMouse(true);
 }
 
 void EventManager::mouseHide() {
-	if (!_mouseHidden) {
-		_mouseHidden = true;
-
-		_vm->_system->showMouse(false);
-	}
+	_vm->_system->showMouse(false);
 }
 
 Common::Point EventManager::getMousePos() {
@@ -183,23 +166,19 @@ void EventManager::setMousePos(Common::Point pos) {
 		_vm->_system->warpMouse(pos.x, pos.y);
 	else
 		_vm->_system->warpMouse(pos.x * 2, pos.y);
-
-	if (!_mouseHidden)
-		processInput();
 }
 
-bool EventManager::keyPress(Common::KeyCode *keyCode) {
-	if (haveNextChar()) {
-		*keyCode = getNextChar();
-		return true;
-	}
-
-	return false;
-}
+Common::KeyCode EventManager::keyPress() {
+	Common::KeyCode key = Common::KEYCODE_INVALID;
 
-bool EventManager::haveNextChar() {
 	processInput();
-	return _nextKeyIn != _nextKeyOut;
+
+	if (_nextKeyIn != _nextKeyOut) {
+		key = _keyBuf[_nextKeyOut];
+		_nextKeyOut = (_nextKeyOut + 1) % 64;
+	}
+
+	return key;
 }
 
 void EventManager::processInput() {
@@ -262,18 +241,6 @@ void EventManager::processInput() {
 	_vm->_system->updateScreen();
 }
 
-Common::KeyCode EventManager::getNextChar() {
-	Common::KeyCode chr = Common::KEYCODE_INVALID;
-
-	processInput();
-	if (_nextKeyIn != _nextKeyOut) {
-		chr = _keyBuf[_nextKeyOut];
-		_nextKeyOut = (_nextKeyOut + 1) % 64;
-	}
-
-	return chr;
-}
-
 Common::Point EventManager::updateAndGetMousePos() {
 	processInput();
 
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 9639721..a5f0e94 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -74,7 +74,6 @@ private:
 
 	bool _leftClick;
 	bool _rightClick;
-	bool _mouseHidden;
 
 	uint16 _nextKeyIn;
 	uint16 _nextKeyOut;
@@ -96,9 +95,7 @@ private:
 	/**
 	 * Checks whether or not a key has been pressed.
 	 */
-	bool keyPress(Common::KeyCode *keyCode);
-	bool haveNextChar();
-	Common::KeyCode getNextChar();
+	Common::KeyCode keyPress();
 
 	/**
 	 * Checks whether or not the coords fall within one of the buttons in a list
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 0d03d21..af52a6a 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -118,7 +118,7 @@ IntuiMessage *EventManager::getMsg() {
 
 	updateMouse();
 
-	Common::KeyCode curKey;
+	Common::KeyCode curKey = keyPress();
 
 	if (_lastButtonHit) {
 		updateMouse();
@@ -135,7 +135,7 @@ IntuiMessage *EventManager::getMsg() {
 			message._mouse.x /= 2;
 		_leftClick = _rightClick = false;
 		return &message;
-	} else if (keyPress(&curKey)) {
+	} else if (curKey != Common::KEYCODE_INVALID) {
 		message._code = curKey;
 		Button *curButton = checkNumButtonHit(_screenButtonList, message._code);
 






More information about the Scummvm-git-logs mailing list