NANCY: Set correct default textbox font

Modified the Textbox code so the conversation font is no
longer the default, but rather has to be requested by
Conversation types. This fixes the nancy6 tutorial having
a blue highlighted text while explicitly needing red.
This commit is contained in:
Kaloyan Chehlarski 2023-09-20 00:50:32 +03:00
parent 29b8052958
commit 09a21ad755
6 changed files with 9 additions and 8 deletions

@ -169,7 +169,10 @@ void ConversationSound::execute() {
case kRun:
if (!_hasDrawnTextbox) {
_hasDrawnTextbox = true;
const TBOX *textboxData = (const TBOX *)g_nancy->getEngineData("TBOX");
assert(textboxData);
NancySceneState.getTextbox().clear();
NancySceneState.getTextbox().setOverrideFont(textboxData->conversationFontID);
if (ConfMan.getBool("subtitles")) {
NancySceneState.getTextbox().addTextLine(_text);

@ -113,9 +113,6 @@ void TextBoxWrite::readData(Common::SeekableReadStream &stream) {
void TextBoxWrite::execute() {
auto &tb = NancySceneState.getTextbox();
tb.clear();
const TBOX *textboxData = (const TBOX *)g_nancy->getEngineData("TBOX");
assert(textboxData);
tb.overrideFontID(textboxData->defaultFontID);
tb.addTextLine(_text);
tb.setVisible(true);
finishExecution();

@ -132,7 +132,7 @@ void RiddlePuzzle::execute() {
g_nancy->_sound->loadSound(_riddles[_riddleID].sound);
g_nancy->_sound->playSound(_riddles[_riddleID].sound);
NancySceneState.getTextbox().clear();
NancySceneState.getTextbox().overrideFontID(_textboxTextFontID);
NancySceneState.getTextbox().setOverrideFont(_textboxTextFontID);
NancySceneState.getTextbox().addTextLine(_riddles[_riddleID].text);
_state = kRun;

@ -131,7 +131,8 @@ void HypertextParser::drawAllText(const Common::Rect &textBounds, uint fontID, u
font = g_nancy->_graphicsManager->getFont(curFontID);
highlightFont = g_nancy->_graphicsManager->getFont(highlightFontID);
// Do word wrapping on the text, sans tokens
// Do word wrapping on the text, sans tokens. This assumes
// all text uses fonts of the same width
Array<Common::String> wrappedLines;
font->wordWrap(currentLine, textBounds.width(), wrappedLines, 0);

@ -145,7 +145,7 @@ void Textbox::drawTextbox() {
textBounds.right -= tbox->rightOffset;
HypertextParser::drawAllText( textBounds, // bounds of text within full surface
_fontIDOverride != -1 ? _fontIDOverride : tbox->conversationFontID, // font for basic text
_fontIDOverride != -1 ? _fontIDOverride : tbox->defaultFontID, // font for basic text
tbox->highlightConversationFontID); // font for highlight text
setVisible(true);
@ -172,7 +172,7 @@ void Textbox::addTextLine(const Common::String &text, uint32 autoClearTime) {
}
}
void Textbox::overrideFontID(const uint fontID) {
void Textbox::setOverrideFont(const uint fontID) {
const BSUM *bsum = (const BSUM *)g_nancy->getEngineData("BSUM");
assert(bsum);

@ -49,7 +49,7 @@ public:
void clear() override;
void addTextLine(const Common::String &text, uint32 autoClearTime = 0);
void overrideFontID(const uint fontID);
void setOverrideFont(const uint fontID);
private:
uint16 getInnerHeight() const;