MADS: Fixes for properly displaying the text of a message dialog

This commit is contained in:
Paul Gilbert 2014-04-04 09:35:18 -04:00
parent 366e6ae38f
commit 4639d37609
3 changed files with 21 additions and 12 deletions

View File

@ -43,6 +43,8 @@ void Dialog::save(MSurface *s) {
s->copyTo(_savedSurface,
Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height),
Common::Point());
_vm->_screen.copyRectToScreen(getBounds());
}
void Dialog::restore(MSurface *s) {
@ -50,6 +52,8 @@ void Dialog::restore(MSurface *s) {
_savedSurface->copyTo(s, _position);
delete _savedSurface;
_savedSurface = nullptr;
_vm->_screen.copyRectToScreen(getBounds());
}
}
@ -76,8 +80,6 @@ void Dialog::draw() {
drawContent(Common::Rect(_position.x + 2, _position.y + 2,
_position.x + _width - 2, _position.y + _height - 2), 0,
TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2);
_vm->_screen.copyRectToScreen(bounds);
}
void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte color2) {
@ -273,7 +275,7 @@ void TextDialog::draw() {
// Draw the text lines
int lineYp = _position.y + 5;
for (int lineNum = 0; lineNum < _numLines; ++lineNum) {
for (int lineNum = 0; lineNum <= _numLines; ++lineNum) {
if (_lineXp[lineNum] == -1) {
// Draw a line across the entire dialog
_vm->_screen.hLine(_position.x + 2,
@ -326,9 +328,14 @@ void TextDialog::show() {
draw();
_vm->_events->showCursor();
// Wait for mouse click
do {
_vm->_events->waitForNextFrame();
} while (!_vm->shouldQuit() && !_vm->_events->_mouseReleased);
// Allow the mouse release to be gobbled up
if (!_vm->shouldQuit())
_vm->_events->waitForNextFrame();
}
/*------------------------------------------------------------------------*/

View File

@ -141,7 +141,7 @@ int Font::writeString(MSurface *surface, const Common::String &msg, const Common
if (width > 0)
xEnd = MIN((int)surface->w, pt.x + width);
else
xEnd = surface->w - pt.x;
xEnd = surface->w;
int x = pt.x;
int y = pt.y;

View File

@ -125,9 +125,9 @@ bool DialogsNebular::show(int msgId) {
Common::String dialogText;
bool result = true;
bool centerFlag = false;
bool underlineFlag;
bool commandFlag;
bool crFlag;
bool underlineFlag = false;
bool commandFlag = false;
bool crFlag = false;
TextDialog *dialog = nullptr;
_dialogWidth = 17;
_capitalizationMode = kUppercase;
@ -136,11 +136,6 @@ bool DialogsNebular::show(int msgId) {
for (uint idx = 0; idx < msg.size(); ++idx) {
Common::String srcLine = msg[idx];
const char *srcP = srcLine.c_str();
dialogText = "";
commandFlag = false;
underlineFlag = false;
centerFlag = false;
crFlag = false;
// Loop through the text of the line
while (srcP < srcLine.c_str() + srcLine.size()) {
@ -226,6 +221,13 @@ bool DialogsNebular::show(int msgId) {
} else {
dialog->wordWrap(dialogText);
}
// Reset line processing flags in preparation for next line
dialogText = "";
commandFlag = false;
underlineFlag = false;
centerFlag = false;
crFlag = false;
}
if (!centerFlag)