summaryrefslogtreecommitdiff
path: root/src/roadveh_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/roadveh_gui.cpp
parent5fdff78c4290e0fd3bfcd552e76bb11f4cb9b312 (diff)
downloadopenttd-9bfcf2b6150d59187a6071943608218a793bbe0b.tar.xz
(svn r18136) -Codechange: support RTL in the vehicle lists
Diffstat (limited to 'src/roadveh_gui.cpp')
-rw-r--r--src/roadveh_gui.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index c0682cf06..43c00f635 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -131,20 +131,26 @@ void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y)
*/
void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection)
{
+ bool rtl = _dynlang.text_dir == TD_RTL;
+ Direction dir = rtl ? DIR_E : DIR_W;
const RoadVehicle *u = RoadVehicle::From(v);
+
int max_width = right - left + 1;
- int x_pos = 0;
- for (; u != NULL && x_pos < max_width; u = u->Next()) {
+ int spent_width = 0;
+ int pos = rtl ? right : left;
+
+ for (; u != NULL && spent_width < max_width; u = u->Next()) {
Point offset;
int width = u->GetDisplayImageWidth(&offset);
SpriteID pal = (u->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(u);
- DrawSprite(u->GetImage(DIR_W), pal, left + x_pos + offset.x, y + 6 + offset.y);
- x_pos += width;
+ DrawSprite(u->GetImage(dir), pal, pos + (rtl ? -offset.x : offset.x), y + 6 + offset.y);
+
+ pos += rtl ? -width : width;
}
if (v->index == selection) {
- DrawFrameRect(left - 1, y - 1, left - 1 + x_pos, y + 12, COLOUR_WHITE, FR_BORDERONLY);
+ DrawFrameRect((rtl ? pos : left) - 1, y - 1, (rtl ? pos : right) - 1, y + 12, COLOUR_WHITE, FR_BORDERONLY);
}
}