Ticket #3075: 1036707-2.diff
File 1036707-2.diff, 9.8 KB (added by , 17 years ago) |
---|
-
scumm/intern.h
972 972 virtual const char *getOpcodeDesc(byte i); 973 973 974 974 virtual void printString(int m, const byte *msg); 975 virtual void CHARSET_1(); 975 976 976 977 virtual void scummLoop_handleSaveLoad(); 977 978 -
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
73 73 virtual void drawChar(int chr, const Graphics::Surface &s, int x, int y) {} 74 74 75 75 int getStringWidth(int a, const byte *str); 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
437 437 if (getTalkingActor() != 0xFF) 438 438 a = derefActorSafe(getTalkingActor(), "CHARSET_1"); 439 439 440 if (a && _string[0].overhead != 0) {440 if (a && _string[0].overhead) { 441 441 int s; 442 442 443 443 _string[0].xpos = a->getPos().x - virtscr[0].xstart; … … 490 490 return; 491 491 492 492 if ((_game.version <= 6 && _haveMsg == 1) || 493 (_game.version == 7 && _haveMsg != 1) || 494 (_game.version == 8 && VAR(VAR_HAVE_MSG))) { 493 (_game.version == 7 && _haveMsg != 1)) { 495 494 496 495 if (_game.heversion >= 60) { 497 496 if (_sound->isSoundRunning(1) == 0) … … 644 643 #endif 645 644 } 646 645 646 #ifndef DISABLE_SCUMM_7_8 647 void ScummEngine_v8::CHARSET_1() { 648 byte subtitleBuffer[2048]; 649 byte *subtitleLine = subtitleBuffer; 650 Common::Point subtitlePos; 651 652 processSubtitleQueue(); 653 654 if (!_haveMsg) 655 return; 656 657 Actor *a = NULL; 658 if (getTalkingActor() != 0xFF) 659 a = derefActorSafe(getTalkingActor(), "CHARSET_1"); 660 661 StringTab saveStr = _string[0]; 662 if (a && _string[0].overhead) { 663 int s; 664 665 _string[0].xpos = a->getPos().x - virtscr[0].xstart; 666 s = a->_scalex * a->_talkPosX / 255; 667 _string[0].xpos += (a->_talkPosX - s) / 2 + s; 668 669 _string[0].ypos = a->getPos().y - a->getElevation() - _screenTop; 670 s = a->_scaley * a->_talkPosY / 255; 671 _string[0].ypos += (a->_talkPosY - s) / 2 + s; 672 } 673 674 _charset->setColor(_charsetColor); 675 676 if (a && a->_charset) 677 _charset->setCurID(a->_charset); 678 else 679 _charset->setCurID(_string[0].charset); 680 681 if (_talkDelay) 682 return; 683 684 if (VAR(VAR_HAVE_MSG)) { 685 if ((_sound->_sfxMode & 2) == 0) { 686 stopTalk(); 687 } 688 return; 689 } 690 691 if (a && !_string[0].no_talk_anim) { 692 a->runActorTalkScript(a->_talkStartFrame); 693 } 694 695 if (!_keepText) { 696 clearSubtitleQueue(); 697 _nextLeft = _string[0].xpos; 698 _nextTop = _string[0].ypos + _screenTop; 699 } 700 701 _charset->_disableOffsX = _charset->_firstChar = !_keepText; 702 703 _talkDelay = VAR(VAR_DEFAULT_TALK_DELAY); 704 for (int i = _charsetBufPos; _charsetBuffer[i]; ++i) { 705 _talkDelay += VAR(VAR_CHARINC); 706 } 707 708 if (_string[0].wrapping) { 709 _charset->addLinebreaks(0, _charsetBuffer, _charsetBufPos, _screenWidth - 20); 710 711 struct { int pos, w; } substring[10]; 712 int count = 0; 713 int maxLineWidth = 0; 714 int lastPos = 0; 715 int code = 0; 716 while (handleNextCharsetCode(a, &code)) { 717 if (code == 13 || code == 0) { 718 *subtitleLine++ = '\0'; 719 assert(count < 10); 720 substring[count].w = _charset->getStringWidth(0, subtitleBuffer + lastPos); 721 if (maxLineWidth < substring[count].w) { 722 maxLineWidth = substring[count].w; 723 } 724 substring[count].pos = lastPos; 725 ++count; 726 lastPos = subtitleLine - subtitleBuffer; 727 } else { 728 *subtitleLine++ = code; 729 *subtitleLine = '\0'; 730 } 731 if (code == 0) { 732 break; 733 } 734 } 735 736 int h = count * _charset->getFontHeight(); 737 h += _charset->getFontHeight() / 2; 738 subtitlePos.y = _string[0].ypos; 739 if (subtitlePos.y + h > _screenHeight - 10) { 740 subtitlePos.y = _screenHeight - 10 - h; 741 } 742 if (subtitlePos.y < 10) { 743 subtitlePos.y = 10; 744 } 745 746 for (int i = 0; i < count; ++i) { 747 subtitlePos.x = _string[0].xpos; 748 if (_string[0].center) { 749 if (subtitlePos.x + maxLineWidth / 2 > _screenWidth - 10) { 750 subtitlePos.x = _screenWidth - 10 - maxLineWidth / 2; 751 } 752 if (subtitlePos.x - maxLineWidth / 2 < 10) { 753 subtitlePos.x = 10 + maxLineWidth / 2; 754 } 755 subtitlePos.x -= substring[i].w / 2; 756 } else { 757 if (subtitlePos.x + maxLineWidth > _screenWidth - 10) { 758 subtitlePos.x = _screenWidth - 10 - maxLineWidth; 759 } 760 if (subtitlePos.x - maxLineWidth < 10) { 761 subtitlePos.x = 10; 762 } 763 } 764 if (subtitlePos.y < _screenHeight - 10) { 765 ((ScummEngine_v7 *)this)->addSubtitleToQueue(subtitleBuffer + substring[i].pos, subtitlePos, _charsetColor, _charset->getCurID()); 766 } 767 subtitlePos.y += _charset->getFontHeight(); 768 } 769 } else { 770 int code = 0; 771 subtitlePos.y = _string[0].ypos; 772 if (subtitlePos.y < 10) { 773 subtitlePos.y = 10; 774 } 775 while (handleNextCharsetCode(a, &code)) { 776 if (code == 13 || code == 0) { 777 subtitlePos.x = _string[0].xpos; 778 if (_string[0].center) { 779 subtitlePos.x -= _charset->getStringWidth(0, subtitleBuffer) / 2; 780 } 781 if (subtitlePos.x < 10) { 782 subtitlePos.x = 10; 783 } 784 if (subtitlePos.y < _screenHeight - 10) { 785 ((ScummEngine_v7 *)this)->addSubtitleToQueue(subtitleBuffer, subtitlePos, _charsetColor, _charset->getCurID()); 786 subtitlePos.y += _charset->getFontHeight(); 787 } 788 subtitleLine = subtitleBuffer; 789 } else { 790 *subtitleLine++ = code; 791 } 792 *subtitleLine = '\0'; 793 if (code == 0) { 794 break; 795 } 796 } 797 } 798 _haveMsg = 2; 799 _keepText = false; 800 _string[0] = saveStr; 801 } 802 #endif 803 647 804 void ScummEngine::drawString(int a, const byte *msg) { 648 805 byte buf[270]; 649 806 byte *space; -
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 { … … 1169 1170 virtual void printString(int m, const byte *msg); 1170 1171 1171 1172 virtual bool handleNextCharsetCode(Actor *a, int *c); 1172 v oid CHARSET_1();1173 virtual void CHARSET_1(); 1173 1174 void drawString(int a, const byte *msg); 1174 1175 void debugMessage(const byte *msg); 1175 1176 void showMessageDialog(const byte *msg); -
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/saveload.cpp
834 834 MKLINE(StringTab, _default.overhead, sleByte, VER(8)), 835 835 MKLINE(StringTab, no_talk_anim, sleByte, VER(8)), 836 836 MKLINE(StringTab, _default.no_talk_anim, sleByte, VER(8)), 837 MKLINE(StringTab, wrapping, sleByte, VER(71)), 838 MKLINE(StringTab, _default.wrapping, sleByte, VER(71)), 837 839 MKEND() 838 840 }; 839 841 -
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); -
scumm/saveload.h
47 47 * only saves/loads those which are valid for the version of the savegame 48 48 * which is being loaded/saved currently. 49 49 */ 50 #define CURRENT_VER 7 050 #define CURRENT_VER 71 51 51 52 52 /** 53 53 * An auxillary macro, used to specify savegame versions. We use this instead