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:
pelya
2016-03-27 22:33:11 +03:00
527 changed files with 33651 additions and 23740 deletions

View File

@@ -98,6 +98,30 @@ const StringID BaseVehicleListWindow::vehicle_depot_name[] = {
STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR
};
/**
* Get the number of digits the biggest unit number of a set of vehicles has.
* @param vehicles The list of vehicles.
* @return The number of digits to allocate space for.
*/
uint GetUnitNumberDigits(VehicleList &vehicles)
{
uint unitnumber = 0;
for (const Vehicle **v = vehicles.Begin(); v != vehicles.End(); v++) {
unitnumber = max<uint>(unitnumber, (*v)->unitnumber);
}
if (unitnumber >= 10000) return 5;
if (unitnumber >= 1000) return 4;
if (unitnumber >= 100) return 3;
/*
* When the smallest unit number is less than 10, it is
* quite likely that it will expand to become more than
* 10 quite soon.
*/
return 2;
}
void BaseVehicleListWindow::BuildVehicleList()
{
if (!this->vehicles.NeedRebuild()) return;
@@ -106,21 +130,7 @@ void BaseVehicleListWindow::BuildVehicleList()
GenerateVehicleSortList(&this->vehicles, this->vli);
uint unitnumber = 0;
for (const Vehicle **v = this->vehicles.Begin(); v != this->vehicles.End(); v++) {
unitnumber = max<uint>(unitnumber, (*v)->unitnumber);
}
/* Because 111 is much less wide than e.g. 999 we use the
* wider numbers to determine the width instead of just
* the random number that it seems to be. */
if (unitnumber >= 1000) {
this->unitnumber_digits = 4;
} else if (unitnumber >= 100) {
this->unitnumber_digits = 3;
} else {
this->unitnumber_digits = 2;
}
this->unitnumber_digits = GetUnitNumberDigits(this->vehicles);
this->vehicles.RebuildDone();
this->vscroll->SetCount(this->vehicles.Length());
@@ -655,7 +665,7 @@ struct RefitWindow : public Window {
break;
case WID_VR_VEHICLE_PANEL_DISPLAY:
size->height = max(GetMinSizing(NWST_STEP), GetVehicleHeight(Vehicle::Get(this->window_number)->type));
size->height = max(GetMinSizing(NWST_STEP), ScaleGUITrad(GetVehicleHeight(Vehicle::Get(this->window_number)->type)));
break;
case WID_VR_INFO:
@@ -691,7 +701,10 @@ struct RefitWindow : public Window {
if (_returned_mail_refit_capacity > 0) {
SetDParam(2, CT_MAIL);
SetDParam(3, _returned_mail_refit_capacity);
if (money <= 0) {
if (this->order != INVALID_VEH_ORDER_ID) {
/* No predictable cost */
return STR_PURCHASE_INFO_AIRCRAFT_CAPACITY;
} else if (money <= 0) {
SetDParam(4, -money);
return STR_REFIT_NEW_CAPACITY_INCOME_FROM_AIRCRAFT_REFIT;
} else {
@@ -699,7 +712,11 @@ struct RefitWindow : public Window {
return STR_REFIT_NEW_CAPACITY_COST_OF_AIRCRAFT_REFIT;
}
} else {
if (money <= 0) {
if (this->order != INVALID_VEH_ORDER_ID) {
/* No predictable cost */
SetDParam(2, STR_EMPTY);
return STR_PURCHASE_INFO_CAPACITY;
} else if (money <= 0) {
SetDParam(2, -money);
return STR_REFIT_NEW_CAPACITY_INCOME_FROM_REFIT;
} else {
@@ -753,7 +770,7 @@ struct RefitWindow : public Window {
}
if (left != right) {
DrawFrameRect(left, r.top + y_offset_frame, right, r.top + y_offset_frame + 13, COLOUR_WHITE, FR_BORDERONLY);
DrawFrameRect(left, r.top + WD_FRAMERECT_TOP, right, r.top + WD_FRAMERECT_TOP + ScaleGUITrad(14) - 1, COLOUR_WHITE, FR_BORDERONLY);
}
left = INT32_MIN;
@@ -1279,6 +1296,9 @@ static void DrawSmallOrderList(const Vehicle *v, int left, int right, int y, Veh
const Order *order = v->GetOrder(start);
if (order == NULL) return;
bool rtl = _current_text_dir == TD_RTL;
int l_offset = rtl ? 0 : ScaleGUITrad(6);
int r_offset = rtl ? ScaleGUITrad(6) : 0;
int i = 0;
VehicleOrderID oid = start;
@@ -1287,7 +1307,7 @@ static void DrawSmallOrderList(const Vehicle *v, int left, int right, int y, Veh
if (order->IsType(OT_GOTO_STATION)) {
SetDParam(0, order->GetDestination());
DrawString(left + 6, right - 6, y, STR_TINY_BLACK_STATION);
DrawString(left + l_offset, right - r_offset, y, STR_TINY_BLACK_STATION);
y += FONT_HEIGHT_SMALL;
if (++i == 4) break;
@@ -1332,7 +1352,11 @@ void DrawVehicleImage(const Vehicle *v, int left, int right, int y, int height,
uint GetVehicleListHeight(VehicleType type, uint divisor)
{
/* Name + vehicle + profit */
<<<<<<< HEAD
uint base = GetMinSizing(NWST_STEP, GetVehicleHeight(type) + 2 * FONT_HEIGHT_SMALL);
=======
uint base = ScaleGUITrad(GetVehicleHeight(type)) + 2 * FONT_HEIGHT_SMALL;
>>>>>>> a8b575671894ffe1329ef37dca4989c0e60d70f5
/* Drawing of the 4 small orders + profit*/
if (type >= VEH_SHIP) base = max(base, 5U * FONT_HEIGHT_SMALL);
@@ -1356,13 +1380,13 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
int width = right - left;
bool rtl = _current_text_dir == TD_RTL;
int text_offset = GetDigitWidth() * this->unitnumber_digits + WD_FRAMERECT_RIGHT;
int text_offset = max<int>(GetSpriteSize(SPR_PROFIT_LOT).width, GetDigitWidth() * this->unitnumber_digits) + WD_FRAMERECT_RIGHT;
int text_left = left + (rtl ? 0 : text_offset);
int text_right = right - (rtl ? text_offset : 0);
bool show_orderlist = this->vli.vtype >= 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 orderlist_left = left + (rtl ? 0 : max(ScaleGUITrad(100) + text_offset, width / 2));
int orderlist_right = right - (rtl ? max(ScaleGUITrad(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;
@@ -1488,7 +1512,7 @@ public:
case WID_VL_SORT_ORDER: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height;
*size = maxdim(*size, d);
break;
@@ -1899,7 +1923,7 @@ struct VehicleDetailsWindow : Window {
uint desired_height;
if (v->HasArticulatedPart()) {
/* An articulated RV has its text drawn under the sprite instead of after it, hence 15 pixels extra. */
desired_height = WD_FRAMERECT_TOP + 15 + 3 * FONT_HEIGHT_NORMAL + 2 + WD_FRAMERECT_BOTTOM;
desired_height = WD_FRAMERECT_TOP + ScaleGUITrad(15) + 3 * FONT_HEIGHT_NORMAL + 2 + WD_FRAMERECT_BOTTOM;
/* Add space for the cargo amount for each part. */
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
if (u->cargo_cap != 0) desired_height += FONT_HEIGHT_NORMAL + 1;
@@ -1956,7 +1980,7 @@ struct VehicleDetailsWindow : Window {
}
case WID_VD_MATRIX:
resize->height = WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
resize->height = max(ScaleGUITrad(14), WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM);
size->height = 4 * resize->height;
break;
@@ -2083,7 +2107,9 @@ struct VehicleDetailsWindow : Window {
case WID_VD_MIDDLE_DETAILS: {
/* For other vehicles, at the place of the matrix. */
bool rtl = _current_text_dir == TD_RTL;
uint sprite_width = max<uint>(UnScaleByZoom(GetSprite(v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DETAILS), ST_NORMAL)->width, ZOOM_LVL_GUI), 70U) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
uint sprite_width = UnScaleGUI(
max<uint>(GetSprite(v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DETAILS), ST_NORMAL)->width, 70U)) +
WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
uint text_left = r.left + (rtl ? 0 : sprite_width);
uint text_right = r.right - (rtl ? sprite_width : 0);
@@ -2836,7 +2862,7 @@ int GetVehicleWidth(Vehicle *v, EngineImageType image_type)
bool rtl = _current_text_dir == TD_RTL;
SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type);
const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
vehicle_width = UnScaleByZoom(real_sprite->width, ZOOM_LVL_GUI);
vehicle_width = UnScaleGUI(real_sprite->width);
break;
}