changeset 16441:86fd9bcc9d2f draft

(svn r21157) -Codechange: remove information about the text direction out of the language "list"
author rubidium <rubidium@openttd.org>
date Sat, 13 Nov 2010 09:56:25 +0000
parents c776a99ce938
children 18b3255ccea4
files src/ai/ai_gui.cpp src/aircraft_gui.cpp src/build_vehicle_gui.cpp src/cheat_gui.cpp src/company_gui.cpp src/depot_gui.cpp src/gfx.cpp src/graph_gui.cpp src/industry_gui.cpp src/music_gui.cpp src/network/network.cpp src/network/network_gui.cpp src/newgrf_gui.cpp src/news_gui.cpp src/order_gui.cpp src/roadveh_gui.cpp src/settings_gui.cpp src/ship_gui.cpp src/signs_gui.cpp src/smallmap_gui.cpp src/station_gui.cpp src/statusbar_gui.cpp src/strings.cpp src/strings_func.h src/strings_type.h src/terraform_gui.cpp src/timetable_gui.cpp src/toolbar_gui.cpp src/town_gui.cpp src/train_gui.cpp src/vehicle_gui.cpp src/widget.cpp src/widgets/dropdown.cpp src/window.cpp
diffstat 34 files changed, 86 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -290,7 +290,7 @@
 		int i = 0;
 		for (; !this->vscroll->IsVisible(i); i++) it++;
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		uint buttons_left = rtl ? r.right - 23 : r.left + 4;
 		uint text_left    = r.left + (rtl ? WD_FRAMERECT_LEFT : 28);
 		uint text_right   = r.right - (rtl ? 28 : WD_FRAMERECT_RIGHT);
@@ -360,7 +360,7 @@
 				bool bool_item = (config_item.flags & AICONFIG_BOOLEAN) != 0;
 
 				int x = pt.x - wid->pos_x;
-				if (_dynlang.text_dir == TD_RTL) x = wid->current_x - x;
+				if (_current_text_dir == TD_RTL) x = wid->current_x - x;
 				x -= 4;
 				/* One of the arrows is clicked (or green/red rect in case of bool value) */
 				if (IsInsideMM(x, 0, 21)) {
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -78,7 +78,7 @@
  */
 void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection)
 {
-	bool rtl = _dynlang.text_dir == TD_RTL;
+	bool rtl = _current_text_dir == TD_RTL;
 
 	SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W);
 	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -842,7 +842,7 @@
 	assert_compile(lengthof(sprite_y_offsets) == lengthof(sprite_widths));
 	assert(max <= eng_list->Length());
 
-	bool rtl = _dynlang.text_dir == TD_RTL;
+	bool rtl = _current_text_dir == TD_RTL;
 	int step_size = GetEngineListHeight(type);
 	int sprite_width = sprite_widths[type];
 
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -163,7 +163,7 @@
 		int y = r.top + WD_FRAMERECT_TOP + this->header_height;
 		DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, y, STR_CHEATS_WARNING, TC_FROMSTRING, SA_CENTER);
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		uint box_left    = rtl ? r.right - 12 : r.left + 5;
 		uint button_left = rtl ? r.right - 40 : r.left + 20;
 		uint text_left   = r.left + (rtl ? WD_FRAMERECT_LEFT: 50);
@@ -280,7 +280,7 @@
 		const NWidgetBase *wid = this->GetWidget<NWidgetBase>(CW_PANEL);
 		uint btn = (pt.y - wid->pos_y - WD_FRAMERECT_TOP - this->header_height) / (FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL);
 		uint x = pt.x - wid->pos_x;
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		if (rtl) x = wid->current_x - x;
 
 		/* Not clicking a button? */
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -547,7 +547,7 @@
 
 	void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
 	{
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOUR_START + this->result, rtl ? right - 16 : left + 16, top + 7);
 		DrawString(rtl ? left + 2 : left + 32, rtl ? right - 32 : right - 2, top + max(0, 13 - FONT_HEIGHT_NORMAL), this->String(), sel ? TC_WHITE : TC_BLACK);
 	}
