mirror of https://github.com/OpenTTD/OpenTTD
(svn r17185) -Codechange: Tweak depot gui and vehicle lists, so text overlaps less with vehicle images.
parent
1f3f53f421
commit
2ad4bf74a1
|
@ -271,7 +271,7 @@ struct DepotWindow : Window {
|
||||||
free_wagon = u->IsFreeWagon();
|
free_wagon = u->IsFreeWagon();
|
||||||
|
|
||||||
uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0;
|
uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0;
|
||||||
DrawTrainImage(u, x + 21 + x_space, sprite_y, this->sel, this->hscroll.cap + 4 - x_space, this->hscroll.pos);
|
DrawTrainImage(u, x + 24 + x_space, sprite_y - 1, this->sel, this->hscroll.cap - x_space, this->hscroll.pos);
|
||||||
|
|
||||||
/* Number of wagons relative to a standard length wagon (rounded up) */
|
/* Number of wagons relative to a standard length wagon (rounded up) */
|
||||||
SetDParam(0, (u->tcache.cached_total_length + 7) / 8);
|
SetDParam(0, (u->tcache.cached_total_length + 7) / 8);
|
||||||
|
|
|
@ -322,7 +322,6 @@ public:
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
const Owner owner = (Owner)GB(this->window_number, 0, 8);
|
const Owner owner = (Owner)GB(this->window_number, 0, 8);
|
||||||
int x = this->widget[GRP_WIDGET_LIST_VEHICLE].left + 2;
|
|
||||||
int y1 = PLY_WND_PRC__OFFSET_TOP_WIDGET + 2;
|
int y1 = PLY_WND_PRC__OFFSET_TOP_WIDGET + 2;
|
||||||
int max;
|
int max;
|
||||||
int i;
|
int i;
|
||||||
|
@ -422,7 +421,7 @@ public:
|
||||||
|
|
||||||
this->DrawSortButtonState(GRP_WIDGET_SORT_BY_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
|
this->DrawSortButtonState(GRP_WIDGET_SORT_BY_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
|
||||||
|
|
||||||
this->DrawVehicleListItems(x, this->vehicle_sel);
|
this->DrawVehicleListItems(this->vehicle_sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnClick(Point pt, int widget)
|
virtual void OnClick(Point pt, int widget)
|
||||||
|
|
|
@ -70,7 +70,7 @@ void DrawTrainImage(const Train *v, int x, int y, VehicleID selection, int max_w
|
||||||
int highlight_l = 0;
|
int highlight_l = 0;
|
||||||
int highlight_r = 0;
|
int highlight_r = 0;
|
||||||
|
|
||||||
if (!FillDrawPixelInfo(&tmp_dpi, x - 2, y - 1, max_width + 1, 14)) return;
|
if (!FillDrawPixelInfo(&tmp_dpi, x, y, max_width, 14)) return;
|
||||||
|
|
||||||
old_dpi = _cur_dpi;
|
old_dpi = _cur_dpi;
|
||||||
_cur_dpi = &tmp_dpi;
|
_cur_dpi = &tmp_dpi;
|
||||||
|
|
|
@ -793,11 +793,12 @@ static void DrawVehicleImage(const Vehicle *v, int x, int y, VehicleID selection
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw all the vehicle list items.
|
* Draw all the vehicle list items.
|
||||||
* @param x the position from where to draw the items.
|
|
||||||
* @param selected_vehicle the vehicle that is to be selected
|
* @param selected_vehicle the vehicle that is to be selected
|
||||||
*/
|
*/
|
||||||
void BaseVehicleListWindow::DrawVehicleListItems(int x, VehicleID selected_vehicle)
|
void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle)
|
||||||
{
|
{
|
||||||
|
int left = this->widget[VLW_WIDGET_LIST].left + WD_MATRIX_LEFT;
|
||||||
|
int right = this->widget[VLW_WIDGET_LIST].right - WD_MATRIX_RIGHT;
|
||||||
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
|
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
|
||||||
uint max = min(this->vscroll.pos + this->vscroll.cap, this->vehicles.Length());
|
uint max = min(this->vscroll.pos + this->vscroll.cap, this->vehicles.Length());
|
||||||
for (uint i = this->vscroll.pos; i < max; ++i) {
|
for (uint i = this->vscroll.pos; i < max; ++i) {
|
||||||
|
@ -807,20 +808,20 @@ void BaseVehicleListWindow::DrawVehicleListItems(int x, VehicleID selected_vehic
|
||||||
SetDParam(0, v->GetDisplayProfitThisYear());
|
SetDParam(0, v->GetDisplayProfitThisYear());
|
||||||
SetDParam(1, v->GetDisplayProfitLastYear());
|
SetDParam(1, v->GetDisplayProfitLastYear());
|
||||||
|
|
||||||
DrawVehicleImage(v, x + 19, y + 6, selected_vehicle, this->widget[VLW_WIDGET_LIST].right - this->widget[VLW_WIDGET_LIST].left - 20, 0);
|
DrawVehicleImage(v, left + 19, y + 5, selected_vehicle, right - left + 1 - 19, 0);
|
||||||
DrawString(x + 19, this->widget[VLW_WIDGET_LIST].right, y + this->resize.step_height - 8, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
|
DrawString(left + 19, right, y + this->resize.step_height - 8, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
|
||||||
|
|
||||||
if (v->name != NULL) {
|
if (v->name != NULL) {
|
||||||
/* The vehicle got a name so we will print it */
|
/* The vehicle got a name so we will print it */
|
||||||
SetDParam(0, v->index);
|
SetDParam(0, v->index);
|
||||||
DrawString(x + 19, this->widget[VLW_WIDGET_LIST].right, y, STR_TINY_BLACK_VEHICLE);
|
DrawString(left + 19, right, y, STR_TINY_BLACK_VEHICLE);
|
||||||
} else if (v->group_id != DEFAULT_GROUP) {
|
} else if (v->group_id != DEFAULT_GROUP) {
|
||||||
/* The vehicle has no name, but is member of a group, so print group name */
|
/* The vehicle has no name, but is member of a group, so print group name */
|
||||||
SetDParam(0, v->group_id);
|
SetDParam(0, v->group_id);
|
||||||
DrawString(x + 19, this->widget[VLW_WIDGET_LIST].right, y, STR_TINT_GROUP, TC_BLACK);
|
DrawString(left + 19, right, y, STR_TINT_GROUP, TC_BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG) DrawSmallOrderList(v, x + 138, this->widget[VLW_WIDGET_LIST].right, y);
|
if (this->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG) DrawSmallOrderList(v, left + 138, right, y);
|
||||||
|
|
||||||
if (v->IsInDepot()) {
|
if (v->IsInDepot()) {
|
||||||
str = STR_BLUE_COMMA;
|
str = STR_BLUE_COMMA;
|
||||||
|
@ -829,9 +830,9 @@ void BaseVehicleListWindow::DrawVehicleListItems(int x, VehicleID selected_vehic
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDParam(0, v->unitnumber);
|
SetDParam(0, v->unitnumber);
|
||||||
DrawString(x, this->widget[VLW_WIDGET_LIST].right, y + 2, str);
|
DrawString(left, right, y + 2, str);
|
||||||
|
|
||||||
DrawVehicleProfitButton(v, x, y + 13);
|
DrawVehicleProfitButton(v, left, y + 13);
|
||||||
|
|
||||||
y += this->resize.step_height;
|
y += this->resize.step_height;
|
||||||
}
|
}
|
||||||
|
@ -911,7 +912,6 @@ struct VehicleListWindow : public BaseVehicleListWindow {
|
||||||
|
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
int x = 2;
|
|
||||||
const Owner owner = this->owner;
|
const Owner owner = this->owner;
|
||||||
const uint16 window_type = this->window_number & VLW_MASK;
|
const uint16 window_type = this->window_number & VLW_MASK;
|
||||||
const uint16 index = GB(this->window_number, 16, 16);
|
const uint16 index = GB(this->window_number, 16, 16);
|
||||||
|
@ -991,7 +991,7 @@ struct VehicleListWindow : public BaseVehicleListWindow {
|
||||||
/* draw arrow pointing up/down for ascending/descending sorting */
|
/* draw arrow pointing up/down for ascending/descending sorting */
|
||||||
this->DrawSortButtonState(VLW_WIDGET_SORT_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
|
this->DrawSortButtonState(VLW_WIDGET_SORT_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
|
||||||
|
|
||||||
this->DrawVehicleListItems(x, INVALID_VEHICLE);
|
this->DrawVehicleListItems(INVALID_VEHICLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnClick(Point pt, int widget)
|
virtual void OnClick(Point pt, int widget)
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
/** Start of functions regarding vehicle list windows */
|
/** Start of functions regarding vehicle list windows */
|
||||||
enum {
|
enum {
|
||||||
PLY_WND_PRC__OFFSET_TOP_WIDGET = 26,
|
PLY_WND_PRC__OFFSET_TOP_WIDGET = 26,
|
||||||
PLY_WND_PRC__SIZE_OF_ROW_TINY = 13,
|
PLY_WND_PRC__SIZE_OF_ROW_TINY = 13, ///< Height of rows in group list
|
||||||
PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26,
|
PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26, ///< Height of rows in train/roadvehicle list
|
||||||
PLY_WND_PRC__SIZE_OF_ROW_BIG = 39,
|
PLY_WND_PRC__SIZE_OF_ROW_BIG = 39, ///< Height of rows in ship/aircraft list
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef GUIList<const Vehicle*> GUIVehicleList;
|
typedef GUIList<const Vehicle*> GUIVehicleList;
|
||||||
|
@ -30,7 +30,7 @@ struct BaseVehicleListWindow: public Window {
|
||||||
this->vehicles.SetSortFuncs(this->vehicle_sorter_funcs);
|
this->vehicles.SetSortFuncs(this->vehicle_sorter_funcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawVehicleListItems(int x, VehicleID selected_vehicle);
|
void DrawVehicleListItems(VehicleID selected_vehicle);
|
||||||
void SortVehicleList();
|
void SortVehicleList();
|
||||||
void BuildVehicleList(Owner owner, uint16 index, uint16 window_type);
|
void BuildVehicleList(Owner owner, uint16 index, uint16 window_type);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue