mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-30 07:23:05 +00:00
MADS: Fixes for correctly displaying inventory list in the user interface
This commit is contained in:
parent
2368ab7886
commit
8df0833546
@ -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();
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user