aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/draci/game.cpp49
-rw-r--r--engines/draci/script.cpp2
-rw-r--r--engines/draci/surface.cpp14
-rw-r--r--engines/draci/surface.h4
4 files changed, 38 insertions, 31 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 2593d5f763..5d3c6a3384 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -268,7 +268,7 @@ void Game::loop() {
updateCursor();
} else {
if (_objUnderCursor != kObjectNotFound) {
- GameObject *obj = &_objects[_objUnderCursor];
+ const GameObject *obj = &_objects[_objUnderCursor];
_vm->_mouse->cursorOff();
titleAnim->markDirtyRect(surface);
@@ -295,7 +295,7 @@ void Game::loop() {
_vm->_mouse->rButtonSet(false);
if (_objUnderCursor != kObjectNotFound) {
- GameObject *obj = &_objects[_objUnderCursor];
+ const GameObject *obj = &_objects[_objUnderCursor];
if (_vm->_script->testExpression(obj->_program, obj->_canUse)) {
_vm->_mouse->cursorOff();
@@ -357,10 +357,9 @@ void Game::loop() {
// If there is an inventory item under the cursor and we aren't
// holding any item, run its look GPL program
if (_itemUnderCursor != kNoItem && _currentItem == kNoItem) {
- const GPL2Program &program = _items[_itemUnderCursor]._program;
- const int lookOffset = _items[_itemUnderCursor]._look;
+ const GameItem *item = &_items[_itemUnderCursor];
- _vm->_script->run(program, lookOffset);
+ _vm->_script->run(item->_program, item->_look);
// Otherwise, if we are holding an item, try to place it inside the
// inventory
} else if (_currentItem != kNoItem) {
@@ -393,12 +392,10 @@ void Game::loop() {
// which will check if the two items are combinable and, finally,
// run the use script for the item.
} else {
- const GPL2Program &program = _items[_itemUnderCursor]._program;
- const int canUseOffset = _items[_itemUnderCursor]._canUse;
- const int useOffset = _items[_itemUnderCursor]._use;
+ const GameItem *item = &_items[_itemUnderCursor];
- if (_vm->_script->testExpression(program, canUseOffset)) {
- _vm->_script->run(program, useOffset);
+ if (_vm->_script->testExpression(item->_program, item->_canUse)) {
+ _vm->_script->run(item->_program, item->_use);
}
}
updateCursor();
@@ -472,10 +469,9 @@ void Game::updateCursor() {
}
if (_itemUnderCursor != kNoItem) {
- const GPL2Program &program = _items[_itemUnderCursor]._program;
- const int canUseOffset = _items[_itemUnderCursor]._canUse;
+ const GameItem *item = &_items[_itemUnderCursor];
- if (_vm->_script->testExpression(program, canUseOffset)) {
+ if (_vm->_script->testExpression(item->_program, item->_canUse)) {
if (_currentItem == kNoItem) {
_vm->_mouse->setCursorType(kHighlightedCursor);
} else {
@@ -518,7 +514,7 @@ void Game::updateCursor() {
}
// If there *is* a game object under the cursor, update the cursor image
} else {
- GameObject *obj = &_objects[_objUnderCursor];
+ const GameObject *obj = &_objects[_objUnderCursor];
// If there is no walking direction set on the object (i.e. the object
// is not a gate / exit), test whether it can be used and, if so,
@@ -559,18 +555,29 @@ void Game::updateTitle() {
// Mark dirty rectangle to delete the previous text
titleAnim->markDirtyRect(surface);
- // If there is no object under the cursor, delete the title.
- // Otherwise, show the object's title.
- if (_objUnderCursor == kObjectNotFound) {
- title->setText("");
+ if (_loopStatus == kStatusInventory) {
+ // If there is no item under the cursor, delete the title.
+ // Otherwise, show the item's title.
+ if (_itemUnderCursor == kNoItem) {
+ title->setText("");
+ } else {
+ const GameItem *item = &_items[_itemUnderCursor];
+ title->setText(item->_title);
+ }
} else {
- GameObject *obj = &_objects[_objUnderCursor];
- title->setText(obj->_title);
+ // If there is no object under the cursor, delete the title.
+ // Otherwise, show the object's title.
+ if (_objUnderCursor == kObjectNotFound) {
+ title->setText("");
+ } else {
+ const GameObject *obj = &_objects[_objUnderCursor];
+ title->setText(obj->_title);
+ }
}
// Move the title to the correct place (just above the cursor)
int newX = surface->centerOnX(x, title->getWidth());
- int newY = surface->centerOnY(y - smallFontHeight / 2, title->getHeight() * 2);
+ int newY = surface->putAboveY(y - smallFontHeight / 2, title->getHeight());
titleAnim->setRelative(newX, newY);
// If we are currently playing the title, mark it dirty so it gets updated.
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index bb53308134..5ff21c8d52 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -699,7 +699,7 @@ void Script::talk(Common::Queue<int> &params) {
// Set speech text coordinates
int x = surface->centerOnX(person->_x, speechFrame->getWidth());
- int y = surface->centerOnY(person->_y, speechFrame->getHeight() * 2);
+ int y = surface->putAboveY(person->_y, speechFrame->getHeight());
speechFrame->setX(x);
speechFrame->setY(y);
diff --git a/engines/draci/surface.cpp b/engines/draci/surface.cpp
index 069c501cab..6330c17cb3 100644
--- a/engines/draci/surface.cpp
+++ b/engines/draci/surface.cpp
@@ -133,11 +133,11 @@ void Surface::fill(uint colour) {
*
* @return The centered x coordinate
*/
-uint Surface::centerOnX(uint x, uint width) const {
+uint Surface::centerOnX(int x, int width) const {
int newX = x - width / 2;
- if (newX + width >= (uint)w - 1)
- newX = (w - 1) - width;
+ if (newX + width > w)
+ newX = w - width;
if (newX < 0)
newX = 0;
@@ -153,11 +153,11 @@ uint Surface::centerOnX(uint x, uint width) const {
*
* @return The centered y coordinate
*/
-uint Surface::centerOnY(uint y, uint height) const {
- int newY = y - height / 2;
+uint Surface::putAboveY(int y, int height) const {
+ int newY = y - height;
- if (newY + height >= (uint)h - 1)
- newY = (h - 1) - height;
+ if (newY + height > h)
+ newY = h - height;
if (newY < 0)
newY = 0;
diff --git a/engines/draci/surface.h b/engines/draci/surface.h
index e3371054e6..90ed9a110b 100644
--- a/engines/draci/surface.h
+++ b/engines/draci/surface.h
@@ -45,8 +45,8 @@ public:
uint getTransparentColour() const;
void setTransparentColour(uint colour);
void fill(uint colour);
- uint centerOnY(uint y, uint height) const;
- uint centerOnX(uint x, uint width) const;
+ uint putAboveY(int y, int height) const;
+ uint centerOnX(int x, int width) const;
Common::Rect getRect() const;
private: