changeset 17998:28dfccce7aae draft

(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
author rubidium <rubidium@openttd.org>
date Sun, 21 Aug 2011 19:23:06 +0000
parents 807e4762a716
children a3db2ad40080
files src/intro_gui.cpp src/lang/english.txt src/settings_type.h src/table/settings.ini
diffstat 4 files changed, 63 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
 	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 @@
 
 	SelectGameWindow(const WindowDesc *desc) : Window()
 	{
-		this->InitNested(desc);
+		this->CreateNestedTree(desc);
+		this->FinishInitNested(desc, 0);
 		this->OnInvalidateData();
 	}
 
@@ -74,18 +79,52 @@
 		if (widget == SGI_DIFFICULTIES) SetDParam(0, STR_DIFFICULTY_LEVEL_EASY + _settings_newgame.difficulty.diff_level);
 	}
 
+	virtual void OnInit()
+	{
+		bool missing = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
+		this->GetWidget<NWidgetStacked>(SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing ? 0 : SZSP_NONE);
+	}
+
+	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)
 	{
-		if (widget != SGI_DIFFICULTIES) return;
+		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;
+			}
 
-		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));
+			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 @@
 	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),
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1401,6 +1401,8 @@
 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}?
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -111,6 +111,7 @@
 	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.
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -2387,6 +2387,13 @@
 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]