Merge branch 'master' into jgrpp

Replace build and refit, and group collapse implementations
Fix template creation build and refit

# Conflicts:
#	Makefile.bundle.in
#	config.lib
#	src/animated_tile.cpp
#	src/blitter/32bpp_anim.hpp
#	src/blitter/32bpp_base.hpp
#	src/blitter/8bpp_base.hpp
#	src/blitter/null.hpp
#	src/build_vehicle_gui.cpp
#	src/command.cpp
#	src/command_func.h
#	src/console_gui.cpp
#	src/core/smallstack_type.hpp
#	src/date.cpp
#	src/debug.cpp
#	src/genworld_gui.cpp
#	src/ground_vehicle.hpp
#	src/group_gui.cpp
#	src/lang/korean.txt
#	src/linkgraph/linkgraph_gui.h
#	src/main_gui.cpp
#	src/misc_gui.cpp
#	src/network/core/game.h
#	src/network/core/packet.cpp
#	src/network/core/udp.cpp
#	src/network/core/udp.h
#	src/network/network_content.cpp
#	src/network/network_type.h
#	src/network/network_udp.cpp
#	src/newgrf_house.h
#	src/openttd.cpp
#	src/order_cmd.cpp
#	src/order_gui.cpp
#	src/os/unix/crashlog_unix.cpp
#	src/os/windows/crashlog_win.cpp
#	src/osk_gui.cpp
#	src/pathfinder/opf/opf_ship.cpp
#	src/rail_cmd.cpp
#	src/rail_gui.cpp
#	src/saveload/saveload.cpp
#	src/settings.cpp
#	src/settings_gui.cpp
#	src/smallmap_gui.h
#	src/station_base.h
#	src/station_cmd.cpp
#	src/table/gameopt_settings.ini
#	src/table/newgrf_debug_data.h
#	src/table/settings.ini
#	src/timetable_gui.cpp
#	src/toolbar_gui.cpp
#	src/train_gui.cpp
#	src/vehicle.cpp
#	src/vehicle_gui.cpp
#	src/vehiclelist.cpp
#	src/viewport.cpp
#	src/widgets/dropdown.cpp
#	src/window_gui.h
This commit is contained in:
Jonathan G Rennison
2019-03-27 18:12:04 +00:00
422 changed files with 4697 additions and 6619 deletions

View File

