OpenTTD Source  1.11.2
group_gui.cpp File Reference
#include "stdafx.h"
#include "textbuf_gui.h"
#include "command_func.h"
#include "vehicle_gui.h"
#include "vehicle_base.h"
#include "string_func.h"
#include "strings_func.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "autoreplace_gui.h"
#include "company_func.h"
#include "widgets/dropdown_func.h"
#include "tilehighlight_func.h"
#include "vehicle_gui_base.h"
#include "core/geometry_func.hpp"
#include "company_base.h"
#include "company_gui.h"
#include "widgets/group_widget.h"
#include "table/sprites.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

class  VehicleGroupWindow
 

Typedefs

typedef GUIList< const Group * > GUIGroupList
 

Functions

void ShowCompanyGroup (CompanyID company, VehicleType vehicle_type, GroupID group=INVALID_GROUP, bool need_existing_window=false)
 Show the group window for the given company and vehicle type. More...
 
void ShowCompanyGroupForVehicle (const Vehicle *v)
 Show the group window for the given vehicle. More...
 
static VehicleGroupWindowFindVehicleGroupWindow (VehicleType vt, Owner owner)
 Finds a group list window determined by vehicle type and owner. More...
 
void CcCreateGroup (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 Opens a 'Rename group' window for newly created group. More...
 
void CcAddVehicleNewGroup (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 Open rename window after adding a vehicle to a new group via drag and drop. More...
 
void DeleteGroupHighlightOfVehicle (const Vehicle *v)
 Removes the highlight of a vehicle in a group window. More...
 

Variables

static const int LEVEL_WIDTH = 10
 Indenting width of a sub-group in pixels.
 
static const NWidgetPart _nested_group_widgets []
 
static WindowDesc _other_group_desc (WDP_AUTO, "list_groups", 460, 246, WC_INVALID, WC_NONE, 0, _nested_group_widgets, lengthof(_nested_group_widgets))
 
static WindowDesc _train_group_desc (WDP_AUTO, "list_groups_train", 525, 246, WC_TRAINS_LIST, WC_NONE, 0, _nested_group_widgets, lengthof(_nested_group_widgets))
 

Detailed Description

GUI for the group window.

Definition in file group_gui.cpp.

Function Documentation

◆ CcAddVehicleNewGroup()

void CcAddVehicleNewGroup ( const CommandCost result,
TileIndex  tile,
uint32  p1,
uint32  p2,
uint32  cmd 
)

Open rename window after adding a vehicle to a new group via drag and drop.

Parameters
resultDid command succeed?
tileUnused.
p1Unused.
p2Bit 0-19: Vehicle ID.
cmdUnused.

Definition at line 1157 of file group_gui.cpp.

References CcCreateGroup(), CommandCost::Failed(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::IsValidID().

◆ CcCreateGroup()

void CcCreateGroup ( const CommandCost result,
TileIndex  tile,
uint32  p1,
uint32  p2,
uint32  cmd 
)

Opens a 'Rename group' window for newly created group.

Parameters
resultDid command succeed?
tileUnused.
p1Vehicle type.
p2Unused.
cmdUnused.
See also
CmdCreateGroup

Definition at line 1140 of file group_gui.cpp.

References _current_company, CommandCost::Failed(), FindVehicleGroupWindow(), and VEH_AIRCRAFT.

Referenced by CcAddVehicleNewGroup().

◆ DeleteGroupHighlightOfVehicle()

void DeleteGroupHighlightOfVehicle ( const Vehicle v)

◆ FindVehicleGroupWindow()

static VehicleGroupWindow* FindVehicleGroupWindow ( VehicleType  vt,
Owner  owner 
)
inlinestatic

Finds a group list window determined by vehicle type and owner.

Parameters
vtvehicle type
ownerowner of groups
Returns
pointer to VehicleGroupWindow, nullptr if not found

Definition at line 1126 of file group_gui.cpp.

References FindWindowById(), and GetWindowClassForVehicleType().

Referenced by CcCreateGroup(), and DeleteGroupHighlightOfVehicle().

◆ ShowCompanyGroup()

void ShowCompanyGroup ( CompanyID  company,
VehicleType  vehicle_type,
GroupID  group = INVALID_GROUP,
bool  need_existing_window = false 
)

Show the group window for the given company and vehicle type.

Parameters
companyThe company to show the window for.
vehicle_typeThe type of vehicle to show it for.
groupThe group to be selected. Defaults to INVALID_GROUP.
need_existing_windowWhether the existing window is needed. Defaults to false.

Definition at line 1096 of file group_gui.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID().

Referenced by ShowCompanyGroupForVehicle().

◆ ShowCompanyGroupForVehicle()

void ShowCompanyGroupForVehicle ( const Vehicle v)

Show the group window for the given vehicle.

Parameters
vThe vehicle to show the window for.

Definition at line 1115 of file group_gui.cpp.

References Vehicle::group_id, Vehicle::owner, ShowCompanyGroup(), and BaseVehicle::type.

Referenced by NewsWindow::OnClick(), and VehicleListWindow::OnClick().