diff options
author | Johannes Schickel | 2008-04-23 20:50:31 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-04-23 20:50:31 +0000 |
commit | c3cec1926f573e3a856a8f323c1eabf24666d9d7 (patch) | |
tree | ea7748afb1777461b3177714e54ddf4a40c7a1ee /engines | |
parent | d0ad5867e0d8ecb21aee7abfe0e7beb8eacfcf25 (diff) | |
download | scummvm-rg350-c3cec1926f573e3a856a8f323c1eabf24666d9d7.tar.gz scummvm-rg350-c3cec1926f573e3a856a8f323c1eabf24666d9d7.tar.bz2 scummvm-rg350-c3cec1926f573e3a856a8f323c1eabf24666d9d7.zip |
Implmenented inventory show/hide.
svn-id: r31676
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/gui_v3.cpp | 315 | ||||
-rw-r--r-- | engines/kyra/kyra_v3.cpp | 42 | ||||
-rw-r--r-- | engines/kyra/kyra_v3.h | 15 | ||||
-rw-r--r-- | engines/kyra/module.mk | 1 | ||||
-rw-r--r-- | engines/kyra/scene_v3.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 10 |
6 files changed, 345 insertions, 40 deletions
diff --git a/engines/kyra/gui_v3.cpp b/engines/kyra/gui_v3.cpp new file mode 100644 index 0000000000..dff5db9da5 --- /dev/null +++ b/engines/kyra/gui_v3.cpp @@ -0,0 +1,315 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra_v3.h" +#include "kyra/text_v3.h" + +namespace Kyra { + +void KyraEngine_v3::showMessage(const char *string, uint8 c0, uint8 c1) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::showMessage('%s', %d, %d)", string, c0, c1); + _shownMessage = string; + _screen->hideMouse(); + + restoreCommandLine(); + _restoreCommandLine = false; + + if (string) { + int x = _text->getCenterStringX(string, 0, 320); + int pageBackUp = _screen->_curPage; + _screen->_curPage = 0; + _text->printText(string, x, _commandLineY, c0, c1, 0); + _screen->_curPage = pageBackUp; + _screen->updateScreen(); + setCommandLineRestoreTimer(7); + } + + _screen->showMouse(); +} + +void KyraEngine_v3::updateCommandLine() { + debugC(9, kDebugLevelMain, "KyraEngine_v3::updateCommandLine()"); + if (_restoreCommandLine) { + restoreCommandLine(); + _restoreCommandLine = false; + } +} + +void KyraEngine_v3::restoreCommandLine() { + debugC(9, kDebugLevelMain, "KyraEngine_v3::restoreCommandLine()"); + int y = _inventoryState ? 144 : 188; + _screen->copyBlockToPage(0, 0, y, 320, 12, _interfaceCommandLine); +} + +void KyraEngine_v3::updateCLState() { + debugC(9, kDebugLevelMain, "KyraEngine_v3::updateCLState()"); + if (_inventoryState) + _commandLineY = 145; + else + _commandLineY = 189; +} + +void KyraEngine_v3::showInventory() { + debugC(9, kDebugLevelMain, "KyraEngine_v3::showInventory()"); + if (!_screen->isMouseVisible()) + return; + if (queryGameFlag(3)) + return; + + _screen->copyBlockToPage(3, 0, 0, 320, 56, _interface); + updateMalcolmSpiritText(); + + _inventoryState = true; + updateCLState(); + + redrawInventory(30); + + //XXX + + if (queryGameFlag(0x97)) + drawJestersStaff(1, 30); + + _screen->hideMouse(); + + if (_itemInHand < 0) { + _handItemSet = -1; + _screen->setMouseCursor(0, 0, getShapePtr(0)); + } + + _screen->copyRegion(0, 188, 0, 0, 320, 12, 0, 2, Screen::CR_NO_P_CHECK); + + if (_inventoryScrollSpeed == -1) { + uint32 endTime = _system->getMillis() + _tickLength * 15; + int times = 0; + while (_system->getMillis() < endTime) { + _screen->copyRegion(0, 188, 0, 0, 320, 12, 0, 2, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 188, 0, 0, 320, 12, 0, 2, Screen::CR_NO_P_CHECK); + ++times; + } + + times = MAX(times, 1); + + int speed = 60 / times; + if (speed <= 1) + _inventoryScrollSpeed = 1; + else if (speed >= 8) + _inventoryScrollSpeed = 8; + else + _inventoryScrollSpeed = speed; + } + + int height = 12; + int y = 188; + int times = 0; + uint32 waitTill = _system->getMillis() + _tickLength; + + while (y > 144) { + _screen->copyRegion(0, 0, 0, y, 320, height, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + + ++times; + if (_inventoryScrollSpeed == 1 && times == 3) { + while (waitTill > _system->getMillis()) + _system->delayMillis(10); + times = 0; + waitTill = _system->getMillis() + _tickLength; + } + + height += _inventoryScrollSpeed; + y -= _inventoryScrollSpeed; + } + + _screen->copyRegion(0, 0, 0, 144, 320, 56, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + + //initInventoryButtonList(0); + + restorePage3(); + _screen->showMouse(); +} + +void KyraEngine_v3::hideInventory() { + debugC(9, kDebugLevelMain, "KyraEngine_v3::hideInventory()"); + if (queryGameFlag(3)) + return; + + _inventoryState = false; + updateCLState(); + //initInventoryButtonList(1); + + _screen->copyBlockToPage(3, 0, 0, 320, 56, _interface); + _screen->hideMouse(); + + restorePage3(); + flagAnimObjsForRefresh(); + drawAnimObjects(); + _screen->copyRegion(0, 144, 0, 0, 320, 56, 0, 2, Screen::CR_NO_P_CHECK); + + if (_inventoryScrollSpeed == -1) { + uint32 endTime = _system->getMillis() + _tickLength * 15; + int times = 0; + while (_system->getMillis() < endTime) { + _screen->copyRegion(0, 144, 0, 0, 320, 12, 0, 2, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, 144, 0, 0, 320, 12, 0, 2, Screen::CR_NO_P_CHECK); + ++times; + } + + times = MAX(times, 1); + + int speed = 60 / times; + if (speed <= 1) + _inventoryScrollSpeed = 1; + else if (speed >= 8) + _inventoryScrollSpeed = 8; + else + _inventoryScrollSpeed = speed; + } + + int y = 144; + int y2 = 144 + _inventoryScrollSpeed; + uint32 waitTill = _system->getMillis() + _tickLength; + int times = 0; + + while (y2 < 188) { + _screen->copyRegion(0, 0, 0, y2, 320, 56, 2, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, y, 0, y, 320, _inventoryScrollSpeed, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + + ++times; + if (_inventoryScrollSpeed == 1 && times == 3) { + while (waitTill > _system->getMillis()) + _system->delayMillis(10); + times = 0; + waitTill = _system->getMillis() + _tickLength; + } + + y += _inventoryScrollSpeed; + y2 += _inventoryScrollSpeed; + } + + _screen->copyRegion(0, 0, 0, 188, 320, 56, 2, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(0, y, 0, y, 320, 188-y, 2, 0, Screen::CR_NO_P_CHECK); + _screen->showMouse(); +} + +void KyraEngine_v3::updateMalcolmSpiritText() { + debugC(9, kDebugLevelMain, "KyraEngine_v3::updateMalcolmSpiritText()"); + static const int stringId[] = { 0x32, 0x37, 0x3C }; + + if (queryGameFlag(0x219)) + return; + + const char *string = (const char*)getTableEntry(_cCodeFile, stringId[_malcolmsSpirit]); + + Screen::FontId oldFont = _screen->setFont(Screen::FID_8_FNT); + _screen->_charWidth = -2; + + int width = _screen->getTextWidth(string); + + _screen->_charWidth = 0; + _screen->setFont(oldFont); + + int pageBackUp = _screen->_curPage; + const int x = 280 - (width / 2); + int y = 0; + if (_inventoryState) { + y = 189; + _screen->_curPage = 0; + } else { + y = 45; + _screen->_curPage = 2; + } + + _screen->hideMouse(); + _screen->drawShape(_screen->_curPage, getShapePtr(432), 244, 189, 0, 0); + _text->printText(string, x, y+1, 0xFF, 0xF0, 0x00); + _screen->showMouse(); + _screen->_curPage = pageBackUp; +} + +void KyraEngine_v3::drawJestersStaff(int type, int page) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::drawJestersStaff(%d, %d)", type, page); + int y = 155; + if (page == 30) { + page = 2; + y -= 144; + } + + int shape = (type != 0) ? 454 : 453; + _screen->drawShape(page, getShapePtr(shape), 217, y, 0, 0); +} + +void KyraEngine_v3::redrawInventory(int page) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::redrawInventory(%d)", page); + int yOffset = 0; + + if (page == 30) { + page = 2; + yOffset = -144; + } + + int pageBackUp = _screen->_curPage; + _screen->_curPage = page; + _screen->hideMouse(); + + for (int i = 0; i < 10; ++i) { + clearInventorySlot(i, page); + if (_mainCharacter.inventory[i] != 0xFFFF) { + _screen->drawShape(page, getShapePtr(_mainCharacter.inventory[i]+248), _inventoryX[i], _inventoryY[i] + yOffset, 0, 0); + drawInventorySlot(page, _mainCharacter.inventory[i], i); + } + } + + _screen->showMouse(); + _screen->_curPage = pageBackUp; + + if (page == 0 || page == 1) + _screen->updateScreen(); +} + +void KyraEngine_v3::clearInventorySlot(int slot, int page) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::clearInventorySlot(%d, %d)", slot, page); + int yOffset = 0; + if (page == 30) { + page = 2; + yOffset = -144; + } + + _screen->drawShape(page, getShapePtr(slot+422), _inventoryX[slot], _inventoryY[slot] + yOffset, 0, 0); +} + +void KyraEngine_v3::drawInventorySlot(int page, int item, int slot) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::drawInventorySlot(%d, %d, %d)", page, item, slot); + int yOffset = 0; + if (page == 30) { + page = 2; + yOffset = -144; + } + + _screen->drawShape(page, getShapePtr(item+248), _inventoryX[slot], _inventoryY[slot] + yOffset, 0, 0); +} + +} // end of namespace Kyra + diff --git a/engines/kyra/kyra_v3.cpp b/engines/kyra/kyra_v3.cpp index 8a445b3548..e2641311a3 100644 --- a/engines/kyra/kyra_v3.cpp +++ b/engines/kyra/kyra_v3.cpp @@ -125,6 +125,7 @@ KyraEngine_v3::KyraEngine_v3(OSystem *system, const GameFlags &flags) : KyraEngi _nextIdleType = false; _newShapeFlag = -1; _newShapeFiledata = 0; + _inventoryScrollSpeed = -1; } KyraEngine_v3::~KyraEngine_v3() { @@ -798,43 +799,6 @@ void KyraEngine_v3::updateMalcolmShapes() { #pragma mark - -void KyraEngine_v3::showMessage(const char *string, uint8 c0, uint8 c1) { - debugC(9, kDebugLevelMain, "KyraEngine_v3::showMessage('%s', %d, %d)", string, c0, c1); - _shownMessage = string; - _screen->hideMouse(); - - restoreCommandLine(); - _restoreCommandLine = false; - - if (string) { - int x = _text->getCenterStringX(string, 0, 320); - int pageBackUp = _screen->_curPage; - _screen->_curPage = 0; - _text->printText(string, x, _commandLineY, c0, c1, 0); - _screen->_curPage = pageBackUp; - _screen->updateScreen(); - setCommandLineRestoreTimer(7); - } - - _screen->showMouse(); -} - -void KyraEngine_v3::updateCommandLine() { - debugC(9, kDebugLevelMain, "KyraEngine_v3::updateCommandLine()"); - if (_restoreCommandLine) { - restoreCommandLine(); - _restoreCommandLine = false; - } -} - -void KyraEngine_v3::restoreCommandLine() { - debugC(9, kDebugLevelMain, "KyraEngine_v3::restoreCommandLine()"); - int y = _inventoryState ? 144 : 188; - _screen->copyBlockToPage(0, 0, y, 320, 12, _interfaceCommandLine); -} - -#pragma mark - - void KyraEngine_v3::moveCharacter(int facing, int x, int y) { debugC(9, kDebugLevelMain, "KyraEngine_v3::moveCharacter(%d, %d, %d)", facing, x, y); x &= ~3; @@ -1220,7 +1184,7 @@ void KyraEngine_v3::updateMouse() { if (_inventoryState) { if (mouse.y >= 144) return; - //hideInventory(); + hideInventory(); } if (hasItemCollision && _handItemSet < -1 && _itemInHand < 0) { @@ -1307,7 +1271,7 @@ void KyraEngine_v3::updateMouse() { } else if (type == 0 && _handItemSet != _itemInHand && mouse.x > 8 && mouse.x < 311 && mouse.y < 171 && mouse.y > 8) { setItemMouseCursor(); } else if (mouse.y > 187 && _handItemSet > -4 && type == 0 && !_inventoryState) { - //showInventory(); + showInventory(); } } diff --git a/engines/kyra/kyra_v3.h b/engines/kyra/kyra_v3.h index daba7a7d56..60732fda5d 100644 --- a/engines/kyra/kyra_v3.h +++ b/engines/kyra/kyra_v3.h @@ -246,11 +246,26 @@ private: void showMessage(const char *string, uint8 c0, uint8 c1); void updateCommandLine(); void restoreCommandLine(); + void updateCLState(); int _commandLineY; const char *_shownMessage; bool _restoreCommandLine; bool _inventoryState; + int _inventoryScrollSpeed; + + void showInventory(); + void hideInventory(); + + void updateMalcolmSpiritText(); + //void updateMalcolmSpiritPtr(); + void drawJestersStaff(int type, int page); + + static const uint8 _inventoryX[]; + static const uint8 _inventoryY[]; + void redrawInventory(int page); + void clearInventorySlot(int slot, int page); + void drawInventorySlot(int page, int item, int slot); // localization uint8 *_scoreFile; diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk index 8bd0fd71b6..bfb0e057fe 100644 --- a/engines/kyra/module.mk +++ b/engines/kyra/module.mk @@ -9,6 +9,7 @@ MODULE_OBJS := \ gui.o \ gui_v1.o \ gui_v2.o \ + gui_v3.o \ items_v1.o \ items_v2.o \ items_v3.o \ diff --git a/engines/kyra/scene_v3.cpp b/engines/kyra/scene_v3.cpp index fabed9dfb9..08dded4801 100644 --- a/engines/kyra/scene_v3.cpp +++ b/engines/kyra/scene_v3.cpp @@ -37,7 +37,7 @@ void KyraEngine_v3::enterNewScene(uint16 sceneId, int facing, int unk1, int unk2 showMessage(0, 0xF0, 0xF0); if (_inventoryState) { - //XXX hideInventory(); + hideInventory(); musicUpdate(0); } diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index ba0178e2c6..c80284531d 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -2326,6 +2326,16 @@ const uint8 KyraEngine_v3::_vocHighTable[] = { 0x64, 0x76, 0x82, 0x83, 0x92 }; +const uint8 KyraEngine_v3::_inventoryX[] = { + 0x45, 0x61, 0x7D, 0x99, 0xB5, + 0x45, 0x61, 0x7D, 0x99, 0xB5 +}; + +const uint8 KyraEngine_v3::_inventoryY[] = { + 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, + 0xB2, 0xB2, 0xB2, 0xB2, 0xB2 +}; + } // End of namespace Kyra |