aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock
diff options
context:
space:
mode:
authorPaul Gilbert2015-03-27 19:52:46 -0400
committerPaul Gilbert2015-03-27 19:52:46 -0400
commit56a854e2292f420a6ab03c65174f9fc0310bc2fa (patch)
treea41694130bf5b6ac0fe6bc6f58daff5d22a6a582 /engines/sherlock
parent4fad808aad87bc15827eed180f395c04c260e447 (diff)
downloadscummvm-rg350-56a854e2292f420a6ab03c65174f9fc0310bc2fa.tar.gz
scummvm-rg350-56a854e2292f420a6ab03c65174f9fc0310bc2fa.tar.bz2
scummvm-rg350-56a854e2292f420a6ab03c65174f9fc0310bc2fa.zip
SHERLOCK: Fixes for examine dialog display
Diffstat (limited to 'engines/sherlock')
-rw-r--r--engines/sherlock/events.cpp2
-rw-r--r--engines/sherlock/scene.cpp15
-rw-r--r--engines/sherlock/scene.h1
-rw-r--r--engines/sherlock/screen.h18
-rw-r--r--engines/sherlock/user_interface.cpp57
-rw-r--r--engines/sherlock/user_interface.h5
6 files changed, 66 insertions, 32 deletions
diff --git a/engines/sherlock/events.cpp b/engines/sherlock/events.cpp
index 5c94b7e1ff..fef22c9301 100644
--- a/engines/sherlock/events.cpp
+++ b/engines/sherlock/events.cpp
@@ -186,7 +186,7 @@ bool Events::checkForNextFrameCounter() {
*/
void Events::clearEvents() {
_pendingKeys.clear();
- _pressed = _rightPressed = false;
+ _pressed = _released = false;
_rightPressed = _rightReleased = false;
_oldButtons = _oldRightButton = false;
}
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index 6442538794..97f7350ea9 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -106,12 +106,9 @@ Scene::Scene(SherlockEngine *vm): _vm(vm) {
_animating = 0;
_doBgAnimDone = true;
_tempFadeStyle = 0;
-
- _controlPanel = new ImageFile("controls.vgs");
}
Scene::~Scene() {
- delete _controlPanel;
freeScene();
}
@@ -198,6 +195,7 @@ bool Scene::loadScene(const Common::String &filename) {
People &people = *_vm->_people;
Screen &screen = *_vm->_screen;
Sound &sound = *_vm->_sound;
+ UserInterface &ui = *_vm->_ui;
bool flag;
freeScene();
@@ -393,9 +391,7 @@ bool Scene::loadScene(const Common::String &filename) {
}
// Clear user interface area and draw controls
- screen._backBuffer2.fillRect(0, INFO_LINE, SHERLOCK_SCREEN_WIDTH, INFO_LINE + 10, INFO_BLACK);
- screen._backBuffer.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y));
- screen._backBuffer2.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y));
+ ui.drawInterface();
_changes = false;
checkSceneStatus();
@@ -1074,6 +1070,13 @@ void Scene::doBgAnim() {
events.setCursor((CursorId)cursorId);
}
+ if (ui._menuMode == LOOK_MODE) {
+ if (mousePos.y > CONTROLS_Y1)
+ events.setCursor(ARROW);
+ else if (mousePos.y < CONTROLS_Y)
+ events.setCursor(MAGNIFY);
+ }
+
// Check for setting magnifying glass cursor
if (ui._menuMode == INV_MODE || ui._menuMode == USE_MODE || ui._menuMode == GIVE_MODE) {
if (_invMode == INVMODE_1) {
diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h
index 27313e34af..007f910b10 100644
--- a/engines/sherlock/scene.h
+++ b/engines/sherlock/scene.h
@@ -123,7 +123,6 @@ public:
Common::Point _bigPos;
Common::Point _overPos;
int _charPoint, _oldCharPoint;
- ImageFile *_controlPanel;
int _keyboardInput;
int _oldKey, _help, _oldHelp;
int _oldTemp, _temp;
diff --git a/engines/sherlock/screen.h b/engines/sherlock/screen.h
index 45a50e7e85..e8f45f7bba 100644
--- a/engines/sherlock/screen.h
+++ b/engines/sherlock/screen.h
@@ -36,13 +36,17 @@ namespace Sherlock {
#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
enum {
- INFO_BLACK = 1,
- INFO_FOREGROUND = 11,
- INFO_BACKGROUND = 1,
- BORDER_COLOR = 237,
- INV_FOREGROUND = 14,
- INV_BACKGROUND = 1,
- COM_FOREGROUND = 15
+ INFO_BLACK = 1,
+ INFO_FOREGROUND = 11,
+ INFO_BACKGROUND = 1,
+ BORDER_COLOR = 237,
+ INV_FOREGROUND = 14,
+ INV_BACKGROUND = 1,
+ COMMAND_HIGHLIGHTED = 10,
+ COMMAND_FOREGROUND = 15,
+ BUTTON_TOP = 233,
+ BUTTON_MIDDLE = 244,
+ BUTTON_BOTTOM = 248
};
class SherlockEngine;
diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp
index 2827e80b78..c15685d82b 100644
--- a/engines/sherlock/user_interface.cpp
+++ b/engines/sherlock/user_interface.cpp
@@ -60,6 +60,8 @@ const char *const PRESS_KEY_TO_CONTINUE = "Press any Key to Continue.";
/*----------------------------------------------------------------*/
UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) {
+ _controls = new ImageFile("menu.all");
+ _controlPanel = new ImageFile("controls.vgs");
_bgFound = 0;
_oldBgFound = -1;
_keycode = Common::KEYCODE_INVALID;
@@ -81,12 +83,11 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) {
_windowBounds = Common::Rect(0, CONTROLS_Y1, SHERLOCK_SCREEN_WIDTH - 1,
SHERLOCK_SCREEN_HEIGHT - 1);
_windowStyle = 0;
-
- _controls = new ImageFile("menu.all");
}
UserInterface::~UserInterface() {
delete _controls;
+ delete _controlPanel;
}
void UserInterface::reset() {
@@ -96,6 +97,17 @@ void UserInterface::reset() {
}
/**
+ * Draw the user interface onto the screen's back buffers
+ */
+void UserInterface::drawInterface() {
+ Screen &screen = *_vm->_screen;
+
+ screen._backBuffer2.fillRect(0, INFO_LINE, SHERLOCK_SCREEN_WIDTH, INFO_LINE + 10, INFO_BLACK);
+ screen._backBuffer.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y));
+ screen._backBuffer2.transBlitFrom((*_controlPanel)[0], Common::Point(0, CONTROLS_Y));
+}
+
+/**
* Main input handler for the user interface
*/
void UserInterface::handleInput() {
@@ -137,7 +149,7 @@ void UserInterface::handleInput() {
(events._rightPressed || (!_helpStyle && !events._released)) &&
(_bgFound != -1) && (_bgFound < 1000) &&
(scene._bgShapes[_bgFound]._defaultCommand ||
- scene._bgShapes[_bgFound]._description[0])) {
+ !scene._bgShapes[_bgFound]._description.empty())) {
// If there is no default command, so set it to Look
if (scene._bgShapes[_bgFound]._defaultCommand)
_help = scene._bgShapes[_bgFound]._defaultCommand - 1;
@@ -151,7 +163,7 @@ void UserInterface::handleInput() {
((events._rightReleased && _helpStyle) || (events._released && !_helpStyle)) &&
(_bgFound != -1 && _bgFound < 1000) &&
(scene._bgShapes[_bgFound]._defaultCommand ||
- scene._bgShapes[_bgFound]._description[0])) {
+ !scene._bgShapes[_bgFound]._description.empty())) {
// If there is no default command, set it to Look
if (scene._bgShapes[_bgFound]._defaultCommand)
_menuMode = (MenuMode)scene._bgShapes[_bgFound]._defaultCommand;
@@ -491,7 +503,7 @@ void UserInterface::examine() {
people.walkToCoords(obj._lookPosition, obj._lookFacing);
}
- if (talk._talkToAbort) {
+ if (!talk._talkToAbort) {
_cAnimStr = obj._examine;
if (obj._lookFlag)
_vm->setFlags(obj._lookFlag);
@@ -548,11 +560,6 @@ void UserInterface::doLookControl() {
} else if (!_lookHelp) {
// Need to close the window and depress the Look button
Common::Point pt(MENU_POINTS[0][0], MENU_POINTS[0][1]);
- Surface tempSurface((*_controls)[0]._frame.w, (*_controls)[0]._frame.h);
- tempSurface.blitFrom(screen._backBuffer2, Common::Point(0, 0),
- Common::Rect(pt.x, pt.y, pt.x + (*_controls)[0]._frame.w,
- pt.y + (*_controls)[1]._frame.h));
-
screen._backBuffer2.blitFrom((*_controls)[0]._frame, pt);
banishWindow(true);
@@ -562,7 +569,8 @@ void UserInterface::doLookControl() {
_menuMode = LOOK_MODE;
events.clearEvents();
- screen._backBuffer2.blitFrom(tempSurface, pt);
+ // Restore UI
+ drawInterface();
}
} else {
// Looking at an inventory object
@@ -865,6 +873,10 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) {
Common::String line(lineStartP, msgP);
screen.gPrint(Common::Point(16, CONTROLS_Y + 12 + lineNum * 9),
INV_FOREGROUND, line.c_str());
+
+ if (!endOfStr)
+ // Start next line at start of the nxet word after space
+ ++msgP;
}
// Handle display depending on whether all the message was shown
@@ -874,7 +886,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) {
PRESS_KEY_FOR_MORE);
screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH -
screen.stringWidth(PRESS_KEY_FOR_MORE)) / 2, CONTROLS_Y),
- COM_FOREGROUND, "P");
+ COMMAND_FOREGROUND, "P");
_descStr = msgP;
} else {
makeButton(Common::Rect(46, CONTROLS_Y, 272, CONTROLS_Y + 10),
@@ -882,7 +894,7 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) {
PRESS_KEY_FOR_MORE);
screen.gPrint(Common::Point((SHERLOCK_SCREEN_WIDTH -
screen.stringWidth(PRESS_KEY_TO_CONTINUE)) / 2, CONTROLS_Y),
- COM_FOREGROUND, "P");
+ COMMAND_FOREGROUND, "P");
_descStr = "";
}
@@ -913,15 +925,28 @@ void UserInterface::printObjectDesc(const Common::String &str, bool firstTime) {
}
/**
-* Print the previously selected object's decription
-*/
+ * Print the previously selected object's decription
+ */
void UserInterface::printObjectDesc() {
printObjectDesc(_cAnimStr, true);
}
+/**
+ * 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) {
- // TODO
+ Screen &screen = *_vm->_screen;
+
+ screen.bar(Common::Rect(bounds.left, bounds.top, bounds.right, bounds.top + 1), BUTTON_TOP);
+ screen.bar(Common::Rect(bounds.left, bounds.top, bounds.left + 1, bounds.bottom), BUTTON_TOP);
+ screen.bar(Common::Rect(bounds.right - 1, bounds.top, bounds.right, bounds.bottom), BUTTON_BOTTOM);
+ screen.bar(Common::Rect(bounds.left + 1, bounds.bottom - 1, bounds.right, bounds.bottom), BUTTON_BOTTOM);
+ screen.bar(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);
}
/**
diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h
index 582d6f87ce..f6e0435f48 100644
--- a/engines/sherlock/user_interface.h
+++ b/engines/sherlock/user_interface.h
@@ -51,6 +51,8 @@ class SherlockEngine;
class UserInterface {
private:
SherlockEngine *_vm;
+ ImageFile *_controlPanel;
+ ImageFile *_controls;
int _bgFound;
int _oldBgFound;
Common::KeyCode _keycode;
@@ -60,7 +62,6 @@ private:
int _key, _oldKey;
int _temp, _oldTemp;
int _invLookFlag;
- ImageFile *_controls;
int _oldLook;
bool _keyboardInput;
int _invMode;
@@ -111,6 +112,8 @@ public:
void reset();
+ void drawInterface();
+
void handleInput();
void clearInfo();