summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bootstrap_gui.cpp66
-rw-r--r--src/lang/english.txt4
-rw-r--r--src/widgets/bootstrap_widget.h7
3 files changed, 77 insertions, 0 deletions
diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp
index 7ec391b47..ff5cb0a7c 100644
--- a/src/bootstrap_gui.cpp
+++ b/src/bootstrap_gui.cpp
@@ -14,6 +14,7 @@
#if defined(WITH_FREETYPE) || defined(WITH_UNISCRIBE) || defined(WITH_COCOA)
#include "core/geometry_func.hpp"
+#include "error.h"
#include "fontcache.h"
#include "gfx_func.h"
#include "network/network.h"
@@ -61,6 +62,63 @@ public:
}
};
+/** Nested widgets for the error window. */
+static const NWidgetPart _nested_bootstrap_errmsg_widgets[] = {
+ NWidget(NWID_HORIZONTAL),
+ NWidget(WWT_CAPTION, COLOUR_GREY, WID_BEM_CAPTION), SetDataTip(STR_MISSING_GRAPHICS_ERROR_TITLE, STR_NULL),
+ EndContainer(),
+ NWidget(WWT_PANEL, COLOUR_GREY),
+ NWidget(WWT_PANEL, COLOUR_GREY, WID_BEM_MESSAGE), EndContainer(),
+ NWidget(NWID_HORIZONTAL),
+ NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BEM_QUIT), SetDataTip(STR_MISSING_GRAPHICS_ERROR_QUIT, STR_NULL), SetFill(1, 0),
+ EndContainer(),
+ EndContainer(),
+};
+
+/** Window description for the error window. */
+static WindowDesc _bootstrap_errmsg_desc(
+ WDP_CENTER, nullptr, 0, 0,
+ WC_BOOTSTRAP, WC_NONE,
+ WDF_MODAL,
+ _nested_bootstrap_errmsg_widgets, lengthof(_nested_bootstrap_errmsg_widgets)
+);
+
+/** The window for a failed bootstrap. */
+class BootstrapErrorWindow : public Window {
+public:
+ BootstrapErrorWindow() : Window(&_bootstrap_errmsg_desc)
+ {
+ this->InitNested(1);
+ }
+
+ ~BootstrapErrorWindow()
+ {
+ _exit_game = true;
+ }
+
+ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
+ {
+ if (widget == WID_BEM_MESSAGE) {
+ *size = GetStringBoundingBox(STR_MISSING_GRAPHICS_ERROR);
+ size->height = GetStringHeight(STR_MISSING_GRAPHICS_ERROR, size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT) + WD_FRAMETEXT_BOTTOM + WD_FRAMETEXT_TOP;
+ }
+ }
+
+ void DrawWidget(const Rect &r, int widget) const override
+ {
+ if (widget == WID_BEM_MESSAGE) {
+ DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMETEXT_TOP, r.bottom - WD_FRAMETEXT_BOTTOM, STR_MISSING_GRAPHICS_ERROR, TC_FROMSTRING, SA_CENTER);
+ }
+ }
+
+ void OnClick(Point pt, int widget, int click_count) override
+ {
+ if (widget == WID_BEM_QUIT) {
+ _exit_game = true;
+ }
+ }
+};
+
/** Nested widgets for the download window. */
static const NWidgetPart _nested_boostrap_download_status_window_widgets[] = {
NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CONTENT_DOWNLOAD_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
@@ -86,6 +144,14 @@ public:
{
}
+ ~BootstrapContentDownloadStatusWindow()
+ {
+ /* If we are not set to exit the game, it means the bootstrap failed. */
+ if (!_exit_game) {
+ new BootstrapErrorWindow();
+ }
+ }
+
void OnDownloadComplete(ContentID cid) override
{
/* We have completed downloading. We can trigger finding the right set now. */
diff --git a/src/lang/english.txt b/src/lang/english.txt
index d4cf1e22e..1837e143e 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2339,6 +2339,10 @@ STR_MISSING_GRAPHICS_SET_MESSAGE :{BLACK}OpenTTD
STR_MISSING_GRAPHICS_YES_DOWNLOAD :{BLACK}Yes, download the graphics
STR_MISSING_GRAPHICS_NO_QUIT :{BLACK}No, exit OpenTTD
+STR_MISSING_GRAPHICS_ERROR_TITLE :{WHITE}Downloading failed
+STR_MISSING_GRAPHICS_ERROR :{BLACK}Downloading graphics failed.{}Please download graphics manually.
+STR_MISSING_GRAPHICS_ERROR_QUIT :{BLACK}Exit OpenTTD
+
# Transparency settings window
STR_TRANSPARENCY_CAPTION :{WHITE}Transparency Options
STR_TRANSPARENT_SIGNS_TOOLTIP :{BLACK}Toggle transparency for signs. Ctrl+Click to lock
diff --git a/src/widgets/bootstrap_widget.h b/src/widgets/bootstrap_widget.h
index 4870f62d5..16a36cc5b 100644
--- a/src/widgets/bootstrap_widget.h
+++ b/src/widgets/bootstrap_widget.h
@@ -15,6 +15,13 @@ enum BootstrapBackgroundWidgets {
WID_BB_BACKGROUND, ///< Background of the window.
};
+/** Widgets of the #BootstrapErrmsgWindow class. */
+enum BootstrapErrorMessageWidgets {
+ WID_BEM_CAPTION, ///< Caption of the window.
+ WID_BEM_MESSAGE, ///< Error message.
+ WID_BEM_QUIT, ///< Quit button.
+};
+
/** Widgets of the #BootstrapContentDownloadStatusWindow class. */
enum BootstrapAskForDownloadWidgets {
WID_BAFD_QUESTION, ///< The question whether to download.