openttd updated to 1.5.0-beta2
--HG-- branch : openttd
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $Id: depot_gui.cpp 26106 2013-11-25 13:28:08Z rubidium $ */
|
||||
/* $Id: depot_gui.cpp 27134 2015-02-01 20:54:24Z frosch $ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
/*
|
||||
* Since all depot window sizes aren't the same, we need to modify sizes a little.
|
||||
* It's done with the following arrays of widget indexes. Each of them tells if a widget side should be moved and in what direction.
|
||||
@@ -188,16 +190,19 @@ static void InitBlocksizeForVehicles(VehicleType type, EngineImageType image_typ
|
||||
if ((int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
|
||||
}
|
||||
|
||||
int min_extend = ScaleGUITrad(16);
|
||||
int max_extend = ScaleGUITrad(98);
|
||||
|
||||
switch (image_type) {
|
||||
case EIT_IN_DEPOT:
|
||||
_base_block_sizes_depot[type].height = max(GetVehicleHeight(type), max_height);
|
||||
_base_block_sizes_depot[type].extend_left = Clamp(max_extend_left, 16, 98);
|
||||
_base_block_sizes_depot[type].extend_right = Clamp(max_extend_right, 16, 98);
|
||||
_base_block_sizes_depot[type].height = max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
|
||||
_base_block_sizes_depot[type].extend_left = Clamp(max_extend_left, min_extend, max_extend);
|
||||
_base_block_sizes_depot[type].extend_right = Clamp(max_extend_right, min_extend, max_extend);
|
||||
break;
|
||||
case EIT_PURCHASE:
|
||||
_base_block_sizes_purchase[type].height = max(GetVehicleHeight(type), max_height);
|
||||
_base_block_sizes_purchase[type].extend_left = Clamp(max_extend_left, 16, 98);
|
||||
_base_block_sizes_purchase[type].extend_right = Clamp(max_extend_right, 16, 98);
|
||||
_base_block_sizes_purchase[type].height = max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
|
||||
_base_block_sizes_purchase[type].extend_left = Clamp(max_extend_left, min_extend, max_extend);
|
||||
_base_block_sizes_purchase[type].extend_right = Clamp(max_extend_right, min_extend, max_extend);
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
@@ -226,6 +231,7 @@ struct DepotWindow : Window {
|
||||
bool generate_list;
|
||||
VehicleList vehicle_list;
|
||||
VehicleList wagon_list;
|
||||
uint unitnumber_digits;
|
||||
uint num_columns; ///< Number of columns.
|
||||
Scrollbar *hscroll; ///< Only for trains.
|
||||
Scrollbar *vscroll;
|
||||
@@ -239,6 +245,7 @@ struct DepotWindow : Window {
|
||||
this->generate_list = true;
|
||||
this->type = type;
|
||||
this->num_columns = 1; // for non-trains this gets set in FinishInitNested()
|
||||
this->unitnumber_digits = 2;
|
||||
|
||||
this->CreateNestedTree();
|
||||
this->hscroll = (this->type == VEH_TRAIN ? this->GetScrollbar(WID_D_H_SCROLL) : NULL);
|
||||
@@ -272,7 +279,7 @@ struct DepotWindow : Window {
|
||||
void DrawVehicleInDepot(const Vehicle *v, int left, int right, int y) const
|
||||
{
|
||||
bool free_wagon = false;
|
||||
int sprite_y = y + (this->resize.step_height - GetVehicleHeight(v->type)) / 2;
|
||||
int sprite_y = y + (this->resize.step_height - ScaleGUITrad(GetVehicleHeight(v->type))) / 2;
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
int image_left = rtl ? left + this->count_width : left + this->header_width;
|
||||
@@ -283,7 +290,7 @@ struct DepotWindow : Window {
|
||||
const Train *u = Train::From(v);
|
||||
free_wagon = u->IsFreeWagon();
|
||||
|
||||
uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0;
|
||||
uint x_space = free_wagon ? ScaleGUITrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) : 0;
|
||||
DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
|
||||
this->sel, EIT_IN_DEPOT, free_wagon ? 0 : this->hscroll->GetPosition(), this->vehicle_over);
|
||||
|
||||
@@ -296,13 +303,7 @@ struct DepotWindow : Window {
|
||||
|
||||
case VEH_ROAD: DrawRoadVehImage( v, image_left, image_right, sprite_y, this->sel, EIT_IN_DEPOT); break;
|
||||
case VEH_SHIP: DrawShipImage( v, image_left, image_right, sprite_y, this->sel, EIT_IN_DEPOT); break;
|
||||
case VEH_AIRCRAFT: {
|
||||
const Sprite *spr = GetSprite(v->GetImage(DIR_W, EIT_IN_DEPOT), ST_NORMAL);
|
||||
DrawAircraftImage(v, image_left, image_right,
|
||||
y + max(UnScaleByZoom(spr->height, ZOOM_LVL_GUI) + UnScaleByZoom(spr->y_offs, ZOOM_LVL_GUI) - 14, 0), // tall sprites needs an y offset
|
||||
this->sel, EIT_IN_DEPOT);
|
||||
break;
|
||||
}
|
||||
case VEH_AIRCRAFT: DrawAircraftImage(v, image_left, image_right, sprite_y, this->sel, EIT_IN_DEPOT); break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
@@ -428,7 +429,7 @@ struct DepotWindow : Window {
|
||||
pos -= this->vehicle_list.Length();
|
||||
*veh = this->wagon_list[pos];
|
||||
/* free wagons don't have an initial loco. */
|
||||
x -= VEHICLEINFO_FULL_VEHICLE_WIDTH;
|
||||
x -= ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
|
||||
wagon = true;
|
||||
}
|
||||
|
||||
@@ -608,16 +609,17 @@ struct DepotWindow : Window {
|
||||
this->count_width = 0;
|
||||
}
|
||||
|
||||
Dimension unumber = { GetDigitWidth() * 4, FONT_HEIGHT_NORMAL };
|
||||
SetDParamMaxDigits(0, this->unitnumber_digits);
|
||||
Dimension unumber = GetStringBoundingBox(STR_BLACK_COMMA);
|
||||
const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL);
|
||||
this->flag_width = UnScaleByZoom(spr->width, ZOOM_LVL_GUI) + WD_FRAMERECT_RIGHT;
|
||||
this->flag_height = UnScaleByZoom(spr->height, ZOOM_LVL_GUI);
|
||||
this->flag_width = UnScaleGUI(spr->width) + WD_FRAMERECT_RIGHT;
|
||||
this->flag_height = UnScaleGUI(spr->height);
|
||||
|
||||
if (this->type == VEH_TRAIN || this->type == VEH_ROAD) {
|
||||
min_height = max<uint>(unumber.height + WD_MATRIX_TOP, UnScaleByZoom(spr->height, ZOOM_LVL_GUI));
|
||||
min_height = max<uint>(unumber.height + WD_MATRIX_TOP, UnScaleGUI(spr->height));
|
||||
this->header_width = unumber.width + this->flag_width + WD_FRAMERECT_LEFT;
|
||||
} else {
|
||||
min_height = unumber.height + UnScaleByZoom(spr->height, ZOOM_LVL_GUI) + WD_MATRIX_TOP + WD_PAR_VSEP_NORMAL + WD_MATRIX_BOTTOM;
|
||||
min_height = unumber.height + UnScaleGUI(spr->height) + WD_MATRIX_TOP + WD_PAR_VSEP_NORMAL + WD_MATRIX_BOTTOM;
|
||||
this->header_width = max<uint>(unumber.width, this->flag_width) + WD_FRAMERECT_RIGHT;
|
||||
}
|
||||
int base_width = this->count_width + this->header_width;
|
||||
@@ -625,7 +627,7 @@ struct DepotWindow : Window {
|
||||
resize->height = max<uint>(GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).height, min_height);
|
||||
if (this->type == VEH_TRAIN) {
|
||||
resize->width = 1;
|
||||
size->width = base_width + 2 * 29; // about 2 parts
|
||||
size->width = base_width + 2 * ScaleGUITrad(29); // about 2 parts
|
||||
size->height = resize->height * 6;
|
||||
} else {
|
||||
resize->width = base_width + GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).extend_left + GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).extend_right;
|
||||
@@ -657,11 +659,17 @@ struct DepotWindow : Window {
|
||||
BuildDepotVehicleList(this->type, this->window_number, &this->vehicle_list, &this->wagon_list);
|
||||
this->generate_list = false;
|
||||
DepotSortList(&this->vehicle_list);
|
||||
|
||||
uint new_unitnumber_digits = GetUnitNumberDigits(this->vehicle_list);
|
||||
if (this->unitnumber_digits != new_unitnumber_digits) {
|
||||
this->unitnumber_digits = new_unitnumber_digits;
|
||||
this->ReInit();
|
||||
}
|
||||
}
|
||||
|
||||
/* determine amount of items for scroller */
|
||||
if (this->type == VEH_TRAIN) {
|
||||
uint max_width = VEHICLEINFO_FULL_VEHICLE_WIDTH;
|
||||
uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
|
||||
for (uint num = 0; num < this->vehicle_list.Length(); num++) {
|
||||
uint width = 0;
|
||||
for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
|
||||
|
||||
Reference in New Issue
Block a user