aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock
diff options
context:
space:
mode:
authorPaul Gilbert2015-03-28 22:31:18 -0400
committerPaul Gilbert2015-03-28 22:31:18 -0400
commit7fec58a57d9c45f7b899f67042af57b54ca80252 (patch)
tree16eca932733be1edb5b040af5f6ad5a8544811bf /engines/sherlock
parentc28416f38ef77eef0858756d0b3265c44ad90216 (diff)
downloadscummvm-rg350-7fec58a57d9c45f7b899f67042af57b54ca80252.tar.gz
scummvm-rg350-7fec58a57d9c45f7b899f67042af57b54ca80252.tar.bz2
scummvm-rg350-7fec58a57d9c45f7b899f67042af57b54ca80252.zip
SHERLOCK: Beginnings of inventory display
Diffstat (limited to 'engines/sherlock')
-rw-r--r--engines/sherlock/inventory.cpp65
-rw-r--r--engines/sherlock/inventory.h3
-rw-r--r--engines/sherlock/scene.h2
-rw-r--r--engines/sherlock/screen.cpp18
-rw-r--r--engines/sherlock/screen.h2
-rw-r--r--engines/sherlock/user_interface.cpp109
-rw-r--r--engines/sherlock/user_interface.h18
7 files changed, 156 insertions, 61 deletions
diff --git a/engines/sherlock/inventory.cpp b/engines/sherlock/inventory.cpp
index 8eb7ecc1a1..c39bba4f5b 100644
--- a/engines/sherlock/inventory.cpp
+++ b/engines/sherlock/inventory.cpp
@@ -31,6 +31,7 @@ Inventory::Inventory(SherlockEngine *vm) : Common::Array<InventoryItem>(), _vm(v
_invIndex = 0;
_holdings = 0;
_oldFlag = 0;
+ _invFlag = 0;
}
Inventory::~Inventory() {
@@ -129,8 +130,11 @@ void Inventory::putInv(int slamit) {
* 3 = give inventory mode
* 128 = Draw window in the back buffer, but don't display it
*/
-void Inventory::invent(int flag) {
+void Inventory::drawInventory(int flag) {
Screen &screen = *_vm->_screen;
+ UserInterface &ui = *_vm->_ui;
+ int tempFlag = flag;
+
_oldFlag = 7;
loadInv();
@@ -138,7 +142,64 @@ void Inventory::invent(int flag) {
screen._backBuffer = &screen._backBuffer2;
}
-
+ // Draw the window background
+ Surface &bb = *screen._backBuffer;
+ bb.fillRect(Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y1 + 10), BORDER_COLOR);
+ bb.fillRect(Common::Rect(0, CONTROLS_Y1 + 10, 2, SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR);
+ bb.fillRect(Common::Rect(SHERLOCK_SCREEN_WIDTH - 2, CONTROLS_Y1 + 10,
+ SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR);
+ bb.fillRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - 2, SHERLOCK_SCREEN_WIDTH,
+ SHERLOCK_SCREEN_HEIGHT), BORDER_COLOR);
+ bb.fillRect(Common::Rect(2, CONTROLS_Y1 + 10, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT - 2),
+ INV_BACKGROUND);
+
+ // Draw the buttons
+ screen.makeButton(Common::Rect(INVENTORY_POINTS[0][0], CONTROLS_Y1, INVENTORY_POINTS[0][1],
+ CONTROLS_Y1 + 9), INVENTORY_POINTS[0][2] - screen.stringWidth("Exit") / 2, "Exit");
+ screen.makeButton(Common::Rect(INVENTORY_POINTS[1][0], CONTROLS_Y1, INVENTORY_POINTS[1][1],
+ CONTROLS_Y1 + 9), INVENTORY_POINTS[1][2] - screen.stringWidth("Look") / 2, "Look");
+ screen.makeButton(Common::Rect(INVENTORY_POINTS[2][0], CONTROLS_Y1, INVENTORY_POINTS[2][1],
+ CONTROLS_Y1 + 9), INVENTORY_POINTS[2][2] - screen.stringWidth("Use") / 2, "Use");
+ screen.makeButton(Common::Rect(INVENTORY_POINTS[3][0], CONTROLS_Y1, INVENTORY_POINTS[3][1],
+ CONTROLS_Y1 + 9), INVENTORY_POINTS[3][2] - screen.stringWidth("Give") / 2, "Give");
+ screen.makeButton(Common::Rect(INVENTORY_POINTS[4][0], CONTROLS_Y1, INVENTORY_POINTS[4][1],
+ CONTROLS_Y1 + 9), INVENTORY_POINTS[4][2], "^^");
+ screen.makeButton(Common::Rect(INVENTORY_POINTS[5][0], CONTROLS_Y1, INVENTORY_POINTS[5][1],
+ CONTROLS_Y1 + 9), INVENTORY_POINTS[5][2], "^");
+ screen.makeButton(Common::Rect(INVENTORY_POINTS[6][0], CONTROLS_Y1, INVENTORY_POINTS[6][1],
+ CONTROLS_Y1 + 9), INVENTORY_POINTS[6][2], "_");
+ screen.makeButton(Common::Rect(INVENTORY_POINTS[7][0], CONTROLS_Y1, INVENTORY_POINTS[7][1],
+ CONTROLS_Y1 + 9), INVENTORY_POINTS[7][2], "__");
+
+ if (tempFlag == 128)
+ flag = 1;
+ ui._invMode = flag;
+
+ if (flag) {
+ ui._oldKey = INVENTORY_COMMANDS[flag];
+ _oldFlag = flag;
+ } else {
+ ui._oldKey = -1;
+ _invFlag = 6;
+ }
+
+ invCommands(0);
+ putInv(0);
+
+ if (tempFlag != 128) {
+ if (!ui._windowStyle) {
+ screen.slamRect(Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT));
+ } else {
+ ui.summonWindow(false, CONTROLS_Y1);
+ }
+
+ ui._windowOpen = true;
+ } else {
+ // Reset the screen back buffer to the first buffer now that drawing is done
+ screen._backBuffer = &screen._backBuffer1;
+ }
+
+ ui._oldUse = -1;
}
void Inventory::invCommands(bool slamIt) {
diff --git a/engines/sherlock/inventory.h b/engines/sherlock/inventory.h
index 1db91292a5..7785250e8c 100644
--- a/engines/sherlock/inventory.h
+++ b/engines/sherlock/inventory.h
@@ -51,6 +51,7 @@ public:
int _holdings;
void freeGraphics();
int _oldFlag;
+ int _invFlag;
public:
Inventory(SherlockEngine *vm);
~Inventory();
@@ -65,7 +66,7 @@ public:
void putInv(int slamit);
- void invent(int flag);
+ void drawInventory(int flag);
void invCommands(bool slamIt);
diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h
index 007f910b10..d89a47e560 100644
--- a/engines/sherlock/scene.h
+++ b/engines/sherlock/scene.h
@@ -34,8 +34,6 @@ namespace Sherlock {
#define SCENES_COUNT 63
#define MAX_ZONES 40
#define INFO_LINE 140
-#define CONTROLS_Y 138
-#define CONTROLS_Y1 151
enum InvMode {
INVMODE_0 = 0,
diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp
index f1562e2468..16d590c0f4 100644
--- a/engines/sherlock/screen.cpp
+++ b/engines/sherlock/screen.cpp
@@ -409,4 +409,22 @@ void Screen::vgaBar(const Common::Rect &r, int color) {
slamRect(r);
}
+/**
+ * Draws a button for use in the inventory, talk, and examine dialogs.
+ */
+void Screen::makeButton(const Common::Rect &bounds, int textX,
+ const Common::String &str) {
+
+ Surface &bb = *_backBuffer;
+ bb.fillRect(Common::Rect(bounds.left, bounds.top, bounds.right, bounds.top + 1), BUTTON_TOP);
+ bb.fillRect(Common::Rect(bounds.left, bounds.top, bounds.left + 1, bounds.bottom), BUTTON_TOP);
+ bb.fillRect(Common::Rect(bounds.right - 1, bounds.top, bounds.right, bounds.bottom), BUTTON_BOTTOM);
+ bb.fillRect(Common::Rect(bounds.left + 1, bounds.bottom - 1, bounds.right, bounds.bottom), BUTTON_BOTTOM);
+ bb.fillRect(Common::Rect(bounds.left + 1, bounds.top + 1, bounds.right - 1, bounds.bottom - 1), BUTTON_MIDDLE);
+
+ gPrint(Common::Point(textX, bounds.top), COMMAND_HIGHLIGHTED, "%c", str[0]);
+ gPrint(Common::Point(textX + charWidth(str[0]), bounds.top),
+ COMMAND_FOREGROUND, "%s", str.c_str() + 1);
+}
+
} // End of namespace Sherlock
diff --git a/engines/sherlock/screen.h b/engines/sherlock/screen.h
index 7d07cfa062..f33bbfceab 100644
--- a/engines/sherlock/screen.h
+++ b/engines/sherlock/screen.h
@@ -112,6 +112,8 @@ public:
int charWidth(char c);
void vgaBar(const Common::Rect &r, int color);
+
+ void makeButton(const Common::Rect &bounds, int textX, const Common::String &str);
};
} // End of namespace Sherlock
diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp
index dbc9108212..a993965429 100644
--- a/engines/sherlock/user_interface.cpp
+++ b/engines/sherlock/user_interface.cpp
@@ -54,6 +54,7 @@ const int INVENTORY_POINTS[8][3] = {
};
const char COMMANDS[13] = "LMTPOCIUGJFS";
+const char INVENTORY_COMMANDS[9] = { "ELUG-+,." };
const char *const PRESS_KEY_FOR_MORE = "Press any Key for More.";
const char *const PRESS_KEY_TO_CONTINUE = "Press any Key to Continue.";
@@ -85,6 +86,7 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) {
SHERLOCK_SCREEN_HEIGHT - 1);
_windowStyle = 1; // Sliding windows
_find = 0;
+ _oldUse = 0;
}
UserInterface::~UserInterface() {
@@ -686,7 +688,6 @@ void UserInterface::doInvControl() {
Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk;
- const char INVENTORY_COMMANDS[9] = { "ELUG-+,." };
int colors[8];
Common::Point mousePos = events.mousePos();
@@ -956,7 +957,7 @@ void UserInterface::doLookControl() {
tempSurface.blitFrom(screen._backBuffer2, Common::Point(0, 0),
Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT));
- inv.invent(128);
+ inv.drawInventory(128);
banishWindow(true);
// Restore the ui
@@ -1060,19 +1061,19 @@ void UserInterface::doMainControl() {
pushButton(6);
_selector = _oldSelector = -1;
_menuMode = INV_MODE;
- inv.invent(1);
+ inv.drawInventory(1);
break;
case 'U':
pushButton(7);
_selector = _oldSelector = -1;
_menuMode = USE_MODE;
- inv.invent(2);
+ inv.drawInventory(2);
break;
case 'G':
pushButton(8);
_selector = _oldSelector = -1;
_menuMode = GIVE_MODE;
- inv.invent(3);
+ inv.drawInventory(3);
break;
case 'J':
pushButton(9);
@@ -1259,7 +1260,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) {
// Handle display depending on whether all the message was shown
if (!endOfStr) {
- makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10),
+ screen.makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10),
(SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_FOR_MORE)) / 2,
PRESS_KEY_FOR_MORE);
screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH -
@@ -1267,7 +1268,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) {
COMMAND_FOREGROUND, "P");
_descStr = msgP;
} else {
- makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10),
+ screen.makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10),
(SHERLOCK_SCREEN_WIDTH - screen.stringWidth(PRESS_KEY_TO_CONTINUE)) / 2,
PRESS_KEY_TO_CONTINUE);
screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH -
@@ -1280,20 +1281,9 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) {
if (!_windowStyle) {
screen.slamRect(Common::Rect(0, CONTROLS_Y,
SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT));
- }
- else {
- // Extract the window that's been drawn on the back buffer
- Surface tempSurface(SHERLOCK_SCREEN_WIDTH,
- (SHERLOCK_SCREEN_HEIGHT - CONTROLS_Y));
- Common::Rect r(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- tempSurface.blitFrom(screen._backBuffer1, Common::Point(0, 0), r);
-
- // Remove drawn window with original user interface
- screen._backBuffer1.blitFrom(screen._backBuffer2,
- Common::Point(0, CONTROLS_Y), r);
-
- // Display the window gradually on-screen
- summonWindow(tempSurface);
+ } else {
+ // Display the window
+ summonWindow();
}
_selector = _oldSelector = -1;
@@ -1312,28 +1302,9 @@ void UserInterface::printObjectDesc() {
}
/**
- * Draws a button for use in the inventory, talk, and examine dialogs.
- */
-void UserInterface::makeButton(const Common::Rect &bounds, int textX,
- const Common::String &str) {
- Screen &screen = *_vm->_screen;
-
- Surface &bb = *screen._backBuffer;
- bb.fillRect(Common::Rect(bounds.left, bounds.top, bounds.right, bounds.top + 1), BUTTON_TOP);
- bb.fillRect(Common::Rect(bounds.left, bounds.top, bounds.left + 1, bounds.bottom), BUTTON_TOP);
- bb.fillRect(Common::Rect(bounds.right - 1, bounds.top, bounds.right, bounds.bottom), BUTTON_BOTTOM);
- bb.fillRect(Common::Rect(bounds.left + 1, bounds.bottom - 1, bounds.right, bounds.bottom), BUTTON_BOTTOM);
- bb.fillRect(Common::Rect(bounds.left + 1, bounds.top + 1, bounds.right - 1, bounds.bottom - 1), BUTTON_MIDDLE);
-
- screen.gPrint(Common::Point(textX, bounds.top), COMMAND_HIGHLIGHTED, "%c", str[0]);
- screen.gPrint(Common::Point(textX + screen.charWidth(str[0]), bounds.top),
- COMMAND_FOREGROUND, "%s", str.c_str() + 1);
-}
-
-/**
* Displays a passed window by gradually scrolling it vertically on-screen
*/
-void UserInterface::summonWindow(const Surface &bgSurface) {
+void UserInterface::summonWindow(const Surface &bgSurface, bool slideUp) {
Events &events = *_vm->_events;
Screen &screen = *_vm->_screen;
@@ -1341,34 +1312,68 @@ void UserInterface::summonWindow(const Surface &bgSurface) {
// A window is already open, so can't open another one
return;
- // Gradually slide up the display of the window
- for (int idx = 1; idx <= bgSurface.h; idx += 2) {
- screen._backBuffer->blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - idx),
- Common::Rect(0, 0, bgSurface.w, idx));
- screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - idx,
- SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT));
+ if (slideUp) {
+ // Gradually slide up the display of the window
+ for (int idx = 1; idx <= bgSurface.h; idx += 2) {
+ screen._backBuffer->blitFrom(bgSurface, Common::Point(0, SHERLOCK_SCREEN_HEIGHT - idx),
+ Common::Rect(0, 0, bgSurface.w, idx));
+ screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - idx,
+ SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT));
- events.delay(10);
+ events.delay(10);
+ }
+ } else {
+ // Gradually slide down the display of the window
+ for (int idx = 1; idx <= bgSurface.h; idx += 2) {
+ screen._backBuffer->blitFrom(bgSurface,
+ Common::Point(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h),
+ Common::Rect(0, bgSurface.h - idx, bgSurface.w, bgSurface.h));
+ screen.slamRect(Common::Rect(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h,
+ SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT - bgSurface.h + idx));
+
+ events.delay(10);
+ }
}
// Final display of the entire window
- screen._backBuffer->blitFrom(bgSurface, Common::Point(0, CONTROLS_Y),
+ screen._backBuffer->blitFrom(bgSurface, Common::Point(0,
+ SHERLOCK_SCREEN_HEIGHT - bgSurface.h),
Common::Rect(0, 0, bgSurface.w, bgSurface.h));
- screen.slamArea(0, CONTROLS_Y, bgSurface.w, bgSurface.h);
+ screen.slamArea(0, SHERLOCK_SCREEN_HEIGHT - bgSurface.h, bgSurface.w, bgSurface.h);
_windowOpen = true;
}
/**
+ * Slide the window stored in the back buffer onto the screen
+ */
+void UserInterface::summonWindow(bool slideUp, int height) {
+ Screen &screen = *_vm->_screen;
+
+ // Extract the window that's been drawn on the back buffer
+ Surface tempSurface(SHERLOCK_SCREEN_WIDTH,
+ (SHERLOCK_SCREEN_HEIGHT - height));
+ Common::Rect r(0, height, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
+ tempSurface.blitFrom(screen._backBuffer1, Common::Point(0, 0), r);
+
+ // Remove drawn window with original user interface
+ screen._backBuffer1.blitFrom(screen._backBuffer2,
+ Common::Point(0, height), r);
+
+ // Display the window gradually on-screen
+ summonWindow(tempSurface, slideUp);
+}
+
+/**
* Close a currently open window
* @param flag 0 = slide old window down, 1 = slide prior UI back up
*/
-void UserInterface::banishWindow(bool flag) {
+void UserInterface::banishWindow(bool slideUp) {
Events &events = *_vm->_events;
Screen &screen = *_vm->_screen;
if (_windowOpen) {
- if (flag || !_windowStyle) {
+ if (slideUp || !_windowStyle) {
// Slide window down
// Only slide the window if the window style allows it
if (_windowStyle) {
diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h
index d94b2fadc5..87fd4a5e99 100644
--- a/engines/sherlock/user_interface.h
+++ b/engines/sherlock/user_interface.h
@@ -31,6 +31,9 @@
namespace Sherlock {
+#define CONTROLS_Y 138
+#define CONTROLS_Y1 151
+
enum MenuMode {
STD_MODE = 0,
LOOK_MODE = 1,
@@ -47,9 +50,16 @@ enum MenuMode {
SETUP_MODE = 12
};
+extern const int MENU_POINTS[12][4];
+
+extern const int INVENTORY_POINTS[8][3];
+extern const char INVENTORY_COMMANDS[9];
+
class SherlockEngine;
+class Inventory;
class UserInterface {
+ friend class Inventory;
private:
SherlockEngine *_vm;
ImageFile *_controlPanel;
@@ -77,6 +87,7 @@ private:
int _windowStyle;
int _find;
Common::String _muse;
+ int _oldUse;
private:
void depressButton(int num);
@@ -106,8 +117,6 @@ private:
void environment();
void doControls();
- void makeButton(const Common::Rect &bounds, int textX, const Common::String &str);
-
void checkUseAction(UseType &use, const Common::String &invName, const Common::String &msg,
int objNum, int giveMode);
public:
@@ -132,8 +141,9 @@ public:
void printObjectDesc(const Common::String &str, bool firstTime);
void printObjectDesc();
- void summonWindow(const Surface &bgSurface);
- void banishWindow(bool flag);
+ void summonWindow(const Surface &bgSurface, bool slideUp = true);
+ void summonWindow(bool slideUp = true, int height = CONTROLS_Y);
+ void banishWindow(bool slideUp = true);
};
} // End of namespace Sherlock