aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-04-09 09:32:14 -0400
committerPaul Gilbert2014-04-09 09:32:14 -0400
commit8df08335462db8fc692f18c9dc5bb4293019d2f6 (patch)
treeb69e840424bb7e5ea664c3f3ab6c2554dfb67d8b /engines
parent2368ab78865f251184908d523edeab34514e08ed (diff)
downloadscummvm-rg350-8df08335462db8fc692f18c9dc5bb4293019d2f6.tar.gz
scummvm-rg350-8df08335462db8fc692f18c9dc5bb4293019d2f6.tar.bz2
scummvm-rg350-8df08335462db8fc692f18c9dc5bb4293019d2f6.zip
MADS: Fixes for correctly displaying inventory list in the user interface
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/game.cpp4
-rw-r--r--engines/mads/inventory.cpp2
-rw-r--r--engines/mads/screen.cpp10
-rw-r--r--engines/mads/user_interface.cpp54
-rw-r--r--engines/mads/user_interface.h12
5 files changed, 58 insertions, 24 deletions
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index eb7ba62fbd..e2e956e8cb 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -208,8 +208,8 @@ void Game::sectionLoop() {
_vm->_events->initVars();
_scene._userInterface._highlightedCommandIndex = -1;
- _scene._userInterface._highlightedItemIndex = -1;
- _scene._userInterface._highlightedActionIndex = -1;
+ _scene._userInterface._highlightedInvIndex = -1;
+ _scene._userInterface._highlightedItemVocabIndex = -1;
_scene._action.clear();
_player.setFinalFacing();
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index 607179a3c2..0795233f6c 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -110,7 +110,7 @@ void InventoryObjects::addToInventory(int objectId) {
userInterface._inventoryTopIndex = CLIP(userInterface._inventoryTopIndex,
0, (int)_inventoryList.size() - 1);
- if ((userInterface._inventoryTopIndex + 5) <= ((int) size() - 1))
+ if ((userInterface._inventoryTopIndex + 5) < (int)_inventoryList.size())
userInterface._inventoryTopIndex = size() - 5;
userInterface._inventoryChanged = true;
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 5553f61a11..519dcabccd 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -131,11 +131,13 @@ void DirtyArea::setUISlot(const UISlot *slot) {
_bounds.top = 0;
setArea(intSurface.w, intSurface.h, intSurface.w, intSurface.h);
break;
+
case IMG_OVERPRINT:
_bounds.left = slot->_position.x;
_bounds.top = slot->_position.y;
- // TODO: spritesIndex & frameNumber used as w & h??!
- error("TODO: Figure out IMG_OVERPRINT. Maybe need a union?");
+ _bounds.setWidth(slot->_width);
+ _bounds.setHeight(slot->_height);
+ setArea(slot->_width, slot->_height, intSurface.w, intSurface.h);
break;
default: {
@@ -491,7 +493,7 @@ void ScreenObjects::elementHighlighted() {
indexEnd = invList.size() - 1;
varA = 0;
topIndex = userInterface._inventoryTopIndex;
- idxP = &userInterface._highlightedItemIndex;
+ idxP = &userInterface._highlightedInvIndex;
var4 = (!_released || (_vm->_events->_mouseButtons && action._interAwaiting == 1)) ? 0 : 1;
break;
@@ -507,7 +509,7 @@ void ScreenObjects::elementHighlighted() {
varA = 0;
topIndex = 0;
- idxP = _vm->_events->_rightMousePressed ? &userInterface._selectedItemVocabIdx : &userInterface._highlightedActionIndex;
+ idxP = _vm->_events->_rightMousePressed ? &userInterface._selectedItemVocabIdx : &userInterface._highlightedItemVocabIndex;
if (_vm->_events->_rightMousePressed && userInterface._selectedActionIndex >= 0)
userInterface.updateSelection(CAT_COMMAND, -1, &userInterface._selectedActionIndex);
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 8d05402b46..941606677d 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -32,6 +32,7 @@ UISlot::UISlot() {
_segmentId = 0;
_spritesIndex = 0;
_frameNumber = 0;
+ _width = _height = 0;
}
/*------------------------------------------------------------------------*/
@@ -44,15 +45,15 @@ void UISlots::fullRefresh() {
push_back(slot);
}
-void UISlots::add(const Common::Point &pt, int frameNumber, int spritesIndex) {
+void UISlots::add(const Common::Rect &bounds) {
assert(size() < 50);
UISlot ie;
ie._flags = IMG_OVERPRINT;
ie._segmentId = IMG_TEXT_UPDATE;
- ie._position = pt;
- ie._frameNumber = frameNumber;
- ie._spritesIndex = spritesIndex;
+ ie._position = Common::Point(bounds.left, bounds.top);
+ ie._width = bounds.width();
+ ie._height = bounds.height();
push_back(ie);
}
@@ -213,8 +214,8 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
_selectedItemVocabIdx = -1;
_scrollerY = 0;
_highlightedCommandIndex = -1;
- _highlightedItemIndex = -1;
- _highlightedActionIndex = -1;
+ _highlightedInvIndex = -1;
+ _highlightedItemVocabIndex = -1;
_dirtyAreas.resize(50);
_inventoryChanged = false;
Common::fill(&_categoryIndexes[0], &_categoryIndexes[7], 0);
@@ -279,8 +280,8 @@ void UserInterface::setup(InputMode inputMode) {
scene._userInterface._uiSlots.fullRefresh();
_vm->_game->_screenObjects._baseTime = _vm->_events->getFrameCounter();
_highlightedCommandIndex = -1;
- _highlightedActionIndex = -1;
- _highlightedItemIndex = -1;
+ _highlightedItemVocabIndex = -1;
+ _highlightedInvIndex = -1;
if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE)
scene._userInterface._uiSlots.draw(false, false);
@@ -358,7 +359,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
case CAT_INV_LIST:
font = _vm->_font->getFont(FONT_INTERFACE);
vocabId = _vm->_game->_objects.getItem(id)._descId;
- if (id == _highlightedItemIndex) {
+ if (id == _highlightedInvIndex) {
_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
} else {
_vm->_font->setColorMode(id == _selectedInvIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
@@ -399,7 +400,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
// Item specific verbs
font = _vm->_font->getFont(FONT_INTERFACE);
vocabId = _vm->_game->_objects.getItem(_selectedInvIndex)._vocabList[id]._vocabId;
- if (id == _highlightedActionIndex) {
+ if (id == _highlightedItemVocabIndex) {
_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
} else {
_vm->_font->setColorMode(id == _selectedInvIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
@@ -714,13 +715,40 @@ void UserInterface::doBackgroundAnimation() {
}
void UserInterface::categoryChanged() {
- _highlightedItemIndex = -1;
+ _highlightedInvIndex = -1;
_vm->_events->initVars();
_category = CAT_NONE;
}
void UserInterface::selectObject(int invIndex) {
- warning("TODO: selectObject");
+ if (_selectedInvIndex != invIndex || _inventoryChanged) {
+ int oldVocabCount = _selectedInvIndex < 0 ? 0 : _vm->_game->_objects.getItem(_selectedInvIndex)._vocabCount;
+ int newVocabCount = invIndex < 0 ? 0 : _vm->_game->_objects.getItem(invIndex)._vocabCount;
+ int maxVocab = MAX(oldVocabCount, newVocabCount);
+
+ updateSelection(CAT_INV_LIST, invIndex, &_selectedInvIndex);
+ _highlightedItemVocabIndex = -1;
+ _selectedItemVocabIdx = -1;
+
+ if (maxVocab) {
+ assert(_uiSlots.size() < 50);
+ int vocabHeight = maxVocab * 8;
+
+ Common::Rect bounds(240, 3, 240 + 80, 3 + vocabHeight);
+ _uiSlots.add(bounds);
+ _uiSlots.draw(false, false);
+ drawItemVocabList();
+ updateRect(bounds);
+ }
+ }
+
+ if (invIndex == -1) {
+ noInventoryAnim();
+ } else {
+ loadInventoryAnim(_vm->_game->_objects._inventoryList[invIndex]);
+ _vm->_palette->setPalette(_vm->_palette->_mainPalette, 7, 1);
+ _vm->_palette->setPalette(_vm->_palette->_mainPalette, 246, 2);
+ }
}
void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx) {
@@ -730,7 +758,7 @@ void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx
if (category == CAT_INV_LIST && _inventoryChanged) {
*idx = newIndex;
bounds = Common::Rect(90, 3, 90 + 69, 3 + 40);
- _uiSlots.add(Common::Point(90, 3), 69, 40);
+ _uiSlots.add(bounds);
_uiSlots.draw(false, false);
drawInventoryList();
updateRect(bounds);
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 6b3abf02f8..46ba478f5b 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -42,6 +42,10 @@ public:
int _spritesIndex;
int _frameNumber;
Common::Point _position;
+
+ // Only used for IMG_OVERPRINT
+ int _width;
+ int _height;
UISlot();
};
@@ -59,9 +63,9 @@ public:
UISlots(MADSEngine *vm) : _vm(vm) {}
/**
- * Add a sprite to the list
+ * Add an overprint (text) entry to the list
*/
- void add(const Common::Point &pt, int frameNumber, int spritesIndex);
+ void add(const Common::Rect &bounds);
/**
* Loads the data from an aimation frame entry
@@ -155,8 +159,8 @@ public:
int _selectedItemVocabIdx;
int _scrollerY;
int _highlightedCommandIndex;
- int _highlightedItemIndex;
- int _highlightedActionIndex;
+ int _highlightedInvIndex;
+ int _highlightedItemVocabIndex;
bool _inventoryChanged;
int _categoryIndexes[8];
Common::StringArray _talkStrings;