mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 07:53:36 +00:00
PETKA: fixed objects positions when xOffset is not zero
This commit is contained in:
parent
965eda5514
commit
be9372d817
@ -453,7 +453,8 @@ void QObject::draw() {
|
||||
_startSound = false;
|
||||
}
|
||||
|
||||
Common::Rect screen(640, 480);
|
||||
QSystem *sys = g_vm->getQSystem();
|
||||
Common::Rect screen(640 + sys->_xOffset, 480);
|
||||
Common::Rect dest(flc->getBounds());
|
||||
dest.translate(_x, _y);
|
||||
|
||||
@ -463,13 +464,16 @@ void QObject::draw() {
|
||||
|
||||
const Graphics::Surface *frame = flc->getCurrentFrame();
|
||||
Graphics::Surface *s = frame->convertTo(g_system->getScreenFormat(), flc->getPalette());
|
||||
const Common::List<Common::Rect> &dirty = g_vm->videoSystem()->rects();
|
||||
for (Common::List<Common::Rect>::const_iterator it = dirty.begin(); it != dirty.end(); ++it) {
|
||||
Common::Rect destRect(intersect.findIntersectingRect(*it));
|
||||
const Common::List<Common::Rect> &dirtyRects = g_vm->videoSystem()->rects();
|
||||
for (Common::List<Common::Rect>::const_iterator it = dirtyRects.begin(); it != dirtyRects.end(); ++it) {
|
||||
Common::Rect dirty = *it;
|
||||
dirty.translate(sys->_xOffset, 0);
|
||||
Common::Rect destRect(intersect.findIntersectingRect(dirty));
|
||||
if (destRect.isEmpty())
|
||||
continue;
|
||||
Common::Rect srcRect(destRect);
|
||||
srcRect.translate(-_x - flc->getPos().x, -_y - flc->getPos().y);
|
||||
destRect.translate(-sys->_xOffset, 0);
|
||||
g_vm->videoSystem()->transBlitFrom(*s, srcRect, destRect, flc->getTransColor(s->format));
|
||||
}
|
||||
s->free();
|
||||
@ -517,6 +521,7 @@ void QObject::update(int time) {
|
||||
if (flc->getCurFrame() + 1 == (int32)flc->getFrameCount() / 2) {
|
||||
g_vm->getQSystem()->addMessage(_id, kHalf, _resourceId, 0, 0, 0, 0);
|
||||
}
|
||||
g_vm->videoSystem()->addDirtyRect(Common::Point(_x, _y), *flc);
|
||||
_time -= flc->getDelay();
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +102,8 @@ void QObjectCase::draw() {
|
||||
FlicDecoder *flc = g_vm->resMgr()->loadFlic(kFirstButtonResourceId + _clickedObjIndex);
|
||||
Graphics::Surface *s = flc->getCurrentFrame()->convertTo(g_system->getScreenFormat(), flc->getPalette());
|
||||
|
||||
QSystem *sys = g_vm->getQSystem();
|
||||
|
||||
const Common::List<Common::Rect> &dirty = g_vm->videoSystem()->rects();
|
||||
const Common::Array<Common::Rect> &mskRects = flc->getMskRects();
|
||||
|
||||
@ -109,7 +111,7 @@ void QObjectCase::draw() {
|
||||
for (uint i = 0; i < mskRects.size(); ++i) {
|
||||
Common::Rect destRect = mskRects[i].findIntersectingRect(*it);
|
||||
Common::Rect srcRect = destRect;
|
||||
srcRect.translate(-flc->getPos().x - _x, -flc->getPos().y - _y);
|
||||
srcRect.translate(-flc->getPos().x - _x + sys->_xOffset, -flc->getPos().y - _y);
|
||||
g_vm->videoSystem()->transBlitFrom(*s, srcRect, destRect, flc->getTransColor(s->format));
|
||||
}
|
||||
}
|
||||
@ -120,19 +122,20 @@ void QObjectCase::draw() {
|
||||
}
|
||||
|
||||
void QObjectCase::show(bool v) {
|
||||
_x = 0; // sys->xOffset
|
||||
QSystem *sys = g_vm->getQSystem();
|
||||
_x = sys->_xOffset;
|
||||
QObject::show(v);
|
||||
if (v) {
|
||||
addItemObjects();
|
||||
|
||||
QMessageObject *obj = g_vm->getQSystem()->findObject(kPoloska);
|
||||
QMessageObject *obj = sys->findObject(kPoloska);
|
||||
obj->_z = kPoloskaZ;
|
||||
obj->_x = 0; // sys->xOffset
|
||||
obj->_x = sys->_xOffset;
|
||||
|
||||
g_vm->getQSystem()->_mainInterface->_objs.push_back(obj);
|
||||
sys->_mainInterface->_objs.push_back(obj);
|
||||
} else {
|
||||
removeObjects(true);
|
||||
g_vm->getQSystem()->_currInterface->_startIndex = 0;
|
||||
sys->_currInterface->_startIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,8 +144,9 @@ bool QObjectCase::isInPoint(Common::Point p) {
|
||||
}
|
||||
|
||||
void QObjectCase::onMouseMove(Common::Point p) {
|
||||
p.x -= _x;
|
||||
FlicDecoder *flc = g_vm->resMgr()->loadFlic(kExitCaseResourceId);
|
||||
if (*(const byte *)flc->getCurrentFrame()->getBasePtr(p.x - _x, p.y - _y) != 0) {
|
||||
if (*(const byte *)flc->getCurrentFrame()->getBasePtr(p.x - flc->getPos().x, p.y - flc->getPos().y) != 0) {
|
||||
if (_clickedObjIndex != kCloseButton && _clickedObjIndex != kInvalidButton) {
|
||||
flc = g_vm->resMgr()->loadFlic(kFirstButtonResourceId + _clickedObjIndex);
|
||||
flc->setFrame(1);
|
||||
@ -153,7 +157,7 @@ void QObjectCase::onMouseMove(Common::Point p) {
|
||||
uint i;
|
||||
for (i = 0; i < kButtonsCount; ++i) {
|
||||
flc = g_vm->resMgr()->loadFlic(kFirstButtonResourceId + i);
|
||||
if (flc->getMskRects()[0].contains(Common::Point(p.x - _x, p.y))) {
|
||||
if (flc->getMskRects()[0].contains(p)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -204,19 +208,20 @@ void QObjectCase::onClick(Common::Point p) {
|
||||
}
|
||||
|
||||
void QObjectCase::addItemObjects() {
|
||||
Common::Array<QVisibleObject *> &objs = g_vm->getQSystem()->_mainInterface->_objs;
|
||||
QSystem *sys = g_vm->getQSystem();
|
||||
Common::Array<QVisibleObject *> &objs = sys->_mainInterface->_objs;
|
||||
removeObjects(false);
|
||||
|
||||
for (uint i = 0; i < objs.size(); ++i) {
|
||||
if (objs[i]->_resourceId == kCaseResourceId) {
|
||||
g_vm->getQSystem()->_currInterface->_startIndex = i;
|
||||
sys->_currInterface->_startIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
const uint size = (_itemIndex + kItemsOnPage >= _items.size()) ? _items.size() : (_itemIndex + kItemsOnPage);
|
||||
for (uint i = _itemIndex; i < size; ++i) {
|
||||
QMessageObject *obj = g_vm->getQSystem()->findObject(_items[i]);
|
||||
obj->_x = _itemsLocation[i - _itemIndex].x;
|
||||
QMessageObject *obj = sys->findObject(_items[i]);
|
||||
obj->_x = sys->_xOffset + _itemsLocation[i - _itemIndex].x;
|
||||
obj->_y = _itemsLocation[i - _itemIndex].y;
|
||||
obj->_z = kItemZ;
|
||||
g_vm->resMgr()->loadFlic(obj->_resourceId);
|
||||
|
@ -90,6 +90,8 @@ void QObjectCursor::setPos(Common::Point p, bool center) {
|
||||
flc->setFrame(1);
|
||||
}
|
||||
|
||||
p.x = p.x - g_vm->getQSystem()->_xOffset;
|
||||
|
||||
g_vm->videoSystem()->addDirtyRect(Common::Point(_x, _y), flc->getBounds());
|
||||
|
||||
if (center) {
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
namespace Petka {
|
||||
|
||||
//const uint kFirstCursorId = 5001;
|
||||
const uint kFirstCursorId = 5001;
|
||||
const uint kCaseButtonIndex = 0;
|
||||
|
||||
QObjectStar::QObjectStar() {
|
||||
@ -60,7 +60,7 @@ void QObjectStar::onMouseMove(Common::Point p) {
|
||||
uint frame = (findButtonIndex(p.x - _x, p.y - _y) + 1) % 7 + 1;
|
||||
FlicDecoder *flc = g_vm->resMgr()->loadFlic(_resourceId);
|
||||
if (flc && flc->getCurFrame() + 1 != (int32)frame) {
|
||||
g_vm->videoSystem()->addDirtyRect(Common::Point(_x, _y), *flc);
|
||||
g_vm->videoSystem()->addDirtyRect(Common::Point(_x - g_vm->getQSystem()->_xOffset, _y), *flc);
|
||||
flc->setFrame(frame);
|
||||
}
|
||||
}
|
||||
@ -87,11 +87,13 @@ uint QObjectStar::findButtonIndex(int16 x, int16 y) const {
|
||||
|
||||
void QObjectStar::setPos(Common::Point p, bool) {
|
||||
if (!_isShown) {
|
||||
QSystem *sys = g_vm->getQSystem();
|
||||
|
||||
FlicDecoder *flc = g_vm->resMgr()->loadFlic(_resourceId);
|
||||
p.x = MAX<int16>(p.x - flc->getWidth() / 2, 0);
|
||||
p.x = MAX<int16>(p.x - sys->_xOffset - flc->getWidth() / 2, 0);
|
||||
p.y = MAX<int16>(p.y - flc->getHeight() / 2, 0);
|
||||
|
||||
_x = MIN<int16>(p.x, 639 - flc->getWidth());
|
||||
_x = MIN<int16>(p.x, 639 - flc->getWidth()) + sys->_xOffset;
|
||||
_y = MIN<int16>(p.y, 479 - flc->getHeight());
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,7 @@ void VideoSystem::addDirtyRect(Common::Point pos, Common::Rect rect) {
|
||||
}
|
||||
|
||||
void VideoSystem::addDirtyRect(Common::Point pos, FlicDecoder &flc) {
|
||||
pos.x = pos.x - g_vm->getQSystem()->_xOffset;
|
||||
addDirtyRect(pos, flc.getBounds());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user