[Scummvm-cvs-logs] scummvm master -> 33c3e19cea2a08fbf26ecbe940763e8ee1c37d28
Littleboy
littleboy22 at gmail.com
Wed May 11 01:21:04 CEST 2011
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1516ba7367 LASTEXPRESS: Implement skeleton code for selected item and inventory selection
3088acf69a LASTEXPRESS: Add button pressed state for inventory handling
8d4622d70d LASTEXPRESS: Draw portrait non-highlighted in Inventory::show()
2bc865f01a LASTEXPRESS: Implement highlight of inventory items
33c3e19cea LASTEXPRESS: Implement item selection and scene loading
Commit: 1516ba73671d59ab5d6e26602dbb1e5055cbb05c
https://github.com/scummvm/scummvm/commit/1516ba73671d59ab5d6e26602dbb1e5055cbb05c
Author: Littleboy (littleboy at users.sourceforge.net)
Date: 2011-05-10T16:18:22-07:00
Commit Message:
LASTEXPRESS: Implement skeleton code for selected item and inventory selection
Changed paths:
engines/lastexpress/game/inventory.cpp
engines/lastexpress/game/inventory.h
engines/lastexpress/game/logic.cpp
diff --git a/engines/lastexpress/game/inventory.cpp b/engines/lastexpress/game/inventory.cpp
index 81189ae..25db782 100644
--- a/engines/lastexpress/game/inventory.cpp
+++ b/engines/lastexpress/game/inventory.cpp
@@ -45,7 +45,7 @@ namespace LastExpress {
Inventory::Inventory(LastExpressEngine *engine) : _engine(engine), _selectedItem(kItemNone), _highlightedItem(kItemNone), _itemsShown(0),
_showingHourGlass(false), _blinkingEgg(false), _blinkingTime(0), _blinkingInterval(_defaultBlinkingInterval), _blinkingBrightness(1),
- _useMagnifier(false), _flag1(false), _isOpened(false), _eggHightlighted(false), _itemScene(NULL) {
+ _useMagnifier(false), _portraitHighlighted(false), _isOpened(false), _eggHightlighted(false), _itemScene(NULL) {
_inventoryRect = Common::Rect(0, 0, 32, 32);
_menuRect = Common::Rect(608, 448, 640, 480);
@@ -143,6 +143,7 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
drawItem((CursorStyle)(getMenu()->getGameId() + 39), 608, 448, 1);
askForRedraw();
}
+
_eggHightlighted = false;
}
} else {
@@ -159,7 +160,7 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
// If clicked, show the menu
if (ev.type == Common::EVENT_LBUTTONDOWN) {
_eggHightlighted = false;
- _flag1 = false;
+ _portraitHighlighted = false;
_isOpened = false;
getSound()->playSoundWithSubtitles("LIB039.SND", SoundManager::kFlagMenuClock, kEntityPlayer);
@@ -178,14 +179,95 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
// Selected item
if (ev.mouse.x >= 32) {
- // TODO
+ if (_isOpened) {
+ // If clicked
+ if (ev.type == Common::EVENT_LBUTTONDOWN) {
+ if (_highlightedItem != kItemNone) {
+ error("[Inventory::handleMouseEvent] Click on highlighted item not implemented");
+ }
+ } else {
+ error("[Inventory::handleMouseEvent] Default handling of open menu not implemented");
+ }
+ } else {
+ if (_portraitHighlighted) {
+ drawItem((CursorStyle)getProgress().portrait, 0, 0, 1);
+ askForRedraw();
+ _portraitHighlighted = false;
+ }
+
+ if (_selectedItem != kItemNone) {
+ error("[Inventory::handleMouseEvent] Default handling of selected item not implemented");
+ }
+ }
return;
}
// Opened inventory
if (ev.mouse.y >= 32) {
- // TODO
+ if (!_isOpened) {
+ if (_portraitHighlighted) {
+ drawItem((CursorStyle)getProgress().portrait, 0, 0, 1);
+ askForRedraw();
+ _portraitHighlighted = false;
+ }
+
+ return;
+ }
+
+ if (ev.type == Common::EVENT_LBUTTONDOWN) {
+ error("[Inventory::handleMouseEvent] Click on open inventory item not implemented");
+
+ return;
+ }
+
+ uint32 index = 0;
+ if (_highlightedItem != kItemNone) {
+ error("[Inventory::handleMouseEvent] Computing of open inventory clicked item not implemented");
+ }
+
+ drawItem((CursorStyle)getProgress().portrait, 0, 0, 1);
+
+ // TODO clear items on inventory surface before redraw
+
+ // Load the scene if an item has been selected
+ if (index) {
+ error("[Inventory::handleMouseEvent] Loading of item scene not implemented");
+
+ _isOpened = false;
+
+ return;
+ }
+
+ // Draw the selected item if any
+ if (!_selectedItem || get(_selectedItem)->manualSelect) {
+ _selectedItem = getFirstExaminableItem();
+
+ if (_selectedItem) {
+ drawItem(get(_selectedItem)->cursor, 44, 0);
+ } else {
+ clearSelectedItem();
+ }
+ askForRedraw();
+ }
+
+ // Stop processing if we are not looking at an item already
+ if (!getState()->sceneUseBackup) {
+ _isOpened = false;
+ return;
+ }
+
+ SceneIndex scene = kSceneNone;
+ if (getState()->sceneBackup2) {
+ scene = getState()->sceneBackup2;
+ getState()->sceneBackup2 = kSceneNone;
+ } else {
+ error("[Inventory::handleMouseEvent] Processing of item scene not implemented");
+ }
+
+ getScenes()->loadScene(scene);
+
+ _isOpened = false;
return;
}
@@ -202,9 +284,9 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
return;
}
- if (!_flag1 && !_isOpened) {
+ if (!_portraitHighlighted && !_isOpened) {
drawItem((CursorStyle)getProgress().portrait, 0, 0);
- _flag1 = true;
+ _portraitHighlighted = true;
} else if (!_isOpened || (ev.type == Common::EVENT_LBUTTONDOWN || ev.type == Common::EVENT_LBUTTONUP)) {
// Do nothing
} else if (_isOpened) {
@@ -239,7 +321,7 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
}
}
- _flag1 = true;
+ _portraitHighlighted = true;
}
// Draw highlighted item
@@ -511,9 +593,13 @@ void Inventory::drawItem(CursorStyle id, uint16 x, uint16 y, int16 brightnessInd
_engine->getGraphicsManager()->draw(&icon, GraphicsManager::kBackgroundInventory);
}
+void Inventory::clearSelectedItem() {
+ _engine->getGraphicsManager()->clear(GraphicsManager::kBackgroundInventory, Common::Rect(44, 0, 44 + 32, 32));
+}
+
// Close inventory: clear items and reset icon
void Inventory::open() {
- _flag1 = false;
+ _portraitHighlighted = false;
_isOpened = true;
// Draw highlighted portrait
diff --git a/engines/lastexpress/game/inventory.h b/engines/lastexpress/game/inventory.h
index 860f825..b38ffa8 100644
--- a/engines/lastexpress/game/inventory.h
+++ b/engines/lastexpress/game/inventory.h
@@ -120,7 +120,7 @@ public:
// State
bool isMagnifierInUse() { return _useMagnifier; }
- bool isFlag1() { return _flag1; }
+ bool isPortraitHighlighted() { return _portraitHighlighted; }
bool isOpened() { return _isOpened; }
bool isEggHighlighted() { return _eggHightlighted; }
@@ -154,7 +154,7 @@ private:
// Flags
bool _useMagnifier;
- bool _flag1;
+ bool _portraitHighlighted;
bool _isOpened;
bool _eggHightlighted;
@@ -175,6 +175,7 @@ private:
bool isItemSceneParameter(InventoryItem item) const;
void drawItem(CursorStyle id, uint16 x, uint16 y, int16 brighnessIndex = -1);
+ void clearSelectedItem();
};
} // End of namespace LastExpress
diff --git a/engines/lastexpress/game/logic.cpp b/engines/lastexpress/game/logic.cpp
index bfed65e..83e067f 100644
--- a/engines/lastexpress/game/logic.cpp
+++ b/engines/lastexpress/game/logic.cpp
@@ -89,7 +89,7 @@ Logic::~Logic() {
#define REDRAW_CURSOR() { \
if (getInventory()->isMagnifierInUse()) \
_engine->getCursor()->setStyle(kCursorMagnifier); \
- if (getInventory()->isFlag1() \
+ if (getInventory()->isPortraitHighlighted() \
|| getInventory()->isOpened() \
|| getInventory()->isEggHighlighted()) \
_engine->getCursor()->setStyle(kCursorNormal); \
@@ -104,7 +104,7 @@ void Logic::eventMouse(const Common::Event &ev) {
getFlags()->mouseRightClick = false;
// Process event flags
- if (ev.type == Common::EVENT_LBUTTONUP) {
+ if (ev.type == Common::EVENT_LBUTTONDOWN) {
if (getFlags()->frameInterval)
_ignoreFrameInterval = false;
@@ -113,7 +113,7 @@ void Logic::eventMouse(const Common::Event &ev) {
}
if (getFlags()->flag_0) {
- if (ev.type == Common::EVENT_LBUTTONUP || ev.type == Common::EVENT_RBUTTONUP) {
+ if (ev.type == Common::EVENT_LBUTTONDOWN || ev.type == Common::EVENT_RBUTTONDOWN) {
getFlags()->flag_0 = false;
getFlags()->shouldRedraw = true;
updateCursor(true);
@@ -143,7 +143,7 @@ void Logic::eventMouse(const Common::Event &ev) {
&& !getProgress().isEggOpen
&& !getEntities()->isPlayerPosition(kCarGreenSleeping, 59)
&& !getEntities()->isPlayerPosition(kCarGreenSleeping, 76)
- && !getInventory()->isFlag1()
+ && !getInventory()->isPortraitHighlighted()
&& !getInventory()->isOpened()
&& !getInventory()->isEggHighlighted()
&& !getInventory()->isMagnifierInUse()) {
@@ -173,7 +173,7 @@ void Logic::eventMouse(const Common::Event &ev) {
if (getInventory()->getSelectedItem() == kItemMatch
&& (getEntities()->isPlayerInCar(kCarGreenSleeping) || getEntities()->isPlayerInCar(kCarRedSleeping))
&& getProgress().jacket == kJacketGreen
- && !getInventory()->isFlag1()
+ && !getInventory()->isPortraitHighlighted()
&& !getInventory()->isOpened()
&& !getInventory()->isEggHighlighted()
&& !getInventory()->isMagnifierInUse()
@@ -198,7 +198,7 @@ void Logic::eventMouse(const Common::Event &ev) {
// Handle entity item case
EntityIndex entityIndex = getEntities()->canInteractWith(ev.mouse);
if (entityIndex
- && !getInventory()->isFlag1()
+ && !getInventory()->isPortraitHighlighted()
&& !getInventory()->isOpened()
&& !getInventory()->isEggHighlighted()
&& !getInventory()->isMagnifierInUse()) {
@@ -223,17 +223,17 @@ void Logic::eventMouse(const Common::Event &ev) {
//////////////////////////////////////////////////////////////////////////
// Handle standard actions
- if (getInventory()->isFlag1() || getInventory()->isOpened() || getInventory()->isEggHighlighted())
+ if (getInventory()->isPortraitHighlighted() || getInventory()->isOpened() || getInventory()->isEggHighlighted())
_engine->getCursor()->setStyle(kCursorNormal);
- if (hotspotHandled || getInventory()->isFlag1() || getInventory()->isOpened() || getInventory()->isEggHighlighted())
+ if (hotspotHandled || getInventory()->isPortraitHighlighted() || getInventory()->isOpened() || getInventory()->isEggHighlighted())
return;
// Magnifier in use
if (getInventory()->isMagnifierInUse()) {
_engine->getCursor()->setStyle(kCursorMagnifier);
- if (getInventory()->isFlag1()
+ if (getInventory()->isPortraitHighlighted()
|| getInventory()->isOpened()
|| getInventory()->isEggHighlighted())
_engine->getCursor()->setStyle(kCursorNormal);
@@ -518,7 +518,7 @@ void Logic::updateCursor(bool) const { /* the cursor is always updated, even whe
|| getProgress().isEggOpen
|| getEntities()->isPlayerPosition(kCarGreenSleeping, 59)
|| getEntities()->isPlayerPosition(kCarGreenSleeping, 76)
- || getInventory()->isFlag1()
+ || getInventory()->isPortraitHighlighted()
|| getInventory()->isOpened()
|| getInventory()->isEggHighlighted()
|| getInventory()->isMagnifierInUse()) {
@@ -526,7 +526,7 @@ void Logic::updateCursor(bool) const { /* the cursor is always updated, even whe
if (getInventory()->getSelectedItem() != kItemMatch
|| (!getEntities()->isPlayerInCar(kCarGreenSleeping) && !getEntities()->isPlayerInCar(kCarRedSleeping))
|| getProgress().jacket != kJacketGreen
- || getInventory()->isFlag1()
+ || getInventory()->isPortraitHighlighted()
|| getInventory()->isOpened()
|| getInventory()->isEggHighlighted()
|| getInventory()->isMagnifierInUse()
@@ -536,7 +536,7 @@ void Logic::updateCursor(bool) const { /* the cursor is always updated, even whe
EntityIndex entity = getEntities()->canInteractWith(getCoords());
if (entity
- && !getInventory()->isFlag1()
+ && !getInventory()->isPortraitHighlighted()
&& !getInventory()->isOpened()
&& !getInventory()->isEggHighlighted()
&& !getInventory()->isMagnifierInUse()) {
@@ -550,7 +550,7 @@ void Logic::updateCursor(bool) const { /* the cursor is always updated, even whe
}
if (!interact
- && !getInventory()->isFlag1()
+ && !getInventory()->isPortraitHighlighted()
&& !getInventory()->isOpened()
&& !getInventory()->isEggHighlighted()
&& !getInventory()->isMagnifierInUse()) {
@@ -587,7 +587,7 @@ void Logic::updateCursor(bool) const { /* the cursor is always updated, even whe
if (getInventory()->isMagnifierInUse())
style = kCursorMagnifier;
- if (getInventory()->isFlag1() || getInventory()->isOpened() || getInventory()->isEggHighlighted())
+ if (getInventory()->isPortraitHighlighted() || getInventory()->isOpened() || getInventory()->isEggHighlighted())
style = kCursorNormal;
_engine->getCursor()->setStyle(style);
Commit: 3088acf69a41dc0e942faad1b624fe097c690a3e
https://github.com/scummvm/scummvm/commit/3088acf69a41dc0e942faad1b624fe097c690a3e
Author: Littleboy (littleboy at users.sourceforge.net)
Date: 2011-05-10T16:18:26-07:00
Commit Message:
LASTEXPRESS: Add button pressed state for inventory handling
Changed paths:
engines/lastexpress/game/inventory.cpp
engines/lastexpress/game/state.h
engines/lastexpress/lastexpress.cpp
diff --git a/engines/lastexpress/game/inventory.cpp b/engines/lastexpress/game/inventory.cpp
index 25db782..5df745d 100644
--- a/engines/lastexpress/game/inventory.cpp
+++ b/engines/lastexpress/game/inventory.cpp
@@ -186,7 +186,7 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
error("[Inventory::handleMouseEvent] Click on highlighted item not implemented");
}
} else {
- error("[Inventory::handleMouseEvent] Default handling of open menu not implemented");
+ warning("[Inventory::handleMouseEvent] Default handling of open menu not implemented");
}
} else {
if (_portraitHighlighted) {
@@ -251,6 +251,8 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
askForRedraw();
}
+ return;
+
// Stop processing if we are not looking at an item already
if (!getState()->sceneUseBackup) {
_isOpened = false;
@@ -287,7 +289,7 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
if (!_portraitHighlighted && !_isOpened) {
drawItem((CursorStyle)getProgress().portrait, 0, 0);
_portraitHighlighted = true;
- } else if (!_isOpened || (ev.type == Common::EVENT_LBUTTONDOWN || ev.type == Common::EVENT_LBUTTONUP)) {
+ } else if (!_isOpened || getFlags()->mouseLeftPressed) {
// Do nothing
} else if (_isOpened) {
close();
diff --git a/engines/lastexpress/game/state.h b/engines/lastexpress/game/state.h
index 4196bfe..663550a 100644
--- a/engines/lastexpress/game/state.h
+++ b/engines/lastexpress/game/state.h
@@ -566,6 +566,9 @@ public:
bool mouseLeftClick;
bool mouseRightClick;
+ bool mouseLeftPressed;
+ bool mouseRightPressed;
+
bool flag_entities_0;
bool flag_entities_1;
@@ -587,6 +590,9 @@ public:
mouseRightClick = false;
mouseLeftClick = false;
+ mouseLeftPressed = false;
+ mouseRightPressed = false;
+
flag_entities_0 = false;
flag_entities_1 = false;
diff --git a/engines/lastexpress/lastexpress.cpp b/engines/lastexpress/lastexpress.cpp
index 7c08fef..535f5e8 100644
--- a/engines/lastexpress/lastexpress.cpp
+++ b/engines/lastexpress/lastexpress.cpp
@@ -215,6 +215,7 @@ bool LastExpressEngine::handleEvents() {
case Common::EVENT_LBUTTONUP:
case Common::EVENT_LBUTTONDOWN:
getGameLogic()->getGameState()->getGameFlags()->mouseLeftClick = true;
+ getGameLogic()->getGameState()->getGameFlags()->mouseLeftPressed = (ev.type == Common::EVENT_LBUTTONDOWN) ? true : false;
// Adjust frameInterval flag
if (_frameCounter < _lastFrameCount + 30)
@@ -228,6 +229,8 @@ bool LastExpressEngine::handleEvents() {
case Common::EVENT_RBUTTONUP:
case Common::EVENT_RBUTTONDOWN:
getGameLogic()->getGameState()->getGameFlags()->mouseRightClick = true;
+ getGameLogic()->getGameState()->getGameFlags()->mouseRightPressed = (ev.type == Common::EVENT_RBUTTONDOWN) ? true : false;
+
if (_eventMouse && _eventMouse->isValid())
(*_eventMouse)(ev);
break;
Commit: 8d4622d70dc6f9d6b2788c849a0dfb0beb2ecc96
https://github.com/scummvm/scummvm/commit/8d4622d70dc6f9d6b2788c849a0dfb0beb2ecc96
Author: Littleboy (littleboy at users.sourceforge.net)
Date: 2011-05-10T16:18:29-07:00
Commit Message:
LASTEXPRESS: Draw portrait non-highlighted in Inventory::show()
Changed paths:
engines/lastexpress/game/inventory.cpp
diff --git a/engines/lastexpress/game/inventory.cpp b/engines/lastexpress/game/inventory.cpp
index 5df745d..a8a6556 100644
--- a/engines/lastexpress/game/inventory.cpp
+++ b/engines/lastexpress/game/inventory.cpp
@@ -340,7 +340,7 @@ void Inventory::show() {
askForRedraw();
// Show portrait (first draw, cannot be highlighted)
- drawItem((CursorStyle)getProgress().portrait, 0, 0);
+ drawItem((CursorStyle)getProgress().portrait, 0, 0, 1);
// Show selected item
if (_selectedItem != kItemNone)
@@ -599,7 +599,7 @@ void Inventory::clearSelectedItem() {
_engine->getGraphicsManager()->clear(GraphicsManager::kBackgroundInventory, Common::Rect(44, 0, 44 + 32, 32));
}
-// Close inventory: clear items and reset icon
+// Open inventory: show portrait selected and draw contents
void Inventory::open() {
_portraitHighlighted = false;
_isOpened = true;
Commit: 2bc865f01af8733e8411eb4b50bfb0d3b29dd2a5
https://github.com/scummvm/scummvm/commit/2bc865f01af8733e8411eb4b50bfb0d3b29dd2a5
Author: Littleboy (littleboy at users.sourceforge.net)
Date: 2011-05-10T16:18:30-07:00
Commit Message:
LASTEXPRESS: Implement highlight of inventory items
Changed paths:
engines/lastexpress/game/inventory.cpp
engines/lastexpress/game/inventory.h
diff --git a/engines/lastexpress/game/inventory.cpp b/engines/lastexpress/game/inventory.cpp
index a8a6556..05348fb 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 b38ffa8..301e32d 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;
Commit: 33c3e19cea2a08fbf26ecbe940763e8ee1c37d28
https://github.com/scummvm/scummvm/commit/33c3e19cea2a08fbf26ecbe940763e8ee1c37d28
Author: Littleboy (littleboy at users.sourceforge.net)
Date: 2011-05-10T16:18:32-07:00
Commit Message:
LASTEXPRESS: Implement item selection and scene loading
Changed paths:
engines/lastexpress/game/inventory.cpp
engines/lastexpress/game/inventory.h
diff --git a/engines/lastexpress/game/inventory.cpp b/engines/lastexpress/game/inventory.cpp
index 05348fb..c4d43d5 100644
--- a/engines/lastexpress/game/inventory.cpp
+++ b/engines/lastexpress/game/inventory.cpp
@@ -49,7 +49,7 @@ Inventory::Inventory(LastExpressEngine *engine) : _engine(engine), _selectedItem
//_inventoryRect = Common::Rect(0, 0, 32, 32);
_menuEggRect = Common::Rect(608, 448, 640, 480);
- //_selectedItemRect = Common::Rect(44, 0, 76, 32);
+ _selectedItemRect = Common::Rect(44, 0, 76, 32);
init();
}
@@ -195,7 +195,9 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
_portraitHighlighted = false;
}
- if (_selectedItem != kItemNone) {
+ if (_selectedItem != kItemNone
+ && get(_selectedItem)->scene != kSceneNone
+ && _selectedItemRect.contains(ev.mouse)) {
error("[Inventory::handleMouseEvent] Default handling of selected item not implemented");
}
}
@@ -205,6 +207,7 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
// Opened inventory
if (ev.mouse.y >= 32) {
+ // Draw portrait (darkened) if the inventory is closed (and we are not on top of it)
if (!_isOpened) {
if (_portraitHighlighted) {
drawItem((CursorStyle)getProgress().portrait, 0, 0, 1);
@@ -215,7 +218,7 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
return;
}
- // Change highlights on item list
+ // Change item highlight on list
if (getFlags()->mouseLeftPressed) {
uint32 index = ev.mouse.y / 40;
@@ -228,37 +231,46 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
return;
}
- uint32 index = 0;
- if (_highlightedItemIndex) {
- error("[Inventory::handleMouseEvent] Computing of open inventory clicked item not implemented");
- }
+ // User released the mouse button, check if we were on a valid item
+ uint32 index = _highlightedItemIndex ? getItemIndex(_highlightedItemIndex) : 0;
+ // Reset items and portrait
drawItem((CursorStyle)getProgress().portrait, 0, 0, 1);
-
- // TODO clear items on inventory surface before redraw
+ _engine->getGraphicsManager()->clear(GraphicsManager::kBackgroundInventory, Common::Rect(0, 44, 32, (int16)(40 * _itemsShown + 40)));
+ _highlightedItemIndex = 0;
+ _itemsShown = 0;
// Load the scene if an item has been selected
if (index) {
- error("[Inventory::handleMouseEvent] Loading of item scene not implemented");
-
- _isOpened = false;
-
- return;
- }
+ InventoryEntry entry = _entries[index];
+
+ // If a scene is affected to the item
+ if (entry.scene) {
+ if (getState()->sceneUseBackup) {
+ if (getFirstExaminableItem() && !getState()->sceneBackup2)
+ getState()->sceneBackup2 = getState()->scene;
+ } else {
+ getState()->sceneUseBackup = true;
+ getState()->sceneBackup = getState()->scene;
+ }
- // Draw the selected item if any
- if (!_selectedItem || get(_selectedItem)->manualSelect) {
- _selectedItem = getFirstExaminableItem();
+ getScenes()->loadScene(entry.scene);
+ }
- if (_selectedItem) {
- drawItem(get(_selectedItem)->cursor, 44, 0);
+ if (entry.field_2) {
+ selectItem((InventoryItem)index);
} else {
- clearSelectedItem();
+ drawSelectedItem();
}
- askForRedraw();
+
+ // Set inventory as closed (will cause a cleanup on next call)
+ _isOpened = false;
+
+ return;
}
- return;
+ // Draw the currently selected item
+ drawSelectedItem();
// Stop processing if we are not looking at an item already
if (!getState()->sceneUseBackup) {
@@ -271,7 +283,16 @@ void Inventory::handleMouseEvent(const Common::Event &ev) {
scene = getState()->sceneBackup2;
getState()->sceneBackup2 = kSceneNone;
} else {
- error("[Inventory::handleMouseEvent] Processing of item scene not implemented");
+ if (getEvent(kEventKronosBringFirebird) || getProgress().isEggOpen) {
+ _isOpened = false;
+ return;
+ }
+
+ getState()->sceneUseBackup = false;
+ scene = getState()->sceneBackup;
+
+ if (getEntities()->getPosition(getScenes()->get(scene)->car, getScenes()->get(scene)->position))
+ scene = getScenes()->processIndex(getState()->sceneBackup);
}
getScenes()->loadScene(scene);
@@ -602,6 +623,20 @@ void Inventory::drawItem(CursorStyle id, uint16 x, uint16 y, int16 brightnessInd
_engine->getGraphicsManager()->draw(&icon, GraphicsManager::kBackgroundInventory);
}
+void Inventory::drawSelectedItem() {
+ // Draw the selected item if any
+ if (!_selectedItem || get(_selectedItem)->manualSelect) {
+ _selectedItem = getFirstExaminableItem();
+
+ if (_selectedItem) {
+ drawItem(get(_selectedItem)->cursor, 44, 0);
+ } else {
+ clearSelectedItem();
+ }
+ askForRedraw();
+ }
+}
+
void Inventory::clearSelectedItem() {
_engine->getGraphicsManager()->clear(GraphicsManager::kBackgroundInventory, Common::Rect(44, 0, 44 + 32, 32));
}
@@ -648,8 +683,17 @@ void Inventory::close() {
}
void Inventory::drawHighlight(uint32 currentIndex, bool reset) {
+ uint32 index = getItemIndex(currentIndex);
+
+ if (index) {
+ drawItem(_entries[index].cursor, 0, 40 * currentIndex + 4, reset ? 1 : -1);
+ _highlightedItemIndex = reset ? 0 : currentIndex;
+ askForRedraw();
+ }
+}
+
+uint32 Inventory::getItemIndex(uint32 currentIndex) {
uint32 count = 0;
- uint32 index = 0;
for (uint32 i = 1; i < ARRAYSIZE(_entries); i++) {
if (!_entries[i].isPresent)
@@ -660,18 +704,13 @@ void Inventory::drawHighlight(uint32 currentIndex, bool reset) {
if (count < 11) {
++count;
- if (count == currentIndex) {
- index = i;
- break;
- }
+
+ if (count == currentIndex)
+ return i;
}
}
- if (index) {
- drawItem(_entries[index].cursor, 0, 40 * currentIndex + 4, reset ? 1 : -1);
- _highlightedItemIndex = reset ? 0 : currentIndex;
- askForRedraw();
- }
+ return 0;
}
} // End of namespace LastExpress
diff --git a/engines/lastexpress/game/inventory.h b/engines/lastexpress/game/inventory.h
index 301e32d..9a88543 100644
--- a/engines/lastexpress/game/inventory.h
+++ b/engines/lastexpress/game/inventory.h
@@ -163,7 +163,7 @@ private:
// Important rects
//Common::Rect _inventoryRect;
Common::Rect _menuEggRect;
- //Common::Rect _selectedItemRect;
+ Common::Rect _selectedItemRect;
void init();
@@ -171,10 +171,13 @@ private:
void close();
void examine(InventoryItem item);
void drawHighlight(uint32 currentIndex, bool reset);
+ uint32 getItemIndex(uint32 currentIndex);
bool isItemSceneParameter(InventoryItem item) const;
void drawItem(CursorStyle id, uint16 x, uint16 y, int16 brighnessIndex = -1);
+
+ void drawSelectedItem();
void clearSelectedItem();
};
More information about the Scummvm-git-logs
mailing list