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:
@@ -19,6 +19,7 @@
|
||||
#include "cargotype.h"
|
||||
#include "station_gui.h"
|
||||
#include "strings_func.h"
|
||||
#include "string_func.h"
|
||||
#include "window_func.h"
|
||||
#include "viewport_func.h"
|
||||
#include "widgets/dropdown_func.h"
|
||||
@@ -31,6 +32,7 @@
|
||||
#include "vehiclelist.h"
|
||||
#include "town.h"
|
||||
#include "linkgraph/linkgraph.h"
|
||||
#include "zoom_func.h"
|
||||
|
||||
#include "widgets/station_widget.h"
|
||||
|
||||
@@ -221,7 +223,9 @@ protected:
|
||||
GetString(buf_cache, STR_STATION_NAME, lastof(buf_cache));
|
||||
}
|
||||
|
||||
return strcmp(buf, buf_cache);
|
||||
int r = strnatcmp(buf, buf_cache); // Sort by name (natural sorting).
|
||||
if (r == 0) return (*a)->index - (*b)->index;
|
||||
return r;
|
||||
}
|
||||
|
||||
/** Sort stations by their type */
|
||||
@@ -338,7 +342,7 @@ public:
|
||||
switch (widget) {
|
||||
case WID_STL_SORTBY: {
|
||||
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;
|
||||
@@ -805,17 +809,20 @@ static const NWidgetPart _nested_station_view_widgets[] = {
|
||||
*/
|
||||
static void DrawCargoIcons(CargoID i, uint waiting, int left, int right, int top, int bottom)
|
||||
{
|
||||
int width = ScaleGUITrad(10);
|
||||
uint num = min((waiting + (width / 2)) / width, (right - left) / width); // maximum is width / 10 icons so it won't overflow
|
||||
if (num == 0) return;
|
||||
|
||||
SpriteID sprite = CargoSpec::Get(i)->GetCargoIcon();
|
||||
Dimension d = GetSpriteSize(sprite);
|
||||
|
||||
uint num = min((waiting + 5) / d.width, (right - left) / d.width); // maximum is width / 10 icons so it won't overflow
|
||||
if (num == 0) return;
|
||||
|
||||
int x = _current_text_dir == TD_RTL ? left : right - num * d.width;
|
||||
int y = Center(top, bottom - top, d.height);
|
||||
int x = _current_text_dir == TD_RTL ? left : right - num * width;
|
||||
do {
|
||||
DrawSprite(sprite, PAL_NONE, x, y);
|
||||
x += d.width;
|
||||
x += width;
|
||||
} while (--num);
|
||||
}
|
||||
|
||||
@@ -1189,7 +1196,7 @@ bool CargoSorter::SortStation(StationID st1, StationID st2) const
|
||||
SetDParam(0, st2);
|
||||
GetString(buf2, STR_STATION_NAME, lastof(buf2));
|
||||
|
||||
int res = strcmp(buf1, buf2);
|
||||
int res = strnatcmp(buf1, buf2); // Sort by name (natural sorting).
|
||||
if (res == 0) {
|
||||
return this->SortId(st1, st2);
|
||||
} else {
|
||||
@@ -1306,17 +1313,15 @@ struct StationViewWindow : public Window {
|
||||
this->SelectSortBy(_settings_client.gui.station_gui_sort_by);
|
||||
this->sort_orders[0] = SO_ASCENDING;
|
||||
this->SelectSortOrder((SortOrder)_settings_client.gui.station_gui_sort_order);
|
||||
Owner owner = Station::Get(window_number)->owner;
|
||||
if (owner != OWNER_NONE) this->owner = owner;
|
||||
this->owner = Station::Get(window_number)->owner;
|
||||
}
|
||||
|
||||
~StationViewWindow()
|
||||
{
|
||||
Owner owner = Station::Get(this->window_number)->owner;
|
||||
DeleteWindowById(WC_TRAINS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_TRAIN, owner, this->window_number).Pack(), false);
|
||||
DeleteWindowById(WC_ROADVEH_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_ROAD, owner, this->window_number).Pack(), false);
|
||||
DeleteWindowById(WC_SHIPS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_SHIP, owner, this->window_number).Pack(), false);
|
||||
DeleteWindowById(WC_AIRCRAFT_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_AIRCRAFT, owner, this->window_number).Pack(), false);
|
||||
DeleteWindowById(WC_TRAINS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_TRAIN, this->owner, this->window_number).Pack(), false);
|
||||
DeleteWindowById(WC_ROADVEH_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_ROAD, this->owner, this->window_number).Pack(), false);
|
||||
DeleteWindowById(WC_SHIPS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_SHIP, this->owner, this->window_number).Pack(), false);
|
||||
DeleteWindowById(WC_AIRCRAFT_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_AIRCRAFT, this->owner, this->window_number).Pack(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1417,7 +1422,7 @@ struct StationViewWindow : public Window {
|
||||
if (!this->IsShaded()) {
|
||||
/* Draw 'accepted cargo' or 'cargo ratings'. */
|
||||
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SV_ACCEPT_RATING_LIST);
|
||||
const Rect r = {wid->pos_x, wid->pos_y, wid->pos_x + wid->current_x - 1, wid->pos_y + wid->current_y - 1};
|
||||
const Rect r = {(int)wid->pos_x, (int)wid->pos_y, (int)(wid->pos_x + wid->current_x - 1), (int)(wid->pos_y + wid->current_y - 1)};
|
||||
if (this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) {
|
||||
int lines = this->DrawAcceptedCargo(r);
|
||||
if (lines > this->accepts_lines) { // Resize the widget, and perform re-initialization of the window.
|
||||
@@ -1445,7 +1450,7 @@ struct StationViewWindow : public Window {
|
||||
|
||||
/* Draw waiting cargo. */
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_SV_WAITING);
|
||||
Rect waiting_rect = {nwi->pos_x, nwi->pos_y, nwi->pos_x + nwi->current_x - 1, nwi->pos_y + nwi->current_y - 1};
|
||||
Rect waiting_rect = { (int)nwi->pos_x, (int)nwi->pos_y, (int)(nwi->pos_x + nwi->current_x - 1), (int)(nwi->pos_y + nwi->current_y - 1)};
|
||||
this->DrawEntries(&cargo, waiting_rect, pos, maxrows, 0);
|
||||
scroll_to_row = INT_MAX;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user