Skip to content

Commit

Permalink
ACCeSS: Fix display of items in inventory screen
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 24, 2014
1 parent e53417f commit ce97ba5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
43 changes: 37 additions & 6 deletions engines/access/inventory.cpp
Expand Up @@ -36,7 +36,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {
_invModeFlag = false;
_startAboutItem = 0;
_startTravelItem = 0;
_iconDisplayFlag = false;
_iconDisplayFlag = true;

const char *const *names;
switch (vm->getGameID()) {
Expand All @@ -57,7 +57,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) {

for (uint i = 0; i < 26; ++i) {
const int *r = INVCOORDS[i];
_invCoords.push_back(Common::Rect(r[0], r[1], r[0] + r[2], r[1] + r[3]));
_invCoords.push_back(Common::Rect(r[0], r[2], r[1], r[3]));
}
}

Expand Down Expand Up @@ -99,7 +99,7 @@ int InventoryManager::newDisplayInv() {
getList();
initFields();

_vm->_files->loadScreen(&_vm->_buffer1, 99, 0);
files.loadScreen(&_vm->_buffer1, 99, 0);
_vm->_buffer1.copyTo(&_vm->_buffer2);
_vm->copyBF2Vid();

Expand Down Expand Up @@ -247,9 +247,13 @@ void InventoryManager::initFields() {

void InventoryManager::getList() {
_items.clear();
_tempLOff.clear();

for (uint i = 0; i < _inv.size(); ++i) {
if (_inv[i])
if (_inv[i]) {
_items.push_back(i);
_tempLOff.push_back(_names[i]);
}
}
}

Expand All @@ -265,7 +269,7 @@ void InventoryManager::putInvIcon(int itemIndex, int itemId) {
_vm->_buffer2.plotImage(spr, itemId, pt);

if (_iconDisplayFlag) {
_vm->_buffer1.copyBlock(&_vm->_buffer2, Common::Rect(pt.x, pt.y, pt.x + 46, pt.y + 35));
_vm->_screen->copyBlock(&_vm->_buffer2, Common::Rect(pt.x, pt.y, pt.x + 46, pt.y + 35));
}
}

Expand All @@ -287,7 +291,12 @@ void InventoryManager::chooseItem() {
_vm->_useItem = -1;
break;
} else if (selIndex < (int)_items.size()) {
warning("TODO: Combine items");
_boxNum = selIndex;
_vm->copyBF2Vid();
combineItems();
_vm->copyBF2Vid();
outlineIcon(_boxNum);
_vm->_useItem = _items[_boxNum];
}
}
}
Expand All @@ -311,6 +320,8 @@ int InventoryManager::coordIndexOf() {
void InventoryManager::saveScreens() {
_vm->_buffer1.copyTo(&_savedBuffer1);
_vm->_screen->copyTo(&_savedScreen);
_vm->_newRects.push_back(Common::Rect(0, 0, _savedScreen.w, _savedScreen.h));

}

void InventoryManager::restoreScreens() {
Expand All @@ -319,4 +330,24 @@ void InventoryManager::restoreScreens() {
_savedScreen.copyTo(_vm->_screen);
}

void InventoryManager::outlineIcon(int itemIndex) {
Screen &screen = *_vm->_screen;
screen.frameRect(_invCoords[itemIndex], 7);

Common::String s = _tempLOff[itemIndex];
Font &font = _vm->_fonts._font2;
int strWidth = font.stringWidth(s);

font._fontColors[0] = 0;
font._fontColors[1] = 10;
font._fontColors[2] = 11;
font._fontColors[3] = 12;
font.drawString(&screen, s, Common::Point((screen.w - strWidth) / 2, 184));
}

void InventoryManager::combineItems() {
warning("TODO: combineItems");
}


} // End of namespace Access
9 changes: 8 additions & 1 deletion engines/access/inventory.h
Expand Up @@ -58,6 +58,10 @@ class InventoryManager : public Manager {
ASurface _savedScreen;
SavedFields _fields;
bool _iconDisplayFlag;
Common::StringArray _names;
Common::Array<int> _tempLPtr;
Common::StringArray _tempLOff;
int _boxNum;

void savedFields();

Expand All @@ -80,9 +84,12 @@ class InventoryManager : public Manager {
void saveScreens();

void restoreScreens();

void outlineIcon(int itemIndex);

void combineItems();
public:
Common::Array<int> _inv;
Common::StringArray _names;
int _startInvItem;
int _startInvBox;
bool _invChangeFlag;
Expand Down

0 comments on commit ce97ba5

Please sign in to comment.