[Scummvm-git-logs] scummvm master -> c9c784c2faed5f1c3889c03b52dde4e75e39b768
fracturehill
noreply at scummvm.org
Fri Aug 25 17:32:51 UTC 2023
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9754cc9b33 NANCY: Implement font id token in text
31f90a3015 NANCY: Implement EventFlagsCursorHS record type
dac3378729 NANCY: Implement HotMultiframeMultisceneCursorTypeSceneChange
3850da2c92 NANCY: Implement TextboxClear action record
c9c784c2fa NANCY: Clear textbox on every scene change
Commit: 9754cc9b337b65c0e72317aac26c55bc7e05d9fe
https://github.com/scummvm/scummvm/commit/9754cc9b337b65c0e72317aac26c55bc7e05d9fe
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-08-25T20:32:06+03:00
Commit Message:
NANCY: Implement font id token in text
Added logic for the <f#> token introduced in nancy5,
which selects which font to use when rendering the string.
Rewrote the hypertext handling to use StringTokenizer.
This makes the addition of new tokens much easier, while
also ensuring unimplemented tokens no longer crash the
engine.
Changed paths:
engines/nancy/ui/textbox.cpp
engines/nancy/ui/textbox.h
diff --git a/engines/nancy/ui/textbox.cpp b/engines/nancy/ui/textbox.cpp
index 35e0914ff14..fa6dd4c2900 100644
--- a/engines/nancy/ui/textbox.cpp
+++ b/engines/nancy/ui/textbox.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "common/tokenizer.h"
+
#include "engines/nancy/nancy.h"
#include "engines/nancy/graphics.h"
#include "engines/nancy/cursor.h"
@@ -33,15 +35,6 @@
namespace Nancy {
namespace UI {
-const char Textbox::_CCBeginToken[] = "<i>";
-const char Textbox::_CCEndToken[] = "<o>";
-const char Textbox::_colorBeginToken[] = "<c1>";
-const char Textbox::_colorEndToken[] = "<c0>";
-const char Textbox::_hotspotToken[] = "<h>";
-const char Textbox::_newLineToken[] = "<n>";
-const char Textbox::_tabToken[] = "<t>";
-const char Textbox::_telephoneEndToken[] = "<e>";
-
Textbox::Textbox() :
RenderObject(6),
_needsTextRedraw(false),
@@ -145,81 +138,99 @@ void Textbox::drawTextbox() {
_numLines = 0;
- const Font *font = g_nancy->_graphicsManager->getFont(_fontIDOverride == -1 ? tbox->conversationFontID : _fontIDOverride);
- const Font *highlightFont = g_nancy->_graphicsManager->getFont(tbox->highlightConversationFontID);
-
uint maxWidth = _fullSurface.w - tbox->maxWidthDifference - tbox->borderWidth - 2;
uint lineDist = tbox->lineHeight + tbox->lineHeight / 4;
for (uint lineID = 0; lineID < _textLines.size(); ++lineID) {
- Common::String currentLine = _textLines[lineID];
+ Common::String currentLine;
bool hasHotspot = false;
Rect hotspot;
+ Common::Queue<uint> colorTokens;
+ int fontID = _fontIDOverride;
+
+ // Token braces plus invalid characters that are known to appear in strings
+ Common::StringTokenizer tokenizer(_textLines[lineID], "<>\"");
+
+ Common::String curToken;
+ while(!tokenizer.empty()) {
+ curToken = tokenizer.nextToken();
+
+ if (curToken.size() <= 2) {
+ switch (curToken.firstChar()) {
+ case 'i' :
+ // CC begin
+ // fall through
+ case 'o' :
+ // CC end
+ // fall through
+ case 'e' :
+ // Telephone end
+ // Do nothing and just skip
+ continue;
+ case 'h' :
+ // Hotspot
+ if (hasHotspot) {
+ // Replace duplicate hotspot token with a newline to copy the original behavior
+ currentLine += '\n';
+ }
+ hasHotspot = true;
+ continue;
+ case 'n' :
+ // Newline
+ currentLine += '\n';
+ continue;
+ case 't' :
+ // Tab
+ currentLine += " ";
+ continue;
+ case 'c' :
+ // Color tokens
+ // We keep the positions of the color tokens in a queue
+ if (curToken.size() != 2) {
+ break;
+ }
- // Erase the begin and end tokens from the line
- uint32 newLinePos;
- while (newLinePos = currentLine.find(_CCBeginToken), newLinePos != String::npos) {
- currentLine.erase(newLinePos, ARRAYSIZE(_CCBeginToken) - 1);
- }
-
- while (newLinePos = currentLine.find(_CCEndToken), newLinePos != String::npos) {
- currentLine.erase(newLinePos, ARRAYSIZE(_CCEndToken) - 1);
- }
-
- // Replace every newline token with \n
- while (newLinePos = currentLine.find(_newLineToken), newLinePos != String::npos) {
- currentLine.replace(newLinePos, ARRAYSIZE(_newLineToken) - 1, "\n");
- }
-
- // Replace tab token with four spaces
- while (newLinePos = currentLine.find(_tabToken), newLinePos != String::npos) {
- currentLine.replace(newLinePos, ARRAYSIZE(_tabToken) - 1, " ");
- }
-
- // Simply remove telephone end token
- if (currentLine.hasSuffix(_telephoneEndToken)) {
- currentLine.erase(currentLine.size() - ARRAYSIZE(_telephoneEndToken) + 1, String::npos);
- }
-
- // Remove hotspot tokens and mark that we need to calculate the bounds
- // A single text line should only have one hotspot, but there's at least
- // one malformed line in TVD that breaks this
- uint32 hotspotPos, lastHotspotPos = 0;
- while (hotspotPos = currentLine.find(_hotspotToken), hotspotPos != String::npos) {
- currentLine.erase(hotspotPos, ARRAYSIZE(_hotspotToken) - 1);
-
- if (hasHotspot) {
- // Replace the second hotspot token with a newline to copy the original behavior
- // Maybe consider fixing the glitch instead of replicating it??
- currentLine.insertChar('\n', lastHotspotPos);
- }
+ if (curToken[1] == '0' && colorTokens.size() == 0) {
+ // Found a color end token ("c0") without a corresponding begin ("c1"),
+ // insert a fake one at the beginning of the queue to make the color logic work.
+ // This happens in nancy5's intro
+ colorTokens.push(0);
+ }
- hasHotspot = true;
- lastHotspotPos = hotspotPos;
- }
+ if (curToken[1] == '1' && colorTokens.size() % 2 == 1) {
+ // Found a color begin token ("c1") following another color begin token.
+ // This is invalid, so we just skip it
+ // This probably also happens somewhere
+ continue;
+ }
- // Scan for color begin and end tokens and keep their positions
- // in a queue. We do this last so the positions are accurate
- Common::Queue<uint> colorTokens;
- while (newLinePos = currentLine.find(_colorBeginToken), newLinePos != String::npos) {
- currentLine.erase(newLinePos, ARRAYSIZE(_colorBeginToken) - 1);
- colorTokens.push(newLinePos);
+ if (curToken[1] == '0' && colorTokens.size() % 2 == 0) {
+ // Found a color end token ("c0") following another color end token.
+ // This is invalid, so we just skip it
+ // This happens in nancy5's intro
+ continue;
+ }
+
+ colorTokens.push(currentLine.size());
+ continue;
+ case 'f' :
+ // Font token
+ // This selects a specific font ID for the current line
+ if (curToken.size() != 2) {
+ break;
+ }
- newLinePos = currentLine.find(_colorEndToken);
+ fontID = (int)Common::String(curToken[1]).asUint64();
- if (newLinePos != Common::String::npos) {
- currentLine.erase(newLinePos, ARRAYSIZE(_colorEndToken) - 1);
- } else {
- // If we find no color end token we assume the whole line needs to be colored
- newLinePos = currentLine.size();
+ continue;
+ }
}
- colorTokens.push(newLinePos);
- }
- // A closing color token may appear without an open one. This happens in nancy4's intro
- while (newLinePos = currentLine.find(_colorEndToken), newLinePos != String::npos) {
- currentLine.erase(newLinePos, ARRAYSIZE(_colorEndToken) - 1);
+ currentLine += curToken;
}
+
+ const Font *font = g_nancy->_graphicsManager->getFont(fontID == -1 ? tbox->conversationFontID : fontID);
+ const Font *highlightFont = g_nancy->_graphicsManager->getFont(tbox->highlightConversationFontID);
// Do word wrapping on the text, sans tokens
Array<Common::String> wrappedLines;
@@ -260,8 +271,14 @@ void Textbox::drawTextbox() {
if (totalCharsDrawn >= colorTokens.front()) {
// Token is at begginning of (what's left of) the current line
- isColor = !isColor;
- colorTokens.pop();
+ uint val = colorTokens.pop();
+
+ if (!colorTokens.empty() && colorTokens.front() == val) {
+ // Two tokens with the same position just get ignored
+ colorTokens.pop();
+ } else {
+ isColor = !isColor;
+ }
}
if (totalCharsDrawn < colorTokens.front() && colorTokens.front() < (totalCharsDrawn + line.size())) {
diff --git a/engines/nancy/ui/textbox.h b/engines/nancy/ui/textbox.h
index ee9ce9364cb..23bb982360a 100644
--- a/engines/nancy/ui/textbox.h
+++ b/engines/nancy/ui/textbox.h
@@ -78,15 +78,6 @@ private:
float _scrollbarPos;
int _fontIDOverride;
-
- static const char _CCBeginToken[];
- static const char _CCEndToken[];
- static const char _colorBeginToken[];
- static const char _colorEndToken[];
- static const char _hotspotToken[];
- static const char _newLineToken[];
- static const char _tabToken[];
- static const char _telephoneEndToken[];
};
} // End of namespace UI
Commit: 31f90a30151073cb5b893872e89f2187762fcafd
https://github.com/scummvm/scummvm/commit/31f90a30151073cb5b893872e89f2187762fcafd
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-08-25T20:32:06+03:00
Commit Message:
NANCY: Implement EventFlagsCursorHS record type
Changed paths:
engines/nancy/action/arfactory.cpp
engines/nancy/action/recordtypes.cpp
engines/nancy/action/recordtypes.h
diff --git a/engines/nancy/action/arfactory.cpp b/engines/nancy/action/arfactory.cpp
index 141d2289f87..a22b12c133b 100644
--- a/engines/nancy/action/arfactory.cpp
+++ b/engines/nancy/action/arfactory.cpp
@@ -119,6 +119,8 @@ ActionRecord *ActionManager::createActionRecord(uint16 type) {
return new TextBoxWrite();
case 76:
return new TextBoxClear();
+ case 99:
+ return new EventFlagsMultiHS(true);
case 100:
return new BumpPlayerClock();
case 101:
@@ -132,7 +134,7 @@ ActionRecord *ActionManager::createActionRecord(uint16 type) {
case 105:
return new StopTimer();
case 106:
- return new EventFlagsMultiHS();
+ return new EventFlagsMultiHS(false);
case 107:
return new EventFlags();
case 108:
diff --git a/engines/nancy/action/recordtypes.cpp b/engines/nancy/action/recordtypes.cpp
index dff33d64a22..e68eded2e3c 100644
--- a/engines/nancy/action/recordtypes.cpp
+++ b/engines/nancy/action/recordtypes.cpp
@@ -374,6 +374,11 @@ void EventFlags::execute() {
void EventFlagsMultiHS::readData(Common::SeekableReadStream &stream) {
EventFlags::readData(stream);
+
+ if (_isCursor) {
+ _hoverCursor = (CursorManager::CursorType)stream.readUint16LE();
+ }
+
uint16 numHotspots = stream.readUint16LE();
_hotspots.reserve(numHotspots);
diff --git a/engines/nancy/action/recordtypes.h b/engines/nancy/action/recordtypes.h
index 0700f3f4135..b457f0fdeba 100644
--- a/engines/nancy/action/recordtypes.h
+++ b/engines/nancy/action/recordtypes.h
@@ -304,14 +304,22 @@ protected:
class EventFlagsMultiHS : public EventFlags {
public:
+ EventFlagsMultiHS(bool isCursor) : _isCursor(isCursor) {}
+ virtual ~EventFlagsMultiHS() {}
+
void readData(Common::SeekableReadStream &stream) override;
void execute() override;
+ CursorManager::CursorType getHoverCursor() const override { return _hoverCursor; }
+
+ CursorManager::CursorType _hoverCursor = CursorManager::kHotspot;
Common::Array<HotspotDescription> _hotspots;
+ bool _isCursor;
+
protected:
bool canHaveHotspot() const override { return true; }
- Common::String getRecordTypeName() const override { return "EventFlagsMultiHS"; }
+ Common::String getRecordTypeName() const override { return _isCursor ? "EventFlagsCursorHS" : "EventFlagsMultiHS"; }
};
class LoseGame : public ActionRecord {
Commit: dac3378729b133d4d5e3471b533dc7747224b0b0
https://github.com/scummvm/scummvm/commit/dac3378729b133d4d5e3471b533dc7747224b0b0
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-08-25T20:32:06+03:00
Commit Message:
NANCY: Implement HotMultiframeMultisceneCursorTypeSceneChange
Implemented action record type which selects a scene based
on the item the player is currently holding. Yes, that's the
actual name the original devs used.
Changed paths:
engines/nancy/action/arfactory.cpp
engines/nancy/action/recordtypes.cpp
engines/nancy/action/recordtypes.h
diff --git a/engines/nancy/action/arfactory.cpp b/engines/nancy/action/arfactory.cpp
index a22b12c133b..0a0386b3e9f 100644
--- a/engines/nancy/action/arfactory.cpp
+++ b/engines/nancy/action/arfactory.cpp
@@ -84,6 +84,8 @@ ActionRecord *ActionManager::createActionRecord(uint16 type) {
return new Hot1FrSceneChange(CursorManager::kTurnLeft);
case 23:
return new Hot1FrSceneChange(CursorManager::kTurnRight);
+ case 24:
+ return new HotMultiframeMultisceneCursorTypeSceneChange();
case 40:
if (g_nancy->getGameType() < kGameTypeNancy2) {
// Only used in TVD
diff --git a/engines/nancy/action/recordtypes.cpp b/engines/nancy/action/recordtypes.cpp
index e68eded2e3c..40da417166e 100644
--- a/engines/nancy/action/recordtypes.cpp
+++ b/engines/nancy/action/recordtypes.cpp
@@ -167,6 +167,56 @@ void HotMultiframeMultisceneChange::execute() {
}
}
+void HotMultiframeMultisceneCursorTypeSceneChange::readData(Common::SeekableReadStream &stream) {
+ uint16 numScenes = stream.readUint16LE();
+ _scenes.resize(numScenes);
+ _cursorTypes.resize(numScenes);
+ for (uint i = 0; i < numScenes; ++i) {
+ _cursorTypes[i] = stream.readUint16LE();
+ _scenes[i].readData(stream);
+ }
+
+ stream.skip(2);
+ _defaultScene.readData(stream);
+
+ uint16 numHotspots = stream.readUint16LE();
+ _hotspots.resize(numHotspots);
+ for (uint i = 0; i < numHotspots; ++i) {
+ _hotspots[i].readData(stream);
+ }
+}
+
+void HotMultiframeMultisceneCursorTypeSceneChange::execute() {
+ switch (_state) {
+ case kBegin:
+ // turn main rendering on
+ _state = kRun;
+ // fall through
+ case kRun:
+ _hasHotspot = false;
+ for (uint i = 0; i < _hotspots.size(); ++i) {
+ if (_hotspots[i].frameID == NancySceneState.getSceneInfo().frameID) {
+ _hasHotspot = true;
+ _hotspot = _hotspots[i].coords;
+ }
+ }
+ break;
+ case kActionTrigger:
+ for (uint i = 0; i < _cursorTypes.size(); ++i) {
+ if (NancySceneState.getHeldItem() == _cursorTypes[i]) {
+ NancySceneState.changeScene(_scenes[i]);
+
+ _isDone = true;
+ return;
+ }
+ }
+
+ NancySceneState.changeScene(_defaultScene);
+ _isDone = true;
+ break;
+ }
+}
+
void PaletteThisScene::readData(Common::SeekableReadStream &stream) {
_paletteID = stream.readByte();
_unknownEnum = stream.readByte();
diff --git a/engines/nancy/action/recordtypes.h b/engines/nancy/action/recordtypes.h
index b457f0fdeba..162f552b7cf 100644
--- a/engines/nancy/action/recordtypes.h
+++ b/engines/nancy/action/recordtypes.h
@@ -128,6 +128,21 @@ protected:
Common::String getRecordTypeName() const override { return "HotMultiframeMultisceneChange"; }
};
+class HotMultiframeMultisceneCursorTypeSceneChange : public ActionRecord {
+public:
+ void readData(Common::SeekableReadStream &stream) override;
+ void execute() override;
+
+ Common::Array<SceneChangeDescription> _scenes;
+ Common::Array<uint16> _cursorTypes;
+
+ SceneChangeDescription _defaultScene;
+ Common::Array<HotspotDescription> _hotspots;
+
+protected:
+ Common::String getRecordTypeName() const override { return "HotMultiframeMultisceneCursorTypeSceneChange"; }
+};
+
class PaletteThisScene : public ActionRecord {
public:
void readData(Common::SeekableReadStream &stream) override;
Commit: 3850da2c92b21aa159cbaa89a529e6bce5119530
https://github.com/scummvm/scummvm/commit/3850da2c92b21aa159cbaa89a529e6bce5119530
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-08-25T20:32:06+03:00
Commit Message:
NANCY: Implement TextboxClear action record
Changed paths:
engines/nancy/action/arfactory.cpp
engines/nancy/action/recordtypes.cpp
engines/nancy/action/recordtypes.h
diff --git a/engines/nancy/action/arfactory.cpp b/engines/nancy/action/arfactory.cpp
index 0a0386b3e9f..e58d29af038 100644
--- a/engines/nancy/action/arfactory.cpp
+++ b/engines/nancy/action/arfactory.cpp
@@ -120,7 +120,7 @@ ActionRecord *ActionManager::createActionRecord(uint16 type) {
case 75:
return new TextBoxWrite();
case 76:
- return new TextBoxClear();
+ return new TextboxClear();
case 99:
return new EventFlagsMultiHS(true);
case 100:
diff --git a/engines/nancy/action/recordtypes.cpp b/engines/nancy/action/recordtypes.cpp
index 40da417166e..aba05d25f2b 100644
--- a/engines/nancy/action/recordtypes.cpp
+++ b/engines/nancy/action/recordtypes.cpp
@@ -363,10 +363,15 @@ void TextBoxWrite::execute() {
finishExecution();
}
-void TextBoxClear::readData(Common::SeekableReadStream &stream) {
+void TextboxClear::readData(Common::SeekableReadStream &stream) {
stream.skip(1);
}
+void TextboxClear::execute() {
+ NancySceneState.getTextbox().clear();
+ finishExecution();
+}
+
void BumpPlayerClock::readData(Common::SeekableReadStream &stream) {
_relative = stream.readByte();
_hours = stream.readUint16LE();
diff --git a/engines/nancy/action/recordtypes.h b/engines/nancy/action/recordtypes.h
index 162f552b7cf..607a9aa468c 100644
--- a/engines/nancy/action/recordtypes.h
+++ b/engines/nancy/action/recordtypes.h
@@ -242,12 +242,13 @@ protected:
Common::String getRecordTypeName() const override { return "TextBoxWrite"; }
};
-class TextBoxClear : public Unimplemented {
+class TextboxClear : public ActionRecord {
public:
void readData(Common::SeekableReadStream &stream) override;
+ void execute() override;
protected:
- Common::String getRecordTypeName() const override { return "TextBoxClear"; }
+ Common::String getRecordTypeName() const override { return "TextboxClear"; }
};
class BumpPlayerClock : public ActionRecord {
Commit: c9c784c2faed5f1c3889c03b52dde4e75e39b768
https://github.com/scummvm/scummvm/commit/c9c784c2faed5f1c3889c03b52dde4e75e39b768
Author: Kaloyan Chehlarski (strahy at outlook.com)
Date: 2023-08-25T20:32:06+03:00
Commit Message:
NANCY: Clear textbox on every scene change
The previous design, where the textbox kept its contents
unless it was explicitly cleared, was probably a leftover
from the early days of the engine, though I honestly can't
remember.
Changed paths:
engines/nancy/action/conversation.cpp
engines/nancy/action/recordtypes.cpp
engines/nancy/action/recordtypes.h
engines/nancy/action/riddlepuzzle.cpp
engines/nancy/action/telephone.cpp
engines/nancy/state/scene.cpp
engines/nancy/state/scene.h
engines/nancy/ui/textbox.cpp
diff --git a/engines/nancy/action/conversation.cpp b/engines/nancy/action/conversation.cpp
index 4db170e4ecd..1d5684d5d79 100644
--- a/engines/nancy/action/conversation.cpp
+++ b/engines/nancy/action/conversation.cpp
@@ -47,14 +47,10 @@ ConversationSound::~ConversationSound() {
if (NancySceneState.getActiveConversation() == this) {
NancySceneState.setActiveConversation(nullptr);
}
-
- NancySceneState.setShouldClearTextbox(true);
- NancySceneState.getTextbox().setVisible(false);
}
void ConversationSound::init() {
RenderObject::init();
- NancySceneState.setShouldClearTextbox(false);
}
void ConversationSound::readData(Common::SeekableReadStream &stream) {
diff --git a/engines/nancy/action/recordtypes.cpp b/engines/nancy/action/recordtypes.cpp
index aba05d25f2b..66ede04956f 100644
--- a/engines/nancy/action/recordtypes.cpp
+++ b/engines/nancy/action/recordtypes.cpp
@@ -348,18 +348,12 @@ void TextBoxWrite::readData(Common::SeekableReadStream &stream) {
delete[] buf;
}
-TextBoxWrite::~TextBoxWrite() {
- NancySceneState.setShouldClearTextbox(true);
- NancySceneState.getTextbox().setVisible(false);
-}
-
void TextBoxWrite::execute() {
auto &tb = NancySceneState.getTextbox();
tb.clear();
tb.overrideFontID(g_nancy->_textboxData->defaultFontID);
tb.addTextLine(_text);
tb.setVisible(true);
- NancySceneState.setShouldClearTextbox(false);
finishExecution();
}
@@ -680,6 +674,7 @@ void PlayDigiSoundCC::readData(Common::SeekableReadStream &stream) {
void PlayDigiSoundCC::execute() {
if (_state == kBegin) {
+ NancySceneState.getTextbox().clear();
NancySceneState.getTextbox().addTextLine(_ccText);
}
PlayDigiSoundAndDie::execute();
diff --git a/engines/nancy/action/recordtypes.h b/engines/nancy/action/recordtypes.h
index 607a9aa468c..035bd82ce61 100644
--- a/engines/nancy/action/recordtypes.h
+++ b/engines/nancy/action/recordtypes.h
@@ -231,8 +231,6 @@ protected:
class TextBoxWrite : public ActionRecord {
public:
- virtual ~TextBoxWrite();
-
void readData(Common::SeekableReadStream &stream) override;
void execute() override;
diff --git a/engines/nancy/action/riddlepuzzle.cpp b/engines/nancy/action/riddlepuzzle.cpp
index d683ed2b161..08485f3d8f7 100644
--- a/engines/nancy/action/riddlepuzzle.cpp
+++ b/engines/nancy/action/riddlepuzzle.cpp
@@ -134,7 +134,6 @@ void RiddlePuzzle::execute() {
NancySceneState.getTextbox().clear();
NancySceneState.getTextbox().overrideFontID(_textboxTextFontID);
NancySceneState.getTextbox().addTextLine(_riddles[_riddleID].text);
- NancySceneState.setShouldClearTextbox(false);
_state = kRun;
}
@@ -257,7 +256,6 @@ void RiddlePuzzle::execute() {
sceneChange->execute();
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
- NancySceneState.setShouldClearTextbox(true);
finishExecution();
}
}
diff --git a/engines/nancy/action/telephone.cpp b/engines/nancy/action/telephone.cpp
index 1e63f72696d..5bda6b9e029 100644
--- a/engines/nancy/action/telephone.cpp
+++ b/engines/nancy/action/telephone.cpp
@@ -40,8 +40,6 @@ void Telephone::init() {
setTransparent(true);
g_nancy->_resource->loadImage(_imageName, _image);
-
- NancySceneState.setShouldClearTextbox(false);
}
void Telephone::readData(Common::SeekableReadStream &stream) {
@@ -222,8 +220,6 @@ void Telephone::execute() {
}
finishExecution();
- NancySceneState.setShouldClearTextbox(true);
- NancySceneState.getTextbox().clear();
}
}
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 6f755a712bb..6ace33407a2 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -408,8 +408,6 @@ void Scene::registerGraphics() {
if (_clock) {
_clock->registerGraphics();
}
-
- _textbox.setVisible(!_shouldClearTextbox);
}
void Scene::synchronize(Common::Serializer &ser) {
@@ -917,6 +915,8 @@ void Scene::clearSceneData() {
if (_lightning) {
_lightning->endLightning();
}
+
+ _textbox.clear();
}
void Scene::clearPuzzleData() {
diff --git a/engines/nancy/state/scene.h b/engines/nancy/state/scene.h
index 0d63cd330a7..026a8bf643c 100644
--- a/engines/nancy/state/scene.h
+++ b/engines/nancy/state/scene.h
@@ -164,8 +164,6 @@ public:
void synchronize(Common::Serializer &serializer);
- void setShouldClearTextbox(bool shouldClear) { _shouldClearTextbox = shouldClear; }
-
UI::FullScreenImage &getFrame() { return _frame; }
UI::Viewport &getViewport() { return _viewport; }
UI::Textbox &getTextbox() { return _textbox; }
@@ -277,8 +275,6 @@ private:
Action::ConversationSound *_activeConversation;
State _state;
-
- bool _shouldClearTextbox = true;
};
#define NancySceneState Nancy::State::Scene::instance()
diff --git a/engines/nancy/ui/textbox.cpp b/engines/nancy/ui/textbox.cpp
index fa6dd4c2900..8be10bb5457 100644
--- a/engines/nancy/ui/textbox.cpp
+++ b/engines/nancy/ui/textbox.cpp
@@ -346,15 +346,17 @@ void Textbox::drawTextbox() {
}
void Textbox::clear() {
- _fullSurface.clear();
- _textHighlightSurface.clear(_textHighlightSurface.getTransparentColor());
- _textLines.clear();
- _hotspots.clear();
- _scrollbar->resetPosition();
- _numLines = 0;
- _fontIDOverride = -1;
- onScrollbarMove();
- _needsRedraw = true;
+ if (_textLines.size()) {
+ _fullSurface.clear();
+ _textHighlightSurface.clear(_textHighlightSurface.getTransparentColor());
+ _textLines.clear();
+ _hotspots.clear();
+ _scrollbar->resetPosition();
+ _numLines = 0;
+ _fontIDOverride = -1;
+ onScrollbarMove();
+ _needsRedraw = true;
+ }
}
void Textbox::addTextLine(const Common::String &text) {
More information about the Scummvm-git-logs
mailing list