aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMatthew Stewart2018-05-19 21:59:11 -0400
committerEugene Sandulenko2018-08-09 08:37:30 +0200
commit66b4ec36bdfb19a5242325e58c3180bc79574c89 (patch)
treeec72997bbb14cbf1eca06ae5b9ecd7a41795ddad /engines
parenta6bee58f62f3d7d696c6b5493f248390d5c303ac (diff)
downloadscummvm-rg350-66b4ec36bdfb19a5242325e58c3180bc79574c89.tar.gz
scummvm-rg350-66b4ec36bdfb19a5242325e58c3180bc79574c89.tar.bz2
scummvm-rg350-66b4ec36bdfb19a5242325e58c3180bc79574c89.zip
STARTREK: Cleanup some text code
Diffstat (limited to 'engines')
-rw-r--r--engines/startrek/awaymission.cpp7
-rw-r--r--engines/startrek/menu.cpp4
-rw-r--r--engines/startrek/startrek.h6
-rw-r--r--engines/startrek/text.cpp47
4 files changed, 36 insertions, 28 deletions
diff --git a/engines/startrek/awaymission.cpp b/engines/startrek/awaymission.cpp
index ec931bb735..16d4591304 100644
--- a/engines/startrek/awaymission.cpp
+++ b/engines/startrek/awaymission.cpp
@@ -31,7 +31,7 @@ void StarTrekEngine::initAwayMission() {
// memset(bitmapBuffer->pixels, 0, 0xfa00);
_txtFilename = "ground";
- _itemDescription = "";
+ _loadedText = "";
// sub_23a60(); // TODO
_sound->loadMusicFile("ground");
@@ -425,6 +425,11 @@ void StarTrekEngine::handleAwayMissionCommand() {
else {
if (command.action.activeObject == OBJECT_REDSHIRT)
showTextbox("", getItemDescription(0x4c), 20, 20, TEXTCOLOR_YELLOW, 0);
+
+ // Show generic "nothing of note" text.
+ // BUG? This text is also shown after looking at the redshirt. However, his
+ // text is normally overridden on a per-mission basis, so perhaps this bug
+ // never manifests itself?
showTextbox("", getItemDescription(0x4d), 20, 20, TEXTCOLOR_YELLOW, 0);
}
break;
diff --git a/engines/startrek/menu.cpp b/engines/startrek/menu.cpp
index 37ab57bc6d..b0aea1f284 100644
--- a/engines/startrek/menu.cpp
+++ b/engines/startrek/menu.cpp
@@ -839,7 +839,7 @@ void StarTrekEngine::showQuitGamePrompt(int x, int y) {
return;
_inQuitGameMenu = true;
- int val = showText(&StarTrekEngine::readTextFromArray, (uintptr)options, x, y, 0xb0, true, 0, 1);
+ int val = showText(&StarTrekEngine::readTextFromArray, (uintptr)options, x, y, TEXTCOLOR_YELLOW, true, 0, true);
_inQuitGameMenu = false;
if (val == 0) {
@@ -863,7 +863,7 @@ void StarTrekEngine::showTextConfigurationMenu(bool fromOptionMenu) {
int val;
if (fromOptionMenu || (val = loadTextDisplayMode()) == -1) {
- val = showText(&StarTrekEngine::readTextFromArray, (uintptr)options, 20, 30, 0xb0, true, 0, 1);
+ val = showText(&StarTrekEngine::readTextFromArray, (uintptr)options, 20, 30, TEXTCOLOR_YELLOW, true, 0, true);
saveTextDisplayMode(val);
}
diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h
index 9689c04ef8..5301f4d7c1 100644
--- a/engines/startrek/startrek.h
+++ b/engines/startrek/startrek.h
@@ -317,12 +317,12 @@ public:
String readTextFromRdf(int choiceIndex, uintptr data, String *headerTextOutput);
String readTextFromBuffer(int choiceIndex, uintptr data, String *headerTextOutput);
- int showTextbox(String headerText, const String &mainText, int xoffset, int yoffset, byte textColor, int maxTextLines); // TODO: better name. (return type?)
+ void showTextbox(String headerText, const String &mainText, int xoffset, int yoffset, byte textColor, int maxTextLines); // TODO: better name. (return type?)
String skipTextAudioPrompt(const String &str);
String playTextAudio(const String &str);
- int showText(TextGetterFunc textGetter, uintptr var, int xoffset, int yoffset, int textColor, bool loopChoices, int maxTextLines, int arg10);
+ int showText(TextGetterFunc textGetter, uintptr var, int xoffset, int yoffset, int textColor, bool loopChoices, int maxTextLines, bool rclickCancelsChoice);
int getNumTextboxLines(const String &str);
String putTextIntoLines(const String &text);
@@ -403,7 +403,7 @@ public:
int32 _playerActorScale;
Common::String _txtFilename;
- Common::String _itemDescription;
+ Common::String _loadedText; // TODO: might be OK to delete this
// Queue of "commands" (ie. next frame, clicked on object) for away mission or bridge
Common::Queue<Command> _commandQueue;
diff --git a/engines/startrek/text.cpp b/engines/startrek/text.cpp
index 217bd7feb7..11602bf60e 100644
--- a/engines/startrek/text.cpp
+++ b/engines/startrek/text.cpp
@@ -40,7 +40,6 @@ const char *StarTrekEngine::getNextTextLine(const char *text, char *lineOutput,
const char *lastSpaceInput = nullptr;
char *lastSpaceOutput = nullptr;
- int var4;
int charIndex = 0;
while (charIndex != lineWidth && *text != '\0') {
@@ -52,7 +51,6 @@ const char *StarTrekEngine::getNextTextLine(const char *text, char *lineOutput,
}
if (c == ' ') {
- var4 = charIndex;
lastSpaceInput = text;
lastSpaceOutput = lineOutput;
}
@@ -132,13 +130,14 @@ String StarTrekEngine::readTextFromRdf(int choiceIndex, uintptr data, String *he
/**
* Shows text with the given header and main text.
*/
-int StarTrekEngine::showTextbox(String headerText, const String &mainText, int xoffset, int yoffset, byte textColor, int maxTextLines) {
+void 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);
+ int commandParam = (maxTextLines < 0 ? 0 : maxTextLines);
+
if (maxTextLines < 0)
maxTextLines = -maxTextLines;
@@ -151,11 +150,9 @@ int StarTrekEngine::showTextbox(String headerText, const String &mainText, int x
strings[1] = mainText.c_str();
strings[2] = "";
- showText(&StarTrekEngine::readTextFromArray, (uintptr)strings, xoffset, yoffset, textColor, false, maxTextLines, 0);
+ showText(&StarTrekEngine::readTextFromArray, (uintptr)strings, xoffset, yoffset, textColor, false, maxTextLines, false);
- // TODO
- // sub_15a77();
- // sub_14669(newMaxTextLines);
+ addCommand(Command(COMMAND_TALK, commandParam, 0, 0));
}
String StarTrekEngine::skipTextAudioPrompt(const String &str) {
@@ -199,12 +196,16 @@ String StarTrekEngine::playTextAudio(const String &str) {
return String(text+1);
}
-int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset, int yoffset, int textColor, bool loopChoices, int maxTextLines, int arg10) {
+/**
+ * @param rclickCancelsChoice If true, right-clicks return "-1" as choice instead of
+ * whetever was selected.
+ */
+int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset, int yoffset, int textColor, bool loopChoices, int maxTextLines, bool rclickCancelsChoice) {
int16 tmpTextDisplayMode = _textDisplayMode;
- uint32 var7c = 8;
- if (_frameIndex > _textboxVar2+1) {
- var7c = 0x10;
+ uint32 ticksUntilClickingEnabled = 8;
+ if (_frameIndex > _textboxVar2 + 1) {
+ ticksUntilClickingEnabled = 0x10;
}
int numChoicesWithNames = 0;
@@ -217,11 +218,11 @@ int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset
if (choiceText.empty())
break;
- int lines = getNumTextboxLines(choiceText);
+ int lines = getNumTextboxLines(skipTextAudioPrompt(choiceText));
if (lines > numTextboxLines)
numTextboxLines = lines;
- if (!speakerText.empty()) // Technically should check for nullptr
+ if (!speakerText.empty()) // FIXME: Technically should check for nullptr
numChoicesWithNames++;
numChoices++;
@@ -256,6 +257,8 @@ int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset
String lineFormattedText = readLineFormattedText(textGetter, var, choiceIndex, textBitmap, numTextboxLines, &numTextLines);
if (lineFormattedText.empty()) { // Technically should check for nullptr
+ _gfx->delSprite(&textboxSprite);
+
// TODO
}
else {
@@ -280,7 +283,7 @@ int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset
disableMenuButtons(1 << TEXTBUTTON_SCROLLUP); // Disable scroll up
- if (var7c == 0) { // Disable done button
+ if (ticksUntilClickingEnabled == 0) { // Disable done button
disableMenuButtons(1 << TEXTBUTTON_CONFIRM);
}
if (!loopChoices) { // Disable prev button
@@ -291,9 +294,9 @@ int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset
// Loop until text is done being displayed
while (!doneShowingText) {
- int textboxReturnCode = handleMenuEvents(var7c, true);
+ int textboxReturnCode = handleMenuEvents(ticksUntilClickingEnabled, true);
- if (var7c == 0) {
+ if (ticksUntilClickingEnabled == 0) {
enableMenuButtons(1 << TEXTBUTTON_CONFIRM);
}
@@ -301,9 +304,9 @@ int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset
case MENUEVENT_RCLICK_OFFBUTTON:
case MENUEVENT_RCLICK_ONBUTTON:
- if (var7c == 0) {
+ if (ticksUntilClickingEnabled == 0) {
doneShowingText = true;
- if (arg10)
+ if (rclickCancelsChoice)
choiceIndex = -1;
}
break;
@@ -411,6 +414,8 @@ reloadText:
default:
break;
}
+
+ ticksUntilClickingEnabled = 0;
}
_gfx->setMouseBitmap(oldMouseBitmap);
@@ -418,12 +423,10 @@ reloadText:
_mouseControllingShip = tmpMouseControllingShip;
unloadMenuButtons();
- textboxSprite.field16 = true;
- textboxSprite.bitmapChanged = true;
+ textboxSprite.dontDrawNextFrame();
_gfx->drawAllSprites();
_gfx->delSprite(&textboxSprite);
- // sub_272B4
}
_textboxVar2 = _frameIndex;