@@ -687,7 +687,7 @@
 	{
 		if (widget != SCLW_WIDGET_MATRIX) return;
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 
 		/* Horizontal coordinates of scheme name column. */
 		const NWidgetBase *nwi = this->GetWidget<NWidgetBase>(SCLW_WIDGET_SPACER_DROPDOWN);
@@ -776,7 +776,7 @@
 				if (j >= LS_END) return;
 
 				/* If clicking on the left edge, toggle using the livery */
-				if (_dynlang.text_dir == TD_RTL ? pt.x - wid->pos_x > wid->current_x - TEXT_INDENT : pt.x - wid->pos_x < TEXT_INDENT) {
+				if (_current_text_dir == TD_RTL ? pt.x - wid->pos_x > wid->current_x - TEXT_INDENT : pt.x - wid->pos_x < TEXT_INDENT) {
 					DoCommandP(0, j | (2 << 8), !Company::Get((CompanyID)this->window_number)->livery[j].in_use, CMD_SET_COMPANY_COLOUR);
 				}
 
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -273,7 +273,7 @@
 		bool free_wagon = false;
 		int sprite_y = y + (this->resize.step_height - GetVehicleHeight(v->type)) / 2;
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		int image_left  = rtl ? left  + this->count_width  : left  + this->header_width;
 		int image_right = rtl ? right - this->header_width : right - this->count_width;
 
@@ -331,7 +331,7 @@
 	{
 		if (widget != DEPOT_WIDGET_MATRIX) return;
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 
 		/* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */
 		uint16 mat_data = this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->widget_data;
@@ -389,7 +389,7 @@
 	{
 		const NWidgetCore *matrix_widget = this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX);
 		/* In case of RTL the widgets are swapped as a whole */
-		if (_dynlang.text_dir == TD_RTL) x = matrix_widget->current_x - x;
+		if (_current_text_dir == TD_RTL) x = matrix_widget->current_x - x;
 
 		uint xt = 0, xm = 0, ym = 0;
 		if (this->type == VEH_TRAIN) {
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -346,7 +346,7 @@
 	UBiDi *para = ubidi_openSized((int32_t)length, 0, &err);
 	if (para == NULL) return buffer;
 
-	ubidi_setPara(para, input_output, (int32_t)length, _dynlang.text_dir == TD_RTL ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, NULL, &err);
+	ubidi_setPara(para, input_output, (int32_t)length, _current_text_dir == TD_RTL ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, NULL, &err);
 	ubidi_writeReordered(para, intermediate, (int32_t)length, UBIDI_REMOVE_BIDI_CONTROLS, &err);
 	length = u_shapeArabic(intermediate, (int32_t)length, input_output, lengthof(input_output), U_SHAPE_TEXT_DIRECTION_VISUAL_LTR | U_SHAPE_LETTERS_SHAPE, &err);
 	ubidi_close(para);
@@ -555,7 +555,7 @@
 	}
 
 	/* In case we have a RTL language we swap the alignment. */
-	if (!(align & SA_FORCE) && _dynlang.text_dir == TD_RTL && !(align & SA_STRIP) && (align & SA_HOR_MASK) != SA_HOR_CENTER) align ^= SA_RIGHT;
+	if (!(align & SA_FORCE) && _current_text_dir == TD_RTL && !(align & SA_STRIP) && (align & SA_HOR_MASK) != SA_HOR_CENTER) align ^= SA_RIGHT;
 
 	for (UChar **iter = setx_offsets.Begin(); iter != setx_offsets.End(); iter++) {
 		UChar *to_draw = *iter;
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -74,7 +74,7 @@
 
 		if (!Company::IsValidID(cid)) return;
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 
 		DrawCompanyIcon(cid, rtl ? r.right - 16 : r.left + 2, r.top + 2 + (FONT_HEIGHT_NORMAL - 10) / 2);
 
@@ -964,7 +964,7 @@
 		}
 
 		const CargoSpec *cs = _sorted_cargo_specs[widget - CPW_CARGO_FIRST];
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 
 		/* Since the buttons have no text, no images,
 		 * both the text and the coloured box have to be manually painted.
@@ -1196,7 +1196,7 @@
 		uint y = r.top + WD_FRAMERECT_TOP;
 		int icon_y_offset = 1 + (FONT_HEIGHT_NORMAL - 10) / 2;
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		uint ordinal_left  = rtl ? r.right - WD_FRAMERECT_LEFT - this->ordinal_width : r.left + WD_FRAMERECT_LEFT;
 		uint ordinal_right = rtl ? r.right - WD_FRAMERECT_LEFT : r.left + WD_FRAMERECT_LEFT + this->ordinal_width;
 		uint icon_left     = r.left + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT + (rtl ? this->text_width : this->ordinal_width);
@@ -1381,7 +1381,7 @@
 				uint left  = 7;
 				uint right = size->width - 7;
 
-				bool rtl = _dynlang.text_dir == TD_RTL;
+				bool rtl = _current_text_dir == TD_RTL;
 				this->score_info_left  = rtl ? right - score_info_width : left;
 				this->score_info_right = rtl ? right : left + score_info_width;
 
@@ -1444,7 +1444,7 @@
 
 		/* Calculate the %-bar */
 		uint x = Clamp(val, 0, needed) * this->bar_width / needed;
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		if (rtl) {
 			x = this->bar_right - x;
 		} else {
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -1654,7 +1654,7 @@
 
 					/* Draw the industry legend. */
 					int blob_left, blob_right;
-					if (_dynlang.text_dir == TD_RTL) {
+					if (_current_text_dir == TD_RTL) {
 						blob_right = xpos2 - BLOB_DISTANCE;
 						blob_left  = blob_right - BLOB_WIDTH;
 					} else {
@@ -1669,7 +1669,7 @@
 
 				/* Draw the other_produced/other_accepted cargoes. */
 				const CargoID *other_right, *other_left;
-				if (_dynlang.text_dir == TD_RTL) {
+				if (_current_text_dir == TD_RTL) {
 					other_right = this->u.industry.other_accepted;
 					other_left  = this->u.industry.other_produced;
 				} else {
@@ -1713,7 +1713,7 @@
 				}
 
 				const CargoID *hor_left, *hor_right;
-				if (_dynlang.text_dir == TD_RTL) {
+				if (_current_text_dir == TD_RTL) {
 					hor_left  = this->u.cargo.cust_cargoes;
 					hor_right = this->u.cargo.supp_cargoes;
 				} else {
@@ -2434,7 +2434,7 @@
 			if (vpos + row_height >= 0) {
 				int xpos = left_pos;
 				int col, dir;
-				if (_dynlang.text_dir == TD_RTL) {
+				if (_current_text_dir == TD_RTL) {
 					col = last_column;
 					dir = -1;
 				} else {
@@ -2490,7 +2490,7 @@
 		/* Return both positions, compensating for RTL languages (which works due to the equal symmetry in both displays). */
 		fieldxy->y = row;
 		xy->y = vpos;
-		if (_dynlang.text_dir == TD_RTL) {
+		if (_current_text_dir == TD_RTL) {
 			fieldxy->x = num_columns - column;
 			xy->x = ((column & 1) ? CargoesField::CARGO_FIELD_WIDTH : CargoesField::industry_width) - xpos;
 		} else {
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -580,9 +580,9 @@
 
 			/* Hack-ish: set the proper widget data; only needs to be done once
 			 * per (Re)Init as that's the only time the language changes. */
-			case MW_PREV: this->GetWidget<NWidgetCore>(MW_PREV)->widget_data = _dynlang.text_dir == TD_RTL ? SPR_IMG_SKIP_TO_NEXT : SPR_IMG_SKIP_TO_PREV; break;
-			case MW_NEXT: this->GetWidget<NWidgetCore>(MW_NEXT)->widget_data = _dynlang.text_dir == TD_RTL ? SPR_IMG_SKIP_TO_PREV : SPR_IMG_SKIP_TO_NEXT; break;
-			case MW_PLAY: this->GetWidget<NWidgetCore>(MW_PLAY)->widget_data = _dynlang.text_dir == TD_RTL ? SPR_IMG_PLAY_MUSIC_RTL : SPR_IMG_PLAY_MUSIC; break;
+			case MW_PREV: this->GetWidget<NWidgetCore>(MW_PREV)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_SKIP_TO_NEXT : SPR_IMG_SKIP_TO_PREV; break;
+			case MW_NEXT: this->GetWidget<NWidgetCore>(MW_NEXT)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_SKIP_TO_PREV : SPR_IMG_SKIP_TO_NEXT; break;
+			case MW_PLAY: this->GetWidget<NWidgetCore>(MW_PLAY)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_PLAY_MUSIC_RTL : SPR_IMG_PLAY_MUSIC; break;
 		}
 	}
 
@@ -631,7 +631,7 @@
 				DrawFrameRect(r.left, r.top + 2, r.right, r.bottom - 2, COLOUR_GREY, FR_LOWERED);
 				byte volume = (widget == MW_MUSIC_VOL) ? msf.music_vol : msf.effect_vol;
 				int x = (volume * (r.right - r.left) / 127);
-				if (_dynlang.text_dir == TD_RTL) {
+				if (_current_text_dir == TD_RTL) {
 					x = r.right - x;
 				} else {
 					x += r.left;
@@ -684,7 +684,7 @@
 				byte *vol = (widget == MW_MUSIC_VOL) ? &msf.music_vol : &msf.effect_vol;
 
 				byte new_vol = x * 127 / this->GetWidget<NWidgetBase>(widget)->current_x;
-				if (_dynlang.text_dir == TD_RTL) new_vol = 127 - new_vol;
+				if (_current_text_dir == TD_RTL) new_vol = 127 - new_vol;
 				if (new_vol != *vol) {
 					*vol = new_vol;
 					if (widget == MW_MUSIC_VOL) MusicVolumeChanged(new_vol);
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -207,7 +207,7 @@
 	 * right-to-left characters depending on the context. As the next text might be an user's name, the
 	 * user name's characters will influence the direction of the "***" instead of the language setting
 	 * of the game. Manually set the direction of the "***" by inserting a text-direction marker. */
-	char *msg_ptr = message + Utf8Encode(message, _dynlang.text_dir == TD_LTR ? CHAR_TD_LRM : CHAR_TD_RLM);
+	char *msg_ptr = message + Utf8Encode(message, _current_text_dir == TD_LTR ? CHAR_TD_LRM : CHAR_TD_RLM);
 	GetString(msg_ptr, strid, lastof(message));
 
 	DEBUG(desync, 1, "msg: %08x; %02x; %s", _date, _date_fract, message);
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -1543,7 +1543,7 @@
 
 	void DrawMatrix(const Rect &r) const
 	{
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		uint left = r.left + WD_FRAMERECT_LEFT;
 		uint right = r.right - WD_FRAMERECT_RIGHT;
 
@@ -2064,7 +2064,7 @@
 	{
 		if (widget != CLW_PANEL) return;
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		int icon_y_offset = 1 + (FONT_HEIGHT_NORMAL - 10) / 2;
 		uint y = r.top + WD_FRAMERECT_TOP;
 		uint left = r.left + WD_FRAMERECT_LEFT;
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -243,7 +243,7 @@
 			return;
 		}
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		uint buttons_left = rtl ? r.right - 23 : r.left + 4;
 		uint text_left    = r.left + (rtl ? WD_FRAMERECT_LEFT : 28);
 		uint text_right   = r.right - (rtl ? 28 : WD_FRAMERECT_RIGHT);
@@ -316,7 +316,7 @@
 
 				const NWidgetBase *wid = this->GetWidget<NWidgetBase>(GRFPAR_WIDGET_BACKGROUND);
 				int x = pt.x - wid->pos_x;
-				if (_dynlang.text_dir == TD_RTL) x = wid->current_x - x;
+				if (_current_text_dir == TD_RTL) x = wid->current_x - x;
 				x -= 4;
 
 				GRFParameterInfo *par_info = (num < this->grf_config->param_info.Length()) ? this->grf_config->param_info[num] : NULL;
@@ -700,7 +700,7 @@
 				int sprite_offset_y = (step_height - 10) / 2;
 				int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
 
-				bool rtl = _dynlang.text_dir == TD_RTL;
+				bool rtl = _current_text_dir == TD_RTL;
 				uint text_left    = rtl ? r.left + WD_FRAMERECT_LEFT : r.left + 25;
 				uint text_right   = rtl ? r.right - 25 : r.right - WD_FRAMERECT_RIGHT;
 				uint square_left  = rtl ? r.right - 15 : r.left + 5;
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -994,7 +994,7 @@
 
 		/* Fill the widget with news items. */
 		int y = r.top + this->top_spacing;
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		uint date_left  = rtl ? r.right - WD_FRAMERECT_RIGHT - this->date_width : r.left + WD_FRAMERECT_LEFT;
 		uint date_right = rtl ? r.right - WD_FRAMERECT_RIGHT : r.left + WD_FRAMERECT_LEFT + this->date_width;
 		uint news_left  = rtl ? r.left + WD_FRAMERECT_LEFT : r.left + WD_FRAMERECT_LEFT + this->date_width + WD_FRAMERECT_RIGHT;
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -188,7 +188,7 @@
  */
 void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable, int left, int middle, int right)
 {
-	bool rtl = _dynlang.text_dir == TD_RTL;
+	bool rtl = _current_text_dir == TD_RTL;
 
 	SpriteID sprite = rtl ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT;
 	Dimension sprite_size = GetSpriteSize(sprite);
@@ -944,7 +944,7 @@
 	{
 		if (widget != ORDER_WIDGET_ORDER_LIST) return;
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		SetDParam(0, 99);
 		int index_column_width = GetStringBoundingBox(STR_ORDER_INDEX).width + GetSpriteSize(rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT).width + 3;
 		int middle = rtl ? r.right - WD_FRAMETEXT_RIGHT - index_column_width : r.left + WD_FRAMETEXT_LEFT + index_column_width;
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -131,7 +131,7 @@
  */
 void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection)
 {
-	bool rtl = _dynlang.text_dir == TD_RTL;
+	bool rtl = _current_text_dir == TD_RTL;
 	Direction dir = rtl ? DIR_E : DIR_W;
 	const RoadVehicle *u = RoadVehicle::From(v);
 
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1046,7 +1046,7 @@
 {
 	if (cur_row >= max_row) return cur_row;
 
-	bool rtl = _dynlang.text_dir == TD_RTL;
+	bool rtl = _current_text_dir == TD_RTL;
 	int offset = rtl ? -4 : 4;
 	int level_width = rtl ? -LEVEL_WIDTH : LEVEL_WIDTH;
 
@@ -1126,7 +1126,7 @@
 	bool editable = true;
 	bool disabled = false;
 
-	bool rtl = _dynlang.text_dir == TD_RTL;
+	bool rtl = _current_text_dir == TD_RTL;
 	uint buttons_left = rtl ? right - 19 : left;
 	uint text_left  = left + (rtl ? 0 : 25);
 	uint text_right = right - (rtl ? 25 : 0);
@@ -1566,7 +1566,7 @@
 
 		if (pe == NULL) return;  // Clicked below the last setting of the page
 
-		int x = (_dynlang.text_dir == TD_RTL ? this->width - pt.x : pt.x) - SETTINGTREE_LEFT_OFFSET - (pe->level + 1) * LEVEL_WIDTH;  // Shift x coordinate
+		int x = (_current_text_dir == TD_RTL ? this->width - pt.x : pt.x) - SETTINGTREE_LEFT_OFFSET - (pe->level + 1) * LEVEL_WIDTH;  // Shift x coordinate
 		if (x < 0) return;  // Clicked left of the entry
 
 		if ((pe->flags & SEF_KIND_MASK) == SEF_SUBTREE_KIND) {
@@ -1631,7 +1631,7 @@
 							this->clicked_entry->SetButtons(0);
 						}
 						this->clicked_entry = pe;
-						this->clicked_entry->SetButtons((x >= 10) != (_dynlang.text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
+						this->clicked_entry->SetButtons((x >= 10) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
 						this->flags4 |= WF_TIMEOUT_BEGIN;
 						_left_button_clicked = false;
 					}
@@ -1753,7 +1753,7 @@
 	DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, x + WD_IMGBTN_LEFT + 10, y + WD_IMGBTN_TOP);
 
 	/* Grey out the buttons that aren't clickable */
-	bool rtl = _dynlang.text_dir == TD_RTL;
+	bool rtl = _current_text_dir == TD_RTL;
 	if (rtl ? !clickable_right : !clickable_left) {
 		GfxFillRect(x +  1, y + 1, x +  1 + 8, y + 8, colour, FILLRECT_CHECKER);
 	}
--- a/src/ship_gui.cpp
+++ b/src/ship_gui.cpp
@@ -30,7 +30,7 @@
  */
 void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection)
 {
-	bool rtl = _dynlang.text_dir == TD_RTL;
+	bool rtl = _current_text_dir == TD_RTL;
 
 	SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W);
 	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -229,7 +229,7 @@
 					return;
 				}
 
-				bool rtl = _dynlang.text_dir == TD_RTL;
+				bool rtl = _current_text_dir == TD_RTL;
 				int sprite_offset_y = (FONT_HEIGHT_NORMAL - 10) / 2 + 1;
 				uint icon_left  = 4 + (rtl ? r.right - this->text_offset : r.left);
 				uint text_left  = r.left + (rtl ? WD_FRAMERECT_LEFT : this->text_offset);
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -1081,7 +1081,7 @@
 			case SM_WIDGET_LEGEND: {
 				uint columns = this->GetNumberColumnsLegend(r.right - r.left + 1);
 				uint number_of_rows = max(this->map_type == SMT_INDUSTRY ? CeilDiv(_smallmap_industry_count, columns) : 0, this->min_number_of_fixed_rows);
-				bool rtl = _dynlang.text_dir == TD_RTL;
+				bool rtl = _current_text_dir == TD_RTL;
 				uint y_org = r.top + WD_FRAMERECT_TOP;
 				uint x = rtl ? r.right - this->column_width - WD_FRAMERECT_RIGHT : r.left + WD_FRAMERECT_LEFT;
 				uint y = y_org;
@@ -1226,7 +1226,7 @@
 					uint number_of_rows = max(CeilDiv(_smallmap_industry_count, columns), this->min_number_of_fixed_rows);
 					if (line >= number_of_rows) break;
 
-					bool rtl = _dynlang.text_dir == TD_RTL;
+					bool rtl = _current_text_dir == TD_RTL;
 					int x = pt.x - wi->pos_x;
 					if (rtl) x = wi->current_x - x;
 					uint column = (x - WD_FRAMERECT_LEFT) / this->column_width;
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -450,7 +450,7 @@
 				break;
 
 			case SLW_LIST: {
-				bool rtl = _dynlang.text_dir == TD_RTL;
+				bool rtl = _current_text_dir == TD_RTL;
 				int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.Length());
 				int y = r.top + WD_FRAMERECT_TOP;
 				for (int i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner
@@ -850,7 +850,7 @@
 
 	SpriteID sprite = CargoSpec::Get(i)->GetCargoIcon();
 
-	int x = _dynlang.text_dir == TD_RTL ? right - num * 10 : left;
+	int x = _current_text_dir == TD_RTL ? right - num * 10 : left;
 	do {
 		DrawSprite(sprite, PAL_NONE, x, y);
 		x += 10;
@@ -1059,7 +1059,7 @@
 			y += FONT_HEIGHT_NORMAL;
 		}
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		int text_left    = rtl ? r.left + this->expand_shrink_width : r.left + WD_FRAMERECT_LEFT;
 		int text_right   = rtl ? r.right - WD_FRAMERECT_LEFT : r.right - this->expand_shrink_width;
 		int shrink_left  = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - this->expand_shrink_width + WD_FRAMERECT_LEFT;
--- a/src/statusbar_gui.cpp
+++ b/src/statusbar_gui.cpp
@@ -62,14 +62,14 @@
 	if (!FillDrawPixelInfo(&tmp_dpi, left, top, right - left, bottom)) return true;
 
 	int width = GetStringBoundingBox(buffer).width;
-	int pos = (_dynlang.text_dir == TD_RTL) ? (scroll_pos - width) : (right - scroll_pos - left);
+	int pos = (_current_text_dir == TD_RTL) ? (scroll_pos - width) : (right - scroll_pos - left);
 
 	DrawPixelInfo *old_dpi = _cur_dpi;
 	_cur_dpi = &tmp_dpi;
 	DrawString(pos, INT16_MAX, 0, buffer, TC_LIGHT_BLUE, SA_LEFT | SA_FORCE);
 	_cur_dpi = old_dpi;
 
-	return (_dynlang.text_dir == TD_RTL) ? (pos < right - left) : (pos + width > 0);
+	return (_current_text_dir == TD_RTL) ? (pos < right - left) : (pos + width > 0);
 }
 
 enum StatusbarWidget {
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -40,8 +40,9 @@
 #include "table/strings.h"
 #include "table/control_codes.h"
 
-DynamicLanguages _dynlang;     ///< Language information of the program.
-uint64 _decode_parameters[20]; ///< Global array of string parameters. To access, use #SetDParam.
+DynamicLanguages _dynlang;       ///< Language information of the program.
+TextDirection _current_text_dir; ///< Text direction of the currently selected language
+uint64 _decode_parameters[20];   ///< Global array of string parameters. To access, use #SetDParam.
 
 static char *StationGetSpecialString(char *buff, int x, const char *last);
 static char *GetSpecialTownNameString(char *buff, int ind, uint32 seed, const char *last);
@@ -1385,7 +1386,7 @@
 	strecpy(_dynlang.curr_file, c_file, lastof(_dynlang.curr_file));
 
 	_dynlang.curr = lang_index;
-	_dynlang.text_dir = (TextDirection)lang_pack->text_dir;
+	_current_text_dir = (TextDirection)lang_pack->text_dir;
 	SetCurrentGrfLangID(_langpack->newgrflangid);
 	InitializeSortedCargoSpecs();
 	SortIndustryTypes();
@@ -1701,7 +1702,7 @@
 	 * exactly three characters, so it replaces the "XXX" with
 	 * the colour marker.
 	 */
-	if (_dynlang.text_dir != TD_LTR) {
+	if (_current_text_dir != TD_LTR) {
 		static char *err_str = strdup("XXXThis version of OpenTTD does not support right-to-left languages. Recompile with icu enabled.");
 		Utf8Encode(err_str, SCC_YELLOW);
 		SetDParamStr(0, err_str);
--- a/src/strings_func.h
+++ b/src/strings_func.h
@@ -96,6 +96,7 @@
 }
 
 extern DynamicLanguages _dynlang; // defined in strings.cpp
+extern TextDirection _current_text_dir; ///< Text direction of the currently selected language
 
 bool ReadLanguagePack(int index);
 void InitializeLanguagePacks();
--- a/src/strings_type.h
+++ b/src/strings_type.h
@@ -37,7 +37,6 @@
 	int num;                  ///< Number of languages
 	int curr;                 ///< Currently selected language index
 	char curr_file[MAX_PATH]; ///< Currently selected language file name without path (needed for saving the filename of the loaded language).
-	TextDirection text_dir;   ///< Text direction of the currently selected language
 	Language ent[MAX_LANG];   ///< Information about the languages
 };
 
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -373,7 +373,7 @@
 	w->top -= w->height;
 	w->SetDirty();
 	/* Put the linked toolbar to the left / right of it. */
-	link->left = w->left + (_dynlang.text_dir == TD_RTL ? w->width : -link->width);
+	link->left = w->left + (_current_text_dir == TD_RTL ? w->width : -link->width);
 	link->top  = w->top;
 	link->SetDirty();
 
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -364,7 +364,7 @@
 				VehicleOrderID order_id = (i + 1) / 2;
 				bool final_order = false;
 
-				bool rtl = _dynlang.text_dir == TD_RTL;
+				bool rtl = _current_text_dir == TD_RTL;
 				SetDParam(0, 99);
 				int index_column_width = GetStringBoundingBox(STR_ORDER_INDEX).width + GetSpriteSize(rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT).width + 3;
 				int middle = rtl ? r.right - WD_FRAMERECT_RIGHT - index_column_width : r.left + WD_FRAMERECT_LEFT + index_column_width;
@@ -426,7 +426,7 @@
 				bool show_late = this->show_expected && v->lateness_counter > DAY_TICKS;
 				Ticks offset = show_late ? 0 : -v->lateness_counter;
 
-				bool rtl = _dynlang.text_dir == TD_RTL;
+				bool rtl = _current_text_dir == TD_RTL;
 				int abbr_left  = rtl ? r.right - WD_FRAMERECT_RIGHT - this->deparr_abbr_width : r.left + WD_FRAMERECT_LEFT;
 				int abbr_right = rtl ? r.right - WD_FRAMERECT_RIGHT : r.left + WD_FRAMERECT_LEFT + this->deparr_abbr_width;
 				int time_left  = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - WD_FRAMERECT_RIGHT - this->deparr_time_width;
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -138,7 +138,7 @@
 
 	void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
 	{
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		if (this->checked) {
 			DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_JUST_CHECKMARK, sel ? TC_WHITE : TC_BLACK);
 		}
@@ -177,7 +177,7 @@
 	void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
 	{
 		CompanyID company = (CompanyID)this->result;
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 
 		/* It's possible the company is deleted while the dropdown is open */
 		if (!Company::IsValidID(company)) return;
@@ -1054,7 +1054,7 @@
 		GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, 0xB2);
 		GfxFillRect(this->pos_x, this->pos_y, this->pos_x + this->current_x - 1, this->pos_y + this->current_y - 1, 0xB4, FILLRECT_CHECKER);
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		for (NWidgetBase *child_wid = rtl ? this->tail : this->head; child_wid != NULL; child_wid = rtl ? child_wid->prev : child_wid->next) {
 			if (child_wid->type == NWID_SPACER) continue;
 			if (!this->visible[((NWidgetCore*)child_wid)->index]) continue;
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -144,7 +144,7 @@
 		int exclusive_width      = exclusive_size.width;
 		int exclusive_y_offset   = (FONT_HEIGHT_NORMAL - exclusive_size.height) / 2;
 
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		uint text_left      = left  + (rtl ? 0 : icon_width + exclusive_width + 4);
 		uint text_right     = right - (rtl ? icon_width + exclusive_width + 4 : 0);
 		uint icon_left      = rtl ? right - icon_width : left;
@@ -398,7 +398,7 @@
 		if (cargo_needed_for_growth > 0) {
 			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH);
 
-			bool rtl = _dynlang.text_dir == TD_RTL;
+			bool rtl = _current_text_dir == TD_RTL;
 			uint cargo_text_left = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : 20);
 			uint cargo_text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? 20 : 0);
 
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -55,7 +55,7 @@
  */
 static int HighlightDragPosition(int px, int max_width, VehicleID selection)
 {
-	bool rtl = _dynlang.text_dir == TD_RTL;
+	bool rtl = _current_text_dir == TD_RTL;
 
 	assert(selection != INVALID_VEHICLE);
 	Point offset;
@@ -85,7 +85,7 @@
  */
 void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, int skip, VehicleID drag_dest)
 {
-	bool rtl = _dynlang.text_dir == TD_RTL;
+	bool rtl = _current_text_dir == TD_RTL;
 	Direction dir = rtl ? DIR_E : DIR_W;
 
 	DrawPixelInfo tmp_dpi, *old_dpi;
@@ -335,7 +335,7 @@
 {
 	/* draw the first 3 details tabs */
 	if (det_tab != TDW_TAB_TOTALS) {
-		bool rtl = _dynlang.text_dir == TD_RTL;
+		bool rtl = _current_text_dir == TD_RTL;
 		Direction dir = rtl ? DIR_E : DIR_W;
 		int x = rtl ? right : left;
 		int sprite_y_offset = 4 + (FONT_HEIGHT_NORMAL - 10) / 2;
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1032,7 +1032,7 @@
 	int left = r.left + WD_MATRIX_LEFT;
 	int right = r.right - WD_MATRIX_RIGHT;
 	int width = right - left;
-	bool rtl = _dynlang.text_dir == TD_RTL;
+	bool rtl = _current_text_dir == TD_RTL;
 
 	int text_offset = GetDigitWidth() * this->unitnumber_digits + WD_FRAMERECT_RIGHT;
 	int text_left  = left  + (rtl ?           0 : text_offset);
@@ -1739,7 +1739,7 @@
 
 			case VLD_WIDGET_MIDDLE_DETAILS: {
 				/* For other vehicles, at the place of the matrix. */
-				bool rtl = _dynlang.text_dir == TD_RTL;
+				bool rtl = _current_text_dir == TD_RTL;
 				uint sprite_width = max<uint>(GetSprite(v->GetImage(rtl ? DIR_E : DIR_W), ST_NORMAL)->width, 70U) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
 				uint text_left  = r.left  + (rtl ? 0 : sprite_width);
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -52,7 +52,7 @@
 	if (count != 0) bottom -= (count - pos - cap) * height / count;
 
 	Point pt;
-	if (horizontal && _dynlang.text_dir == TD_RTL) {
+	if (horizontal && _current_text_dir == TD_RTL) {
 		pt.x = rev_base - (bottom - 1);
 		pt.y = rev_base - top;
 	} else {
@@ -78,7 +78,7 @@
 
 	if (sb->type == NWID_HSCROLLBAR) {
 		pos = x;
-		rtl = _dynlang.text_dir == TD_RTL;
+		rtl = _current_text_dir == TD_RTL;
 	} else {
 		pos = y;
 	}
@@ -387,7 +387,7 @@
 	if (str != STR_NULL) dy1 = FONT_HEIGHT_NORMAL / 2 - 1;
 	int dy2 = dy1 + 1;
 
-	if (_dynlang.text_dir == TD_LTR) {
+	if (_current_text_dir == TD_LTR) {
 		/* Line from upper left corner to start of text */
 		GfxFillRect(r.left, r.top + dy1, r.left + 4, r.top + dy1, c1);
 		GfxFillRect(r.left + 1, r.top + dy2, r.left + 4, r.top + dy2, c2);
@@ -514,7 +514,7 @@
  */
 static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicked_button, bool clicked_dropdown, StringID str)
 {
-	if (_dynlang.text_dir == TD_LTR) {
+	if (_current_text_dir == TD_LTR) {
 		DrawFrameRect(r.left, r.top, r.right - 12, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
 		DrawFrameRect(r.right - 11, r.top, r.right, r.bottom, colour, clicked_dropdown ? FR_LOWERED : FR_NONE);
 		DrawString(r.right - (clicked_dropdown ? 10 : 11), r.right, r.top + (clicked_dropdown ? 2 : 1), DOWNARROW, TC_BLACK, SA_HOR_CENTER);
@@ -564,7 +564,7 @@
 	const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget);
 
 	int offset = this->IsWidgetLowered(widget) ? 1 : 0;
-	int base = offset + nwid->pos_x + (_dynlang.text_dir == TD_LTR ? nwid->current_x - WD_SORTBUTTON_ARROW_WIDTH : 0);
+	int base = offset + nwid->pos_x + (_current_text_dir == TD_LTR ? nwid->current_x - WD_SORTBUTTON_ARROW_WIDTH : 0);
 	int top = nwid->pos_y;
 
 	DrawString(base, base + WD_SORTBUTTON_ARROW_WIDTH, top + 1 + offset, state == SBS_DOWN ? DOWNARROW : UPARROW, TC_BLACK, SA_HOR_CENTER);
@@ -2014,8 +2014,8 @@
 		case WWT_PUSHARROWBTN: {
 			SpriteID sprite;
 			switch (this->widget_data) {
-				case AWV_DECREASE: sprite = _dynlang.text_dir != TD_RTL ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT; break;
-				case AWV_INCREASE: sprite = _dynlang.text_dir == TD_RTL ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT; break;
+				case AWV_DECREASE: sprite = _current_text_dir != TD_RTL ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT; break;
+				case AWV_INCREASE: sprite = _current_text_dir == TD_RTL ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT; break;
 				case AWV_LEFT:     sprite = SPR_ARROW_LEFT;  break;
 				case AWV_RIGHT:    sprite = SPR_ARROW_RIGHT; break;
 				default: NOT_REACHED();
@@ -2098,7 +2098,7 @@
  */
 bool NWidgetLeaf::ButtonHit(const Point &pt)
 {
-	if (_dynlang.text_dir == TD_LTR) {
+	if (_current_text_dir == TD_LTR) {
 		int button_width = this->pos_x + this->current_x - 12;
 		return pt.x < button_width;
 	} else {
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -413,7 +413,7 @@
 
 	if (auto_width) width = max(width, max_item_width);
 
-	Point dw_pos = { w->left + (_dynlang.text_dir == TD_RTL ? wi_rect.right + 1 - width : wi_rect.left), top};
+	Point dw_pos = { w->left + (_current_text_dir == TD_RTL ? wi_rect.right + 1 - width : wi_rect.left), top};
 	Dimension dw_size = {width, height};
 	new DropdownWindow(w, list, selected, button, instant_close, dw_pos, dw_size, wi_colour, scroll);
 }
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -573,7 +573,7 @@
 	this->OnInit();
 	/* Re-initialize the window from the ground up. No need to change the nested_array, as all widgets stay where they are. */
 	this->nested_root->SetupSmallestSize(this, false);
-	this->nested_root->AssignSizePosition(ST_SMALLEST, 0, 0, this->nested_root->smallest_x, this->nested_root->smallest_y, _dynlang.text_dir == TD_RTL);
+	this->nested_root->AssignSizePosition(ST_SMALLEST, 0, 0, this->nested_root->smallest_x, this->nested_root->smallest_y, _current_text_dir == TD_RTL);
 	this->width  = this->nested_root->smallest_x;
 	this->height = this->nested_root->smallest_y;
 	this->resize.step_width  = this->nested_root->resize_x;
@@ -907,7 +907,7 @@
 		this->nested_root->SetupSmallestSize(this, false);
 	}
 	/* Initialize to smallest size. */
-	this->nested_root->AssignSizePosition(ST_SMALLEST, 0, 0, this->nested_root->smallest_x, this->nested_root->smallest_y, _dynlang.text_dir == TD_RTL);
+	this->nested_root->AssignSizePosition(ST_SMALLEST, 0, 0, this->nested_root->smallest_x, this->nested_root->smallest_y, _current_text_dir == TD_RTL);
 
 	/* Further set up window properties,
 	 * this->left, this->top, this->width, this->height, this->resize.width, and this->resize.height are initialized later. */
@@ -1186,7 +1186,7 @@
 {
 	const Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
 	assert(w != NULL);
-	Point pt = { _dynlang.text_dir == TD_RTL ? w->left : (w->left + w->width) - window_width, w->top + w->height };
+	Point pt = { _current_text_dir == TD_RTL ? w->left : (w->left + w->width) - window_width, w->top + w->height };
 	return pt;
 }
 
@@ -1594,7 +1594,7 @@
 		assert(w->nested_root->resize_x == 0 || new_xinc % w->nested_root->resize_x == 0);
 		assert(w->nested_root->resize_y == 0 || new_yinc % w->nested_root->resize_y == 0);
 
-		w->nested_root->AssignSizePosition(ST_RESIZE, 0, 0, w->nested_root->smallest_x + new_xinc, w->nested_root->smallest_y + new_yinc, _dynlang.text_dir == TD_RTL);
+		w->nested_root->AssignSizePosition(ST_RESIZE, 0, 0, w->nested_root->smallest_x + new_xinc, w->nested_root->smallest_y + new_yinc, _current_text_dir == TD_RTL);
 		w->width  = w->nested_root->current_x;
 		w->height = w->nested_root->current_y;
 	}
@@ -1861,7 +1861,7 @@
 
 			if (sb->type == NWID_HSCROLLBAR) {
 				i = _cursor.pos.x - _cursorpos_drag_start.x;
-				rtl = _dynlang.text_dir == TD_RTL;
+				rtl = _current_text_dir == TD_RTL;
 			} else {
 				i = _cursor.pos.y - _cursorpos_drag_start.y;
 			}