diff options
author | Matthew Stewart | 2018-05-19 21:15:13 -0400 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-09 08:37:30 +0200 |
commit | a6bee58f62f3d7d696c6b5493f248390d5c303ac (patch) | |
tree | b64fdb3711fdfff7ead9068c9edf76ed57c8bbdf /engines/startrek/text.cpp | |
parent | f66b77d9fd34e4845a214e1c1ff42e5e2211c991 (diff) | |
download | scummvm-rg350-a6bee58f62f3d7d696c6b5493f248390d5c303ac.tar.gz scummvm-rg350-a6bee58f62f3d7d696c6b5493f248390d5c303ac.tar.bz2 scummvm-rg350-a6bee58f62f3d7d696c6b5493f248390d5c303ac.zip |
STARTREK: Default behaviour for look action
Diffstat (limited to 'engines/startrek/text.cpp')
-rw-r--r-- | engines/startrek/text.cpp | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/engines/startrek/text.cpp b/engines/startrek/text.cpp index 04b40bfee2..217bd7feb7 100644 --- a/engines/startrek/text.cpp +++ b/engines/startrek/text.cpp @@ -130,17 +130,32 @@ String StarTrekEngine::readTextFromRdf(int choiceIndex, uintptr data, String *he } /** - * Text getter for showText which reads from a given buffer. + * Shows text with the given header and main text. */ -String StarTrekEngine::readTextFromBuffer(int choiceIndex, uintptr data, String *headerTextOutput) { - char buf[TEXTBOX_WIDTH]; - memcpy(buf, (byte*)data, TEXTBOX_WIDTH-2); - buf[TEXTBOX_WIDTH-2] = '\0'; +int StarTrekEngine::showTextbox(String headerText, const String &mainText, int xoffset, int yoffset, byte textColor, int maxTextLines) { + if (!headerText.empty()) { + while (headerText.size() < TEXTBOX_WIDTH - 2) + headerText += ' '; + } + + int newMaxTextLines = (maxTextLines < 0 ? 0 : maxTextLines); + if (maxTextLines < 0) + maxTextLines = -maxTextLines; - *headerTextOutput = String(buf); + const char *strings[3]; + + if (headerText.empty()) + strings[0] = nullptr; + else + strings[0] = headerText.c_str(); + strings[1] = mainText.c_str(); + strings[2] = ""; - char *text = (char*)data+TEXTBOX_WIDTH-2; - return String(text); + showText(&StarTrekEngine::readTextFromArray, (uintptr)strings, xoffset, yoffset, textColor, false, maxTextLines, 0); + + // TODO + // sub_15a77(); + // sub_14669(newMaxTextLines); } String StarTrekEngine::skipTextAudioPrompt(const String &str) { @@ -587,8 +602,7 @@ String StarTrekEngine::readLineFormattedText(TextGetterFunc textGetter, uintptr String lineFormattedText = putTextIntoLines(text); drawMainText(textBitmap, *numTextLines, numTextboxLines, lineFormattedText, hasHeader); - assert(headerText.size() == TEXTBOX_WIDTH-2); - memcpy(textBitmap->pixels+TEXTBOX_WIDTH+1, headerText.c_str(), TEXTBOX_WIDTH-2); + memcpy(textBitmap->pixels+TEXTBOX_WIDTH+1, headerText.c_str(), headerText.size()); return lineFormattedText; } @@ -627,9 +641,13 @@ String StarTrekEngine::readTextFromArray(int choiceIndex, uintptr data, String * if (*mainText == '\0') return Common::String(); // Technically should be nullptr... - *headerTextOutput = headerText; - while (headerTextOutput->size() < TEXTBOX_WIDTH-2) - *headerTextOutput += ' '; + if (headerText == nullptr) + *headerTextOutput = ""; + else { + *headerTextOutput = headerText; + while (headerTextOutput->size() < TEXTBOX_WIDTH-2) + *headerTextOutput += ' '; + } return String(mainText); } |