aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock
diff options
context:
space:
mode:
authorPaul Gilbert2015-06-19 21:25:16 -0400
committerPaul Gilbert2015-06-19 21:25:16 -0400
commit77f256011a239110d3e57d970c14f6b84b964b01 (patch)
tree4f881610c03fc39a3d25d88f9fc5af92296b6638 /engines/sherlock
parent4ce4431c61092ed58e072f3f01f785cad796ab87 (diff)
downloadscummvm-rg350-77f256011a239110d3e57d970c14f6b84b964b01.tar.gz
scummvm-rg350-77f256011a239110d3e57d970c14f6b84b964b01.tar.bz2
scummvm-rg350-77f256011a239110d3e57d970c14f6b84b964b01.zip
SHERLOCK: RT: Added remaining rendering code for inventory widget
Diffstat (limited to 'engines/sherlock')
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.cpp1
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.h1
-rw-r--r--engines/sherlock/tattoo/widget_inventory.cpp119
-rw-r--r--engines/sherlock/tattoo/widget_inventory.h15
4 files changed, 129 insertions, 7 deletions
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 09cd1575b5..7c408c820a 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -45,6 +45,7 @@ TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm),
_activeObj = -1;
_cAnimFramePause = 0;
_widget = nullptr;
+ _scrollHighlight = 0;
}
void TattooUserInterface::initScrollVars() {
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index 39939c4aea..ae647917ab 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -137,6 +137,7 @@ public:
int _activeObj;
Common::KeyState _keyState;
Common::Point _lookPos;
+ int _scrollHighlight;
public:
TattooUserInterface(SherlockEngine *vm);
virtual ~TattooUserInterface() {}
diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp
index d3caa8002d..dfa4736ccc 100644
--- a/engines/sherlock/tattoo/widget_inventory.cpp
+++ b/engines/sherlock/tattoo/widget_inventory.cpp
@@ -29,9 +29,9 @@ namespace Sherlock {
namespace Tattoo {
#define INVENTORY_XSIZE 70 // Width of the box that surrounds inventory items
-#define INVENTORY_YSIZE 70 // Width of the box that surrounds inventory items
+#define INVENTORY_YSIZE 70 // Height of the box that surrounds inventory items
#define NUM_INVENTORY_SHOWN 8 // Number of Inventory Items Shown
-#define BUTTON_XSIZE 15 // Button width
+#define BUTTON_SIZE 15 // Button width/height
WidgetInventory::WidgetInventory(SherlockEngine *vm) : WidgetBase(vm) {
_invMode = 0;
@@ -56,7 +56,7 @@ void WidgetInventory::load(int mode) {
if (mode == 0) {
banishWindow();
} else {
- _bounds = Common::Rect((INVENTORY_XSIZE + 3) * NUM_INVENTORY_SHOWN / 2 + BUTTON_XSIZE + 6,
+ _bounds = Common::Rect((INVENTORY_XSIZE + 3) * NUM_INVENTORY_SHOWN / 2 + BUTTON_SIZE + 6,
(INVENTORY_YSIZE + 3) * 2 + 3);
_bounds.moveTo(mousePos.x - _bounds.width() / 2, mousePos.y - _bounds.height() / 2);
}
@@ -73,11 +73,118 @@ void WidgetInventory::load(int mode) {
// Draw the window background and then the inventory on top of it
makeInfoArea();
- //putInv(0);
+ drawInventory();
}
-void WidgetInventory::loadInv() {
- // TODO
+void WidgetInventory::drawInventory() {
+ Inventory &inv = *_vm->_inventory;
+
+ // TODO: Refactor _invIndexinto this widget class
+ for (int idx= 0, itemId = inv._invIndex; idx < NUM_INVENTORY_SHOWN; ++idx) {
+ // Figure out the drawing position
+ Common::Point pt(3 + (INVENTORY_XSIZE + 3) * (idx % (NUM_INVENTORY_SHOWN / 2)),
+ 3 + (INVENTORY_YSIZE + 3) * idx / (NUM_INVENTORY_SHOWN / 2));
+
+ // Draw the box to serve as the background for the item
+ _surface.hLine(pt.x + 1, pt.y, pt.x + INVENTORY_XSIZE - 2, TRANSPARENCY);
+ _surface.fillRect(Common::Rect(pt.x, pt.y + 1, pt.x + INVENTORY_XSIZE, pt.y + INVENTORY_YSIZE - 1), TRANSPARENCY);
+ _surface.hLine(pt.x + 1, pt.y + INVENTORY_YSIZE - 1, pt.x + INVENTORY_XSIZE - 2, TRANSPARENCY);
+
+ // Draw the item
+ if (itemId < inv._holdings) {
+ ImageFrame &img = (*inv._invShapes[idx])[0];
+ _surface.transBlitFrom(img, Common::Point(pt.x + (INVENTORY_XSIZE - img._width) / 2,
+ pt.y + (INVENTORY_YSIZE - img._height) / 2));
+ }
+ }
+
+ drawScrollBar();
+}
+
+void WidgetInventory::drawScrollBar() {
+ Inventory &inv = *_vm->_inventory;
+ TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+ bool raised;
+
+ // Fill the area with transparency
+ Common::Rect r(BUTTON_SIZE, _bounds.height() - 6);
+ r.moveTo(_bounds.width() - BUTTON_SIZE - 3, 3);
+ _surface.fillRect(r, TRANSPARENCY);
+
+ raised = ui._scrollHighlight != 1;
+ _surface.fillRect(Common::Rect(r.left + 2, r.top + 2, r.right - 2, r.top + BUTTON_SIZE - 2), INFO_MIDDLE);
+ drawDialogRect(Common::Rect(r.left, r.top, r.left + BUTTON_SIZE, r.top + BUTTON_SIZE), raised);
+
+ raised = ui._scrollHighlight != 5;
+ _surface.fillRect(Common::Rect(r.left + 2, r.bottom - BUTTON_SIZE + 2, r.right - 2, r.bottom - 2), INFO_MIDDLE);
+ drawDialogRect(Common::Rect(r.left, r.bottom - BUTTON_SIZE, r.right, r.bottom), raised);
+
+ // Draw the arrows on the scroll buttons
+ byte color = inv._invIndex? INFO_BOTTOM + 2 : INFO_BOTTOM;
+ _surface.hLine(r.right / 2, r.top - 2 + BUTTON_SIZE / 2, r.right / 2, color);
+ _surface.fillRect(Common::Rect(r.right / 2 - 1, r.top - 1 + BUTTON_SIZE / 2,
+ r.right / 2 + 1, r.top - 1 + BUTTON_SIZE / 2), color);
+ _surface.fillRect(Common::Rect(r.right / 2 - 2, r.top + BUTTON_SIZE / 2,
+ r.right / 2 + 2, r.top + BUTTON_SIZE / 2), color);
+ _surface.fillRect(Common::Rect(r.right / 2 - 3, r.top + 1 + BUTTON_SIZE / 2,
+ r.right / 2 + 3, r.top + 1 + BUTTON_SIZE / 2), color);
+
+ color = (inv._invIndex + NUM_INVENTORY_SHOWN) < inv._holdings ? INFO_BOTTOM + 2 : INFO_BOTTOM;
+ _surface.fillRect(Common::Rect(r.right / 2 - 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2,
+ r.right / 2 + 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2), color);
+ _surface.fillRect(Common::Rect(r.right / 2 - 2, r.bottom - 1 - BUTTON_SIZE + 1 + BUTTON_SIZE / 2,
+ r.right / 2 + 2, r.bottom - 1 - BUTTON_SIZE + 1 + BUTTON_SIZE / 2), color);
+ _surface.fillRect(Common::Rect(r.right / 2 - 1, r.bottom - 1 - BUTTON_SIZE + 2 + BUTTON_SIZE / 2,
+ r.right / 2 + 1, r.bottom - 1 - BUTTON_SIZE + 2 + BUTTON_SIZE / 2), color);
+ _surface.fillRect(Common::Rect(r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2,
+ r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2), color);
+
+ // Draw the scroll position bar
+ int idx= inv._holdings;
+ if (idx% (NUM_INVENTORY_SHOWN / 2))
+ idx= (idx + (NUM_INVENTORY_SHOWN / 2)) / (NUM_INVENTORY_SHOWN / 2)*(NUM_INVENTORY_SHOWN / 2);
+ int barHeight = NUM_INVENTORY_SHOWN * (_bounds.height() - BUTTON_SIZE * 2) / idx;
+ barHeight = CLIP(barHeight, BUTTON_SIZE, _bounds.height() - BUTTON_SIZE * 2);
+
+ int barY = (idx<= NUM_INVENTORY_SHOWN) ? r.top + BUTTON_SIZE :
+ (r.height() - BUTTON_SIZE * 2 - barHeight) * FIXED_INT_MULTIPLIER / (idx- NUM_INVENTORY_SHOWN)
+ * inv._invIndex / FIXED_INT_MULTIPLIER + r.top + BUTTON_SIZE;
+ _surface.fillRect(Common::Rect(r.left + 2, barY + 2, r.right - 2, barY + barHeight - 3), INFO_MIDDLE);
+ drawDialogRect(Common::Rect(r.left, barY, r.right, barY + barHeight), true);
+}
+
+void WidgetInventory::drawDialogRect(const Common::Rect &r, bool raised) {
+ switch (raised) {
+ case true:
+ // Draw Left
+ _surface.vLine(r.left, r.top, r.bottom - 1, INFO_TOP);
+ _surface.vLine(r.left + 1, r.top, r.bottom - 2, INFO_TOP);
+ // Draw Top
+ _surface.hLine(r.left + 2, r.top, r.right - 1, INFO_TOP);
+ _surface.hLine(r.left + 2, r.top + 1, r.right - 2, INFO_TOP);
+ // Draw Right
+ _surface.vLine(r.right - 1, r.top + 1,r.bottom - 1, INFO_BOTTOM);
+ _surface.vLine(r.right - 2, r.top + 2, r.bottom - 1, INFO_BOTTOM);
+ // Draw Bottom
+ _surface.hLine(r.left + 1, r.bottom - 1, r.right - 3, INFO_BOTTOM);
+ _surface.hLine(r.left + 2, r.bottom - 2, r.right - 3, INFO_BOTTOM);
+ break;
+
+ case false:
+ // Draw Left
+ _surface.vLine(r.left, r.top, r.bottom - 1, INFO_BOTTOM);
+ _surface.vLine(r.left + 1, r.top, r.bottom - 2, INFO_BOTTOM);
+ // Draw Top
+ _surface.hLine(r.left + 2, r.top, r.right - 1, INFO_BOTTOM);
+ _surface.hLine(r.left + 2, r.top + 1, r.right - 2, INFO_BOTTOM);
+ // Draw Right
+ _surface.vLine(r.right - 1, r.top + 1, r.bottom - 1, INFO_TOP);
+ _surface.vLine(r.right - 2, r.top + 2, r.bottom - 1, INFO_TOP);
+ // Draw Bottom
+ _surface.hLine(r.left + 1, r.bottom - 1, r.right - 3, INFO_TOP);
+ _surface.hLine(r.left + 2, r.bottom - 2, r.right - 3, INFO_TOP);
+ break;
+ }
}
diff --git a/engines/sherlock/tattoo/widget_inventory.h b/engines/sherlock/tattoo/widget_inventory.h
index b2096f63e3..34e25eeaa0 100644
--- a/engines/sherlock/tattoo/widget_inventory.h
+++ b/engines/sherlock/tattoo/widget_inventory.h
@@ -39,7 +39,15 @@ private:
int _selector, _oldSelector;
int _dialogTimer;
- void loadInv();
+ /**
+ * Draw the scrollbar for the dialog
+ */
+ void drawScrollBar();
+
+ /**
+ * Draws all the dialog rectangles for any items that need them
+ */
+ void drawDialogRect(const Common::Rect &r, bool raised);
public:
int _invMode;
public:
@@ -47,6 +55,11 @@ public:
virtual ~WidgetInventory() {}
void load(int mode);
+
+ /**
+ * Draw the inventory on the surface
+ */
+ void drawInventory();
};
} // End of namespace Tattoo