summaryrefslogtreecommitdiff
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
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
-rw-r--r--src/intro_gui.cpp64
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/settings_type.h1
-rw-r--r--src/table/settings.ini7
4 files changed, 64 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),
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 38defa63c..3f6338bb8 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1401,6 +1401,8 @@ STR_INTRO_TOOLTIP_ONLINE_CONTENT :{BLACK}Check fo
STR_INTRO_TOOLTIP_AI_SETTINGS :{BLACK}Display AI settings
STR_INTRO_TOOLTIP_QUIT :{BLACK}Quit 'OpenTTD'
+STR_INTRO_TRANSLATION :{BLACK}This translation misses {NUM} string{P "" s}. Please help make OpenTTD better by signing up as translator. See readme.txt for details.
+
# Quit window
STR_QUIT_CAPTION :{WHITE}Quit
STR_QUIT_ARE_YOU_SURE_YOU_WANT_TO_EXIT_OPENTTD :{YELLOW}Are you sure you want to exit OpenTTD and return to {STRING}?
diff --git a/src/settings_type.h b/src/settings_type.h
index dd073cec0..8e7d196e3 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -111,6 +111,7 @@ struct GUISettings {
bool persistent_buildingtools; ///< keep the building tools active after usage
bool expenses_layout; ///< layout of expenses window
uint32 last_newgrf_count; ///< the numbers of NewGRFs we found during the last scan
+ byte missing_strings_threshold; ///< the number of missing strings before showing the warning
uint16 console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity.
uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed.
diff --git a/src/table/settings.ini b/src/table/settings.ini
index 3f01abeeb..72ce27276 100644
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -2387,6 +2387,13 @@ def = 100
min = 0
max = UINT32_MAX
+[SDTC_VAR]
+var = gui.missing_strings_threshold
+type = SLE_UINT8
+flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
+def = 25
+min = 1
+max = UINT8_MAX
; For the dedicated build we'll enable dates in logs by default.
[SDTC_BOOL]