Merge commit 'a8b575671894ffe1329ef37dca4989c0e60d70f5'
These merges are becoming more awful every time Conflicts: src/ai/ai_gui.cpp src/build_vehicle_gui.cpp src/cheat_gui.cpp src/company_gui.cpp src/depot_gui.cpp src/dock_gui.cpp src/error_gui.cpp src/genworld_gui.cpp src/misc_gui.cpp src/network/network_content_gui.cpp src/network/network_gui.cpp src/newgrf_gui.cpp src/news_gui.cpp src/rail_gui.cpp src/rev.cpp.in src/road_gui.cpp src/settings_gui.cpp src/settings_gui.h src/signs_gui.cpp src/station_gui.cpp src/table/settings.ini src/terraform_gui.cpp src/toolbar_gui.cpp src/toolbar_gui.h src/vehicle_gui.cpp src/video/sdl_v.cpp src/viewport.cpp src/widget.cpp src/widgets/settings_widget.h
This commit is contained in:
@@ -190,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,8 +229,10 @@ struct DepotWindow : Window {
|
||||
VehicleID vehicle_over; ///< Rail vehicle over which another one is dragged, \c INVALID_VEHICLE if none.
|
||||
VehicleType type;
|
||||
bool generate_list;
|
||||
int hovered_widget; ///< Index of the widget being hovered during drag/drop. -1 if no drag is in progress.
|
||||
VehicleList vehicle_list;
|
||||
VehicleList wagon_list;
|
||||
uint unitnumber_digits;
|
||||
uint num_columns; ///< Number of columns.
|
||||
Scrollbar *hscroll; ///< Only for trains.
|
||||
Scrollbar *vscroll;
|
||||
@@ -239,8 +244,10 @@ struct DepotWindow : Window {
|
||||
this->sel = INVALID_VEHICLE;
|
||||
this->vehicle_over = INVALID_VEHICLE;
|
||||
this->generate_list = true;
|
||||
this->hovered_widget = -1;
|
||||
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);
|
||||
@@ -274,7 +281,7 @@ struct DepotWindow : Window {
|
||||
void DrawVehicleInDepot(const Vehicle *v, int left, int right, int y) const
|
||||
{
|
||||
bool free_wagon = false;
|
||||
int sprite_y = Center(y, this->resize.step_height, GetVehicleHeight(v->type));
|
||||
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;
|
||||
@@ -285,8 +292,8 @@ struct DepotWindow : Window {
|
||||
const Train *u = Train::From(v);
|
||||
free_wagon = u->IsFreeWagon();
|
||||
|
||||
uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0;
|
||||
DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y,
|
||||
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);
|
||||
|
||||
/* Length of consist in tiles with 1 fractional digit (rounded up) */
|
||||
@@ -298,13 +305,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,
|
||||
Center(y, this->resize.step_height, UnScaleByZoom(spr->height, ZOOM_LVL_GUI) + UnScaleByZoom(spr->y_offs, ZOOM_LVL_GUI)), // 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();
|
||||
}
|
||||
|
||||
@@ -432,7 +433,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;
|
||||
}
|
||||
|
||||
@@ -612,16 +613,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;
|
||||
@@ -630,7 +632,7 @@ struct DepotWindow : Window {
|
||||
resize->height = GetMinSizing(NWST_STEP, resize->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;
|
||||
@@ -662,11 +664,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()) {
|
||||
@@ -864,11 +872,29 @@ struct DepotWindow : Window {
|
||||
this->sel = INVALID_VEHICLE;
|
||||
this->vehicle_over = INVALID_VEHICLE;
|
||||
this->SetWidgetDirty(WID_D_MATRIX);
|
||||
|
||||
if (this->hovered_widget != -1) {
|
||||
this->SetWidgetLoweredState(this->hovered_widget, false);
|
||||
this->SetWidgetDirty(this->hovered_widget);
|
||||
this->hovered_widget = -1;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnMouseDrag(Point pt, int widget)
|
||||
{
|
||||
if (this->type != VEH_TRAIN || this->sel == INVALID_VEHICLE) return;
|
||||
if (this->sel == INVALID_VEHICLE) return;
|
||||
if (widget != this->hovered_widget) {
|
||||
if (this->hovered_widget == WID_D_SELL || this->hovered_widget == WID_D_SELL_CHAIN) {
|
||||
this->SetWidgetLoweredState(this->hovered_widget, false);
|
||||
this->SetWidgetDirty(this->hovered_widget);
|
||||
}
|
||||
this->hovered_widget = widget;
|
||||
if (this->hovered_widget == WID_D_SELL || this->hovered_widget == WID_D_SELL_CHAIN) {
|
||||
this->SetWidgetLoweredState(this->hovered_widget, true);
|
||||
this->SetWidgetDirty(this->hovered_widget);
|
||||
}
|
||||
}
|
||||
if (this->type != VEH_TRAIN) return;
|
||||
|
||||
/* A rail vehicle is dragged.. */
|
||||
if (widget != WID_D_MATRIX) { // ..outside of the depot matrix.
|
||||
@@ -955,7 +981,9 @@ struct DepotWindow : Window {
|
||||
default:
|
||||
this->sel = INVALID_VEHICLE;
|
||||
this->SetDirty();
|
||||
break;
|
||||
}
|
||||
this->hovered_widget = -1;
|
||||
_cursor.vehchain = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user