aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLittleboy2011-05-10 18:19:01 -0400
committerLittleboy2011-05-10 19:18:30 -0400
commit2bc865f01af8733e8411eb4b50bfb0d3b29dd2a5 (patch)
tree541f1bf4f8e165f3969fdbc0f891ff93a1ce43a4
parent8d4622d70dc6f9d6b2788c849a0dfb0beb2ecc96 (diff)
downloadscummvm-rg350-2bc865f01af8733e8411eb4b50bfb0d3b29dd2a5.tar.gz
scummvm-rg350-2bc865f01af8733e8411eb4b50bfb0d3b29dd2a5.tar.bz2
scummvm-rg350-2bc865f01af8733e8411eb4b50bfb0d3b29dd2a5.zip
LASTEXPRESS: Implement highlight of inventory items
-rw-r--r--engines/lastexpress/game/inventory.cpp40
-rw-r--r--engines/lastexpress/game/inventory.h10
2 files changed, 29 insertions, 21 deletions
diff --git a/engines/lastexpress/game/inventory.cpp b/engines/lastexpress/game/inventory.cpp
index a8a6556626..05348fb5a4 100644
--- a/engines/lastexpress/game/inventory.cpp
+++ b/engines/lastexpress/game/inventory.cpp
@@ -43,13 +43,13 @@
namespace LastExpress {
-Inventory::Inventory(LastExpressEngine *engine) : _engine(engine), _selectedItem(kItemNone), _highlightedItem(kItemNone), _itemsShown(0),
+Inventory::Inventory(LastExpressEngine *engine) : _engine(engine), _selectedItem(kItemNone), _highlightedItemIndex(0), _itemsShown(0),
_showingHourGlass(false), _blinkingEgg(false), _blinkingTime(0), _blinkingInterval(_defaultBlinkingInterval), _blinkingBrightness(1),
_useMagnifier(false), _portraitHighlighted(false), _isOpened(false), _eggHightlighted(false), _itemScene(NULL) {
- _inventoryRect = Common::Rect(0, 0, 32, 32);
- _menuRect = Common::Rect(608, 448, 640, 480);
- _selectedRect = Common::Rect(44, 0, 76, 32);
+ //_inventoryRect = Common::Rect(0, 0, 32, 32);
+ _menuEggRect = Common::Rect(608, 448, 640, 480);
+ //_selectedItemRect = Common::Rect(44, 0, 76, 32);
init();
}
@@ -136,7 +136,7 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
_useMagnifier = false;
// Egg (menu)
- if (!_menuRect.contains(ev.mouse)) {
+ if (!_menuEggRect.contains(ev.mouse)) {
// Remove highlight if needed
if (_eggHightlighted) {
if (!getGlobalTimer()) {
@@ -182,7 +182,7 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
if (_isOpened) {
// If clicked
if (ev.type == Common::EVENT_LBUTTONDOWN) {
- if (_highlightedItem != kItemNone) {
+ if (_highlightedItemIndex != 0) {
error("[Inventory::handleMouseEvent] Click on highlighted item not implemented");
}
} else {
@@ -215,14 +215,21 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
return;
}
- if (ev.type == Common::EVENT_LBUTTONDOWN) {
- error("[Inventory::handleMouseEvent] Click on open inventory item not implemented");
+ // Change highlights on item list
+ if (getFlags()->mouseLeftPressed) {
+ uint32 index = ev.mouse.y / 40;
+
+ if (_highlightedItemIndex && _highlightedItemIndex != index)
+ drawHighlight(_highlightedItemIndex, true);
+
+ if (index && index <= _itemsShown && index != _highlightedItemIndex)
+ drawHighlight(index, false);
return;
}
uint32 index = 0;
- if (_highlightedItem != kItemNone) {
+ if (_highlightedItemIndex) {
error("[Inventory::handleMouseEvent] Computing of open inventory clicked item not implemented");
}
@@ -327,8 +334,8 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
}
// Draw highlighted item
- if (_highlightedItem)
- drawHighlight();
+ if (_highlightedItemIndex)
+ drawHighlight(_highlightedItemIndex, true);
}
}
@@ -640,8 +647,8 @@ void Inventory::close() {
askForRedraw();
}
-void Inventory::drawHighlight() {
- int32 count = 0;
+void Inventory::drawHighlight(uint32 currentIndex, bool reset) {
+ uint32 count = 0;
uint32 index = 0;
for (uint32 i = 1; i < ARRAYSIZE(_entries); i++) {
@@ -653,7 +660,7 @@ void Inventory::drawHighlight() {
if (count < 11) {
++count;
- if (count == _highlightedItem) {
+ if (count == currentIndex) {
index = i;
break;
}
@@ -661,8 +668,9 @@ void Inventory::drawHighlight() {
}
if (index) {
- drawItem(_entries[index].cursor, 0, 40 * _highlightedItem + 4, 1);
- _highlightedItem = kItemNone;
+ drawItem(_entries[index].cursor, 0, 40 * currentIndex + 4, reset ? 1 : -1);
+ _highlightedItemIndex = reset ? 0 : currentIndex;
+ askForRedraw();
}
}
diff --git a/engines/lastexpress/game/inventory.h b/engines/lastexpress/game/inventory.h
index b38ffa849e..301e32d2a7 100644
--- a/engines/lastexpress/game/inventory.h
+++ b/engines/lastexpress/game/inventory.h
@@ -142,7 +142,7 @@ private:
InventoryEntry _entries[32];
InventoryItem _selectedItem;
- InventoryItem _highlightedItem;
+ uint32 _highlightedItemIndex;
uint32 _itemsShown;
@@ -161,16 +161,16 @@ private:
Scene *_itemScene;
// Important rects
- Common::Rect _inventoryRect;
- Common::Rect _menuRect;
- Common::Rect _selectedRect;
+ //Common::Rect _inventoryRect;
+ Common::Rect _menuEggRect;
+ //Common::Rect _selectedItemRect;
void init();
void open();
void close();
void examine(InventoryItem item);
- void drawHighlight();
+ void drawHighlight(uint32 currentIndex, bool reset);
bool isItemSceneParameter(InventoryItem item) const;