@@ -145,8 +145,8 @@ const StringID BaseVehicleListWindow::vehicle_depot_sell_name[] = {
uint GetUnitNumberDigits(VehicleList &vehicles)
{
uint unitnumber = 0;
for (const Vehicle **v = vehicles.Begin(); v != vehicles.End(); v++) {
unitnumber = max<uint>(unitnumber, (*v)->unitnumber);
for (const Vehicle *v : vehicles) {
unitnumber = max<uint>(unitnumber, v->unitnumber);
}
if (unitnumber >= 10000) return 5;
@@ -174,7 +174,7 @@ void BaseVehicleListWindow::BuildVehicleList()
this->unitnumber_digits = GetUnitNumberDigits(this->vehicles);
this->vehicles.RebuildDone();
this->vscroll->SetCount(this->vehicles.Length());
this->vscroll->SetCount(this->vehicles.size());
}
/** Cargo filter functions */
@@ -268,10 +268,10 @@ void BaseVehicleListWindow::SetCargoFilterArray()
void BaseVehicleListWindow::FilterVehicleList()
{
this->vehicles.Filter(this->cargo_filter[this->cargo_filter_criteria]);
if (0 == this->vehicles.Length()) {
if (0 == this->vehicles.size()) {
// no vehicle passed through the filter, invalidate the previously selected vehicle
this->vehicle_sel = INVALID_VEHICLE;
} else if (this->vehicle_sel != INVALID_VEHICLE && !this->vehicles.Contains(Vehicle::Get(this->vehicle_sel))) { // previously selected engine didn't pass the filter, remove selection
} else if (this->vehicle_sel != INVALID_VEHICLE && std::find(this->vehicles.begin(), this->vehicles.end(), Vehicle::Get(this->vehicle_sel)) == this->vehicles.end()) { // previously selected engine didn't pass the filter, remove selection
this->vehicle_sel = INVALID_VEHICLE;
}
}
@@ -328,7 +328,7 @@ Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_autoreplace, bo
*/
bool BaseVehicleListWindow::ShouldShowActionDropdownList() const
{
return this->vehicles.Length() != 0 || (this->vli.vtype == VEH_TRAIN && _settings_client.gui.show_adv_tracerestrict_features);
return this->vehicles.size() != 0 || (this->vli.vtype == VEH_TRAIN && _settings_client.gui.show_adv_tracerestrict_features);
}
/**
@@ -341,30 +341,30 @@ DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_autorepla
StringID change_order_str, bool show_create_group, bool consider_top_level)
{
DropDownList *list = new DropDownList();
bool disable = this->vehicles.Length() == 0;
bool disable = this->vehicles.size() == 0;
bool mass_action_disable = disable || (_settings_client.gui.disable_top_veh_list_mass_actions && consider_top_level);
if (show_autoreplace) *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, disable);
if (show_autoreplace) list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, disable));
if (show_autoreplace && show_template_replace) {
*list->Append() = new DropDownListStringItem(STR_TMPL_TEMPLATE_REPLACEMENT, ADI_TEMPLATE_REPLACE, disable);
list->push_back(new DropDownListStringItem(STR_TMPL_TEMPLATE_REPLACEMENT, ADI_TEMPLATE_REPLACE, disable));
}
*list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, mass_action_disable);
*list->Append() = new DropDownListStringItem(this->vehicle_depot_name[this->vli.vtype], ADI_DEPOT, mass_action_disable);
if (_settings_client.gui.show_depot_sell_gui) *list->Append() = new DropDownListStringItem(this->vehicle_depot_sell_name[this->vli.vtype], ADI_DEPOT_SELL, mass_action_disable);
*list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_CANCEL_DEPOT_SERVICE, ADI_CANCEL_DEPOT, mass_action_disable);
list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, mass_action_disable));
list->push_back(new DropDownListStringItem(this->vehicle_depot_name[this->vli.vtype], ADI_DEPOT, mass_action_disable));
if (_settings_client.gui.show_depot_sell_gui) list->push_back(new DropDownListStringItem(this->vehicle_depot_sell_name[this->vli.vtype], ADI_DEPOT_SELL, mass_action_disable));
list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_CANCEL_DEPOT_SERVICE, ADI_CANCEL_DEPOT, mass_action_disable));
if (show_group) {
*list->Append() = new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE, ADI_ADD_SHARED, disable);
*list->Append() = new DropDownListStringItem(STR_GROUP_REMOVE_ALL_VEHICLES, ADI_REMOVE_ALL, disable);
list->push_back(new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE, ADI_ADD_SHARED, disable));
list->push_back(new DropDownListStringItem(STR_GROUP_REMOVE_ALL_VEHICLES, ADI_REMOVE_ALL, disable));
}
if (this->vli.vtype == VEH_TRAIN && _settings_client.gui.show_adv_tracerestrict_features) {
*list->Append() = new DropDownListStringItem(STR_TRACE_RESTRICT_SLOT_MANAGE, ADI_TRACERESTRICT_SLOT_MGMT, false);
list->push_back(new DropDownListStringItem(STR_TRACE_RESTRICT_SLOT_MANAGE, ADI_TRACERESTRICT_SLOT_MGMT, false));
}
if (change_order_str != 0) {
*list->Append() = new DropDownListStringItem(change_order_str, ADI_CHANGE_ORDER, false);
list->push_back(new DropDownListStringItem(change_order_str, ADI_CHANGE_ORDER, false));
}
if (show_create_group) {
*list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_CREATE_GROUP, ADI_CREATE_GROUP, false);
list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_CREATE_GROUP, ADI_CREATE_GROUP, false));
}
return list;
@@ -383,8 +383,8 @@ void BaseVehicleListWindow::SortVehicleList()
void DepotSortList(VehicleList *list)
{
if (list->Length() < 2) return;
QSortT(list->Begin(), list->Length(), &VehicleNumberSorter);
if (list->size() < 2) return;
QSortT(list->data(), list->size(), &VehicleNumberSorter);
}
/** draw the vehicle profit button in the vehicle list window. */
@@ -423,17 +423,17 @@ byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_t
v_for = v_for->GetFirstEnginePart();
/* Create a list of subtypes used by the various parts of v_for */
static SmallVector<StringID, 4> subtypes;
subtypes.Clear();
static std::vector<StringID> subtypes;
subtypes.clear();
for (; v_from != NULL; v_from = v_from->HasArticulatedPart() ? v_from->GetNextArticulatedPart() : NULL) {
const Engine *e_from = v_from->GetEngine();
if (!e_from->CanCarryCargo() || !HasBit(e_from->info.callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) continue;
subtypes.Include(GetCargoSubtypeText(v_from));
include(subtypes, GetCargoSubtypeText(v_from));
}
byte ret_refit_cyc = 0;
bool success = false;
if (subtypes.Length() > 0) {
if (subtypes.size() > 0) {
/* Check whether any articulated part is refittable to 'dest_cargo_type' with a subtype listed in 'subtypes' */
for (Vehicle *v = v_for; v != NULL; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : NULL) {
const Engine *e = v->GetEngine();
@@ -457,7 +457,7 @@ byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_t
StringID subtype = GetCargoSubtypeText(v);
if (subtype == STR_EMPTY) break;
if (!subtypes.Contains(subtype)) continue;
if (std::find(subtypes.begin(), subtypes.end(), subtype) == subtypes.end()) continue;
/* We found something matching. */
ret_refit_cyc = refit_cyc;
@@ -532,7 +532,7 @@ struct RefitOption {
}
};
typedef SmallVector<RefitOption, 32> SubtypeList; ///< List of refit subtypes associated to a cargo.
typedef std::vector<RefitOption> SubtypeList; ///< List of refit subtypes associated to a cargo.
/**
* Draw the list of available refit options for a consist and highlight the selected refit option (if any).
@@ -562,7 +562,7 @@ static void DrawVehicleRefitWindow(const SubtypeList list[NUM_CARGO], const int
/* Draw the list of subtypes for each cargo, and find the selected refit option (by its position). */
for (uint i = 0; current < pos + rows && i < NUM_CARGO; i++) {
for (uint j = 0; current < pos + rows && j < list[i].Length(); j++) {
for (uint j = 0; current < pos + rows && j < list[i].size(); j++) {
const RefitOption &refit = list[i][j];
/* Hide subtypes if sel[0] does not match */
@@ -574,11 +574,11 @@ static void DrawVehicleRefitWindow(const SubtypeList list[NUM_CARGO], const int
continue;
}
if (list[i].Length() > 1) {
if (list[i].size() > 1) {
if (refit.subtype != 0xFF) {
/* Draw tree lines */
int ycenter = y + FONT_HEIGHT_NORMAL / 2;
GfxDrawLine(iconcenter, y - WD_MATRIX_TOP, iconcenter, j == list[i].Length() - 1 ? ycenter : y - WD_MATRIX_TOP + delta - 1, linecolour);
GfxDrawLine(iconcenter, y - WD_MATRIX_TOP, iconcenter, j == list[i].size() - 1 ? ycenter : y - WD_MATRIX_TOP + delta - 1, linecolour);
GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour);
} else {
/* Draw expand/collapse icon */
@@ -622,7 +622,7 @@ struct RefitWindow : public Window {
*/
void BuildRefitList()
{
for (uint i = 0; i < NUM_CARGO; i++) this->list[i].Clear();
for (uint i = 0; i < NUM_CARGO; i++) this->list[i].clear();
Vehicle *v = Vehicle::Get(this->window_number);
/* Check only the selected vehicles. */
@@ -630,7 +630,7 @@ struct RefitWindow : public Window {
GetVehicleSet(vehicles_to_refit, Vehicle::Get(this->selected_vehicle), this->num_vehicles);
do {
if (v->type == VEH_TRAIN && !vehicles_to_refit.Contains(v->index)) continue;
if (v->type == VEH_TRAIN && std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), v->index) == vehicles_to_refit.end()) continue;
const Engine *e = v->GetEngine();
CargoTypes cmask = e->info.refit_mask;
byte callback_mask = e->info.callback_mask;
@@ -651,13 +651,10 @@ struct RefitWindow : public Window {
continue;
}
bool first_vehicle = this->list[current_index].Length() == 0;
bool first_vehicle = this->list[current_index].size() == 0;
if (first_vehicle) {
/* Keeping the current subtype is always an option. It also serves as the option in case of no subtypes */
RefitOption *option = this->list[current_index].Append();
option->cargo = cid;
option->subtype = 0xFF;
option->string = STR_EMPTY;
this->list[current_index].push_back({cid, 0xFF, STR_EMPTY});
}
/* Check the vehicle's callback mask for cargo suffixes.
@@ -689,16 +686,16 @@ struct RefitWindow : public Window {
option.cargo = cid;
option.subtype = refit_cyc;
option.string = subtype;
this->list[current_index].Include(option);
include(this->list[current_index], option);
} else {
/* Intersect the subtypes of earlier vehicles with the subtypes of this vehicle */
if (subtype == STR_EMPTY) {
/* No more subtypes for this vehicle, delete all subtypes >= refit_cyc */
SubtypeList &l = this->list[current_index];
/* 0xFF item is in front, other subtypes are sorted. So just truncate the list in the right spot */
for (uint i = 1; i < l.Length(); i++) {
for (uint i = 1; i < l.size(); i++) {
if (l[i].subtype >= refit_cyc) {
l.Resize(i);
l.resize(i);
break;
}
}
@@ -707,10 +704,10 @@ struct RefitWindow : public Window {
/* Check whether the subtype matches with the subtype of earlier vehicles. */
uint pos = 1;
SubtypeList &l = this->list[current_index];
while (pos < l.Length() && l[pos].subtype != refit_cyc) pos++;
if (pos < l.Length() && l[pos].string != subtype) {
while (pos < l.size() && l[pos].subtype != refit_cyc) pos++;
if (pos < l.size() && l[pos].string != subtype) {
/* String mismatch, remove item keeping the order */
l.ErasePreservingOrder(pos);
l.erase(l.begin() + pos);
}
}
}
@@ -738,7 +735,7 @@ struct RefitWindow : public Window {
uint row = 0;
for (uint i = 0; i < NUM_CARGO; i++) {
for (uint j = 0; j < this->list[i].Length(); j++) {
for (uint j = 0; j < this->list[i].size(); j++) {
const RefitOption &refit = this->list[i][j];
/* Hide subtypes if sel[0] does not match */
@@ -763,7 +760,7 @@ struct RefitWindow : public Window {
uint row = 0;
for (uint i = 0; i < NUM_CARGO; i++) {
for (uint j = 0; j < this->list[i].Length(); j++) {
for (uint j = 0; j < this->list[i].size(); j++) {
const RefitOption &refit = this->list[i][j];
/* Hide subtypes if sel[0] does not match */
@@ -792,7 +789,7 @@ struct RefitWindow : public Window {
if (this->sel[0] < 0) return NULL;
SubtypeList &l = this->list[this->sel[0]];
if ((uint)this->sel[1] >= l.Length()) return NULL;
if ((uint)this->sel[1] >= l.size()) return NULL;
return &l[this->sel[1]];
}
@@ -835,7 +832,7 @@ struct RefitWindow : public Window {
}
}
virtual void OnFocus(Window *previously_focused_window)
void OnFocus(Window *previously_focused_window) override
{
if (HasFocusedVehicleChanged(this->window_number, previously_focused_window)) {
if (this->window_number != INVALID_VEHICLE) {
@@ -846,7 +843,7 @@ struct RefitWindow : public Window {
}
}
virtual void OnFocusLost(Window *newly_focused_window)
void OnFocusLost(Window *newly_focused_window) override
{
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
if (this->window_number != INVALID_VEHICLE) {
@@ -857,7 +854,7 @@ struct RefitWindow : public Window {
}
}
virtual void OnInit()
void OnInit() override
{
if (this->cargo != NULL) {
/* Store the RefitOption currently in use. */
@@ -869,7 +866,7 @@ struct RefitWindow : public Window {
this->sel[1] = 0;
this->cargo = NULL;
for (uint i = 0; this->cargo == NULL && i < NUM_CARGO; i++) {
for (uint j = 0; j < list[i].Length(); j++) {
for (uint j = 0; j < list[i].size(); j++) {
if (list[i][j] == current_refit_option) {
this->sel[0] = i;
this->sel[1] = j;
@@ -887,7 +884,7 @@ struct RefitWindow : public Window {
}
}
virtual void OnPaint()
void OnPaint() override
{
/* Determine amount of items for scroller. */
if (this->hscroll != NULL) this->hscroll->SetCount(this->vehicle_width);
@@ -908,7 +905,7 @@ struct RefitWindow : public Window {
this->DrawWidgets();
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_VR_MATRIX:
@@ -926,7 +923,7 @@ struct RefitWindow : public Window {
}
}
virtual void SetStringParameters(int widget) const
void SetStringParameters(int widget) const override
{
if (widget == WID_VR_CAPTION) SetDParam(0, Vehicle::Get(this->window_number)->index);
}
@@ -978,7 +975,7 @@ struct RefitWindow : public Window {
}
}
virtual void DrawWidget(const Rect &r, int widget) const
void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_VR_VEHICLE_PANEL_DISPLAY: {
@@ -999,14 +996,15 @@ struct RefitWindow : public Window {
for (Train *u = Train::From(v); u != NULL; u = u->Next()) {
/* Start checking. */
if (vehicles_to_refit.Contains(u->index) && left == INT32_MIN) {
const bool contained = std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), u->index) != vehicles_to_refit.end();
if (contained && left == INT32_MIN) {
left = x - this->hscroll->GetPosition() + r.left + this->vehicle_margin;
width = 0;
}
/* Draw a selection. */
if ((!vehicles_to_refit.Contains(u->index) || u->Next() == NULL) && left != INT32_MIN) {
if (u->Next() == NULL && vehicles_to_refit.Contains(u->index)) {
if ((!contained || u->Next() == NULL) && left != INT32_MIN) {
if (u->Next() == NULL && contained) {
int current_width = u->GetDisplayImageWidth();
width += current_width;
x += current_width;
@@ -1060,7 +1058,7 @@ struct RefitWindow : public Window {
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
switch (data) {
case VIWD_AUTOREPLACE: // Autoreplace replaced the vehicle; selected_vehicle became invalid.
@@ -1082,7 +1080,7 @@ struct RefitWindow : public Window {
/* Check the width of all cargo information strings. */
for (uint i = 0; i < NUM_CARGO; i++) {
for (uint j = 0; j < this->list[i].Length(); j++) {
for (uint j = 0; j < this->list[i].size(); j++) {
StringID string = this->GetCapacityString(&list[i][j]);
if (string != INVALID_STRING_ID) {
Dimension dim = GetStringBoundingBox(string);
@@ -1168,7 +1166,7 @@ struct RefitWindow : public Window {
}
}
virtual void OnClick(Point pt, int widget, int click_count)
void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image.
@@ -1213,7 +1211,7 @@ struct RefitWindow : public Window {
}
}
virtual void OnMouseDrag(Point pt, int widget)
void OnMouseDrag(Point pt, int widget) override
{
switch (widget) {
case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image.
@@ -1226,7 +1224,7 @@ struct RefitWindow : public Window {
}
}
virtual void OnDragDrop(Point pt, int widget)
void OnDragDrop(Point pt, int widget) override
{
switch (widget) {
case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image.
@@ -1239,7 +1237,7 @@ struct RefitWindow : public Window {
}
}
virtual void OnResize()
void OnResize() override
{
this->vehicle_width = GetVehicleWidth(Vehicle::Get(this->window_number), EIT_IN_DETAILS);
this->vscroll->SetCapacityFromWidget(this, WID_VR_MATRIX);
@@ -1660,7 +1658,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
int vehicle_button_x = rtl ? right - GetSpriteSize(SPR_PROFIT_LOT).width : left;
int y = r.top;
uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.Length());
uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.size());
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
const Vehicle *v = this->vehicles[i];
@@ -1877,7 +1875,7 @@ public:
*this->sorting = this->vehicles.GetListing();
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_VL_LIST:
@@ -1915,7 +1913,7 @@ public:
}
}
virtual void SetStringParameters(int widget) const
void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_VL_AVAILABLE_VEHICLES:
@@ -1929,7 +1927,7 @@ public:
case WID_VL_CAPTION: {
switch (this->vli.type) {
case VL_SHARED_ORDERS: // Shared Orders
if (this->vehicles.Length() == 0) {
if (this->vehicles.size() == 0) {
/* We can't open this window without vehicles using this order
* and we should close the window when deleting the order. */
NOT_REACHED();
@@ -1962,7 +1960,7 @@ public:
}
}
virtual void DrawWidget(const Rect &r, int widget) const
void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_VL_SORT_ORDER:
@@ -1976,7 +1974,7 @@ public:
}
}
virtual void OnPaint()
void OnPaint() override
{
this->BuildVehicleList();
this->SortVehicleList();
@@ -1996,7 +1994,7 @@ public:
if (this->owner == _local_company) {
this->SetWidgetDisabledState(WID_VL_AVAILABLE_VEHICLES, this->vli.type != VL_STANDARD);
this->SetWidgetDisabledState(WID_VL_MANAGE_VEHICLES_DROPDOWN, !this->ShouldShowActionDropdownList());
this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || (this->vli.type == VL_STANDARD && _settings_client.gui.disable_top_veh_list_mass_actions),
this->SetWidgetsDisabledState(this->vehicles.size() == 0 || (this->vli.type == VL_STANDARD && _settings_client.gui.disable_top_veh_list_mass_actions),
WID_VL_STOP_ALL,
WID_VL_START_ALL,
WIDGET_LIST_END);
@@ -2010,7 +2008,7 @@ public:
this->DrawWidgets();
}
virtual void OnClick(Point pt, int widget, int click_count)
void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_VL_SORT_ORDER: // Flip sorting method ascending/descending
@@ -2029,7 +2027,7 @@ public:
case WID_VL_LIST: { // Matrix to show vehicles
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_VL_LIST);
if (id_v >= this->vehicles.Length()) return; // click out of list bound
if (id_v >= this->vehicles.size()) return; // click out of list bound
const Vehicle *v = this->vehicles[id_v];
if (!VehicleClicked(v)) ShowVehicleViewWindow(v);
@@ -2055,7 +2053,7 @@ public:
}
}
virtual void OnDropdownSelect(int widget, int index)
void OnDropdownSelect(int widget, int index) override
{
switch (widget) {
case WID_VL_SORT_BY_PULLDOWN:
@@ -2110,7 +2108,7 @@ public:
this->SetDirty();
}
virtual void OnQueryTextFinished(char *str)
void OnQueryTextFinished(char *str) override
{
DoCommandP(0, this->window_number, 0, CMD_CREATE_GROUP_FROM_LIST | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), NULL, str);
}
@@ -2159,7 +2157,7 @@ public:
}
}
virtual void OnGameTick()
void OnGameTick() override
{
if (this->vehicles.NeedResort()) {
StationID station = (this->vli.type == VL_STATION_LIST) ? this->vli.index : INVALID_STATION;
@@ -2169,7 +2167,7 @@ public:
}
}
virtual void OnResize()
void OnResize() override
{
this->vscroll->SetCapacityFromWidget(this, WID_VL_LIST);
}
@@ -2179,7 +2177,7 @@ public:
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (!gui_scope && HasBit(data, 31) && this->vli.type == VL_SHARED_ORDERS) {
/* Needs to be done in command-scope, so everything stays valid */
@@ -2192,7 +2190,7 @@ public:
if (data == 0) {
/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
this->vehicles.ForceRebuild();
if (this->vli.type == VL_SHARED_ORDERS && !_settings_client.gui.enable_single_veh_shared_order_gui && this->vehicles.Length() == 1) {
if (this->vli.type == VL_SHARED_ORDERS && !_settings_client.gui.enable_single_veh_shared_order_gui && this->vehicles.size() == 1) {
delete this;
return;
}
@@ -2391,7 +2389,7 @@ struct VehicleDetailsWindow : Window {
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (data == VIWD_AUTOREPLACE) {
/* Autoreplace replaced the vehicle.
@@ -2452,7 +2450,7 @@ struct VehicleDetailsWindow : Window {
return HasBit(Train::From(v)->flags, VRF_HAVE_SLOT);
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_VD_TOP_DETAILS: {
@@ -2584,12 +2582,12 @@ struct VehicleDetailsWindow : Window {
}
}
virtual void SetStringParameters(int widget) const
void SetStringParameters(int widget) const override
{
if (widget == WID_VD_CAPTION) SetDParam(0, Vehicle::Get(this->window_number)->index);
}
virtual void DrawWidget(const Rect &r, int widget) const
void DrawWidget(const Rect &r, int widget) const override
{
const Vehicle *v = Vehicle::Get(this->window_number);
@@ -2760,7 +2758,7 @@ struct VehicleDetailsWindow : Window {
}
/** Repaint vehicle details window. */
virtual void OnPaint()
void OnPaint() override
{
const Vehicle *v = Vehicle::Get(this->window_number);
@@ -2785,7 +2783,7 @@ struct VehicleDetailsWindow : Window {
this->DrawWidgets();
}
virtual void OnClick(Point pt, int widget, int click_count)
void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_VD_RENAME_VEHICLE: { // rename
@@ -2833,7 +2831,7 @@ struct VehicleDetailsWindow : Window {
}
}
virtual void OnDropdownSelect(int widget, int index)
void OnDropdownSelect(int widget, int index) override
{
switch (widget) {
case WID_VD_SERVICE_INTERVAL_DROPDOWN: {
@@ -2847,14 +2845,14 @@ struct VehicleDetailsWindow : Window {
}
}
virtual void OnQueryTextFinished(char *str)
void OnQueryTextFinished(char *str) override
{
if (str == NULL) return;
DoCommandP(0, this->window_number, 0, CMD_RENAME_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type), NULL, str);
}
virtual void OnResize()
void OnResize() override
{
NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_VD_MATRIX);
if (nwi != NULL) {
@@ -3200,7 +3198,7 @@ public:
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
const Vehicle *v = Vehicle::Get(this->window_number);
switch (widget) {
@@ -3222,7 +3220,7 @@ public:
}
}
virtual void OnPaint()
void OnPaint() override
{
const Vehicle *v = Vehicle::Get(this->window_number);
bool is_localcompany = v->owner == _local_company;
@@ -3242,7 +3240,7 @@ public:
this->DrawWidgets();
}
virtual void SetStringParameters(int widget) const
void SetStringParameters(int widget) const override
{
if (widget != WID_VV_CAPTION) return;
@@ -3250,7 +3248,7 @@ public:
SetDParam(0, v->index);
}
virtual void DrawWidget(const Rect &r, int widget) const
void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_VV_START_STOP) return;
@@ -3403,7 +3401,7 @@ public:
DrawString(text_left + lowered, text_right + lowered, r.top + WD_FRAMERECT_TOP + lowered, str, TC_FROMSTRING, SA_HOR_CENTER);
}
virtual void OnClick(Point pt, int widget, int click_count)
void OnClick(Point pt, int widget, int click_count) override
{
const Vehicle *v = Vehicle::Get(this->window_number);
@@ -3439,10 +3437,10 @@ public:
if (_ctrl_pressed) {
OrderDepotActionFlags flags = v->current_order.GetDepotActionType() & (ODATFB_HALT | ODATFB_SELL);
DropDownList *list = new DropDownList();
*list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, DEPOT_SERVICE | DEPOT_DONT_CANCEL, !flags);
*list->Append() = new DropDownListStringItem(BaseVehicleListWindow::vehicle_depot_name[v->type], DEPOT_DONT_CANCEL, flags == ODATFB_HALT);
*list->Append() = new DropDownListStringItem(BaseVehicleListWindow::vehicle_depot_sell_name[v->type], DEPOT_SELL | DEPOT_DONT_CANCEL, flags == (ODATFB_HALT | ODATFB_SELL));
*list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_CANCEL_DEPOT_SERVICE, DEPOT_CANCEL, false);
list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, DEPOT_SERVICE | DEPOT_DONT_CANCEL, !flags));
list->push_back(new DropDownListStringItem(BaseVehicleListWindow::vehicle_depot_name[v->type], DEPOT_DONT_CANCEL, flags == ODATFB_HALT));
list->push_back(new DropDownListStringItem(BaseVehicleListWindow::vehicle_depot_sell_name[v->type], DEPOT_SELL | DEPOT_DONT_CANCEL, flags == (ODATFB_HALT | ODATFB_SELL)));
list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_CANCEL_DEPOT_SERVICE, DEPOT_CANCEL, false));
ShowDropDownList(this, list, -1, widget, 0, true);
} else {
DoCommandP(v->tile, v->index | DEPOT_CANCEL, 0, GetCmdSendToDepot(v));
@@ -3486,7 +3484,6 @@ public:
}
}
virtual void OnDropdownSelect(int widget, int index) OVERRIDE
{
switch (widget) {
@@ -3551,7 +3548,7 @@ public:
}
}
virtual void OnResize()
void OnResize() override
{
if (this->viewport != NULL) {
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_VV_VIEWPORT);
@@ -3594,7 +3591,7 @@ public:
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
if (data == VIWD_AUTOREPLACE) {
/* Autoreplace replaced the vehicle.
@@ -3605,12 +3602,12 @@ public:
this->UpdateButtonStatus();
}
virtual bool IsNewGRFInspectable() const
bool IsNewGRFInspectable() const override
{
return ::IsNewGRFInspectable(GetGrfSpecFeature(Vehicle::Get(this->window_number)->type), this->window_number);
}
virtual void ShowNewGRFInspectWindow() const
void ShowNewGRFInspectWindow() const override
{
::ShowNewGRFInspectWindow(GetGrfSpecFeature(Vehicle::Get(this->window_number)->type), this->window_number);
}