aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sherlock/journal.cpp58
-rw-r--r--engines/sherlock/journal.h2
-rw-r--r--engines/sherlock/objects.cpp6
-rw-r--r--engines/sherlock/objects.h4
-rw-r--r--engines/sherlock/resources.cpp9
-rw-r--r--engines/sherlock/screen.cpp4
-rw-r--r--engines/sherlock/talk.cpp2
7 files changed, 39 insertions, 46 deletions
diff --git a/engines/sherlock/journal.cpp b/engines/sherlock/journal.cpp
index 71d104e3f7..be2a013069 100644
--- a/engines/sherlock/journal.cpp
+++ b/engines/sherlock/journal.cpp
@@ -27,6 +27,10 @@ namespace Sherlock {
#define JOURNAL_BUTTONS_Y 178
#define LINES_PER_PAGE 11
+#define JOURNAL_SEARCH_LEFT 15
+#define JOURNAL_SEARCH_TOP 186
+#define JOURNAL_SEARCH_RIGHT 296
+#define JOURNAL_SEACRH_MAX_CHARS 50
// Positioning of buttons in the journal view
static const int JOURNAL_POINTS[9][3] = {
@@ -910,11 +914,11 @@ bool Journal::handleEvents(int key) {
screen.buttonPrint(Common::Point(JOURNAL_POINTS[8][2], JOURNAL_BUTTONS_Y + 11), COMMAND_NULL, true, "Print Text");
}
- if (found == BTN_EXIT && events._released)
+ if (found == BTN_EXIT && events._released) {
// Exit button pressed
doneFlag = true;
- if (((found == BTN_BACK10 && events._released) || key == 'B') && (_page > 1)) {
+ } else if (((found == BTN_BACK10 && events._released) || key == 'B') && (_page > 1)) {
// Scrolll up 10 pages
if (_page < 11)
drawJournal(1, (_page - 1) * LINES_PER_PAGE);
@@ -923,23 +927,20 @@ bool Journal::handleEvents(int key) {
doArrows();
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- }
- if (((found == BTN_UP && events._released) || key == 'U') && _up) {
+ } else if (((found == BTN_UP && events._released) || key == 'U') && _up) {
// Scroll up
drawJournal(1, LINES_PER_PAGE);
doArrows();
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- }
-
- if (((found == BTN_DOWN && events._released) || key == 'D') && _down) {
+
+ } else if (((found == BTN_DOWN && events._released) || key == 'D') && _down) {
// Scroll down
drawJournal(2, LINES_PER_PAGE);
doArrows();
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- }
- if (((found == BTN_AHEAD110 && events._released) || key == 'A') && _down) {
+ } else if (((found == BTN_AHEAD110 && events._released) || key == 'A') && _down) {
// Scroll down 10 pages
if ((_page + 10) > _maxPage)
drawJournal(2, (_maxPage - _page) * LINES_PER_PAGE);
@@ -948,15 +949,14 @@ bool Journal::handleEvents(int key) {
doArrows();
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- }
-
- if (((found == BTN_SEARCH && events._released) || key == 'S') && !_journal.empty()) {
+
+ } else if (((found == BTN_SEARCH && events._released) || key == 'S') && !_journal.empty()) {
screen.buttonPrint(Common::Point(JOURNAL_POINTS[5][2], JOURNAL_BUTTONS_Y + 11), COMMAND_FOREGROUND, true, "Search");
bool notFound = false;
do {
int dir;
- if ((dir = getFindName(notFound)) != 0) {
+ if ((dir = getSearchString(notFound)) != 0) {
int savedIndex = _index;
int savedSub = _sub;
int savedPage = _page;
@@ -980,9 +980,8 @@ bool Journal::handleEvents(int key) {
}
} while (!doneFlag);
doneFlag = false;
- }
-
- if (((found == BTN_FIRST_PAGE && events._released) || key == 'F') && _up) {
+
+ } else if (((found == BTN_FIRST_PAGE && events._released) || key == 'F') && _up) {
// First page
_index = _sub = 0;
_up = _down = false;
@@ -992,9 +991,8 @@ bool Journal::handleEvents(int key) {
drawJournal(0, 0);
doArrows();
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- }
-
- if (((found == BTN_LAST_PAGE && events._released) || key == 'L') && _down) {
+
+ } else if (((found == BTN_LAST_PAGE && events._released) || key == 'L') && _down) {
// Last page
if ((_page + 10) > _maxPage)
drawJournal(2, (_maxPage - _page) * LINES_PER_PAGE);
@@ -1011,9 +1009,9 @@ bool Journal::handleEvents(int key) {
}
/**
- * Show the search submenu
+ * Show the search submenu and allow the player to enter a search string
*/
-int Journal::getFindName(bool printError) {
+int Journal::getSearchString(bool printError) {
enum Button { BTN_NONE, BTN_EXIT, BTN_BACKWARD, BTN_FORWARD };
Events &events = *_vm->_events;
@@ -1078,8 +1076,8 @@ int Journal::getFindName(bool printError) {
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
}
- xp = 15 + screen.stringWidth(name);
- yp = 186;
+ xp = JOURNAL_SEARCH_LEFT + screen.stringWidth(name);
+ yp = JOURNAL_SEARCH_TOP;
do {
events._released = false;
@@ -1136,18 +1134,14 @@ int Journal::getFindName(bool printError) {
name.deleteLastChar();
}
- if (keyState.keycode == Common::KEYCODE_RETURN)
+ if (keyState.keycode == Common::KEYCODE_RETURN) {
done = 1;
-
- if (keyState.keycode == Common::KEYCODE_ESCAPE) {
+ } else if (keyState.keycode == Common::KEYCODE_ESCAPE) {
screen.vgaBar(Common::Rect(xp, yp, xp + 8, yp + 9), BUTTON_MIDDLE);
done = -1;
- }
-
- if (keyState.keycode >= Common::KEYCODE_SPACE && keyState.keycode <= Common::KEYCODE_z
- && keyState.keycode != Common::KEYCODE_AT && name.size() < 50
- && (xp + screen.charWidth(keyState.keycode)) < 296) {
- char ch = toupper(keyState.keycode);
+ } else if (keyState.ascii >= ' ' && keyState.keycode <= 'z' && keyState.keycode != Common::KEYCODE_AT &&
+ name.size() < JOURNAL_SEACRH_MAX_CHARS && (xp + screen.charWidth(keyState.keycode)) < JOURNAL_SEARCH_RIGHT) {
+ char ch = toupper(keyState.ascii);
screen.vgaBar(Common::Rect(xp, yp, xp + 8, yp + 9), BUTTON_MIDDLE);
screen.print(Common::Point(xp, yp), TALK_FOREGROUND, "%c", ch);
xp += screen.charWidth(ch);
diff --git a/engines/sherlock/journal.h b/engines/sherlock/journal.h
index 97696ef74f..026579bac2 100644
--- a/engines/sherlock/journal.h
+++ b/engines/sherlock/journal.h
@@ -68,7 +68,7 @@ private:
bool drawJournal(int direction, int howFar);
- int getFindName(bool printError);
+ int getSearchString(bool printError);
void drawJournalFrame();
public:
diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp
index 310afbf94b..eb4676dd5f 100644
--- a/engines/sherlock/objects.cpp
+++ b/engines/sherlock/objects.cpp
@@ -566,7 +566,7 @@ void Object::toggleHidden() {
void Object::checkObject() {
Scene &scene = *_vm->_scene;
Sound &sound = *_vm->_sound;
- int checkFrame = _allow ? MAX_FRAME : 32000;
+ int checkFrame = _allow ? MAX_FRAME : FRAMES_END;
bool codeFound;
if (_seqTo) {
@@ -693,7 +693,7 @@ void Object::checkObject() {
*/
bool Object::checkEndOfSequence() {
Screen &screen = *_vm->_screen;
- int checkFrame = _allow ? MAX_FRAME : 32000;
+ int checkFrame = _allow ? MAX_FRAME : FRAMES_END;
bool result = false;
if (_type == REMOVE || _type == INVALID)
@@ -749,7 +749,7 @@ bool Object::checkEndOfSequence() {
*/
void Object::setObjSequence(int seq, bool wait) {
Scene &scene = *_vm->_scene;
- int checkFrame = _allow ? MAX_FRAME : 32000;
+ int checkFrame = _allow ? MAX_FRAME : FRAMES_END;
if (seq >= 128) {
// Loop the sequence until the count exceeded
diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h
index 0b3a26f1f9..e3e07d89b7 100644
--- a/engines/sherlock/objects.h
+++ b/engines/sherlock/objects.h
@@ -102,8 +102,8 @@ class Sprite {
private:
static SherlockEngine *_vm;
public:
- Common::String _name; // Name
- Common::String _description; // Description
+ Common::String _name;
+ Common::String _description;
Common::StringArray _examine; // Examine in-depth description
Common::String _pickUp; // Message for if you can't pick up object
diff --git a/engines/sherlock/resources.cpp b/engines/sherlock/resources.cpp
index fa68074c60..5a98d57011 100644
--- a/engines/sherlock/resources.cpp
+++ b/engines/sherlock/resources.cpp
@@ -156,12 +156,11 @@ Common::SeekableReadStream *Resources::load(const Common::String &filename) {
// Secondly, iterate through any loaded library file looking for a resource
// that has the same name
- LibraryIndexes::iterator i;
- for (i = _indexes.begin(); i != _indexes.end(); ++i) {
- if ((*i)._value.contains(filename)) {
+ for (LibraryIndexes::iterator i = _indexes.begin(); i != _indexes.end(); ++i) {
+ if (i->_value.contains(filename)) {
// Get a stream reference to the given library file
- Common::SeekableReadStream *stream = load((*i)._key);
- LibraryEntry &entry = (*i)._value[filename];
+ Common::SeekableReadStream *stream = load(i->_key);
+ LibraryEntry &entry = i->_value[filename];
_resourceIndex = entry._index;
stream->seek(entry._offset);
diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp
index 4c70bf21c5..f43bf17288 100644
--- a/engines/sherlock/screen.cpp
+++ b/engines/sherlock/screen.cpp
@@ -387,7 +387,7 @@ int Screen::stringWidth(const Common::String &str) {
int Screen::charWidth(char c) {
if (c == ' ')
return 5;
- else if (c > ' ' && c <= '~')
+ else if (Common::isPrint(c))
return (*_font)[c - 33]._frame.w + 1;
else
return 0;
@@ -403,7 +403,7 @@ void Screen::writeString(const Common::String &str, const Common::Point &pt, byt
if (*c == ' ')
charPos.x += 5;
else {
- assert(*c > ' ' && *c <= '~');
+ assert(Common::isPrint(*c));
ImageFrame &frame = (*_font)[*c - 33];
_backBuffer->transBlitFrom(frame, charPos, false, color);
charPos.x += frame._frame.w + 1;
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
index 79ed052c1e..fd0b7cb378 100644
--- a/engines/sherlock/talk.cpp
+++ b/engines/sherlock/talk.cpp
@@ -1665,7 +1665,7 @@ int Talk::waitForMore(int delay) {
if (events.kbHit()) {
Common::KeyState keyState = events.getKey();
- if (keyState.keycode >= ' ' && keyState.keycode < '~')
+ if (Common::isPrint(keyState.ascii))
key2 = keyState.keycode;
}