aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLittleboy2011-04-29 22:00:38 -0400
committerLittleboy2011-05-10 19:18:22 -0400
commit1516ba73671d59ab5d6e26602dbb1e5055cbb05c (patch)
treee3fd91eceb610cda97c2bd0379af8f7682003ec4
parent9b896e473e36f1738340d3e15f8feb1f105ae60d (diff)
downloadscummvm-rg350-1516ba73671d59ab5d6e26602dbb1e5055cbb05c.tar.gz
scummvm-rg350-1516ba73671d59ab5d6e26602dbb1e5055cbb05c.tar.bz2
scummvm-rg350-1516ba73671d59ab5d6e26602dbb1e5055cbb05c.zip
LASTEXPRESS: Implement skeleton code for selected item and inventory selection
-rw-r--r--engines/lastexpress/game/inventory.cpp102
-rw-r--r--engines/lastexpress/game/inventory.h5
-rw-r--r--engines/lastexpress/game/logic.cpp28
3 files changed, 111 insertions, 24 deletions
diff --git a/engines/lastexpress/game/inventory.cpp b/engines/lastexpress/game/inventory.cpp
index 81189ae633..25db782c62 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 860f8257fe..b38ffa849e 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 bfed65eb4a..83e067f67c 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);