mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Move to GetWidgetString for vehicle windows.
parent
d58eb15a0f
commit
e1f9159b51
|
@ -169,7 +169,7 @@ BaseVehicleListWindow::BaseVehicleListWindow(WindowDesc &desc, const VehicleList
|
||||||
this->UpdateSortingFromGrouping();
|
this->UpdateSortingFromGrouping();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::span<const StringID> BaseVehicleListWindow::GetVehicleSorterNames()
|
std::span<const StringID> BaseVehicleListWindow::GetVehicleSorterNames() const
|
||||||
{
|
{
|
||||||
switch (this->grouping) {
|
switch (this->grouping) {
|
||||||
case GB_NONE:
|
case GB_NONE:
|
||||||
|
@ -992,9 +992,11 @@ struct RefitWindow : public Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStringParameters(WidgetID widget) const override
|
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
|
||||||
{
|
{
|
||||||
if (widget == WID_VR_CAPTION) SetDParam(0, Vehicle::Get(this->window_number)->index);
|
if (widget == WID_VR_CAPTION) return GetString(STR_REFIT_CAPTION, Vehicle::Get(this->window_number)->index);
|
||||||
|
|
||||||
|
return this->Window::GetWidgetString(widget, stringid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1310,7 +1312,7 @@ struct RefitWindow : public Window {
|
||||||
static constexpr NWidgetPart _nested_vehicle_refit_widgets[] = {
|
static constexpr NWidgetPart _nested_vehicle_refit_widgets[] = {
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||||
NWidget(WWT_CAPTION, COLOUR_GREY, WID_VR_CAPTION), SetStringTip(STR_REFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
NWidget(WWT_CAPTION, COLOUR_GREY, WID_VR_CAPTION),
|
||||||
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
/* Vehicle display + scrollbar. */
|
/* Vehicle display + scrollbar. */
|
||||||
|
@ -1621,7 +1623,7 @@ static constexpr NWidgetPart _nested_vehicle_list[] = {
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 1), SetResize(1, 0), EndContainer(),
|
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 1), SetResize(1, 0), EndContainer(),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_VL_FILTER_BY_CARGO_SEL),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_VL_FILTER_BY_CARGO_SEL),
|
||||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_VL_FILTER_BY_CARGO), SetMinimalSize(0, 12), SetFill(0, 1), SetStringTip(STR_JUST_STRING, STR_TOOLTIP_FILTER_CRITERIA),
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_VL_FILTER_BY_CARGO), SetMinimalSize(0, 12), SetFill(0, 1), SetToolTip(STR_TOOLTIP_FILTER_CRITERIA),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 1), SetResize(1, 0), EndContainer(),
|
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 1), SetResize(1, 0), EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
@ -1637,7 +1639,7 @@ static constexpr NWidgetPart _nested_vehicle_list[] = {
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_VL_HIDE_BUTTONS),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_VL_HIDE_BUTTONS),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VL_AVAILABLE_VEHICLES), SetMinimalSize(106, 12), SetFill(0, 1),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VL_AVAILABLE_VEHICLES), SetMinimalSize(106, 12), SetFill(0, 1),
|
||||||
SetStringTip(STR_JUST_STRING, STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
|
SetToolTip(STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetResize(1, 0), SetFill(1, 1), EndContainer(),
|
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetResize(1, 0), SetFill(1, 1), EndContainer(),
|
||||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_VL_MANAGE_VEHICLES_DROPDOWN), SetMinimalSize(118, 12), SetFill(0, 1),
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_VL_MANAGE_VEHICLES_DROPDOWN), SetMinimalSize(118, 12), SetFill(0, 1),
|
||||||
SetStringTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
|
SetStringTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
|
||||||
|
@ -1998,46 +2000,42 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStringParameters(WidgetID widget) const override
|
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_VL_AVAILABLE_VEHICLES:
|
case WID_VL_AVAILABLE_VEHICLES:
|
||||||
SetDParam(0, STR_VEHICLE_LIST_AVAILABLE_TRAINS + this->vli.vtype);
|
return GetString(STR_VEHICLE_LIST_AVAILABLE_TRAINS + this->vli.vtype);
|
||||||
break;
|
|
||||||
|
case WID_VL_GROUP_BY_PULLDOWN:
|
||||||
|
return GetString(std::data(this->vehicle_group_by_names)[this->grouping]);
|
||||||
|
|
||||||
|
case WID_VL_SORT_BY_PULLDOWN:
|
||||||
|
return GetString(this->GetVehicleSorterNames()[this->vehgroups.SortType()]);
|
||||||
|
|
||||||
case WID_VL_FILTER_BY_CARGO:
|
case WID_VL_FILTER_BY_CARGO:
|
||||||
SetDParam(0, this->GetCargoFilterLabel(this->cargo_filter_criteria));
|
return GetString(this->GetCargoFilterLabel(this->cargo_filter_criteria));
|
||||||
break;
|
|
||||||
|
|
||||||
case WID_VL_CAPTION:
|
case WID_VL_CAPTION:
|
||||||
case WID_VL_CAPTION_SHARED_ORDERS: {
|
case WID_VL_CAPTION_SHARED_ORDERS: {
|
||||||
switch (this->vli.type) {
|
switch (this->vli.type) {
|
||||||
case VL_SHARED_ORDERS: // Shared Orders
|
case VL_SHARED_ORDERS: // Shared Orders
|
||||||
SetDParam(0, this->vehicles.size());
|
return GetString(stringid, this->vehicles.size());
|
||||||
break;
|
|
||||||
|
|
||||||
case VL_STANDARD: // Company Name
|
case VL_STANDARD: // Company Name
|
||||||
SetDParam(0, STR_COMPANY_NAME);
|
return GetString(stringid, STR_COMPANY_NAME, this->vli.ToCompanyID(), std::monostate{}, this->vehicles.size());
|
||||||
SetDParam(1, this->vli.ToCompanyID());
|
|
||||||
SetDParam(3, this->vehicles.size());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VL_STATION_LIST: // Station/Waypoint Name
|
case VL_STATION_LIST: // Station/Waypoint Name
|
||||||
SetDParam(0, Station::IsExpected(BaseStation::Get(this->vli.ToStationID())) ? STR_STATION_NAME : STR_WAYPOINT_NAME);
|
return GetString(stringid, Station::IsExpected(BaseStation::Get(this->vli.ToStationID())) ? STR_STATION_NAME : STR_WAYPOINT_NAME, this->vli.ToStationID(), std::monostate{}, this->vehicles.size());
|
||||||
SetDParam(1, this->vli.ToStationID());
|
|
||||||
SetDParam(3, this->vehicles.size());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VL_DEPOT_LIST:
|
case VL_DEPOT_LIST:
|
||||||
SetDParam(0, STR_DEPOT_CAPTION);
|
return GetString(stringid, STR_DEPOT_CAPTION, this->vli.vtype, this->vli.ToDestinationID(), this->vehicles.size());
|
||||||
SetDParam(1, this->vli.vtype);
|
|
||||||
SetDParam(2, this->vli.ToDestinationID());
|
|
||||||
SetDParam(3, this->vehicles.size());
|
|
||||||
break;
|
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return this->Window::GetWidgetString(widget, stringid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2080,14 +2078,6 @@ public:
|
||||||
WID_VL_START_ALL);
|
WID_VL_START_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set text of group by dropdown widget. */
|
|
||||||
this->GetWidget<NWidgetCore>(WID_VL_GROUP_BY_PULLDOWN)->SetString(std::data(this->vehicle_group_by_names)[this->grouping]);
|
|
||||||
|
|
||||||
/* Set text of sort by dropdown widget. */
|
|
||||||
this->GetWidget<NWidgetCore>(WID_VL_SORT_BY_PULLDOWN)->SetString(this->GetVehicleSorterNames()[this->vehgroups.SortType()]);
|
|
||||||
|
|
||||||
this->GetWidget<NWidgetCore>(WID_VL_FILTER_BY_CARGO)->SetString(this->GetCargoFilterLabel(this->cargo_filter_criteria));
|
|
||||||
|
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2340,7 +2330,7 @@ static_assert(WID_VD_DETAILS_TOTAL_CARGO == WID_VD_DETAILS_CARGO_CARRIED +
|
||||||
static constexpr NWidgetPart _nested_nontrain_vehicle_details_widgets[] = {
|
static constexpr NWidgetPart _nested_nontrain_vehicle_details_widgets[] = {
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||||
NWidget(WWT_CAPTION, COLOUR_GREY, WID_VD_CAPTION), SetStringTip(STR_VEHICLE_DETAILS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
NWidget(WWT_CAPTION, COLOUR_GREY, WID_VD_CAPTION),
|
||||||
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
||||||
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
||||||
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
||||||
|
@ -2580,9 +2570,11 @@ struct VehicleDetailsWindow : Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStringParameters(WidgetID widget) const override
|
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
|
||||||
{
|
{
|
||||||
if (widget == WID_VD_CAPTION) SetDParam(0, Vehicle::Get(this->window_number)->index);
|
if (widget == WID_VD_CAPTION) return GetString(STR_VEHICLE_DETAILS_CAPTION, Vehicle::Get(this->window_number)->index);
|
||||||
|
|
||||||
|
return this->Window::GetWidgetString(widget, stringid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawWidget(const Rect &r, WidgetID widget) const override
|
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||||
|
@ -2835,7 +2827,7 @@ static constexpr NWidgetPart _nested_vehicle_view_widgets[] = {
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_RENAME), SetAspect(WidgetDimensions::ASPECT_RENAME), SetSpriteTip(SPR_RENAME),
|
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_RENAME), SetAspect(WidgetDimensions::ASPECT_RENAME), SetSpriteTip(SPR_RENAME),
|
||||||
NWidget(WWT_CAPTION, COLOUR_GREY, WID_VV_CAPTION), SetStringTip(STR_VEHICLE_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
NWidget(WWT_CAPTION, COLOUR_GREY, WID_VV_CAPTION),
|
||||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_LOCATION), SetAspect(WidgetDimensions::ASPECT_LOCATION), SetSpriteTip(SPR_GOTO_LOCATION),
|
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_LOCATION), SetAspect(WidgetDimensions::ASPECT_LOCATION), SetSpriteTip(SPR_GOTO_LOCATION),
|
||||||
NWidget(WWT_DEBUGBOX, COLOUR_GREY),
|
NWidget(WWT_DEBUGBOX, COLOUR_GREY),
|
||||||
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
||||||
|
@ -3117,12 +3109,12 @@ public:
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStringParameters(WidgetID widget) const override
|
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
|
||||||
{
|
{
|
||||||
if (widget != WID_VV_CAPTION) return;
|
if (widget != WID_VV_CAPTION) return this->Window::GetWidgetString(widget, stringid);
|
||||||
|
|
||||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||||
SetDParam(0, v->index);
|
return GetString(STR_VEHICLE_VIEW_CAPTION, v->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetVehicleStatusString(const Vehicle *v, TextColour &text_colour) const
|
std::string GetVehicleStatusString(const Vehicle *v, TextColour &text_colour) const
|
||||||
|
|
|
@ -124,9 +124,9 @@ struct BaseVehicleListWindow : public Window {
|
||||||
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group, bool show_create);
|
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group, bool show_create);
|
||||||
DropDownList BuildActionDropdownList(bool show_autoreplace, bool show_group, bool show_create);
|
DropDownList BuildActionDropdownList(bool show_autoreplace, bool show_group, bool show_create);
|
||||||
|
|
||||||
std::span<const StringID> GetVehicleSorterNames();
|
std::span<const StringID> GetVehicleSorterNames() const;
|
||||||
|
|
||||||
std::span<VehicleGroupSortFunction * const> GetVehicleSorterFuncs()
|
std::span<VehicleGroupSortFunction * const> GetVehicleSorterFuncs() const
|
||||||
{
|
{
|
||||||
switch (this->grouping) {
|
switch (this->grouping) {
|
||||||
case GB_NONE:
|
case GB_NONE:
|
||||||
|
|
Loading…
Reference in New Issue