Merge remote-tracking branch 'upstream/master'

This commit is contained in:
dP
2025-06-14 17:01:17 +05:00
1132 changed files with 59430 additions and 52889 deletions

View File

@@ -34,6 +34,7 @@
#include "widgets/group_widget.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "citymania/cm_hotkeys.hpp"
@@ -49,7 +50,7 @@ static constexpr NWidgetPart _nested_group_widgets[] = {
EndContainer(),
NWidget(NWID_HORIZONTAL),
/* left part */
NWidget(NWID_VERTICAL, NC_BIGFIRST),
NWidget(NWID_VERTICAL, NWidContainerFlag::BigFirst),
NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_ALL_VEHICLES), SetFill(1, 0), EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_DEFAULT_VEHICLES), SetFill(1, 0), EndContainer(),
NWidget(NWID_HORIZONTAL),
@@ -60,52 +61,52 @@ static constexpr NWidgetPart _nested_group_widgets[] = {
NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_INFO), SetFill(1, 1), SetMinimalTextLines(3, WidgetDimensions::unscaled.framerect.Vertical()), EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_CREATE_GROUP),
SetDataTip(SPR_GROUP_CREATE_TRAIN, STR_GROUP_CREATE_TOOLTIP),
SetToolTip(STR_GROUP_CREATE_TOOLTIP),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_DELETE_GROUP),
SetDataTip(SPR_GROUP_DELETE_TRAIN, STR_GROUP_DELETE_TOOLTIP),
SetToolTip(STR_GROUP_DELETE_TOOLTIP),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_RENAME_GROUP),
SetDataTip(SPR_GROUP_RENAME_TRAIN, STR_GROUP_RENAME_TOOLTIP),
SetToolTip(STR_GROUP_RENAME_TOOLTIP),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_LIVERY_GROUP),
SetDataTip(SPR_GROUP_LIVERY_TRAIN, STR_GROUP_LIVERY_TOOLTIP),
SetToolTip(STR_GROUP_LIVERY_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 0), EndContainer(),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_REPLACE_PROTECTION),
SetDataTip(SPR_GROUP_REPLACE_OFF_TRAIN, STR_GROUP_REPLACE_PROTECTION_TOOLTIP),
SetToolTip(STR_GROUP_REPLACE_PROTECTION_TOOLTIP),
EndContainer(),
EndContainer(),
/* right part */
NWidget(NWID_VERTICAL),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_VERTICAL, NC_EQUALSIZE),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GL_GROUP_BY_ORDER), SetFill(1, 1), SetMinimalSize(0, 12), SetDataTip(STR_STATION_VIEW_GROUP, STR_TOOLTIP_GROUP_ORDER),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GL_SORT_BY_ORDER), SetFill(1, 1), SetMinimalSize(0, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GL_GROUP_BY_ORDER), SetFill(1, 1), SetMinimalSize(0, 12), SetStringTip(STR_STATION_VIEW_GROUP, STR_TOOLTIP_GROUP_ORDER),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GL_SORT_BY_ORDER), SetFill(1, 1), SetMinimalSize(0, 12), SetStringTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
EndContainer(),
NWidget(NWID_VERTICAL, NC_EQUALSIZE),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_GROUP_BY_DROPDOWN), SetFill(1, 1), SetMinimalSize(0, 12), SetDataTip(0x0, STR_TOOLTIP_GROUP_ORDER),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_SORT_BY_DROPDOWN), SetFill(1, 1), SetMinimalSize(0, 12), SetDataTip(0x0, STR_TOOLTIP_SORT_CRITERIA),
NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_GROUP_BY_DROPDOWN), SetFill(1, 1), SetMinimalSize(0, 12), SetToolTip(STR_TOOLTIP_GROUP_ORDER),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_SORT_BY_DROPDOWN), SetFill(1, 1), SetMinimalSize(0, 12), SetToolTip(STR_TOOLTIP_SORT_CRITERIA),
EndContainer(),
NWidget(NWID_VERTICAL, NC_EQUALSIZE),
NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize),
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical()), SetFill(0, 1), SetResize(1, 0), EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_FILTER_BY_CARGO), SetMinimalSize(0, 12), SetFill(0, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_FILTER_CRITERIA),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_FILTER_BY_CARGO), SetMinimalSize(0, 12), SetFill(0, 1), SetToolTip(STR_TOOLTIP_FILTER_CRITERIA),
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(0, 1), SetResize(1, 0), EndContainer(),
EndContainer(),
EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_MATRIX, COLOUR_GREY, WID_GL_LIST_VEHICLE), SetMinimalSize(248, 0), SetMatrixDataTip(1, 0, STR_NULL), SetResize(1, 1), SetFill(1, 0), SetScrollbar(WID_GL_LIST_VEHICLE_SCROLLBAR),
NWidget(WWT_MATRIX, COLOUR_GREY, WID_GL_LIST_VEHICLE), SetMinimalSize(248, 0), SetMatrixDataTip(1, 0), SetResize(1, 1), SetFill(1, 0), SetScrollbar(WID_GL_LIST_VEHICLE_SCROLLBAR),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_GL_LIST_VEHICLE_SCROLLBAR),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(1, 0), SetFill(1, 1), SetResize(1, 0), EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GL_AVAILABLE_VEHICLES), SetMinimalSize(106, 12),
SetDataTip(STR_JUST_STRING, STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
SetToolTip(STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetResize(1, 0), EndContainer(),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_MANAGE_VEHICLES_DROPDOWN), SetMinimalSize(118, 12),
SetDataTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
SetStringTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_STOP_ALL), SetAspect(WidgetDimensions::ASPECT_VEHICLE_FLAG),
SetDataTip(SPR_FLAG_VEH_STOPPED, STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP),
SetSpriteTip(SPR_FLAG_VEH_STOPPED, STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_START_ALL), SetAspect(WidgetDimensions::ASPECT_VEHICLE_FLAG),
SetDataTip(SPR_FLAG_VEH_RUNNING, STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP),
SetSpriteTip(SPR_FLAG_VEH_RUNNING, STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(),
EndContainer(),
@@ -120,7 +121,7 @@ static constexpr NWidgetPart _nested_group_widgets[] = {
* @param parent Current tree parent (set by self with recursion).
* @param indent Current tree indentation level (set by self with recursion).
*/
static void GuiGroupListAddChildren(GUIGroupList &dst, const GUIGroupList &src, bool fold, GroupID parent = INVALID_GROUP, uint8_t indent = 0)
static void GuiGroupListAddChildren(GUIGroupList &dst, const GUIGroupList &src, bool fold, GroupID parent = GroupID::Invalid(), uint8_t indent = 0)
{
for (const auto &item : src) {
if (item.group->parent != parent) continue;
@@ -172,13 +173,11 @@ void BuildGuiGroupList(GUIGroupList &dst, bool fold, Owner owner, VehicleType ve
list.Sort([&last_group](const GUIGroupListItem &a, const GUIGroupListItem &b) -> bool {
if (a.group != last_group[0].first) {
SetDParam(0, a.group->index);
last_group[0] = {a.group, GetString(STR_GROUP_NAME)};
last_group[0] = {a.group, GetString(STR_GROUP_NAME, a.group->index)};
}
if (b.group != last_group[1].first) {
SetDParam(0, b.group->index);
last_group[1] = {b.group, GetString(STR_GROUP_NAME)};
last_group[1] = {b.group, GetString(STR_GROUP_NAME, b.group->index)};
}
int r = StrNaturalCompare(last_group[0].second, last_group[1].second); // Sort by name (natural sorting).
@@ -186,13 +185,13 @@ void BuildGuiGroupList(GUIGroupList &dst, bool fold, Owner owner, VehicleType ve
return r < 0;
});
GuiGroupListAddChildren(dst, list, fold, INVALID_GROUP, 0);
GuiGroupListAddChildren(dst, list, fold, GroupID::Invalid(), 0);
}
class VehicleGroupWindow : public BaseVehicleListWindow {
private:
/* Columns in the group list */
enum ListColumns {
enum ListColumns : uint8_t {
VGC_FOLD, ///< Fold / Unfold button.
VGC_NAME, ///< Group name.
VGC_PROTECT, ///< Autoreplace protect icon.
@@ -203,15 +202,16 @@ private:
VGC_END
};
GroupID group_sel; ///< Selected group (for drag/drop)
GroupID group_rename; ///< Group being renamed, INVALID_GROUP if none
GroupID group_over; ///< Group over which a vehicle is dragged, INVALID_GROUP if none
GroupID group_confirm; ///< Group awaiting delete confirmation
GUIGroupList groups; ///< List of groups
uint tiny_step_height; ///< Step height for the group list
Scrollbar *group_sb;
GroupID group_sel = GroupID::Invalid(); ///< Selected group (for drag/drop)
GroupID group_rename = GroupID::Invalid(); ///< Group being renamed, GroupID::Invalid() if none
GroupID group_over = GroupID::Invalid(); ///< Group over which a vehicle is dragged, GroupID::Invalid() if none
GroupID group_confirm = GroupID::Invalid(); ///< Group awaiting delete confirmation
GUIGroupList groups{}; ///< List of groups
uint tiny_step_height = 0; ///< Step height for the group list
Scrollbar *group_sb = nullptr;
Dimension column_size[VGC_END]; ///< Size of the columns in the group list.
std::array<Dimension, VGC_END> column_size{}; ///< Size of the columns in the group list.
bool last_overlay_state = false;
/**
* (Re)Build the group list.
@@ -258,9 +258,8 @@ private:
this->tiny_step_height = std::max(this->tiny_step_height, this->column_size[VGC_PROFIT].height);
int num_vehicle = GetGroupNumVehicle(this->vli.company, ALL_GROUP, this->vli.vtype);
SetDParamMaxValue(0, num_vehicle, 3, FS_SMALL);
SetDParamMaxValue(1, num_vehicle, 3, FS_SMALL);
this->column_size[VGC_NUMBER] = GetStringBoundingBox(STR_GROUP_COUNT_WITH_SUBGROUP);
uint64_t max_value = GetParamMaxValue(num_vehicle, 3, FS_SMALL);
this->column_size[VGC_NUMBER] = GetStringBoundingBox(GetString(STR_GROUP_COUNT_WITH_SUBGROUP, max_value, max_value));
this->tiny_step_height = std::max(this->tiny_step_height, this->column_size[VGC_NUMBER].height);
this->tiny_step_height += WidgetDimensions::scaled.framerect.Vertical();
@@ -295,7 +294,7 @@ private:
if (g_id == NEW_GROUP) return;
/* draw the selected group in white, else we draw it in black */
TextColour colour = g_id == this->vli.index ? TC_WHITE : TC_BLACK;
TextColour colour = g_id == this->vli.ToGroupID() ? TC_WHITE : TC_BLACK;
const GroupStatistics &stats = GroupStatistics::Get(this->vli.company, g_id, this->vli.vtype);
bool rtl = _current_text_dir == TD_RTL;
@@ -323,17 +322,16 @@ private:
}
/* draw group name */
StringID str;
std::string str;
if (IsAllGroupID(g_id)) {
str = STR_GROUP_ALL_TRAINS + this->vli.vtype;
str = GetString(STR_GROUP_ALL_TRAINS + this->vli.vtype);
} else if (IsDefaultGroupID(g_id)) {
str = STR_GROUP_DEFAULT_TRAINS + this->vli.vtype;
str = GetString(STR_GROUP_DEFAULT_TRAINS + this->vli.vtype);
} else {
SetDParam(0, g_id);
str = STR_GROUP_NAME;
str = GetString(STR_GROUP_NAME, g_id);
}
x = rtl ? x - WidgetDimensions::scaled.hsep_normal - this->column_size[VGC_NAME].width : x + WidgetDimensions::scaled.hsep_normal + this->column_size[VGC_FOLD].width;
DrawString(x + (rtl ? 0 : indent * WidgetDimensions::scaled.hsep_indent), x + this->column_size[VGC_NAME].width - 1 - (rtl ? indent * WidgetDimensions::scaled.hsep_indent : 0), y + (this->tiny_step_height - this->column_size[VGC_NAME].height) / 2, str, colour);
DrawString(x + (rtl ? 0 : indent * WidgetDimensions::scaled.hsep_indent), x + this->column_size[VGC_NAME].width - 1 - (rtl ? indent * WidgetDimensions::scaled.hsep_indent : 0), y + (this->tiny_step_height - this->column_size[VGC_NAME].height) / 2, std::move(str), colour);
/* draw autoreplace protection */
x = rtl ? x - WidgetDimensions::scaled.hsep_wide - this->column_size[VGC_PROTECT].width : x + WidgetDimensions::scaled.hsep_wide + this->column_size[VGC_NAME].width;
@@ -364,12 +362,9 @@ private:
int num_vehicle_with_subgroups = GetGroupNumVehicle(this->vli.company, g_id, this->vli.vtype);
int num_vehicle = GroupStatistics::Get(this->vli.company, g_id, this->vli.vtype).num_vehicle;
if (IsAllGroupID(g_id) || IsDefaultGroupID(g_id) || num_vehicle_with_subgroups == num_vehicle) {
SetDParam(0, num_vehicle);
DrawString(x, x + this->column_size[VGC_NUMBER].width - 1, y + (this->tiny_step_height - this->column_size[VGC_NUMBER].height) / 2, STR_JUST_COMMA, colour, SA_RIGHT | SA_FORCE, false, FS_SMALL);
DrawString(x, x + this->column_size[VGC_NUMBER].width - 1, y + (this->tiny_step_height - this->column_size[VGC_NUMBER].height) / 2, GetString(STR_JUST_COMMA, num_vehicle), colour, SA_RIGHT | SA_FORCE, false, FS_SMALL);
} else {
SetDParam(0, num_vehicle);
SetDParam(1, num_vehicle_with_subgroups - num_vehicle);
DrawString(x, x + this->column_size[VGC_NUMBER].width - 1, y + (this->tiny_step_height - this->column_size[VGC_NUMBER].height) / 2, STR_GROUP_COUNT_WITH_SUBGROUP, colour, SA_RIGHT | SA_FORCE);
DrawString(x, x + this->column_size[VGC_NUMBER].width - 1, y + (this->tiny_step_height - this->column_size[VGC_NUMBER].height) / 2, GetString(STR_GROUP_COUNT_WITH_SUBGROUP, num_vehicle, num_vehicle_with_subgroups - num_vehicle), colour, SA_RIGHT | SA_FORCE);
}
}
@@ -378,7 +373,7 @@ private:
*/
void DirtyHighlightedGroupWidget()
{
if (this->group_over == INVALID_GROUP) return;
if (this->group_over == GroupID::Invalid()) return;
if (IsAllGroupID(this->group_over)) {
this->SetWidgetDirty(WID_GL_ALL_VEHICLES);
@@ -390,31 +385,28 @@ private:
}
public:
VehicleGroupWindow(WindowDesc &desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number)
VehicleGroupWindow(WindowDesc &desc, WindowNumber window_number, const VehicleListIdentifier &vli) : BaseVehicleListWindow(desc, vli)
{
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_GL_LIST_VEHICLE_SCROLLBAR);
this->group_sb = this->GetScrollbar(WID_GL_LIST_GROUP_SCROLLBAR);
this->vli.index = ALL_GROUP;
this->group_sel = INVALID_GROUP;
this->group_rename = INVALID_GROUP;
this->group_over = INVALID_GROUP;
this->vli.SetIndex(ALL_GROUP);
this->groups.ForceRebuild();
this->groups.NeedResort();
this->BuildGroupList(vli.company);
this->group_sb->SetCount(this->groups.size());
this->GetWidget<NWidgetCore>(WID_GL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->vli.vtype;
this->GetWidget<NWidgetCore>(WID_GL_LIST_VEHICLE)->tool_tip = STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->vli.vtype;
this->GetWidget<NWidgetCore>(WID_GL_CAPTION)->SetString(STR_VEHICLE_LIST_TRAIN_CAPTION + this->vli.vtype);
this->GetWidget<NWidgetCore>(WID_GL_LIST_VEHICLE)->SetToolTip(STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->vli.vtype);
this->GetWidget<NWidgetCore>(WID_GL_CREATE_GROUP)->widget_data += this->vli.vtype;
this->GetWidget<NWidgetCore>(WID_GL_RENAME_GROUP)->widget_data += this->vli.vtype;
this->GetWidget<NWidgetCore>(WID_GL_DELETE_GROUP)->widget_data += this->vli.vtype;
this->GetWidget<NWidgetCore>(WID_GL_LIVERY_GROUP)->widget_data += this->vli.vtype;
this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->widget_data += this->vli.vtype;
this->GetWidget<NWidgetCore>(WID_GL_CREATE_GROUP)->SetSprite(SPR_GROUP_CREATE_TRAIN + this->vli.vtype);
this->GetWidget<NWidgetCore>(WID_GL_RENAME_GROUP)->SetSprite(SPR_GROUP_RENAME_TRAIN + this->vli.vtype);
this->GetWidget<NWidgetCore>(WID_GL_DELETE_GROUP)->SetSprite(SPR_GROUP_DELETE_TRAIN + this->vli.vtype);
this->GetWidget<NWidgetCore>(WID_GL_LIVERY_GROUP)->SetSprite(SPR_GROUP_LIVERY_TRAIN + this->vli.vtype);
this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->SetSprite(SPR_GROUP_REPLACE_OFF_TRAIN + this->vli.vtype);
this->FinishInitNested(window_number);
this->owner = vli.company;
@@ -444,7 +436,7 @@ public:
break;
case WID_GL_SORT_BY_ORDER: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->GetString());
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);
@@ -500,46 +492,41 @@ public:
}
/* Process ID-invalidation in command-scope as well */
if (this->group_rename != INVALID_GROUP && !Group::IsValidID(this->group_rename)) {
if (this->group_rename != GroupID::Invalid() && !Group::IsValidID(this->group_rename)) {
CloseWindowByClass(WC_QUERY_STRING);
this->group_rename = INVALID_GROUP;
this->group_rename = GroupID::Invalid();
}
if (!(IsAllGroupID(this->vli.index) || IsDefaultGroupID(this->vli.index) || Group::IsValidID(this->vli.index))) {
this->vli.index = ALL_GROUP;
GroupID group = this->vli.ToGroupID();
if (!(IsAllGroupID(group) || IsDefaultGroupID(group) || Group::IsValidID(group))) {
this->vli.SetIndex(ALL_GROUP);
this->CloseChildWindows(WC_DROPDOWN_MENU);
}
this->SetDirty();
}
void SetStringParameters(WidgetID widget) const override
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
{
switch (widget) {
case WID_GL_FILTER_BY_CARGO:
SetDParam(0, this->GetCargoFilterLabel(this->cargo_filter_criteria));
break;
return GetString(this->GetCargoFilterLabel(this->cargo_filter_criteria));
case WID_GL_AVAILABLE_VEHICLES:
SetDParam(0, STR_VEHICLE_LIST_AVAILABLE_TRAINS + this->vli.vtype);
break;
return GetString(STR_VEHICLE_LIST_AVAILABLE_TRAINS + this->vli.vtype);
case WID_GL_CAPTION:
/* If selected_group == DEFAULT_GROUP || ALL_GROUP, draw the standard caption
* We list all vehicles or ungrouped vehicles */
if (IsDefaultGroupID(this->vli.index) || IsAllGroupID(this->vli.index)) {
SetDParam(0, STR_COMPANY_NAME);
SetDParam(1, this->vli.company);
SetDParam(2, this->vehicles.size());
SetDParam(3, this->vehicles.size());
if (IsDefaultGroupID(this->vli.ToGroupID()) || IsAllGroupID(this->vli.ToGroupID())) {
return GetString(stringid, STR_COMPANY_NAME, this->vli.company, this->vehicles.size(), this->vehicles.size());
} else {
uint num_vehicle = GetGroupNumVehicle(this->vli.company, this->vli.index, this->vli.vtype);
uint num_vehicle = GetGroupNumVehicle(this->vli.company, this->vli.ToGroupID(), this->vli.vtype);
SetDParam(0, STR_GROUP_NAME);
SetDParam(1, this->vli.index);
SetDParam(2, num_vehicle);
SetDParam(3, num_vehicle);
return GetString(stringid, STR_GROUP_NAME, this->vli.ToGroupID(), num_vehicle, num_vehicle);
}
break;
default:
return this->Window::GetWidgetString(widget, stringid);
}
}
@@ -568,7 +555,8 @@ public:
WID_GL_MANAGE_VEHICLES_DROPDOWN);
/* Disable the group specific function when we select the default group or all vehicles */
this->SetWidgetsDisabledState(IsDefaultGroupID(this->vli.index) || IsAllGroupID(this->vli.index) || _local_company != this->vli.company,
GroupID group = this->vli.ToGroupID();
this->SetWidgetsDisabledState(IsDefaultGroupID(group) || IsAllGroupID(group) || _local_company != this->vli.company,
WID_GL_DELETE_GROUP,
WID_GL_RENAME_GROUP,
WID_GL_LIVERY_GROUP,
@@ -586,14 +574,14 @@ public:
/* If not a default group and the group has replace protection, show an enabled replace sprite. */
uint16_t protect_sprite = SPR_GROUP_REPLACE_OFF_TRAIN;
if (!IsDefaultGroupID(this->vli.index) && !IsAllGroupID(this->vli.index) && HasBit(Group::Get(this->vli.index)->flags, GroupFlags::GF_REPLACE_PROTECTION)) protect_sprite = SPR_GROUP_REPLACE_ON_TRAIN;
this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->widget_data = protect_sprite + this->vli.vtype;
if (!IsDefaultGroupID(group) && !IsAllGroupID(group) && Group::Get(group)->flags.Test(GroupFlag::ReplaceProtection)) protect_sprite = SPR_GROUP_REPLACE_ON_TRAIN;
this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->SetSprite(protect_sprite + this->vli.vtype);
/* Set text of "group by" dropdown widget. */
this->GetWidget<NWidgetCore>(WID_GL_GROUP_BY_DROPDOWN)->widget_data = std::data(this->vehicle_group_by_names)[this->grouping];
this->GetWidget<NWidgetCore>(WID_GL_GROUP_BY_DROPDOWN)->SetString(std::data(this->vehicle_group_by_names)[this->grouping]);
/* Set text of "sort by" dropdown widget. */
this->GetWidget<NWidgetCore>(WID_GL_SORT_BY_DROPDOWN)->widget_data = this->GetVehicleSorterNames()[this->vehgroups.SortType()];
this->GetWidget<NWidgetCore>(WID_GL_SORT_BY_DROPDOWN)->SetString(this->GetVehicleSorterNames()[this->vehgroups.SortType()]);
this->DrawWidgets();
}
@@ -625,20 +613,17 @@ public:
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
DrawString(tr, TimerGameEconomy::UsingWallclockUnits() ? STR_GROUP_PROFIT_THIS_PERIOD : STR_GROUP_PROFIT_THIS_YEAR, TC_BLACK);
SetDParam(0, this_year);
DrawString(tr, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
DrawString(tr, GetString(STR_JUST_CURRENCY_LONG, this_year), TC_BLACK, SA_RIGHT);
tr.top += GetCharacterHeight(FS_NORMAL);
DrawString(tr, TimerGameEconomy::UsingWallclockUnits() ? STR_GROUP_PROFIT_LAST_PERIOD : STR_GROUP_PROFIT_LAST_YEAR, TC_BLACK);
SetDParam(0, last_year);
DrawString(tr, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
DrawString(tr, GetString(STR_JUST_CURRENCY_LONG, last_year), TC_BLACK, SA_RIGHT);
tr.top += GetCharacterHeight(FS_NORMAL);
DrawString(tr, STR_GROUP_OCCUPANCY, TC_BLACK);
const size_t vehicle_count = this->vehicles.size();
if (vehicle_count > 0) {
SetDParam(0, occupancy / vehicle_count);
DrawString(tr, STR_GROUP_OCCUPANCY_VALUE, TC_BLACK, SA_RIGHT);
DrawString(tr, GetString(STR_GROUP_OCCUPANCY_VALUE, occupancy / vehicle_count), TC_BLACK, SA_RIGHT);
}
break;
@@ -652,7 +637,7 @@ public:
assert(g->owner == this->owner);
DrawGroupInfo(y1, r.left, r.right, g->index, it->level_mask, it->indent, HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION), g->folded || (std::next(it) != std::end(this->groups) && std::next(it)->indent > it->indent));
DrawGroupInfo(y1, r.left, r.right, g->index, it->level_mask, it->indent, g->flags.Test(GroupFlag::ReplaceProtection), g->folded || (std::next(it) != std::end(this->groups) && std::next(it)->indent > it->indent));
y1 += this->tiny_step_height;
}
@@ -667,13 +652,13 @@ public:
break;
case WID_GL_LIST_VEHICLE:
if (this->vli.index != ALL_GROUP && this->grouping == GB_NONE) {
if (this->vli.ToGroupID() != ALL_GROUP && this->grouping == GB_NONE) {
/* Mark vehicles which are in sub-groups (only if we are not using shared order coalescing) */
Rect mr = r.WithHeight(this->resize.step_height);
auto [first, last] = this->vscroll->GetVisibleRangeIterators(this->vehgroups);
for (auto it = first; it != last; ++it) {
const Vehicle *v = it->GetSingleVehicle();
if (v->group_id != this->vli.index) {
if (v->group_id != this->vli.ToGroupID()) {
GfxFillRect(mr.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(COLOUR_GREY, SHADE_DARK), FILLRECT_CHECKER);
}
mr = mr.Translate(0, this->resize.step_height);
@@ -689,12 +674,11 @@ public:
{
if (confirmed) {
VehicleGroupWindow *w = (VehicleGroupWindow*)win;
w->vli.index = ALL_GROUP;
w->vli.SetIndex(ALL_GROUP);
Command<CMD_DELETE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_DELETE, w->group_confirm);
}
}
bool last_overlay_state;
void OnMouseLoop() override
{
if (last_overlay_state != ShowCargoIconOverlay()) {
@@ -724,16 +708,16 @@ public:
break;
case WID_GL_ALL_VEHICLES: // All vehicles button
if (!IsAllGroupID(this->vli.index)) {
this->vli.index = ALL_GROUP;
if (!IsAllGroupID(this->vli.ToGroupID())) {
this->vli.SetIndex(ALL_GROUP);
this->vehgroups.ForceRebuild();
this->SetDirty();
}
break;
case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles button
if (!IsDefaultGroupID(this->vli.index)) {
this->vli.index = DEFAULT_GROUP;
if (!IsDefaultGroupID(this->vli.ToGroupID())) {
this->vli.SetIndex(DEFAULT_GROUP);
this->vehgroups.ForceRebuild();
this->SetDirty();
}
@@ -751,15 +735,15 @@ public:
group_display->pos_x + WidgetDimensions::scaled.framerect.left + it->indent * WidgetDimensions::scaled.hsep_indent;
if (click_count > 1 || (pt.x >= x && pt.x < (int)(x + this->column_size[VGC_FOLD].width))) {
GroupID g = this->vli.index;
GroupID g = this->vli.ToGroupID();
if (!IsAllGroupID(g) && !IsDefaultGroupID(g)) {
do {
g = Group::Get(g)->parent;
if (g == it->group->index) {
this->vli.index = g;
this->vli.SetIndex(g);
break;
}
} while (g != INVALID_GROUP);
} while (g != GroupID::Invalid());
}
Group::Get(it->group->index)->folded = !it->group->folded;
@@ -770,7 +754,8 @@ public:
}
}
this->group_sel = this->vli.index = it->group->index;
this->vli.SetIndex(it->group->index);
this->group_sel = it->group->index;
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this, CM_DDSP_GROUP);
@@ -834,22 +819,25 @@ public:
}
case WID_GL_CREATE_GROUP: { // Create a new group
Command<CMD_CREATE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_CREATE, CcCreateGroup, this->vli.vtype, this->vli.index);
Command<CMD_CREATE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_CREATE, CcCreateGroup, this->vli.vtype, this->vli.ToGroupID());
break;
}
case WID_GL_DELETE_GROUP: { // Delete the selected group
this->group_confirm = this->vli.index;
ShowQuery(STR_QUERY_GROUP_DELETE_CAPTION, STR_GROUP_DELETE_QUERY_TEXT, this, DeleteGroupCallback);
this->group_confirm = this->vli.ToGroupID();
ShowQuery(
GetEncodedString(STR_QUERY_GROUP_DELETE_CAPTION),
GetEncodedString(STR_GROUP_DELETE_QUERY_TEXT),
this, DeleteGroupCallback);
break;
}
case WID_GL_RENAME_GROUP: // Rename the selected roup
this->ShowRenameGroupWindow(this->vli.index, false);
this->ShowRenameGroupWindow(this->vli.ToGroupID(), false);
break;
case WID_GL_LIVERY_GROUP: // Set group livery
ShowCompanyLiveryWindow(this->owner, this->vli.index);
ShowCompanyLiveryWindow(this->owner, this->vli.ToGroupID());
break;
case WID_GL_AVAILABLE_VEHICLES:
@@ -857,20 +845,20 @@ public:
break;
case WID_GL_MANAGE_VEHICLES_DROPDOWN: {
ShowDropDownList(this, this->BuildActionDropdownList(true, Group::IsValidID(this->vli.index), IsDefaultGroupID(this->vli.index)), -1, WID_GL_MANAGE_VEHICLES_DROPDOWN);
ShowDropDownList(this, this->BuildActionDropdownList(true, Group::IsValidID(this->vli.ToGroupID()), IsDefaultGroupID(this->vli.ToGroupID())), -1, WID_GL_MANAGE_VEHICLES_DROPDOWN);
break;
}
case WID_GL_START_ALL:
case WID_GL_STOP_ALL: { // Start/stop all vehicles of the list
Command<CMD_MASS_START_STOP>::Post(0, widget == WID_GL_START_ALL, true, this->vli);
Command<CMD_MASS_START_STOP>::Post(TileIndex{}, widget == WID_GL_START_ALL, true, this->vli);
break;
}
case WID_GL_REPLACE_PROTECTION: {
const Group *g = Group::GetIfValid(this->vli.index);
const Group *g = Group::GetIfValid(this->vli.ToGroupID());
if (g != nullptr) {
Command<CMD_SET_GROUP_FLAG>::Post(this->vli.index, GroupFlags::GF_REPLACE_PROTECTION, !HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION), citymania::_fn_mod);
Command<CMD_SET_GROUP_FLAG>::Post(this->vli.ToGroupID(), GroupFlag::ReplaceProtection, !g->flags.Test(GroupFlag::ReplaceProtection), citymania::_fn_mod);
}
break;
}
@@ -884,25 +872,25 @@ public:
switch (widget) {
case WID_GL_ALL_VEHICLES: // All vehicles
case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
if (g->parent != INVALID_GROUP) {
Command<CMD_ALTER_GROUP>::Post(STR_ERROR_GROUP_CAN_T_SET_PARENT, AlterGroupMode::SetParent, this->group_sel, INVALID_GROUP, {});
if (g->parent != GroupID::Invalid()) {
Command<CMD_ALTER_GROUP>::Post(STR_ERROR_GROUP_CAN_T_SET_PARENT, AlterGroupMode::SetParent, this->group_sel, GroupID::Invalid(), {});
}
this->group_sel = INVALID_GROUP;
this->group_over = INVALID_GROUP;
this->group_sel = GroupID::Invalid();
this->group_over = GroupID::Invalid();
this->SetDirty();
break;
case WID_GL_LIST_GROUP: { // Matrix group
auto it = this->group_sb->GetScrolledItemFromWidget(this->groups, pt.y, this, WID_GL_LIST_GROUP);
GroupID new_g = it == this->groups.end() ? INVALID_GROUP : it->group->index;
GroupID new_g = it == this->groups.end() ? GroupID::Invalid() : it->group->index;
if (this->group_sel != new_g && g->parent != new_g) {
Command<CMD_ALTER_GROUP>::Post(STR_ERROR_GROUP_CAN_T_SET_PARENT, AlterGroupMode::SetParent, this->group_sel, new_g, {});
}
this->group_sel = INVALID_GROUP;
this->group_over = INVALID_GROUP;
this->group_sel = GroupID::Invalid();
this->group_over = GroupID::Invalid();
this->SetDirty();
break;
}
@@ -915,16 +903,16 @@ public:
case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
Command<CMD_ADD_VEHICLE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, DEFAULT_GROUP, this->vehicle_sel, citymania::_fn_mod || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{});
this->vehicle_sel = INVALID_VEHICLE;
this->group_over = INVALID_GROUP;
this->vehicle_sel = VehicleID::Invalid();
this->group_over = GroupID::Invalid();
this->SetDirty();
break;
case WID_GL_LIST_GROUP: { // Matrix group
const VehicleID vindex = this->vehicle_sel;
this->vehicle_sel = INVALID_VEHICLE;
this->group_over = INVALID_GROUP;
this->vehicle_sel = VehicleID::Invalid();
this->group_over = GroupID::Invalid();
this->SetDirty();
auto it = this->group_sb->GetScrolledItemFromWidget(this->groups, pt.y, this, WID_GL_LIST_GROUP);
@@ -936,8 +924,8 @@ public:
case WID_GL_LIST_VEHICLE: { // Matrix vehicle
const VehicleID vindex = this->vehicle_sel;
this->vehicle_sel = INVALID_VEHICLE;
this->group_over = INVALID_GROUP;
this->vehicle_sel = VehicleID::Invalid();
this->group_over = GroupID::Invalid();
this->SetDirty();
auto it = this->vscroll->GetScrolledItemFromWidget(this->vehgroups, pt.y, this, WID_GL_LIST_VEHICLE);
@@ -977,16 +965,16 @@ public:
void OnDragDrop(Point pt, WidgetID widget) override
{
if (this->vehicle_sel != INVALID_VEHICLE) OnDragDrop_Vehicle(pt, widget);
if (this->group_sel != INVALID_GROUP) OnDragDrop_Group(pt, widget);
if (this->vehicle_sel != VehicleID::Invalid()) OnDragDrop_Vehicle(pt, widget);
if (this->group_sel != GroupID::Invalid()) OnDragDrop_Group(pt, widget);
_cursor.vehchain = false;
}
void OnQueryTextFinished(std::optional<std::string> str) override
{
if (str.has_value()) Command<CMD_ALTER_GROUP>::Post(STR_ERROR_GROUP_CAN_T_RENAME, AlterGroupMode::Rename, this->group_rename, 0, *str);
this->group_rename = INVALID_GROUP;
if (str.has_value()) Command<CMD_ALTER_GROUP>::Post(STR_ERROR_GROUP_CAN_T_RENAME, AlterGroupMode::Rename, this->group_rename, GroupID::Invalid(), *str);
this->group_rename = GroupID::Invalid();
}
void OnResize() override
@@ -1015,27 +1003,27 @@ public:
switch (index) {
case ADI_REPLACE: // Replace window
ShowReplaceGroupVehicleWindow(this->vli.index, this->vli.vtype);
ShowReplaceGroupVehicleWindow(this->vli.ToGroupID(), this->vli.vtype);
break;
case ADI_SERVICE: // Send for servicing
case ADI_DEPOT: { // Send to Depots
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Post(GetCmdSendToDepotMsg(this->vli.vtype), 0, DepotCommand::MassSend | (index == ADI_SERVICE ? DepotCommand::Service : DepotCommand::None), this->vli);
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Post(GetCmdSendToDepotMsg(this->vli.vtype), VehicleID::Invalid(), (index == ADI_SERVICE ? DepotCommandFlag::Service : DepotCommandFlags{}) | DepotCommandFlag::MassSend, this->vli);
break;
}
case ADI_CREATE_GROUP: // Create group
Command<CMD_ADD_VEHICLE_GROUP>::Post(CcAddVehicleNewGroup, NEW_GROUP, INVALID_VEHICLE, false, this->vli);
Command<CMD_ADD_VEHICLE_GROUP>::Post(CcAddVehicleNewGroup, NEW_GROUP, VehicleID::Invalid(), false, this->vli);
break;
case ADI_ADD_SHARED: // Add shared Vehicles
assert(Group::IsValidID(this->vli.index));
assert(Group::IsValidID(this->vli.ToGroupID()));
Command<CMD_ADD_SHARED_VEHICLE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_ADD_SHARED_VEHICLE, this->vli.index, this->vli.vtype);
Command<CMD_ADD_SHARED_VEHICLE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_ADD_SHARED_VEHICLE, this->vli.ToGroupID(), this->vli.vtype);
break;
case ADI_REMOVE_ALL: // Remove all Vehicles from the selected group
assert(Group::IsValidID(this->vli.index));
assert(Group::IsValidID(this->vli.ToGroupID()));
Command<CMD_REMOVE_ALL_VEHICLES_GROUP>::Post(STR_ERROR_GROUP_CAN_T_REMOVE_ALL_VEHICLES, this->vli.index);
Command<CMD_REMOVE_ALL_VEHICLES_GROUP>::Post(STR_ERROR_GROUP_CAN_T_REMOVE_ALL_VEHICLES, this->vli.ToGroupID());
break;
default: NOT_REACHED();
}
@@ -1057,19 +1045,19 @@ public:
void OnPlaceObjectAbort() override
{
/* abort drag & drop */
this->vehicle_sel = INVALID_VEHICLE;
this->vehicle_sel = VehicleID::Invalid();
this->DirtyHighlightedGroupWidget();
this->group_sel = INVALID_GROUP;
this->group_over = INVALID_GROUP;
this->group_sel = GroupID::Invalid();
this->group_over = GroupID::Invalid();
this->SetWidgetDirty(WID_GL_LIST_VEHICLE);
}
void OnMouseDrag(Point pt, WidgetID widget) override
{
if (this->vehicle_sel == INVALID_VEHICLE && this->group_sel == INVALID_GROUP) return;
if (this->vehicle_sel == VehicleID::Invalid() && this->group_sel == GroupID::Invalid()) return;
/* A vehicle is dragged over... */
GroupID new_group_over = INVALID_GROUP;
GroupID new_group_over = GroupID::Invalid();
switch (widget) {
case WID_GL_DEFAULT_VEHICLES: // ... the 'default' group.
new_group_over = DEFAULT_GROUP;
@@ -1083,10 +1071,10 @@ public:
}
/* Do not highlight when dragging over the current group */
if (this->vehicle_sel != INVALID_VEHICLE) {
if (Vehicle::Get(vehicle_sel)->group_id == new_group_over) new_group_over = INVALID_GROUP;
} else if (this->group_sel != INVALID_GROUP) {
if (this->group_sel == new_group_over || Group::Get(this->group_sel)->parent == new_group_over) new_group_over = INVALID_GROUP;
if (this->vehicle_sel != VehicleID::Invalid()) {
if (Vehicle::Get(vehicle_sel)->group_id == new_group_over) new_group_over = GroupID::Invalid();
} else if (this->group_sel != GroupID::Invalid()) {
if (this->group_sel == new_group_over || Group::Get(this->group_sel)->parent == new_group_over) new_group_over = GroupID::Invalid();
}
/* Mark widgets as dirty if the group changed. */
@@ -1101,13 +1089,12 @@ public:
{
assert(Group::IsValidID(group));
this->group_rename = group;
/* Show empty query for new groups */
StringID str = STR_EMPTY;
if (!empty) {
SetDParam(0, group);
str = STR_GROUP_NAME;
}
ShowQueryString(str, STR_GROUP_RENAME_CAPTION, MAX_LENGTH_GROUP_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
std::string str;
if (!empty) str = GetString(STR_GROUP_NAME, group);
ShowQueryString(str, STR_GROUP_RENAME_CAPTION, MAX_LENGTH_GROUP_NAME_CHARS, this, CS_ALPHANUMERAL, {QueryStringFlag::EnableDefault, QueryStringFlag::LengthIsInChars});
}
/**
@@ -1127,9 +1114,9 @@ public:
*/
void SelectGroup(const GroupID g_id)
{
if (g_id == INVALID_GROUP || g_id == this->vli.index) return;
if (g_id == GroupID::Invalid() || g_id == this->vli.ToGroupID()) return;
this->vli.index = g_id;
this->vli.SetIndex(g_id);
if (g_id != ALL_GROUP && g_id != DEFAULT_GROUP) {
const Group *g = Group::Get(g_id);
@@ -1152,50 +1139,69 @@ public:
};
static WindowDesc _other_group_desc(
WDP_AUTO, "list_groups", 460, 246,
WC_INVALID, WC_NONE,
0,
_nested_group_widgets
);
static WindowDesc _train_group_desc(
WDP_AUTO, "list_groups_train", 525, 246,
WC_TRAINS_LIST, WC_NONE,
0,
_nested_group_widgets
);
static WindowDesc _vehicle_group_desc[] = {
{
WDP_AUTO, "list_groups_train", 525, 246,
WC_TRAINS_LIST, WC_NONE,
{},
_nested_group_widgets
},
{
WDP_AUTO, "list_groups_roadveh", 460, 246,
WC_ROADVEH_LIST, WC_NONE,
{},
_nested_group_widgets
},
{
WDP_AUTO, "list_groups_ship", 460, 246,
WC_SHIPS_LIST, WC_NONE,
{},
_nested_group_widgets
},
{
WDP_AUTO, "list_groups_aircraft", 460, 246,
WC_AIRCRAFT_LIST, WC_NONE,
{},
_nested_group_widgets
},
};
/**
* Show the group window for the given company and vehicle type.
* @param company The company to show the window for.
* @param vehicle_type The type of vehicle to show it for.
* @param group The group to be selected. Defaults to INVALID_GROUP.
* @param need_existing_window Whether the existing window is needed. Defaults to false.
* @param group The group to be selected. Defaults to GroupID::Invalid().
* @tparam Tneed_existing_window Whether the existing window is needed.
*/
void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type, GroupID group, bool need_existing_window)
template <bool Tneed_existing_window>
static void ShowCompanyGroupInternal(CompanyID company, VehicleType vehicle_type, GroupID group)
{
if (!Company::IsValidID(company)) return;
const WindowNumber num = VehicleListIdentifier(VL_GROUP_LIST, vehicle_type, company).Pack();
VehicleGroupWindow *w;
if (vehicle_type == VEH_TRAIN) {
w = AllocateWindowDescFront<VehicleGroupWindow>(_train_group_desc, num, need_existing_window);
} else {
_other_group_desc.cls = GetWindowClassForVehicleType(vehicle_type);
w = AllocateWindowDescFront<VehicleGroupWindow>(_other_group_desc, num, need_existing_window);
}
assert(vehicle_type < std::size(_vehicle_group_desc));
VehicleListIdentifier vli(VL_GROUP_LIST, vehicle_type, company);
VehicleGroupWindow *w = AllocateWindowDescFront<VehicleGroupWindow, Tneed_existing_window>(_vehicle_group_desc[vehicle_type], vli.ToWindowNumber(), vli);
if (w != nullptr) w->SelectGroup(group);
}
/**
* Show the group window for the given company and vehicle type.
* @param company The company to show the window for.
* @param vehicle_type The type of vehicle to show it for.
* @param group The group to be selected. Defaults to GroupID::Invalid().
*/
void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type, GroupID group)
{
ShowCompanyGroupInternal<false>(company, vehicle_type, group);
}
/**
* Show the group window for the given vehicle.
* @param v The vehicle to show the window for.
*/
void ShowCompanyGroupForVehicle(const Vehicle *v)
{
ShowCompanyGroup(v->owner, v->type, v->group_id, true);
ShowCompanyGroupInternal<true>(v->owner, v->type, v->group_id);
}
/**
@@ -1206,7 +1212,7 @@ void ShowCompanyGroupForVehicle(const Vehicle *v)
*/
static inline VehicleGroupWindow *FindVehicleGroupWindow(VehicleType vt, Owner owner)
{
return dynamic_cast<VehicleGroupWindow *>(FindWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, owner).Pack()));
return dynamic_cast<VehicleGroupWindow *>(FindWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, owner).ToWindowNumber()));
}
/**