diff options
author | Paul Gilbert | 2011-09-09 21:16:32 +1000 |
---|---|---|
committer | Paul Gilbert | 2011-09-09 21:16:32 +1000 |
commit | 528ff10d2bb7bb5d1d43546485861e83b773c1df (patch) | |
tree | 37ad44b22aec3b25d63a896fbdd7cc2980eee73e /engines/tsage | |
parent | a2a894c5b7570e103d4ccf140dcff456b3eaab46 (diff) | |
download | scummvm-rg350-528ff10d2bb7bb5d1d43546485861e83b773c1df.tar.gz scummvm-rg350-528ff10d2bb7bb5d1d43546485861e83b773c1df.tar.bz2 scummvm-rg350-528ff10d2bb7bb5d1d43546485861e83b773c1df.zip |
TSAGE: Implemented inventory image display code and slot scrolling
Diffstat (limited to 'engines/tsage')
-rw-r--r-- | engines/tsage/blue_force/blueforce_ui.cpp | 79 | ||||
-rw-r--r-- | engines/tsage/blue_force/blueforce_ui.h | 9 | ||||
-rw-r--r-- | engines/tsage/core.cpp | 7 |
3 files changed, 80 insertions, 15 deletions
diff --git a/engines/tsage/blue_force/blueforce_ui.cpp b/engines/tsage/blue_force/blueforce_ui.cpp index f9f580079e..8f40d2b565 100644 --- a/engines/tsage/blue_force/blueforce_ui.cpp +++ b/engines/tsage/blue_force/blueforce_ui.cpp @@ -63,7 +63,7 @@ void UIElement::setEnabled(bool flag) { void UIQuestion::process(Event &event) { if (event.eventType == EVENT_BUTTON_DOWN) { - int currentCursor = GLOBALS._events.getCursor(); + CursorType currentCursor = GLOBALS._events.getCursor(); GLOBALS._events.hideCursor(); showDescription(currentCursor); @@ -71,12 +71,13 @@ void UIQuestion::process(Event &event) { } } -void UIQuestion::showDescription(int lineNum) { - if (lineNum == 8) { - // Unknown object description +void UIQuestion::showDescription(CursorType cursor) { + if (cursor == INV_FOREST_RAP) { + // Forest rap item has a graphical display + showItem(5, 1, 1); } else { // Display object description - SceneItem::display2(9001, lineNum); + SceneItem::display2(9001, (int)cursor); } } @@ -87,6 +88,29 @@ void UIQuestion::setEnabled(bool flag) { } } +void UIQuestion::showItem(int resNum, int rlbNum, int frameNum) { + GfxDialog::setPalette(); + + // Get the item to display + GfxSurface objImage = surfaceFromRes(resNum, rlbNum, frameNum); + Rect imgRect; + imgRect.resize(objImage, 0, 0, 100); + imgRect.center(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); + + // Save the area behind where the image will be displayed + GfxSurface *savedArea = Surface_getArea(BF_GLOBALS.gfxManager().getSurface(), imgRect); + + // Draw the image + BF_GLOBALS.gfxManager().copyFrom(objImage, imgRect); + + // Wait for a press + BF_GLOBALS._events.waitForPress(); + + // Restore the old area + BF_GLOBALS.gfxManager().copyFrom(*savedArea, imgRect); + delete savedArea; +} + /*--------------------------------------------------------------------------*/ void UIScore::postInit(SceneObjectList *OwnerList) { @@ -165,9 +189,28 @@ void UIInventoryScroll::synchronize(Serializer &s) { } void UIInventoryScroll::process(Event &event) { - if (event.eventType == EVENT_BUTTON_DOWN) { - warning("TODO: UIInventoryScroll::process"); + switch (event.eventType) { + case EVENT_BUTTON_DOWN: + // Draw the button as selected + toggle(true); + + event.handled = true; + break; + case EVENT_BUTTON_UP: + // Restore unselected version + toggle(false); + + // Scroll the inventory as necessary + BF_GLOBALS._uiElements.scrollInventory(_isLeft); event.handled = true; + break; + } +} + +void UIInventoryScroll::toggle(bool pressed) { + if (_enabled) { + setFrame(pressed ? (_frameNum + 1) : _frameNum); + BF_GLOBALS._uiElements.draw(); } } @@ -345,7 +388,7 @@ void UIElements::updateInventory() { updateInvList(); // Enable scroll buttons if the player has more than four items - if (_itemCount > 4) { + if (_itemList.size() > 4) { _scrollLeft.setEnabled(true); _scrollRight.setEnabled(true); } else { @@ -354,10 +397,10 @@ void UIElements::updateInventory() { } // Handle cropping the slots start within inventory - int last = (_itemList.size() - 1) / 4 + 1; + int lastPage = (_itemList.size() - 1) / 4 + 1; if (_slotStart < 0) - _slotStart = last - 1; - else if (_slotStart > (last - 1)) + _slotStart = lastPage - 1; + else if (_slotStart > (lastPage - 1)) _slotStart = 0; // Handle refreshing slot graphics @@ -371,7 +414,7 @@ void UIElements::updateInventory() { // Check whether the object is in any of the four inventory slots for (int slotIndex = 0; slotIndex < 4; ++slotIndex) { - int idx = _slotStart + slotIndex; + int idx = _slotStart * 4 + slotIndex; int objectIdx = (idx < (int)_itemList.size()) ? _itemList[idx] : 0; if (objectIdx == objIndex) { @@ -416,6 +459,18 @@ void UIElements::addScore(int amount) { updateInventory(); } +/* + * Scroll the inventory slots + */ +void UIElements::scrollInventory(bool isLeft) { + if (isLeft) + --_slotStart; + else + ++_slotStart; + + updateInventory(); +} + } // End of namespace BlueForce } // End of namespace TsAGE diff --git a/engines/tsage/blue_force/blueforce_ui.h b/engines/tsage/blue_force/blueforce_ui.h index 8dae914f55..927e667cff 100644 --- a/engines/tsage/blue_force/blueforce_ui.h +++ b/engines/tsage/blue_force/blueforce_ui.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "tsage/core.h" +#include "tsage/graphics.h" #include "tsage/sound.h" namespace TsAGE { @@ -54,7 +55,8 @@ public: // This class implements the Question mark button class UIQuestion: public UIElement { private: - void showDescription(int lineNum); + void showDescription(CursorType item); + void showItem(int resNum, int rlbNum, int frameNum); public: virtual void process(Event &event); void setEnabled(bool flag); @@ -87,6 +89,8 @@ public: }; class UIInventoryScroll: public UIElement { +private: + void toggle(bool pressed); public: bool _isLeft; @@ -126,7 +130,7 @@ public: UIInventorySlot _slot1, _slot2, _slot3, _slot4; UIInventoryScroll _scrollLeft, _scrollRight; ASound _sound; - int _itemCount, _slotStart, _scoreValue; + int _slotStart, _scoreValue; bool _active; Common::Array<int> _itemList; Visage _cursorVisage; @@ -138,6 +142,7 @@ public: void setup(const Common::Point &pt); void updateInventory(); void addScore(int amount); + void scrollInventory(bool isLeft); }; } // End of namespace BlueForce diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 85b59b40aa..78a4cef146 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -2503,7 +2503,12 @@ void AltSceneObject::postInit(SceneObjectList *OwnerList) { } void AltSceneObject::draw() { - SceneObject::draw(); + Rect destRect = _bounds; + destRect.translate(-_globals->_sceneManager._scene->_sceneBounds.left, + -_globals->_sceneManager._scene->_sceneBounds.top); + Region *priorityRegion = _globals->_sceneManager._scene->_priorities.find(_priority); + GfxSurface frame = getFrame(); + _globals->_gfxManagerInstance.copyFrom(frame, destRect, priorityRegion); } /*--------------------------------------------------------------------------*/ |