aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2013-01-04 10:32:10 +0100
committerTorbjörn Andersson2013-01-04 10:32:10 +0100
commit8afe7a2361284fec8e9971a7f9bb915e108d8e6b (patch)
treeed500346a54ec4af51932f4f1eeae228bb69acce
parentf93facaf45ba4eedb9f443c18c90892e06d9889b (diff)
downloadscummvm-rg350-8afe7a2361284fec8e9971a7f9bb915e108d8e6b.tar.gz
scummvm-rg350-8afe7a2361284fec8e9971a7f9bb915e108d8e6b.tar.bz2
scummvm-rg350-8afe7a2361284fec8e9971a7f9bb915e108d8e6b.zip
TOLTECS: Hide/show arrows in original save/load dialogs
The arrows are only visible when there are savegames to scroll to in that direction.
-rw-r--r--engines/toltecs/menu.cpp37
-rw-r--r--engines/toltecs/menu.h4
2 files changed, 39 insertions, 2 deletions
diff --git a/engines/toltecs/menu.cpp b/engines/toltecs/menu.cpp
index e117351600..24444018f9 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 a72205c2e5..71422b0bbb 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);