Ticket #3075: 1036707.diff
File 1036707.diff, 10.0 KB (added by , 18 years ago) |
---|
-
scumm/actor.cpp
1850 1850 #ifndef DISABLE_SCUMM_7_8 1851 1851 void ScummEngine_v7::actorTalk(const byte *msg) { 1852 1852 Actor *a; 1853 bool stringWrap; 1853 1854 1854 1855 convertMessageToString(msg, _charsetBuffer, sizeof(_charsetBuffer)); 1855 1856 … … 1882 1883 if (_game.version == 7) 1883 1884 VAR(VAR_HAVE_MSG) = 0xFF; 1884 1885 _haveActorSpeechMsg = true; 1886 if (_game.version == 8) { 1887 stringWrap = _string[0].wrapping; 1888 _string[0].wrapping = true; 1889 } 1885 1890 CHARSET_1(); 1886 if (_game.version == 8) 1891 if (_game.version == 8) { 1887 1892 VAR(VAR_HAVE_MSG) = (_string[0].no_talk_anim) ? 2 : 1; 1893 _string[0].wrapping = stringWrap; 1894 } 1888 1895 } 1889 1896 #endif 1890 1897 -
scumm/charset.h
72 72 virtual void printChar(int chr, bool ignoreCharsetMask) = 0; 73 73 virtual void drawChar(int chr, const Graphics::Surface &s, int x, int y) {} 74 74 75 int getStringWidth(int a, const byte *str); 75 int getStringWidth(int a, const byte *text); 76 int getStringHeight(const byte *text); 76 77 void addLinebreaks(int a, byte *str, int pos, int maxwidth); 77 78 void translateColor(); 78 79 -
scumm/string.cpp
409 409 410 410 void ScummEngine::CHARSET_1() { 411 411 Actor *a; 412 StringTab saveStr; 412 413 #ifndef DISABLE_SCUMM_7_8 413 byte subtitleBuffer[20 0];414 byte subtitleBuffer[2048]; 414 415 byte *subtitleLine = subtitleBuffer; 415 416 Common::Point subtitlePos; 416 417 … … 437 438 if (getTalkingActor() != 0xFF) 438 439 a = derefActorSafe(getTalkingActor(), "CHARSET_1"); 439 440 440 if (a && _string[0].overhead != 0) { 441 int s; 441 if (_game.version == 8) { 442 saveStr = _string[0]; 443 if (a && _string[0].overhead) { 444 int s; 442 445 443 _string[0].xpos = a->getPos().x - virtscr[0].xstart; 444 _string[0].ypos = a->getPos().y - a->getElevation() - _screenTop; 446 _string[0].xpos = a->getPos().x - virtscr[0].xstart; 447 s = a->_scalex * a->_talkPosX / 255; 448 _string[0].xpos += (a->_talkPosX - s) / 2 + s; 445 449 446 if (_game.version <= 5) { 450 _string[0].ypos = a->getPos().y - a->getElevation() - _screenTop; 451 s = a->_scaley * a->_talkPosY / 255; 452 _string[0].ypos += (a->_talkPosY - s) / 2 + s; 453 } 454 } else { 455 if (a && _string[0].overhead) { 456 int s; 447 457 448 if (VAR(VAR_V5_TALK_STRING_Y) < 0) { 449 s = (a->_scaley * (int)VAR(VAR_V5_TALK_STRING_Y)) / 0xFF; 450 _string[0].ypos += (int)(((VAR(VAR_V5_TALK_STRING_Y) - s) / 2) + s); 458 _string[0].xpos = a->getPos().x - virtscr[0].xstart; 459 _string[0].ypos = a->getPos().y - a->getElevation() - _screenTop; 460 461 if (_game.version <= 5) { 462 463 if (VAR(VAR_V5_TALK_STRING_Y) < 0) { 464 s = (a->_scaley * (int)VAR(VAR_V5_TALK_STRING_Y)) / 0xFF; 465 _string[0].ypos += (int)(((VAR(VAR_V5_TALK_STRING_Y) - s) / 2) + s); 466 } else { 467 _string[0].ypos = (int)VAR(VAR_V5_TALK_STRING_Y); 468 } 469 451 470 } else { 452 _string[0].ypos = (int)VAR(VAR_V5_TALK_STRING_Y); 471 s = a->_scalex * a->_talkPosX / 0xFF; 472 _string[0].xpos += ((a->_talkPosX - s) / 2) + s; 473 474 s = a->_scaley * a->_talkPosY / 0xFF; 475 _string[0].ypos += ((a->_talkPosY - s) / 2) + s; 476 477 if (_string[0].ypos > _screenHeight - 40) 478 _string[0].ypos = _screenHeight - 40; 453 479 } 454 480 455 } else { 456 s = a->_scalex * a->_talkPosX / 0xFF; 457 _string[0].xpos += ((a->_talkPosX - s) / 2) + s; 481 if (_string[0].ypos < 1) 482 _string[0].ypos = 1; 458 483 459 s = a->_scaley * a->_talkPosY / 0xFF; 460 _string[0].ypos += ((a->_talkPosY - s) / 2) + s; 461 462 if (_string[0].ypos > _screenHeight - 40) 463 _string[0].ypos = _screenHeight - 40; 484 if (_string[0].xpos < 80) 485 _string[0].xpos = 80; 486 if (_string[0].xpos > _screenWidth - 80) 487 _string[0].xpos = _screenWidth - 80; 464 488 } 465 489 466 if (_string[0].ypos < 1) 467 _string[0].ypos = 1; 468 469 if (_string[0].xpos < 80) 470 _string[0].xpos = 80; 471 if (_string[0].xpos > _screenWidth - 80) 472 _string[0].xpos = _screenWidth - 80; 490 _charset->_top = _string[0].ypos + _screenTop; 491 _charset->_startLeft = _charset->_left = _string[0].xpos; 492 _charset->_right = _string[0].right; 493 _charset->_center = _string[0].center; 473 494 } 474 475 _charset->_top = _string[0].ypos + _screenTop;476 _charset->_startLeft = _charset->_left = _string[0].xpos;477 _charset->_right = _string[0].right;478 _charset->_center = _string[0].center;479 495 _charset->setColor(_charsetColor); 480 496 481 497 if (a && a->_charset) … … 522 538 } 523 539 } 524 540 541 _charset->_disableOffsX = _charset->_firstChar = !_keepText; 542 543 // XXX turn CHARSET_1 into a virtual method and overload it for V8 544 // XXX add StringTab.wrapping to the saveload data 545 if (_game.version == 8) { 546 if (_string[0].wrapping) { 547 548 _charset->addLinebreaks(0, _charsetBuffer, _charsetBufPos, _screenWidth - 20); 549 550 struct { int pos, w; } substring[10]; 551 int count = 0; 552 int maxLineWidth = 0; 553 int lastPos = 0; 554 int code = 0; 555 while (handleNextCharsetCode(a, &code)) { 556 if (code == 13 || code == 0) { 557 *subtitleLine++ = '\0'; 558 assert(count < 10); 559 substring[count].w = _charset->getStringWidth(0, subtitleBuffer + lastPos); 560 if (maxLineWidth < substring[count].w) { 561 maxLineWidth = substring[count].w; 562 } 563 substring[count].pos = lastPos; 564 ++count; 565 lastPos = subtitleLine - subtitleBuffer; 566 } else { 567 *subtitleLine++ = code; 568 *subtitleLine = '\0'; 569 } 570 if (code == 0) { 571 break; 572 } 573 } 574 575 int h = count * _charset->getFontHeight(); 576 h += _charset->getFontHeight() / 2; 577 subtitlePos.y = _string[0].ypos; 578 if (subtitlePos.y + h > _screenHeight - 10) { 579 subtitlePos.y = _screenHeight - 10 - h; 580 } 581 if (subtitlePos.y < 10) { 582 subtitlePos.y = 10; 583 } 584 585 for (int i = 0; i < count; ++i) { 586 subtitlePos.x = _string[0].xpos; 587 if (_string[0].center) { 588 if (subtitlePos.x + maxLineWidth / 2 > _screenWidth - 10) { 589 subtitlePos.x = _screenWidth - 10 - maxLineWidth / 2; 590 } 591 if (subtitlePos.x - maxLineWidth / 2 < 10) { 592 subtitlePos.x = 10 + maxLineWidth / 2; 593 } 594 subtitlePos.x -= substring[i].w / 2; 595 } else { 596 if (subtitlePos.x + maxLineWidth > _screenWidth - 10) { 597 subtitlePos.x = _screenWidth - 10 - maxLineWidth; 598 } 599 if (subtitlePos.x - maxLineWidth < 10) { 600 subtitlePos.x = 10; 601 } 602 } 603 if (subtitlePos.y < _screenHeight - 10) { 604 ((ScummEngine_v7 *)this)->addSubtitleToQueue(subtitleBuffer + substring[i].pos, subtitlePos, _charsetColor, _charset->getCurID()); 605 } 606 subtitlePos.y += _charset->getFontHeight(); 607 } 608 } else { 609 int code = 0; 610 subtitlePos.y = _string[0].ypos; 611 if (subtitlePos.y < 10) { 612 subtitlePos.y = 10; 613 } 614 while (handleNextCharsetCode(a, &code)) { 615 if (code == 13 || code == 0) { 616 subtitlePos.x = _string[0].xpos; 617 if (_string[0].center) { 618 subtitlePos.x -= _charset->getStringWidth(0, subtitleBuffer) / 2; 619 } 620 if (subtitlePos.x < 10) { 621 subtitlePos.x = 10; 622 } 623 if (subtitlePos.y < _screenHeight - 10) { 624 ((ScummEngine_v7 *)this)->addSubtitleToQueue(subtitleBuffer, subtitlePos, _charsetColor, _charset->getCurID()); 625 subtitlePos.y += _charset->getFontHeight(); 626 } 627 subtitleLine = subtitleBuffer; 628 } else { 629 *subtitleLine++ = code; 630 } 631 *subtitleLine = '\0'; 632 if (code == 0) { 633 break; 634 } 635 } 636 } 637 _haveMsg = 2; 638 _keepText = false; 639 _string[0] = saveStr; 640 return; 641 } 642 525 643 if (_game.version > 3) { 526 644 int maxwidth = _charset->_right - _string[0].xpos - 1; 527 645 if (_charset->_center) { … … 539 657 _nextLeft = 0; 540 658 } 541 659 542 _charset->_disableOffsX = _charset->_firstChar = !_keepText;543 544 660 int c = 0; 545 661 while (handleNextCharsetCode(a, &c)) { 546 662 if (c == 0) { -
scumm/scumm.h
243 243 bool center; 244 244 bool overhead; 245 245 bool no_talk_anim; 246 bool wrapping; 246 247 }; 247 248 248 249 struct StringTab : StringSlot { -
scumm/charset.cpp
348 348 return width; 349 349 } 350 350 351 int CharsetRenderer::getStringHeight(const byte *text) { 352 int pos = 0; 353 int height = 0; 354 byte chr; 355 int oldID = getCurID(); 356 357 while ((chr = text[pos++]) != 0) { 358 if (chr == '\n' || chr == '\r') 359 break; 360 if (chr == '@') 361 continue; 362 if (chr == 255 || (_vm->_game.version <= 6 && chr == 254)) { 363 chr = text[pos++]; 364 if (chr == 3) { // 'WAIT' 365 height += getFontHeight(); 366 break; 367 } 368 if (chr == 10 || chr == 21 || chr == 12 || chr == 13) { 369 pos += 2; 370 continue; 371 } 372 if (chr == 9 || chr == 1 || chr == 2) { // 'Newline' 373 height += getFontHeight(); 374 continue; 375 } 376 if (chr == 14) { 377 int set = text[pos] | (text[pos + 1] << 8); 378 pos += 2; 379 setCurID(set); 380 continue; 381 } 382 } 383 } 384 385 setCurID(oldID); 386 return height + getFontHeight(); 387 } 388 351 389 void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) { 352 390 int lastspace = -1; 353 391 int curw = 1; -
scumm/script_v8.cpp
488 488 _string[m].charset = pop(); 489 489 break; 490 490 case 0xCE: // SO_PRINT_LEFT 491 _string[m]. center= false;491 _string[m].wrapping = false; 492 492 _string[m].overhead = false; 493 493 break; 494 494 case 0xCF: // SO_PRINT_OVERHEAD … … 503 503 _scriptPointer += resStrLen(_scriptPointer) + 1; 504 504 break; 505 505 case 0xD2: // SO_PRINT_WRAP Set print wordwrap 506 //debug(0, "decodeParseString: SO_PRINT_WRAP"); 506 _string[m].wrapping = true; 507 _string[m].overhead = false; 507 508 break; 508 509 default: 509 510 error("decodeParseString: default case 0x%x", b);