[Scummvm-cvs-logs] scummvm master -> 532dd09b21510e100eec65a3fd29c9f507a16e58

eriktorbjorn eriktorbjorn at telia.com
Fri Jan 4 11:00:22 CET 2013


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

Summary:
8afe7a2361 TOLTECS: Hide/show arrows in original save/load dialogs
c9a175a877 TOLTECS: Scroll original save/load dialog to bottom on opening
532dd09b21 TOLTECS: When a new dialog opens, highlight active item (if any)


Commit: 8afe7a2361284fec8e9971a7f9bb915e108d8e6b
    https://github.com/scummvm/scummvm/commit/8afe7a2361284fec8e9971a7f9bb915e108d8e6b
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2013-01-04T01:32:10-08:00

Commit Message:
TOLTECS: Hide/show arrows in original save/load dialogs

The arrows are only visible when there are savegames to scroll to
in that direction.

Changed paths:
    engines/toltecs/menu.cpp
    engines/toltecs/menu.h



diff --git a/engines/toltecs/menu.cpp b/engines/toltecs/menu.cpp
index e117351..2444401 100644
--- a/engines/toltecs/menu.cpp
+++ b/engines/toltecs/menu.cpp
@@ -132,6 +132,7 @@ void MenuSystem::handleEvents() {
 
 void MenuSystem::addClickTextItem(ItemID id, int x, int y, int w, uint fontNum, const char *caption, byte defaultColor, byte activeColor) {
 	Item item;
+	item.enabled = true;
 	item.id = id;
 	item.defaultColor = defaultColor;
 	item.activeColor = activeColor;
@@ -196,7 +197,7 @@ void MenuSystem::handleKeyDown(const Common::KeyState& kbd) {
 
 ItemID MenuSystem::findItemAt(int x, int y) {
 	for (Common::Array<Item>::iterator iter = _items.begin(); iter != _items.end(); iter++) {
-		if ((*iter).rect.contains(x, y - _top))
+		if ((*iter).enabled && (*iter).rect.contains(x, y - _top))
 			return (*iter).id;
 	}
 	return kItemIdNone;
@@ -324,7 +325,29 @@ void MenuSystem::initMenu(MenuID menuID) {
 	}
 
 	for (Common::Array<Item>::iterator iter = _items.begin(); iter != _items.end(); iter++) {
-		drawItem((*iter).id, false);
+		if ((*iter).enabled)
+			drawItem((*iter).id, false);
+	}
+}
+
+void MenuSystem::enableItem(ItemID id) {
+	Item *item = getItem(id);
+	if (item) {
+		item->enabled = true;
+		drawItem(id, false);
+		Common::Point mousePos = _vm->_system->getEventManager()->getMousePos();
+		handleMouseMove(mousePos.x, mousePos.y);
+	}
+}
+
+void MenuSystem::disableItem(ItemID id) {
+	Item *item = getItem(id);
+	if (item) {
+		item->enabled = false;
+		restoreRect(item->rect.left, item->rect.top, item->rect.width(), item->rect.height());
+		if (_currItemID == id) {
+			_currItemID = kItemIdNone;
+		}
 	}
 }
 
@@ -512,6 +535,16 @@ void MenuSystem::setSavegameCaptions() {
 	uint index = _savegameListTopIndex;
 	for (int i = 1; i <= 7; i++)
 		setItemCaption(getItem((ItemID)(kItemIdSavegame1 + i - 1)), index < _savegames.size() ? _savegames[index++]._description.c_str() : "");
+	if (_savegameListTopIndex == 0) {
+		disableItem(kItemIdSavegameUp);
+	} else {
+		enableItem(kItemIdSavegameUp);
+	}
+	if ((uint)_savegameListTopIndex + 7 > _savegames.size()) {
+		disableItem(kItemIdSavegameDown);
+	} else {
+		enableItem(kItemIdSavegameDown);
+	}
 }
 
 void MenuSystem::scrollSavegames(int delta) {
diff --git a/engines/toltecs/menu.h b/engines/toltecs/menu.h
index a72205c..71422b0 100644
--- a/engines/toltecs/menu.h
+++ b/engines/toltecs/menu.h
@@ -84,6 +84,7 @@ public:
 protected:
 
 	struct Item {
+		bool enabled;
 		Common::Rect rect;
 		ItemID id;
 		Common::String caption;
@@ -130,6 +131,9 @@ protected:
 
 	void initMenu(MenuID menuID);
 
+	void enableItem(ItemID id);
+	void disableItem(ItemID id);
+
 	void enterItem(ItemID id);
 	void leaveItem(ItemID id);
 	void clickItem(ItemID id);


Commit: c9a175a8775faf2c6d3593c5b4984b7dbd02ca99
    https://github.com/scummvm/scummvm/commit/c9a175a8775faf2c6d3593c5b4984b7dbd02ca99
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2013-01-04T01:50:18-08:00

Commit Message:
TOLTECS: Scroll original save/load dialog to bottom on opening

This doesn't behave quite like the original - it seems the original
does not take the fake last entry into account when saving? - but I
think it's actually a bit more consistent this way.

Changed paths:
    engines/toltecs/menu.cpp
    engines/toltecs/menu.h



diff --git a/engines/toltecs/menu.cpp b/engines/toltecs/menu.cpp
index 2444401..85cd15b 100644
--- a/engines/toltecs/menu.cpp
+++ b/engines/toltecs/menu.cpp
@@ -254,7 +254,7 @@ void MenuSystem::initMenu(MenuID menuID) {
 				addClickTextItem((ItemID)(kItemIdSavegame1 + i - 1), 0, 116 + 20 * (i - 1), 300, 0, saveDesc.c_str(), 231, 234);
 			}
 			loadSavegamesList();
-			setSavegameCaptions();
+			setSavegameCaptions(true);
 		} else {
 			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
 			int slot = dialog->runModalWithCurrentTarget();
@@ -279,7 +279,7 @@ void MenuSystem::initMenu(MenuID menuID) {
 			}
 			newSlotNum = loadSavegamesList() + 1;
 			_savegames.push_back(SavegameItem(newSlotNum, Common::String::format("GAME %04d", _savegames.size())));
-			setSavegameCaptions();
+			setSavegameCaptions(true);
 		} else {
 			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
 			int slot = dialog->runModalWithCurrentTarget();
@@ -531,16 +531,21 @@ MenuSystem::SavegameItem *MenuSystem::getSavegameItemByID(ItemID id) {
 		return NULL;
 }
 
-void MenuSystem::setSavegameCaptions() {
-	uint index = _savegameListTopIndex;
+void MenuSystem::setSavegameCaptions(bool scrollToBottom) {
+	int size = _savegames.size();
+	if (scrollToBottom && size > 0) {
+		while (_savegameListTopIndex + 7 <= size)
+			_savegameListTopIndex += 6;
+	}
+	int index = _savegameListTopIndex;
 	for (int i = 1; i <= 7; i++)
-		setItemCaption(getItem((ItemID)(kItemIdSavegame1 + i - 1)), index < _savegames.size() ? _savegames[index++]._description.c_str() : "");
+		setItemCaption(getItem((ItemID)(kItemIdSavegame1 + i - 1)), index < size ? _savegames[index++]._description.c_str() : "");
 	if (_savegameListTopIndex == 0) {
 		disableItem(kItemIdSavegameUp);
 	} else {
 		enableItem(kItemIdSavegameUp);
 	}
-	if ((uint)_savegameListTopIndex + 7 > _savegames.size()) {
+	if (_savegameListTopIndex + 7 > size) {
 		disableItem(kItemIdSavegameDown);
 	} else {
 		enableItem(kItemIdSavegameDown);
@@ -551,7 +556,7 @@ void MenuSystem::scrollSavegames(int delta) {
 	int newPos = CLIP<int>(_savegameListTopIndex + delta, 0, _savegames.size() - 1);
 	_savegameListTopIndex = newPos;
 	restoreRect(80, 92, 440, 140);
-	setSavegameCaptions();
+	setSavegameCaptions(false);
 	for (int i = 1; i <= 7; i++)
 		drawItem((ItemID)(kItemIdSavegame1 + i - 1), false);
 }
diff --git a/engines/toltecs/menu.h b/engines/toltecs/menu.h
index 71422b0..a5eca7c 100644
--- a/engines/toltecs/menu.h
+++ b/engines/toltecs/menu.h
@@ -145,7 +145,7 @@ protected:
 	SavegameItem *getSavegameItemByID(ItemID id);
 
 	int loadSavegamesList();
-	void setSavegameCaptions();
+	void setSavegameCaptions(bool scrollToBottom);
 	void scrollSavegames(int delta);
 	void clickSavegameItem(ItemID id);
 	void setCfgText(bool value, bool active);


Commit: 532dd09b21510e100eec65a3fd29c9f507a16e58
    https://github.com/scummvm/scummvm/commit/532dd09b21510e100eec65a3fd29c9f507a16e58
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2013-01-04T01:58:27-08:00

Commit Message:
TOLTECS: When a new dialog opens, highlight active item (if any)

We do this by acting as if the mouse just moved to its current
position. I first noticed this on the original save/load dialogs.

Changed paths:
    engines/toltecs/menu.cpp



diff --git a/engines/toltecs/menu.cpp b/engines/toltecs/menu.cpp
index 85cd15b..b52d7da 100644
--- a/engines/toltecs/menu.cpp
+++ b/engines/toltecs/menu.cpp
@@ -328,6 +328,11 @@ void MenuSystem::initMenu(MenuID menuID) {
 		if ((*iter).enabled)
 			drawItem((*iter).id, false);
 	}
+
+	// Check if the mouse is already over an item
+	_currItemID = kItemIdNone;
+	Common::Point mousePos = _vm->_system->getEventManager()->getMousePos();
+	handleMouseMove(mousePos.x, mousePos.y);
 }
 
 void MenuSystem::enableItem(ItemID id) {
@@ -335,6 +340,7 @@ void MenuSystem::enableItem(ItemID id) {
 	if (item) {
 		item->enabled = true;
 		drawItem(id, false);
+		_currItemID = kItemIdNone;
 		Common::Point mousePos = _vm->_system->getEventManager()->getMousePos();
 		handleMouseMove(mousePos.x, mousePos.y);
 	}






More information about the Scummvm-git-logs mailing list