aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/unknown-game-dialog.cpp31
-rw-r--r--engines/unknown-game-dialog.h7
2 files changed, 30 insertions, 8 deletions
diff --git a/engines/unknown-game-dialog.cpp b/engines/unknown-game-dialog.cpp
index 33efdcc771..91a593c9b8 100644
--- a/engines/unknown-game-dialog.cpp
+++ b/engines/unknown-game-dialog.cpp
@@ -26,13 +26,15 @@
#include "gui/message.h"
#include "gui/ThemeEval.h"
#include "gui/widgets/popup.h"
+#include "gui/widgets/scrollcontainer.h"
#include "engines/unknown-game-dialog.h"
#include "backends/platform/sdl/sdl.h"
enum {
kCopyToClipboard = 'cpcl',
kOpenBugtrackerURL = 'ourl',
- kClose = 'clse'
+ kClose = 'clse',
+ kScrollContainerReflow = 'SCRf'
};
UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Common::String &reportTranslated, const Common::String &bugtrackerAffectedEngine)
@@ -63,11 +65,16 @@ UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Com
int buttonHeight = g_gui.xmlEval()->getVar("Globals.Button.Height", 0);
//Calculate the size the dialog needs
+ // We use a ScrollContainer to display the text, with a 2 * 8 pixels margin to the dialog border,
+ // the scrollbar, and 2 * 10 margin for the text in the container.
+ // We also keep 2 * 10 pixels between the screen border and the dialog.
+ int scrollbarWidth = g_gui.xmlEval()->getVar("Globals.Scrollbar.Width", 0);
Common::Array<Common::String> lines;
- int maxlineWidth = g_gui.getFont().wordWrapText(_reportTranslated, screenW - 2 * 20, lines);
+ int maxlineWidth = g_gui.getFont().wordWrapText(_reportTranslated, screenW - 2 * 20 - 16 - scrollbarWidth, lines);
+
int lineCount = lines.size() + 1;
- _h = 3 * kLineHeight + lineCount * kLineHeight;
+ _h = MIN(screenH - 20, lineCount * kLineHeight + kLineHeight + buttonHeight + 24);
// Buttons
int closeButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_("Close")) + 10);
@@ -79,7 +86,7 @@ UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Com
if (g_system->hasFeature(OSystem::kFeatureOpenUrl))
totalButtonWidth += 10 + openBugtrackerURLButtonWidth;
- _w = MAX(MAX(maxlineWidth, 0), totalButtonWidth) + 20;
+ _w = MAX(MAX(maxlineWidth, 0) + 16 + scrollbarWidth, totalButtonWidth) + 20;
int buttonPos = _w - closeButtonWidth - 10;
new GUI::ButtonWidget(this, buttonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("Close"), 0, kClose);
@@ -111,10 +118,14 @@ UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Com
#endif
// Each line is represented by one static text item.
- // TODO: Use a ScrollContainer widget instead of truncated text.
- uint y = 10;
- for (uint i = 0; i < lines.size(); i++) {
- new GUI::StaticTextWidget(this, 10, y, _w, kLineHeight, lines[i], Graphics::kTextAlignLeft);
+ // Use a ScrollContainer for the report in case we have a lot of lines.
+ int containerHeight = _h - kLineHeight - buttonHeight - 8;
+ GUI::ScrollContainerWidget *container = new GUI::ScrollContainerWidget(this, 8, 8, _w - 16, containerHeight, kScrollContainerReflow);
+ container->setTarget(this);
+ uint y = 8;
+ for (uint i = 0; i < lines.size() ; i++) {
+ GUI::StaticTextWidget *widget = new GUI::StaticTextWidget(container, 10, y, _w - 36 - scrollbarWidth, kLineHeight, lines[i], Graphics::kTextAlignLeft);
+ _textWidgets.push_back(widget);
y += kLineHeight;
}
}
@@ -152,5 +163,9 @@ void UnknownGameDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, ui
case kOpenBugtrackerURL:
g_system->openUrl(generateBugtrackerURL());
break;
+ case kScrollContainerReflow:
+ for (uint i = 0; i < _textWidgets.size() ; i++)
+ _textWidgets[i]->setVisible(true);
+ break;
}
}
diff --git a/engines/unknown-game-dialog.h b/engines/unknown-game-dialog.h
index 51adf27996..a527339211 100644
--- a/engines/unknown-game-dialog.h
+++ b/engines/unknown-game-dialog.h
@@ -21,6 +21,11 @@
*/
#include "gui/dialog.h"
+#include "common/array.h"
+
+namespace GUI {
+ class StaticTextWidget;
+}
class UnknownGameDialog : public GUI::Dialog {
public:
@@ -34,4 +39,6 @@ private:
Common::String _reportTranslated;
Common::String _bugtrackerGameData;
Common::String _bugtrackerAffectedEngine;
+
+ Common::Array<GUI::StaticTextWidget*> _textWidgets;
};