[Scummvm-git-logs] scummvm master -> 58e921eb8770d6e7c67426098ffa8970d36f1518
bluegr
bluegr at gmail.com
Mon Mar 8 09:57:33 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
58e921eb87 SCUMM: Fix wrong rect for verbs on Hebrew
Commit: 58e921eb8770d6e7c67426098ffa8970d36f1518
https://github.com/scummvm/scummvm/commit/58e921eb8770d6e7c67426098ffa8970d36f1518
Author: Orgad Shaneh (orgads at gmail.com)
Date: 2021-03-08T11:57:30+02:00
Commit Message:
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.
Changed paths:
engines/scumm/script_v8.cpp
engines/scumm/verbs.cpp
diff --git a/engines/scumm/script_v8.cpp b/engines/scumm/script_v8.cpp
index bdc9eadd62..da2929e739 100644
--- a/engines/scumm/script_v8.cpp
+++ b/engines/scumm/script_v8.cpp
@@ -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;
diff --git a/engines/scumm/verbs.cpp b/engines/scumm/verbs.cpp
index 6a5c9904e2..37b0bce2b3 100644
--- a/engines/scumm/verbs.cpp
+++ b/engines/scumm/verbs.cpp
@@ -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);
More information about the Scummvm-git-logs
mailing list