From af289bdb03d7f0a5e8f01c03e462f230835e0077 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Thu, 16 Jul 2009 17:29:31 +0000 Subject: Fixed bug 2820514 ("Help dialog causes crash") svn-id: r42537 --- engines/scumm/dialogs.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'engines/scumm/dialogs.cpp') diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 9fb107f9fc..54ade5b7ca 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -641,6 +641,8 @@ HelpDialog::HelpDialog(const GameSettings &game) new GUI::ButtonWidget(this, "ScummHelp.Close", "Close", kCloseCmd, 'C'); _prevButton->clearFlags(WIDGET_ENABLED); + _numLines = HELP_NUM_LINES; + // Dummy entries for (int i = 0; i < HELP_NUM_LINES; i++) { _key[i] = new StaticTextWidget(this, 0, 0, 10, 10, "", Graphics::kTextAlignRight); @@ -658,15 +660,20 @@ void HelpDialog::reflowLayout() { g_gui.xmlEval()->getWidgetData("ScummHelp.HelpText", x, y, w, h); + /* Make sure than we don't have more lines than what we can fit + * on the space that the layout reserves for text */ + _numLines = MIN(HELP_NUM_LINES, (int)(h / lineHeight)); + + int keyW = w * 20 / 100; int dscX = x + keyW + 32; int dscW = w * 80 / 100; int xoff = (_w >> 1) - (w >> 1); - for (int i = 0; i < HELP_NUM_LINES; i++) { - _key[i]->resize(xoff + x, y + lineHeight * i, keyW, lineHeight + 2); - _dsc[i]->resize(xoff + dscX, y + lineHeight * i, dscW, lineHeight + 2); + for (int i = 0; i < _numLines; i++) { + _key[i]->resize(xoff + x, y + lineHeight * i, keyW, lineHeight); + _dsc[i]->resize(xoff + dscX, y + lineHeight * i, dscW, lineHeight); } displayKeyBindings(); @@ -675,6 +682,7 @@ void HelpDialog::reflowLayout() { void HelpDialog::displayKeyBindings() { String titleStr, *keyStr, *dscStr; + int i; #ifndef __DS__ ScummHelp::updateStrings(_game.id, _game.version, _game.platform, _page, titleStr, keyStr, dscStr); @@ -684,7 +692,7 @@ void HelpDialog::displayKeyBindings() { #endif _title->setLabel(titleStr); - for (int i = 0; i < HELP_NUM_LINES; i++) { + for (i = 0; i < _numLines; i++) { _key[i]->setLabel(keyStr[i]); _dsc[i]->setLabel(dscStr[i]); } -- cgit v1.2.3 From 2422ee06a25a82ce5367a2c36cb72422f61343e8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 16 Jul 2009 17:39:16 +0000 Subject: Formatting fixes. svn-id: r42538 --- engines/scumm/dialogs.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'engines/scumm/dialogs.cpp') diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 54ade5b7ca..9d3ba527c4 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -660,11 +660,10 @@ void HelpDialog::reflowLayout() { g_gui.xmlEval()->getWidgetData("ScummHelp.HelpText", x, y, w, h); - /* Make sure than we don't have more lines than what we can fit - * on the space that the layout reserves for text */ + // Make sure than we don't have more lines than what we can fit + // on the space that the layout reserves for text _numLines = MIN(HELP_NUM_LINES, (int)(h / lineHeight)); - int keyW = w * 20 / 100; int dscX = x + keyW + 32; int dscW = w * 80 / 100; @@ -680,9 +679,7 @@ void HelpDialog::reflowLayout() { } void HelpDialog::displayKeyBindings() { - String titleStr, *keyStr, *dscStr; - int i; #ifndef __DS__ ScummHelp::updateStrings(_game.id, _game.version, _game.platform, _page, titleStr, keyStr, dscStr); @@ -692,7 +689,7 @@ void HelpDialog::displayKeyBindings() { #endif _title->setLabel(titleStr); - for (i = 0; i < _numLines; i++) { + for (int i = 0; i < _numLines; i++) { _key[i]->setLabel(keyStr[i]); _dsc[i]->setLabel(dscStr[i]); } -- cgit v1.2.3 From 1e3beb40c04ef323f5354e4258659764735fdb0c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 16 Jul 2009 17:44:05 +0000 Subject: This commit is just for DrMcCoy. (forgot to fix two usages of whitespaces instead of tabs for indentation -.-) svn-id: r42539 --- engines/scumm/dialogs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/scumm/dialogs.cpp') diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 9d3ba527c4..880fab04a5 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -641,7 +641,7 @@ HelpDialog::HelpDialog(const GameSettings &game) new GUI::ButtonWidget(this, "ScummHelp.Close", "Close", kCloseCmd, 'C'); _prevButton->clearFlags(WIDGET_ENABLED); - _numLines = HELP_NUM_LINES; + _numLines = HELP_NUM_LINES; // Dummy entries for (int i = 0; i < HELP_NUM_LINES; i++) { @@ -662,7 +662,7 @@ void HelpDialog::reflowLayout() { // Make sure than we don't have more lines than what we can fit // on the space that the layout reserves for text - _numLines = MIN(HELP_NUM_LINES, (int)(h / lineHeight)); + _numLines = MIN(HELP_NUM_LINES, (int)(h / lineHeight)); int keyW = w * 20 / 100; int dscX = x + keyW + 32; -- cgit v1.2.3