summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_gui.cpp19
-rw-r--r--src/roadveh_gui.cpp16
-rw-r--r--src/ship_gui.cpp14
-rw-r--r--src/train_gui.cpp23
-rw-r--r--src/vehicle_gui.cpp24
-rw-r--r--src/vehicle_gui_base.h2
6 files changed, 65 insertions, 33 deletions
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index 21cfb7960..3ccea1c52 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -17,6 +17,7 @@
#include "vehicle_func.h"
#include "gfx_func.h"
#include "window_gui.h"
+#include "spritecache.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -79,16 +80,26 @@ void DrawAircraftDetails(const Aircraft *v, int left, int right, int y)
*/
void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection)
{
+ bool rtl = _dynlang.text_dir == TD_RTL;
+
+ SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W);
+ const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
+
+ int x = rtl ? right - real_sprite->width - real_sprite->x_offs : left - real_sprite->x_offs;
+ bool helicopter = v->subtype == AIR_HELICOPTER;
+
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
- DrawSprite(v->GetImage(DIR_W), pal, left + 25, y + 10);
- if (v->subtype == AIR_HELICOPTER) {
+ DrawSprite(sprite, pal, x, y + 10);
+ if (helicopter) {
const Aircraft *a = Aircraft::From(v);
SpriteID rotor_sprite = GetCustomRotorSprite(a, true);
if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
- DrawSprite(rotor_sprite, PAL_NONE, left + 25, y + 5);
+ DrawSprite(rotor_sprite, PAL_NONE, x, y + 5);
}
if (v->index == selection) {
- DrawFrameRect(left - 1, y - 1, left + 58, y + 21, COLOUR_WHITE, FR_BORDERONLY);
+ x += real_sprite->x_offs;
+ y += real_sprite->y_offs + 10 - (helicopter ? 5 : 0);
+ DrawFrameRect(x - 1, y - 1, x + real_sprite->width + 1, y + real_sprite->height + (helicopter ? 5 : 0) + 1, COLOUR_WHITE, FR_BORDERONLY);
}
}
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);
}
}
diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp
index 64a2157d3..b76d5fd86 100644
--- a/src/ship_gui.cpp
+++ b/src/ship_gui.cpp
@@ -16,6 +16,7 @@
#include "vehicle_gui.h"
#include "strings_func.h"
#include "vehicle_func.h"
+#include "spritecache.h"
#include "table/strings.h"
@@ -29,10 +30,19 @@
*/
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection)
{
- DrawSprite(v->GetImage(DIR_W), GetVehiclePalette(v), left + 32, y + 10);
+ bool rtl = _dynlang.text_dir == TD_RTL;
+
+ SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W);
+ const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
+
+ int x = rtl ? right - real_sprite->width - real_sprite->x_offs : left - real_sprite->x_offs;
+
+ DrawSprite(sprite, GetVehiclePalette(v), x, y + 10);
if (v->index == selection) {
- DrawFrameRect(left - 5, y - 1, left + 67, y + 21, COLOUR_WHITE, FR_BORDERONLY);
+ x += real_sprite->x_offs;
+ y += real_sprite->y_offs + 10;
+ DrawFrameRect(x - 1, y - 1, x + real_sprite->width + 1, y + real_sprite->height + 1, COLOUR_WHITE, FR_BORDERONLY);
}
}
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) {
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 9bf5e6841..3e050ddce 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -769,21 +769,14 @@ static void DrawSmallOrderList(const Vehicle *v, int left, int right, int y)
int i = 0;
int sel = v->cur_order_index;
- bool rtl = _dynlang.text_dir == TD_RTL;
FOR_VEHICLE_ORDERS(v, order) {
- if (sel == 0) {
- if (rtl) {
- DrawString(right, right + 6, y, STR_TINY_RIGHT_ARROW, TC_BLACK);
- } else {
- DrawString(left - 6, left, y, STR_TINY_RIGHT_ARROW, TC_BLACK);
- }
- }
+ if (sel == 0) DrawString(left, right, y, STR_TINY_RIGHT_ARROW, TC_BLACK);
sel--;
if (order->IsType(OT_GOTO_STATION)) {
SetDParam(0, order->GetDestination());
- DrawString(left, right, y, STR_TINY_BLACK_STATION);
+ DrawString(left + 6, right - 6, y, STR_TINY_BLACK_STATION);
y += FONT_HEIGHT_SMALL;
if (++i == 4) break;
@@ -841,6 +834,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
{
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;
SetDParam(0, this->max_unitnumber);
@@ -848,8 +842,12 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
int text_left = left + (rtl ? 0 : text_offset);
int text_right = right - (rtl ? text_offset : 0);
- int orderlist_left = left + (rtl ? 0 : 120 + text_offset);
- int orderlist_right = right - (rtl ? 120 + text_offset : 0);
+ bool show_orderlist = vehicle_type >= VEH_SHIP;
+ int orderlist_left = left + (rtl ? 0 : max(100 + text_offset, width / 2));
+ int orderlist_right = right - (rtl ? max(100 + text_offset, width / 2) : 0);
+
+ int image_left = (rtl && show_orderlist) ? orderlist_right : text_left;
+ int image_right = (!rtl && show_orderlist) ? orderlist_left : text_right;
int vehicle_button_x = rtl ? right - 8 : left;
@@ -862,7 +860,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
SetDParam(0, v->GetDisplayProfitThisYear());
SetDParam(1, v->GetDisplayProfitLastYear());
- DrawVehicleImage(v, text_left, text_right, y + FONT_HEIGHT_SMALL - 1, selected_vehicle, 0);
+ DrawVehicleImage(v, image_left, image_right, y + FONT_HEIGHT_SMALL - 1, selected_vehicle, 0);
DrawString(text_left, text_right, y + line_height - FONT_HEIGHT_SMALL - WD_FRAMERECT_BOTTOM - 1, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
if (v->name != NULL) {
@@ -875,7 +873,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
DrawString(text_left, text_right, y, STR_TINY_GROUP, TC_BLACK);
}
- if (vehicle_type >= VEH_SHIP) DrawSmallOrderList(v, orderlist_left, orderlist_right, y);
+ if (show_orderlist) DrawSmallOrderList(v, orderlist_left, orderlist_right, y);
if (v->IsInDepot()) {
str = STR_BLUE_COMMA;
diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h
index 5380aacb0..09d63bd30 100644
--- a/src/vehicle_gui_base.h
+++ b/src/vehicle_gui_base.h
@@ -16,7 +16,7 @@
typedef GUIList<const Vehicle*> GUIVehicleList;
-struct BaseVehicleListWindow: public Window {
+struct BaseVehicleListWindow : public Window {
GUIVehicleList vehicles; ///< The list of vehicles
Listing *sorting; ///< Pointer to the vehicle type related sorting.
VehicleType vehicle_type; ///< The vehicle type that is sorted