mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
SCUMM: Fix wrong rect for verbs on Hebrew
The value of left is applied from the script all the time, and was replaced in drawVerb. The problem with this approach is that redrawVerbs maps the mouse location to verb index *before* calling drawVerb, so the rectangles it compares against are invalid in X-axis (right is always _screenWidth - 1, and left is always 5). This caused several bugs: * Each verb was clickable all over the screen's width, although it was not highlighted. * If the mouse was between 2 verbs, long above short, the Y-axis has 6 overlapping pixels (e.g. 1: 330-360, 2: 354-384). Scanning is done bottom-up, so 1 was highlighted, but 2 was selected because of the previous bullet. * The text on Hebrew was aligned to the right without any padding. Other languages have left = 5. Fixed by setting right instead of left when applying the script, and adjusting left in drawVerb. Other languages are not affected. Another issue, unrelated to language selection: A verb that was split to 2 lines was clickable all over the screen's width. That's because curRect.right was set beyond the _screenWidth, and it was not trimmed to the first (longer) line's length. On Hebrew, curRect.left became negative. This is also fixed in this commit.
This commit is contained in:
committed by
Filippos Karapetis
parent
ed4ae57063
commit
58e921eb87
@@ -978,7 +978,10 @@ void ScummEngine_v8::o8_verbOps() {
|
||||
break;
|
||||
case 0x9A: // SO_VERB_AT Set verb (X,Y) placement
|
||||
vs->curRect.top = pop();
|
||||
vs->curRect.left = pop();
|
||||
if (_language == Common::HE_ISR)
|
||||
vs->curRect.right = _screenWidth - 1 - pop();
|
||||
else
|
||||
vs->curRect.left = pop();
|
||||
break;
|
||||
case 0x9B: // SO_VERB_ON Turn verb on
|
||||
vs->curmode = 1;
|
||||
|
||||
+16
-20
@@ -1013,23 +1013,22 @@ void ScummEngine_v7::drawVerb(int verb, int mode) {
|
||||
_charset->setCurID(vs->charset_nr);
|
||||
|
||||
// Compute the text rect
|
||||
vs->curRect.right = 0;
|
||||
int textWidth = 0;
|
||||
vs->curRect.bottom = 0;
|
||||
const byte *msg2 = msg;
|
||||
while (*msg2) {
|
||||
const int charWidth = _charset->getCharWidth(*msg2);
|
||||
const int charHeight = _charset->getCharHeight(*msg2);
|
||||
vs->curRect.right += charWidth;
|
||||
textWidth += charWidth;
|
||||
if (vs->curRect.bottom < charHeight)
|
||||
vs->curRect.bottom = charHeight;
|
||||
msg2++;
|
||||
}
|
||||
vs->curRect.right += vs->curRect.left;
|
||||
vs->curRect.bottom += vs->curRect.top;
|
||||
vs->oldRect = vs->curRect;
|
||||
|
||||
const int maxWidth = _screenWidth - vs->curRect.left;
|
||||
if (_charset->getStringWidth(0, buf) > maxWidth && _game.version == 8) {
|
||||
const int maxWidth = _language == Common::HE_ISR ? vs->curRect.right + 1 : _screenWidth - vs->curRect.left;
|
||||
if (_game.version == 8 && _charset->getStringWidth(0, buf) > maxWidth) {
|
||||
byte tmpBuf[384];
|
||||
memcpy(tmpBuf, msg, 384);
|
||||
|
||||
@@ -1043,26 +1042,23 @@ void ScummEngine_v7::drawVerb(int verb, int mode) {
|
||||
}
|
||||
--len;
|
||||
}
|
||||
if (_language == Common::HE_ISR) {
|
||||
vs->curRect.right -= vs->curRect.left;
|
||||
vs->curRect.left = _screenWidth - _charset->getStringWidth(0, tmpBuf);
|
||||
vs->curRect.right += vs->curRect.left;
|
||||
}
|
||||
enqueueText(tmpBuf, vs->curRect.left, vs->curRect.top, color, vs->charset_nr, vs->center);
|
||||
int16 leftPos = vs->curRect.left;
|
||||
if (_language == Common::HE_ISR)
|
||||
vs->curRect.left = leftPos = vs->curRect.right - _charset->getStringWidth(0, tmpBuf);
|
||||
else
|
||||
vs->curRect.right = vs->curRect.left + _charset->getStringWidth(0, tmpBuf);
|
||||
enqueueText(tmpBuf, leftPos, vs->curRect.top, color, vs->charset_nr, vs->center);
|
||||
if (len >= 0) {
|
||||
int16 leftPos = vs->curRect.left;
|
||||
if (_language == Common::HE_ISR) {
|
||||
leftPos = _screenWidth - _charset->getStringWidth(0, &msg[len + 1]);
|
||||
}
|
||||
if (_language == Common::HE_ISR)
|
||||
leftPos = vs->curRect.right - _charset->getStringWidth(0, &msg[len + 1]);
|
||||
enqueueText(&msg[len + 1], leftPos, vs->curRect.top + _verbLineSpacing, color, vs->charset_nr, vs->center);
|
||||
vs->curRect.bottom += _verbLineSpacing;
|
||||
}
|
||||
} else {
|
||||
if (_language == Common::HE_ISR) {
|
||||
vs->curRect.right -= vs->curRect.left;
|
||||
vs->curRect.left = _screenWidth - _charset->getStringWidth(0, buf);
|
||||
vs->curRect.right += vs->curRect.left;
|
||||
}
|
||||
if (_language == Common::HE_ISR)
|
||||
vs->curRect.left = vs->curRect.right - textWidth;
|
||||
else
|
||||
vs->curRect.right = vs->curRect.left + textWidth;
|
||||
enqueueText(msg, vs->curRect.left, vs->curRect.top, color, vs->charset_nr, vs->center);
|
||||
}
|
||||
_charset->setCurID(oldID);
|
||||
|
||||
Reference in New Issue
Block a user