summaryrefslogtreecommitdiff
path: root/src/intro_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-08-21 19:23:06 +0000
committerrubidium <rubidium@openttd.org>2011-08-21 19:23:06 +0000
commit0ad82be1f3a6f963a484181bc2fb26b559e1d84e (patch)
treea572a4269d4428a3ae366cb444efc57399aad8b8 /src/intro_gui.cpp
parent525e2c9e73ecab8913d4eafc6685d89e1653d151 (diff)
downloadopenttd-0ad82be1f3a6f963a484181bc2fb26b559e1d84e.tar.xz
(svn r22807) -Feature-ish: show a message about missing strings in the intro window if a certain (configurable) threshold has been reached and its not a stable release
Diffstat (limited to 'src/intro_gui.cpp')
-rw-r--r--src/intro_gui.cpp64
1 files changed, 54 insertions, 10 deletions
diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp
index 1f5692d42..894f54dc4 100644
--- a/src/intro_gui.cpp
+++ b/src/intro_gui.cpp
@@ -23,6 +23,8 @@
#include "ai/ai_gui.hpp"
#include "gfx_func.h"
#include "core/geometry_func.hpp"
+#include "language.h"
+#include "rev.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -38,6 +40,8 @@ enum SelectGameIntroWidgets {
SGI_ARCTIC_LANDSCAPE,
SGI_TROPIC_LANDSCAPE,
SGI_TOYLAND_LANDSCAPE,
+ SGI_TRANSLATION_SELECTION,
+ SGI_TRANSLATION,
SGI_OPTIONS,
SGI_DIFFICULTIES,
SGI_SETTINGS_OPTIONS,
@@ -51,7 +55,8 @@ struct SelectGameWindow : public Window {
SelectGameWindow(const WindowDesc *desc) : Window()
{
- this->InitNested(desc);
+ this->CreateNestedTree(desc);
+ this->FinishInitNested(desc, 0);
this->OnInvalidateData();
}
@@ -74,18 +79,52 @@ struct SelectGameWindow : public Window {
if (widget == SGI_DIFFICULTIES) SetDParam(0, STR_DIFFICULTY_LEVEL_EASY + _settings_newgame.difficulty.diff_level);
}
- virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ virtual void OnInit()
{
- if (widget != SGI_DIFFICULTIES) return;
+ bool missing = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
+ this->GetWidget<NWidgetStacked>(SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing ? 0 : SZSP_NONE);
+ }
- Dimension textdim = {0, 0};
- for (uint i = STR_DIFFICULTY_LEVEL_EASY; i <= STR_DIFFICULTY_LEVEL_CUSTOM; i++) {
- SetDParam(0, i);
- textdim = maxdim(textdim, GetStringBoundingBox(STR_INTRO_DIFFICULTY));
+ virtual void DrawWidget(const Rect &r, int widget) const
+ {
+ switch (widget) {
+ case SGI_TRANSLATION:
+ SetDParam(0, _current_language->missing);
+ DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_INTRO_TRANSLATION, TC_FROMSTRING, SA_CENTER);
+ break;
+ }
+ }
+
+ virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
+ {
+ switch (widget) {
+ case SGI_DIFFICULTIES: {
+ Dimension textdim = {0, 0};
+ for (uint i = STR_DIFFICULTY_LEVEL_EASY; i <= STR_DIFFICULTY_LEVEL_CUSTOM; i++) {
+ SetDParam(0, i);
+ textdim = maxdim(textdim, GetStringBoundingBox(STR_INTRO_DIFFICULTY));
+ }
+ textdim.width += padding.width;
+ textdim.height += padding.height;
+ *size = maxdim(*size, textdim);
+ break;
+ }
+
+ case SGI_TRANSLATION: {
+ SetDParam(0, _current_language->missing);
+ int height = GetStringHeight(STR_INTRO_TRANSLATION, size->width);
+ if (height > 3 * FONT_HEIGHT_NORMAL) {
+ /* Don't let the window become too high. */
+ Dimension textdim = GetStringBoundingBox(STR_INTRO_TRANSLATION);
+ textdim.height *= 3;
+ textdim.width -= textdim.width / 2;
+ *size = maxdim(*size, textdim);
+ } else {
+ size->height = height + padding.height;
+ }
+ break;
+ }
}
- textdim.width += padding.width;
- textdim.height += padding.height;
- *size = maxdim(*size, textdim);
}
virtual void OnClick(Point pt, int widget, int click_count)
@@ -193,6 +232,11 @@ static const NWidgetPart _nested_select_game_widgets[] = {
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 7),
+ NWidget(NWID_SELECTION, INVALID_COLOUR, SGI_TRANSLATION_SELECTION),
+ NWidget(NWID_VERTICAL),
+ NWidget(WWT_EMPTY, COLOUR_ORANGE, SGI_TRANSLATION), SetMinimalSize(316, 12), SetFill(1, 0), SetPadding(0, 10, 7, 10),
+ EndContainer(),
+ EndContainer(),
/* 'game options' and 'difficulty options' buttons */
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),