mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 09:18:38 +00:00
SCI: Merged all the code to get/set the NS rect
This commit is contained in:
parent
7a96bcb3ed
commit
513d0be106
@ -1351,24 +1351,11 @@ reg_t kIsOnMe(EngineState *s, int argc, reg_t *argv) {
|
||||
uint16 y = argv[1].toUint16();
|
||||
reg_t targetObject = argv[2];
|
||||
uint16 illegalBits = argv[3].offset;
|
||||
Common::Rect nsRect;
|
||||
Common::Rect nsRect = g_sci->_gfxCompare->getNSRect(targetObject, true);
|
||||
|
||||
// we assume that x, y are local coordinates
|
||||
|
||||
// Get the bounding rectangle of the object
|
||||
nsRect.left = readSelectorValue(s->_segMan, targetObject, SELECTOR(nsLeft));
|
||||
nsRect.top = readSelectorValue(s->_segMan, targetObject, SELECTOR(nsTop));
|
||||
nsRect.right = readSelectorValue(s->_segMan, targetObject, SELECTOR(nsRight));
|
||||
nsRect.bottom = readSelectorValue(s->_segMan, targetObject, SELECTOR(nsBottom));
|
||||
|
||||
// nsRect top/left may be negative, adjust accordingly
|
||||
Common::Rect checkRect = nsRect;
|
||||
if (checkRect.top < 0)
|
||||
checkRect.top = 0;
|
||||
if (checkRect.left < 0)
|
||||
checkRect.left = 0;
|
||||
|
||||
bool contained = checkRect.contains(x, y);
|
||||
bool contained = nsRect.contains(x, y);
|
||||
if (contained && illegalBits) {
|
||||
// If illegalbits are set, we check the color of the pixel that got clicked on
|
||||
// for now, we return false if the pixel is transparent
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "sci/engine/selector.h"
|
||||
#include "sci/engine/vm.h"
|
||||
#include "sci/graphics/cache.h"
|
||||
#include "sci/graphics/compare.h"
|
||||
#include "sci/graphics/cursor.h"
|
||||
#include "sci/graphics/ports.h"
|
||||
#include "sci/graphics/paint16.h"
|
||||
@ -307,10 +308,7 @@ void GfxAnimate::setNsRect(GfxView *view, AnimateList::iterator it) {
|
||||
// This special handling is not included in the other SCI1.1 interpreters and MUST NOT be
|
||||
// checked in those cases, otherwise we will break games (e.g. EcoQuest 2, room 200)
|
||||
if ((g_sci->getGameId() == GID_HOYLE4) && (it->scaleSignal & kScaleSignalHoyle4SpecialHandling)) {
|
||||
it->celRect.left = readSelectorValue(_s->_segMan, it->object, SELECTOR(nsLeft));
|
||||
it->celRect.top = readSelectorValue(_s->_segMan, it->object, SELECTOR(nsTop));
|
||||
it->celRect.right = readSelectorValue(_s->_segMan, it->object, SELECTOR(nsRight));
|
||||
it->celRect.bottom = readSelectorValue(_s->_segMan, it->object, SELECTOR(nsBottom));
|
||||
it->celRect = g_sci->_gfxCompare->getNSRect(it->object);
|
||||
view->getCelSpecialHoyle4Rect(it->loopNo, it->celNo, it->x, it->y, it->z, it->celRect);
|
||||
shouldSetNsRect = false;
|
||||
} else {
|
||||
@ -319,10 +317,7 @@ void GfxAnimate::setNsRect(GfxView *view, AnimateList::iterator it) {
|
||||
}
|
||||
|
||||
if (shouldSetNsRect) {
|
||||
writeSelectorValue(_s->_segMan, it->object, SELECTOR(nsLeft), it->celRect.left);
|
||||
writeSelectorValue(_s->_segMan, it->object, SELECTOR(nsTop), it->celRect.top);
|
||||
writeSelectorValue(_s->_segMan, it->object, SELECTOR(nsRight), it->celRect.right);
|
||||
writeSelectorValue(_s->_segMan, it->object, SELECTOR(nsBottom), it->celRect.bottom);
|
||||
g_sci->_gfxCompare->setNSRect(it->object, it->celRect);
|
||||
}
|
||||
}
|
||||
|
||||
@ -544,10 +539,7 @@ void GfxAnimate::addToPicDrawCels() {
|
||||
applyGlobalScaling(it, view);
|
||||
}
|
||||
view->getCelScaledRect(it->loopNo, it->celNo, it->x, it->y, it->z, it->scaleX, it->scaleY, it->celRect);
|
||||
writeSelectorValue(_s->_segMan, curObject, SELECTOR(nsLeft), it->celRect.left);
|
||||
writeSelectorValue(_s->_segMan, curObject, SELECTOR(nsTop), it->celRect.top);
|
||||
writeSelectorValue(_s->_segMan, curObject, SELECTOR(nsRight), it->celRect.right);
|
||||
writeSelectorValue(_s->_segMan, curObject, SELECTOR(nsBottom), it->celRect.bottom);
|
||||
g_sci->_gfxCompare->setNSRect(curObject, it->celRect);
|
||||
} else {
|
||||
view->getCelRect(it->loopNo, it->celNo, it->x, it->y, it->z, it->celRect);
|
||||
}
|
||||
|
@ -147,10 +147,7 @@ void GfxCompare::kernelSetNowSeen(reg_t objectReference) {
|
||||
#endif
|
||||
|
||||
if (lookupSelector(_segMan, objectReference, SELECTOR(nsTop), NULL, NULL) == kSelectorVariable) {
|
||||
writeSelectorValue(_segMan, objectReference, SELECTOR(nsLeft), celRect.left);
|
||||
writeSelectorValue(_segMan, objectReference, SELECTOR(nsRight), celRect.right);
|
||||
writeSelectorValue(_segMan, objectReference, SELECTOR(nsTop), celRect.top);
|
||||
writeSelectorValue(_segMan, objectReference, SELECTOR(nsBottom), celRect.bottom);
|
||||
setNSRect(objectReference, celRect);
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,10 +218,7 @@ void GfxCompare::kernelBaseSetter(reg_t object) {
|
||||
scaleSignal = 0;
|
||||
|
||||
if (scaleSignal & kScaleSignalDoScaling) {
|
||||
celRect.left = readSelectorValue(_segMan, object, SELECTOR(nsLeft));
|
||||
celRect.right = readSelectorValue(_segMan, object, SELECTOR(nsRight));
|
||||
celRect.top = readSelectorValue(_segMan, object, SELECTOR(nsTop));
|
||||
celRect.bottom = readSelectorValue(_segMan, object, SELECTOR(nsBottom));
|
||||
celRect = getNSRect(object);
|
||||
} else {
|
||||
if (tmpView->isSci2Hires())
|
||||
tmpView->adjustToUpscaledCoordinates(y, x);
|
||||
@ -247,4 +241,29 @@ void GfxCompare::kernelBaseSetter(reg_t object) {
|
||||
}
|
||||
}
|
||||
|
||||
Common::Rect GfxCompare::getNSRect(reg_t object, bool fixRect) {
|
||||
Common::Rect nsRect;
|
||||
nsRect.top = readSelectorValue(_segMan, object, SELECTOR(nsTop));
|
||||
nsRect.left = readSelectorValue(_segMan, object, SELECTOR(nsLeft));
|
||||
nsRect.bottom = readSelectorValue(_segMan, object, SELECTOR(nsBottom));
|
||||
nsRect.right = readSelectorValue(_segMan, object, SELECTOR(nsRight));
|
||||
|
||||
if (fixRect) {
|
||||
// nsRect top/left may be negative, adjust accordingly
|
||||
if (nsRect.top < 0)
|
||||
nsRect.top = 0;
|
||||
if (nsRect.left < 0)
|
||||
nsRect.left = 0;
|
||||
}
|
||||
|
||||
return nsRect;
|
||||
}
|
||||
|
||||
void GfxCompare::setNSRect(reg_t object, Common::Rect nsRect) {
|
||||
writeSelectorValue(_segMan, object, SELECTOR(nsLeft), nsRect.left);
|
||||
writeSelectorValue(_segMan, object, SELECTOR(nsTop), nsRect.top);
|
||||
writeSelectorValue(_segMan, object, SELECTOR(nsRight), nsRect.right);
|
||||
writeSelectorValue(_segMan, object, SELECTOR(nsBottom), nsRect.bottom);
|
||||
}
|
||||
|
||||
} // End of namespace Sci
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
reg_t kernelCanBeHere(reg_t curObject, reg_t listReference);
|
||||
bool kernelIsItSkip(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Point position);
|
||||
void kernelBaseSetter(reg_t object);
|
||||
Common::Rect getNSRect(reg_t object, bool fixRect = false);
|
||||
void setNSRect(reg_t object, Common::Rect nsRect);
|
||||
|
||||
private:
|
||||
SegManager *_segMan;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "sci/engine/kernel.h"
|
||||
#include "sci/engine/state.h"
|
||||
#include "sci/engine/selector.h"
|
||||
#include "sci/graphics/compare.h"
|
||||
#include "sci/graphics/ports.h"
|
||||
#include "sci/graphics/paint16.h"
|
||||
#include "sci/graphics/font.h"
|
||||
@ -230,8 +231,8 @@ void GfxControls::kernelTexteditChange(reg_t controlObject, reg_t eventObject) {
|
||||
if (textChanged) {
|
||||
GuiResourceId oldFontId = _text16->GetFontId();
|
||||
GuiResourceId fontId = readSelectorValue(_segMan, controlObject, SELECTOR(font));
|
||||
rect = Common::Rect(readSelectorValue(_segMan, controlObject, SELECTOR(nsLeft)), readSelectorValue(_segMan, controlObject, SELECTOR(nsTop)),
|
||||
readSelectorValue(_segMan, controlObject, SELECTOR(nsRight)), readSelectorValue(_segMan, controlObject, SELECTOR(nsBottom)));
|
||||
rect = g_sci->_gfxCompare->getNSRect(controlObject);
|
||||
|
||||
_text16->SetFont(fontId);
|
||||
if (textAddChar) {
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "sci/engine/vm.h"
|
||||
#include "sci/graphics/cache.h"
|
||||
#include "sci/graphics/coordadjuster.h"
|
||||
#include "sci/graphics/compare.h"
|
||||
#include "sci/graphics/font.h"
|
||||
#include "sci/graphics/view.h"
|
||||
#include "sci/graphics/screen.h"
|
||||
@ -546,10 +547,7 @@ void GfxFrameout::kernelFrameout() {
|
||||
continue;
|
||||
}
|
||||
|
||||
writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsLeft), nsRect.left);
|
||||
writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsTop), nsRect.top);
|
||||
writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsRight), nsRect.right);
|
||||
writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsBottom), nsRect.bottom);
|
||||
g_sci->_gfxCompare->setNSRect(itemEntry->object, nsRect);
|
||||
}
|
||||
|
||||
int16 screenHeight = _screen->getHeight();
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "sci/engine/selector.h"
|
||||
#include "sci/engine/state.h"
|
||||
#include "sci/graphics/cache.h"
|
||||
#include "sci/graphics/compare.h"
|
||||
#include "sci/graphics/font.h"
|
||||
#include "sci/graphics/screen.h"
|
||||
#include "sci/graphics/text32.h"
|
||||
@ -123,14 +124,14 @@ void GfxText32::drawTextBitmap(reg_t textObject) {
|
||||
byte *surface = memoryPtr + BITMAP_HEADER_SIZE;
|
||||
|
||||
int curByte = 0;
|
||||
Common::Rect nsRect = getNSRect(textObject);
|
||||
Common::Rect nsRect = g_sci->_gfxCompare->getNSRect(textObject);
|
||||
Common::Rect planeRect = getPlaneRect(textObject);
|
||||
uint16 x = readSelectorValue(_segMan, textObject, SELECTOR(x));
|
||||
uint16 y = readSelectorValue(_segMan, textObject, SELECTOR(y));
|
||||
uint16 textX = planeRect.left + x;
|
||||
uint16 textY = planeRect.top + y;
|
||||
uint16 width = nsRect.width();
|
||||
uint16 height = nsRect.height();
|
||||
uint16 width = nsRect.width() + 1;
|
||||
uint16 height = nsRect.height() + 1;
|
||||
|
||||
// Upscale the coordinates/width if the fonts are already upscaled
|
||||
if (_screen->fontIsUpscaled()) {
|
||||
@ -163,16 +164,6 @@ Common::Rect GfxText32::getPlaneRect(reg_t textObject) {
|
||||
return planeRect;
|
||||
}
|
||||
|
||||
Common::Rect GfxText32::getNSRect(reg_t textObject) {
|
||||
Common::Rect nsRect;
|
||||
nsRect.top = readSelectorValue(_segMan, textObject, SELECTOR(nsTop));
|
||||
nsRect.left = readSelectorValue(_segMan, textObject, SELECTOR(nsLeft));
|
||||
nsRect.bottom = readSelectorValue(_segMan, textObject, SELECTOR(nsBottom)) + 1;
|
||||
nsRect.right = readSelectorValue(_segMan, textObject, SELECTOR(nsRight)) + 1;
|
||||
|
||||
return nsRect;
|
||||
}
|
||||
|
||||
int16 GfxText32::GetLongest(const char *text, int16 maxWidth, GfxFont *font) {
|
||||
uint16 curChar = 0;
|
||||
int16 maxChars = 0, curCharCount = 0;
|
||||
|
@ -47,7 +47,6 @@ private:
|
||||
void Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight, bool restoreFont);
|
||||
void StringWidth(const char *str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight);
|
||||
Common::Rect getPlaneRect(reg_t textObject);
|
||||
Common::Rect getNSRect(reg_t textObject);
|
||||
|
||||
SegManager *_segMan;
|
||||
GfxCache *_cache;
|
||||
|
Loading…
x
Reference in New Issue
Block a user