[Scummvm-cvs-logs] scummvm master -> 076ce7e6c158878305ace5d7f334d54f8d44e966

dreammaster dreammaster at scummvm.org
Sat Feb 21 23:47:04 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:
076ce7e6c1 MADS: Implement scroll wheel support for scrolling inventory


Commit: 076ce7e6c158878305ace5d7f334d54f8d44e966
    https://github.com/scummvm/scummvm/commit/076ce7e6c158878305ace5d7f334d54f8d44e966
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-02-21T17:45:20-05:00

Commit Message:
MADS: Implement scroll wheel support for scrolling inventory

Changed paths:
    engines/mads/events.cpp
    engines/mads/game.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 586ef7c..06c6055f 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -162,6 +162,12 @@ void EventsManager::pollEvents() {
 			return;
 		case Common::EVENT_KEYUP:
 			return;
+		case Common::EVENT_WHEELUP:
+			_pendingKeys.push(Common::KeyState(Common::KEYCODE_PAGEUP));
+			return;
+		case Common::EVENT_WHEELDOWN:
+			_pendingKeys.push(Common::KeyState(Common::KEYCODE_PAGEDOWN));
+			return;
 		case Common::EVENT_LBUTTONDOWN:
 		case Common::EVENT_RBUTTONDOWN:
 			_mouseClicked = true;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 27691d3..3b8b053 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -420,6 +420,7 @@ void Game::handleKeypress(const Common::KeyState &kbd) {
 		}
 	}
 
+	Scene &scene = _vm->_game->_scene;
 	switch (kbd.keycode) {
 	case Common::KEYCODE_F1:
 		_vm->_dialogs->_pendingDialog = DIALOG_GAME_MENU;
@@ -430,6 +431,16 @@ void Game::handleKeypress(const Common::KeyState &kbd) {
 	case Common::KEYCODE_F7:
 		_vm->_dialogs->_pendingDialog = DIALOG_RESTORE;
 		break;
+	case Common::KEYCODE_PAGEUP:
+		scene._userInterface._scrollbarStrokeType = SCROLLBAR_UP;
+		scene._userInterface.changeScrollBar();
+		break;
+	case Common::KEYCODE_PAGEDOWN:
+		scene._userInterface._scrollbarStrokeType = SCROLLBAR_DOWN;
+		scene._userInterface.changeScrollBar();
+		break;
+
+
 	default:
 		break;
 	}
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 822460d..929390a 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -495,7 +495,6 @@ void UserInterface::drawScroller() {
 
 void UserInterface::updateInventoryScroller() {
 	ScreenObjects &screenObjects = _vm->_game->_screenObjects;
-	Common::Array<int> &inventoryList = _vm->_game->_objects._inventoryList;
 
 	if (screenObjects._inputMode != kInputBuildingSentences)
 		return;
@@ -518,45 +517,8 @@ void UserInterface::updateInventoryScroller() {
 					_scrollbarQuickly = _vm->_events->_vD2 < 1;
 					_scrollbarMilliTime = currentMilli;
 
-					switch (_scrollbarStrokeType) {
-					case SCROLLBAR_UP:
-						// Scroll up
-						if (_inventoryTopIndex > 0 && inventoryList.size() > 0) {
-							--_inventoryTopIndex;
-							_inventoryChanged = true;
-						}
-						break;
-
-					case SCROLLBAR_DOWN:
-						// Scroll down
-						if (_inventoryTopIndex < ((int)inventoryList.size() - 1) && inventoryList.size() > 1) {
-							++_inventoryTopIndex;
-							_inventoryChanged = true;
-						}
-						break;
-
-					case SCROLLBAR_ELEVATOR: {
-						// Inventory slider
-						int newIndex = CLIP((int)_vm->_events->currentPos().y - 170, 0, 17)
-							* inventoryList.size() / 10;
-						if (newIndex >= (int)inventoryList.size())
-							newIndex = inventoryList.size() - 1;
-
-						if (inventoryList.size() > 0) {
-							_inventoryChanged = newIndex != _inventoryTopIndex;
-							_inventoryTopIndex = newIndex;
-						}
-						break;
-					}
-
-					default:
-						break;
-					}
-
-					if (_inventoryChanged) {
-						int dummy;
-						updateSelection(CAT_INV_LIST, 0, &dummy);
-					}
+					// Change the scrollbar and visible inventory list
+					changeScrollBar();
 				}
 			}
 		}
@@ -569,6 +531,54 @@ void UserInterface::updateInventoryScroller() {
 	_scrollbarOldElevator = _scrollbarElevator;
 }
 
+void UserInterface::changeScrollBar() {
+	Common::Array<int> &inventoryList = _vm->_game->_objects._inventoryList;
+	ScreenObjects &screenObjects = _vm->_game->_screenObjects;
+
+	if (screenObjects._inputMode != kInputBuildingSentences)
+		return;
+
+	switch (_scrollbarStrokeType) {
+	case SCROLLBAR_UP:
+		// Scroll up
+		if (_inventoryTopIndex > 0 && inventoryList.size() > 0) {
+			--_inventoryTopIndex;
+			_inventoryChanged = true;
+		}
+		break;
+
+	case SCROLLBAR_DOWN:
+		// Scroll down
+		if (_inventoryTopIndex < ((int)inventoryList.size() - 1) && inventoryList.size() > 1) {
+			++_inventoryTopIndex;
+			_inventoryChanged = true;
+		}
+		break;
+
+	case SCROLLBAR_ELEVATOR: {
+		// Inventory slider
+		int newIndex = CLIP((int)_vm->_events->currentPos().y - 170, 0, 17)
+			* inventoryList.size() / 10;
+		if (newIndex >= (int)inventoryList.size())
+			newIndex = inventoryList.size() - 1;
+
+		if (inventoryList.size() > 0) {
+			_inventoryChanged = newIndex != _inventoryTopIndex;
+			_inventoryTopIndex = newIndex;
+		}
+		break;
+	}
+
+	default:
+		break;
+	}
+
+	if (_inventoryChanged) {
+		int dummy;
+		updateSelection(CAT_INV_LIST, 0, &dummy);
+	}
+}
+
 void UserInterface::scrollbarChanged() {
 	Common::Rect r(73, 4, 73 + 9, 4 + 38);
 	_uiSlots.add(r);
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 89044c9..71c6f64 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -140,7 +140,6 @@ private:
 	bool _scrollFlag;
 	int _noSegmentsActive;
 	int _someSegmentsActive;
-	ScrollbarActive _scrollbarStrokeType;
 
 	/**
 	 * Loads the elements of the user interface
@@ -216,6 +215,7 @@ public:
 	bool _scrollbarQuickly;
 	uint32 _scrollbarMilliTime;
 	int _scrollbarElevator, _scrollbarOldElevator;
+	ScrollbarActive _scrollbarStrokeType;
 public:
 	/**
 	* Constructor
@@ -275,6 +275,11 @@ public:
 
 	void updateSelection(ScrCategory category, int newIndex, int *idx);
 
+	/**
+	* Updates the current top visible item of the scrollbar
+	*/
+	void changeScrollBar();
+
 	void scrollerChanged();
 
 	void scrollInventory();






More information about the Scummvm-git-logs mailing list