39 static const NWidgetPart _nested_group_widgets[] = {
61 SetDataTip(SPR_GROUP_CREATE_TRAIN, STR_GROUP_CREATE_TOOLTIP),
63 SetDataTip(SPR_GROUP_DELETE_TRAIN, STR_GROUP_DELETE_TOOLTIP),
65 SetDataTip(SPR_GROUP_RENAME_TRAIN, STR_GROUP_RENAME_TOOLTIP),
68 SetDataTip(SPR_GROUP_REPLACE_OFF_TRAIN, STR_GROUP_REPLACE_PROTECTION_TOOLTIP),
79 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),
85 SetDataTip(STR_BLACK_STRING, STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
88 SetDataTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
90 SetDataTip(SPR_FLAG_VEH_STOPPED, STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP),
92 SetDataTip(SPR_FLAG_VEH_RUNNING, STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP),
127 for (
const Group **g = source->
Begin(); g != source->
End(); g++) {
128 if ((*g)->parent == parent) {
131 AddParents(source, (*g)->index, indent + 1);
139 static const Group *last_group[2] = { NULL, NULL };
140 static char last_name[2][64] = {
"",
"" };
142 if (*a != last_group[0]) {
145 GetString(last_name[0], STR_GROUP_NAME,
lastof(last_name[0]));
148 if (*b != last_group[1]) {
151 GetString(last_name[1], STR_GROUP_NAME,
lastof(last_name[1]));
154 int r =
strnatcmp(last_name[0], last_name[1]);
155 if (r == 0)
return (*a)->index - (*b)->index;
207 static const SpriteID profit_sprites[] = {SPR_PROFIT_NA, SPR_PROFIT_NEGATIVE, SPR_PROFIT_SOME, SPR_PROFIT_LOT};
208 for (uint i = 0; i <
lengthof(profit_sprites); i++) {
255 str = STR_GROUP_ALL_TRAINS + this->
vli.
vtype;
256 }
else if (IsDefaultGroupID(g_id)) {
257 str = STR_GROUP_DEFAULT_TRAINS + this->
vli.
vtype;
260 str = STR_GROUP_NAME;
279 spr = SPR_PROFIT_NEGATIVE;
281 spr = SPR_PROFIT_SOME;
283 spr = SPR_PROFIT_LOT;
302 }
else if (IsDefaultGroupID(this->
group_over)) {
318 default: NOT_REACHED();
335 this->BuildVehicleList();
336 this->SortVehicleList();
342 this->GetWidget<NWidgetCore>(
WID_GL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->
vli.
vtype;
392 d.height += padding.height;
400 size->height = 4 * resize->height;
405 d.height += padding.height;
406 d.width += padding.width;
478 this->BuildVehicleList();
479 this->SortVehicleList();
518 uint16 protect_sprite = SPR_GROUP_REPLACE_OFF_TRAIN;
542 uint32 occupancy = 0;
545 for (uint i = 0; i < vehicle_count; i++) {
547 assert(v->
owner == this->owner);
558 DrawString(left, right, y, STR_GROUP_PROFIT_THIS_YEAR, TC_BLACK);
563 DrawString(left, right, y, STR_GROUP_PROFIT_LAST_YEAR, TC_BLACK);
568 DrawString(left, right, y, STR_GROUP_OCCUPANCY, TC_BLACK);
569 if (vehicle_count > 0) {
583 assert(g->
owner == this->owner);
606 if (v->
group_id != this->vli.index) {
618 static void DeleteGroupCallback(
Window *win,
bool confirmed)
648 if (!IsDefaultGroupID(this->
vli.
index)) {
692 ShowQuery(STR_QUERY_GROUP_DELETE_CAPTION, STR_GROUP_DELETE_QUERY_TEXT,
this, DeleteGroupCallback);
697 this->ShowRenameGroupWindow(this->
vli.
index,
false);
726 void OnDragDrop_Group(
Point pt,
int widget)
758 void OnDragDrop_Vehicle(
Point pt,
int widget)
851 default: NOT_REACHED();
855 default: NOT_REACHED();
911 void ShowRenameGroupWindow(
GroupID group,
bool empty)
919 str = STR_GROUP_NAME;
940 _nested_group_widgets,
lengthof(_nested_group_widgets)
944 WDP_AUTO,
"list_groups_train", 525, 246,
947 _nested_group_widgets,
lengthof(_nested_group_widgets)
961 AllocateWindowDescFront<VehicleGroupWindow>(&_train_group_desc, num);
964 AllocateWindowDescFront<VehicleGroupWindow>(&_other_group_desc, num);
989 if (result.
Failed())
return;
993 if (w != NULL) w->ShowRenameGroupWindow(_new_group_id,
true);
1005 if (result.
Failed())
return;