Skip to content

Commit

Permalink
PRINCE: Items in inventory - drawing position fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslw committed Jun 22, 2014
1 parent bb85844 commit 5309e52
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
19 changes: 14 additions & 5 deletions engines/prince/prince.cpp
Expand Up @@ -79,8 +79,8 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc)
_locationNr(0), _debugger(nullptr), _midiPlayer(nullptr), _room(nullptr), testAnimNr(0), testAnimFrame(0),
_frameNr(0), _cursor1(nullptr), _cursor2(nullptr), _font(nullptr),
_suitcaseBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0), _picWindowY(0), _randomSource("prince"),
_invLineX(134), _invLineY(176), _invLine(5), _invLines(3), _invLineW(70), _invLineH(76), _invLineSkipX(2), _invLineSkipY(3),
_showInventoryFlag(false), _inventoryBackgroundRemember(false) {
_invLineX(134), _invLineY(176), _invLine(5), _invLines(3), _invLineW(70), _invLineH(76), _maxInvW(72), _maxInvH(76),
_invLineSkipX(2), _invLineSkipY(3), _showInventoryFlag(false), _inventoryBackgroundRemember(false) {

// Debug/console setup
DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel");
Expand Down Expand Up @@ -1262,7 +1262,6 @@ void PrinceEngine::drawScreen() {
}

void PrinceEngine::rememberScreenInv() {
_backgroundForInventory = _graph->_frontScreen;
}

void PrinceEngine::inventoryFlagChange() {
Expand Down Expand Up @@ -1330,7 +1329,16 @@ void PrinceEngine::drawInvItems() {
//if (_mainHero->_inventory[item] != 0) {
int itemNr = _mainHero->_inventory[item];
if (itemNr != 68) {
_graph->drawTransparentSurface(currInvX, currInvY, _allInvList[itemNr].getSurface(), 0);
Graphics::Surface *itemSurface = _allInvList[itemNr].getSurface();
int drawX = currInvX;
int drawY = currInvY;
if (itemSurface->w < _maxInvW) {
drawX += (_maxInvW - itemSurface->w) / 2;
}
if (itemSurface->h < _maxInvH) {
drawY += (_maxInvH - itemSurface->h) / 2;
}
_graph->drawTransparentSurface(drawX, drawY, itemSurface, 0);
} else {
// candle item:
}
Expand All @@ -1345,6 +1353,7 @@ void PrinceEngine::drawInvItems() {
}

void PrinceEngine::displayInventory() {
// temp:
_mainHero->_inventory.clear();
_mainHero->_inventory.push_back(0);
_mainHero->_inventory.push_back(1);
Expand All @@ -1355,7 +1364,7 @@ void PrinceEngine::displayInventory() {

prepareInventoryToView();

_graph->drawTransparentSurface(0, 0, _backgroundForInventory, 0);
_graph->drawTransparentSurface(0, 0, _graph->_frontScreen, 0);
Graphics::Surface *suitcase = _suitcaseBmp->getSurface();
_graph->drawTransparentSurface(0, 0, suitcase, 0);

Expand Down
3 changes: 1 addition & 2 deletions engines/prince/prince.h
Expand Up @@ -284,6 +284,7 @@ class PrinceEngine : public Engine {
int _invLineW;
int _invLineH;
int _maxInvW;
int _maxInvH;
int _invLineSkipX;
int _invLineSkipY;

Expand All @@ -294,8 +295,6 @@ class PrinceEngine : public Engine {
void drawInvItems();
void displayInventory();

Graphics::Surface *_backgroundForInventory;

int testAnimNr;
int testAnimFrame;

Expand Down

0 comments on commit 5309e52

Please sign in to comment.