[Scummvm-cvs-logs] SF.net SVN: scummvm:[44550] scummvm/trunk/engines/draci
spalek at users.sourceforge.net
spalek at users.sourceforge.net
Sat Oct 3 07:16:19 CEST 2009
Revision: 44550
http://scummvm.svn.sourceforge.net/scummvm/?rev=44550&view=rev
Author: spalek
Date: 2009-10-03 05:16:19 +0000 (Sat, 03 Oct 2009)
Log Message:
-----------
Fixed positioning and update of the title under the mouse pointer.
Clamping on the border of the screen works precisely. When switched to the
inventory, titles of game items are displayed instead of a (sticky) title of
the last object before entering the inventory. Put some const's where
appropriate.
Modified Paths:
--------------
scummvm/trunk/engines/draci/game.cpp
scummvm/trunk/engines/draci/script.cpp
scummvm/trunk/engines/draci/surface.cpp
scummvm/trunk/engines/draci/surface.h
Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp 2009-10-02 23:13:47 UTC (rev 44549)
+++ scummvm/trunk/engines/draci/game.cpp 2009-10-03 05:16:19 UTC (rev 44550)
@@ -268,7 +268,7 @@
updateCursor();
} else {
if (_objUnderCursor != kObjectNotFound) {
- GameObject *obj = &_objects[_objUnderCursor];
+ const GameObject *obj = &_objects[_objUnderCursor];
_vm->_mouse->cursorOff();
titleAnim->markDirtyRect(surface);
@@ -295,7 +295,7 @@
_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 @@
// 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 @@
// 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 @@
}
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 @@
}
// 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 @@
// 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.
Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp 2009-10-02 23:13:47 UTC (rev 44549)
+++ scummvm/trunk/engines/draci/script.cpp 2009-10-03 05:16:19 UTC (rev 44550)
@@ -699,7 +699,7 @@
// 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);
Modified: scummvm/trunk/engines/draci/surface.cpp
===================================================================
--- scummvm/trunk/engines/draci/surface.cpp 2009-10-02 23:13:47 UTC (rev 44549)
+++ scummvm/trunk/engines/draci/surface.cpp 2009-10-03 05:16:19 UTC (rev 44550)
@@ -133,11 +133,11 @@
*
* @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 @@
*
* @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;
Modified: scummvm/trunk/engines/draci/surface.h
===================================================================
--- scummvm/trunk/engines/draci/surface.h 2009-10-02 23:13:47 UTC (rev 44549)
+++ scummvm/trunk/engines/draci/surface.h 2009-10-03 05:16:19 UTC (rev 44550)
@@ -45,8 +45,8 @@
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:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list