summaryrefslogtreecommitdiff
path: root/src/train_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-11-17 11:36:36 +0000
committerrubidium <rubidium@openttd.org>2009-11-17 11:36:36 +0000
commit9bfcf2b6150d59187a6071943608218a793bbe0b (patch)
treeab04eeb0c4da4283b350ebb8141c903f67a57da6 /src/train_gui.cpp
parent5fdff78c4290e0fd3bfcd552e76bb11f4cb9b312 (diff)
downloadopenttd-9bfcf2b6150d59187a6071943608218a793bbe0b.tar.xz
(svn r18136) -Codechange: support RTL in the vehicle lists
Diffstat (limited to 'src/train_gui.cpp')
-rw-r--r--src/train_gui.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 0ad1c04b6..a28decbc9 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -70,6 +70,9 @@ void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2)
*/
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, int skip)
{
+ bool rtl = _dynlang.text_dir == TD_RTL;
+ Direction dir = rtl ? DIR_E : DIR_W;
+
DrawPixelInfo tmp_dpi, *old_dpi;
/* Position of highlight box */
int highlight_l = 0;
@@ -81,29 +84,33 @@ void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID select
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
- int px = -skip;
+ int px = rtl ? max_width + skip : -skip;
bool sel_articulated = false;
- for (; v != NULL && px < max_width; v = v->Next()) {
+ for (; v != NULL && (rtl ? px > 0 : px < max_width); v = v->Next()) {
Point offset;
int width = Train::From(v)->GetDisplayImageWidth(&offset);
- if (px + width > 0) {
+ if (rtl ? px + width > 0 : px - width < max_width) {
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
- DrawSprite(v->GetImage(DIR_W), pal, px + offset.x, 7 + offset.y);
+ DrawSprite(v->GetImage(dir), pal, px + (rtl ? -offset.x : offset.x), 7 + offset.y);
}
if (!v->IsArticulatedPart()) sel_articulated = false;
if (v->index == selection) {
/* Set the highlight position */
- highlight_l = px + 1;
- highlight_r = px + width + 1;
+ highlight_l = rtl ? px - width + 1 : px + 1;
+ highlight_r = rtl ? px + 1 : px + width + 1;
sel_articulated = true;
} else if ((_cursor.vehchain && highlight_r != 0) || sel_articulated) {
- highlight_r += width;
+ if (rtl) {
+ highlight_r += width;
+ } else {
+ highlight_l -= width;
+ }
}
- px += width;
+ px += rtl ? -width : width;
}
if (highlight_l != highlight_r) {