OpenTTD Source  20241108-master-g80f628063a
group_gui.cpp File Reference

GUI for the group window. More...

#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 "dropdown_func.h"
#include "tilehighlight_func.h"
#include "vehicle_gui_base.h"
#include "core/geometry_func.hpp"
#include "core/container_func.hpp"
#include "company_base.h"
#include "company_gui.h"
#include "gui.h"
#include "group_cmd.h"
#include "group_gui.h"
#include "vehicle_cmd.h"
#include "gfx_func.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
 

Functions

static void GuiGroupListAddChildren (GUIGroupList &dst, const GUIGroupList &src, bool fold, GroupID parent=INVALID_GROUP, uint8_t indent=0)
 Add children to GUI group list to build a hierarchical tree. More...
 
void BuildGuiGroupList (GUIGroupList &dst, bool fold, Owner owner, VehicleType veh_type)
 Build GUI group list, a sorted hierarchical list of groups for owner and vehicle type. More...
 
void ShowCompanyGroup (CompanyID company, VehicleType vehicle_type, GroupID group, bool need_existing_window)
 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...
 
static void CcCreateGroup (GroupID gid, VehicleType veh_type)
 Opens a 'Rename group' window for newly created group. More...
 
void CcCreateGroup (Commands, const CommandCost &result, GroupID new_group, VehicleType vt, GroupID)
 Opens a 'Rename group' window for newly created group. More...
 
void CcAddVehicleNewGroup (Commands, const CommandCost &result, GroupID new_group, GroupID, VehicleID, bool, const VehicleListIdentifier &)
 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 constexpr NWidgetPart _nested_group_widgets []
 
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)
 

Detailed Description

GUI for the group window.

Definition in file group_gui.cpp.

Function Documentation

◆ BuildGuiGroupList()

void BuildGuiGroupList ( GUIGroupList dst,
bool  fold,
Owner  owner,
VehicleType  veh_type 
)

Build GUI group list, a sorted hierarchical list of groups for owner and vehicle type.

Parameters
dstDestination list, owned by the caller.
foldWhether to handle group folding/hiding.
ownerOwner of groups.
veh_typeVehicle type of groups.

Definition at line 156 of file group_gui.cpp.

References GUIList< T, P, F >::ForceResort(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::Iterate(), and GUIList< T, P, F >::Sort().

Referenced by VehicleGroupWindow::BuildGroupList().

◆ CcAddVehicleNewGroup()

void CcAddVehicleNewGroup ( Commands  cmd,
const CommandCost result,
GroupID  new_group,
GroupID  ,
VehicleID  veh_id,
bool  ,
const VehicleListIdentifier  
)

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

Parameters
resultDid command succeed?
new_groupID of the created group.

Definition at line 1240 of file group_gui.cpp.

◆ CcCreateGroup() [1/2]

void CcCreateGroup ( Commands  cmd,
const CommandCost result,
GroupID  new_group,
VehicleType  vt,
GroupID  parent_group 
)

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

Parameters
resultDid command succeed?
new_groupID of the created group.
vtVehicle type.
See also
CmdCreateGroup

Definition at line 1227 of file group_gui.cpp.

◆ CcCreateGroup() [2/2]

static void CcCreateGroup ( GroupID  gid,
VehicleType  veh_type 
)
static

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

Parameters
veh_typeVehicle type.

Definition at line 1214 of file group_gui.cpp.

References _current_company, and FindVehicleGroupWindow().

◆ 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 1205 of file group_gui.cpp.

References FindWindowById(), and GetWindowClassForVehicleType().

Referenced by CcCreateGroup(), and DeleteGroupHighlightOfVehicle().

◆ GuiGroupListAddChildren()

static void GuiGroupListAddChildren ( GUIGroupList dst,
const GUIGroupList src,
bool  fold,
GroupID  parent = INVALID_GROUP,
uint8_t  indent = 0 
)
static

Add children to GUI group list to build a hierarchical tree.

Parameters
dstDestination list.
srcSource list.
foldWhether to handle group folding/hiding.
parentCurrent tree parent (set by self with recursion).
indentCurrent tree indentation level (set by self with recursion).

Definition at line 121 of file group_gui.cpp.

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

◆ ShowCompanyGroup()

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

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 1175 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 1194 of file group_gui.cpp.

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