Update to 1.10.0-beta2
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
@@ -180,8 +178,7 @@ private:
|
||||
|
||||
GUIGroupList list;
|
||||
|
||||
const Group *g;
|
||||
FOR_ALL_GROUPS(g) {
|
||||
for (const Group *g : Group::Iterate()) {
|
||||
if (g->owner == owner && g->vehicle_type == this->vli.vtype) {
|
||||
list.push_back(g);
|
||||
}
|
||||
@@ -371,6 +368,7 @@ public:
|
||||
this->groups.ForceRebuild();
|
||||
this->groups.NeedResort();
|
||||
this->BuildGroupList(vli.company);
|
||||
this->group_sb->SetCount((uint)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;
|
||||
@@ -736,6 +734,10 @@ public:
|
||||
|
||||
this->vehicle_sel = v->index;
|
||||
|
||||
if (_ctrl_pressed) {
|
||||
this->SelectGroup(v->group_id);
|
||||
}
|
||||
|
||||
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
|
||||
SetMouseCursorVehicle(v, EIT_IN_LIST);
|
||||
_cursor.vehchain = true;
|
||||
@@ -794,7 +796,7 @@ public:
|
||||
|
||||
switch (widget) {
|
||||
case WID_GL_ALL_VEHICLES: // All vehicles
|
||||
case WID_GL_DEFAULT_VEHICLES: // Ungroupd vehicles
|
||||
case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
|
||||
if (g->parent != INVALID_GROUP) {
|
||||
DoCommandP(0, this->group_sel | (1 << 16), INVALID_GROUP, CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT));
|
||||
}
|
||||
@@ -994,6 +996,35 @@ public:
|
||||
{
|
||||
if (this->vehicle_sel == vehicle) ResetObjectToPlace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the specified group in the list
|
||||
*
|
||||
* @param g_id The ID of the group to be selected
|
||||
*/
|
||||
void SelectGroup(const GroupID g_id)
|
||||
{
|
||||
if (g_id == INVALID_GROUP || g_id == this->vli.index) return;
|
||||
|
||||
this->vli.index = g_id;
|
||||
if (g_id != ALL_GROUP && g_id != DEFAULT_GROUP) {
|
||||
const Group *g = Group::Get(g_id);
|
||||
int id_g = find_index(this->groups, g);
|
||||
// The group's branch is maybe collapsed, so try to expand it
|
||||
if (id_g == -1) {
|
||||
for (auto pg = Group::GetIfValid(g->parent); pg != nullptr; pg = Group::GetIfValid(pg->parent)) {
|
||||
pg->folded = false;
|
||||
}
|
||||
this->groups.ForceRebuild();
|
||||
this->BuildGroupList(this->owner);
|
||||
id_g = find_index(this->groups, g);
|
||||
}
|
||||
this->group_sb->ScrollTowards(id_g);
|
||||
}
|
||||
this->vehicles.ForceRebuild();
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1015,18 +1046,31 @@ static WindowDesc _train_group_desc(
|
||||
* 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.
|
||||
*/
|
||||
void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type)
|
||||
void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type, GroupID group = INVALID_GROUP, bool need_existing_window = false)
|
||||
{
|
||||
if (!Company::IsValidID(company)) return;
|
||||
|
||||
WindowNumber num = VehicleListIdentifier(VL_GROUP_LIST, vehicle_type, company).Pack();
|
||||
const WindowNumber num = VehicleListIdentifier(VL_GROUP_LIST, vehicle_type, company).Pack();
|
||||
VehicleGroupWindow *w;
|
||||
if (vehicle_type == VEH_TRAIN) {
|
||||
AllocateWindowDescFront<VehicleGroupWindow>(&_train_group_desc, num);
|
||||
w = AllocateWindowDescFront<VehicleGroupWindow>(&_train_group_desc, num, need_existing_window);
|
||||
} else {
|
||||
_other_group_desc.cls = GetWindowClassForVehicleType(vehicle_type);
|
||||
AllocateWindowDescFront<VehicleGroupWindow>(&_other_group_desc, num);
|
||||
w = AllocateWindowDescFront<VehicleGroupWindow>(&_other_group_desc, num, need_existing_window);
|
||||
}
|
||||
if (w != nullptr) w->SelectGroup(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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user