40 static constexpr
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),
67 SetDataTip(SPR_GROUP_LIVERY_TRAIN, STR_GROUP_LIVERY_TOOLTIP),
70 SetDataTip(SPR_GROUP_REPLACE_OFF_TRAIN, STR_GROUP_REPLACE_PROTECTION_TOOLTIP),
93 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),
99 SetDataTip(STR_JUST_STRING, STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
102 SetDataTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
104 SetDataTip(SPR_FLAG_VEH_STOPPED, STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP),
106 SetDataTip(SPR_FLAG_VEH_RUNNING, STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP),
123 for (
const auto &item : src) {
124 if (item.group->parent != parent)
continue;
126 dst.emplace_back(item.group, indent);
128 if (fold && item.group->folded) {
130 GroupID groupid = item.group->index;
131 bool has_children = std::any_of(src.begin(), src.end(), [groupid](
const auto &child) { return child.group->parent == groupid; });
132 Group::Get(item.group->index)->folded = has_children;
138 if (indent > 0 || dst.empty())
return;
141 uint16_t level_mask = 0;
142 for (
auto it = std::rbegin(dst); std::next(it) != std::rend(dst); ++it) {
143 auto next_it = std::next(it);
144 AssignBit(level_mask, it->indent, it->indent <= next_it->indent);
145 next_it->level_mask = level_mask;
161 if (g->owner == owner && g->vehicle_type == veh_type) {
162 list.emplace_back(g, 0);
169 std::array<std::pair<const Group *, std::string>, 2> last_group{};
172 if (a.group != last_group[0].first) {
173 SetDParam(0, a.group->index);
174 last_group[0] = {a.group, GetString(STR_GROUP_NAME)};
177 if (b.group != last_group[1].first) {
178 SetDParam(0, b.group->index);
179 last_group[1] = {b.group, GetString(STR_GROUP_NAME)};
183 if (r == 0)
return a.group->number < b.group->number;
223 this->groups.clear();
237 this->tiny_step_height = this->column_size[
VGC_FOLD].height;
241 this->tiny_step_height = std::max(this->tiny_step_height, this->column_size[
VGC_NAME].
height);
244 this->tiny_step_height = std::max(this->tiny_step_height, this->column_size[
VGC_PROTECT].
height);
247 this->tiny_step_height = std::max(this->tiny_step_height, this->column_size[
VGC_AUTOREPLACE].
height);
251 static const SpriteID profit_sprites[] = {SPR_PROFIT_NA, SPR_PROFIT_NEGATIVE, SPR_PROFIT_SOME, SPR_PROFIT_LOT};
252 for (
const auto &profit_sprite : profit_sprites) {
256 this->tiny_step_height = std::max(this->tiny_step_height, this->column_size[
VGC_PROFIT].
height);
262 this->tiny_step_height = std::max(this->tiny_step_height, this->column_size[
VGC_NUMBER].
height);
286 void DrawGroupInfo(
int y,
int left,
int right,
GroupID g_id, uint16_t level_mask = 0, uint8_t indent = 0,
bool protection =
false,
bool has_children =
false)
const
289 if (g_id == this->group_over) {
300 const int offset = (rtl ? -(int)this->column_size[
VGC_FOLD].
width : (
int)this->column_size[
VGC_FOLD].width) / 2;
307 for (uint lvl = 1; lvl <= indent; ++lvl) {
309 if (lvl < indent) tx += level_width;
312 int ycentre = y + this->tiny_step_height / 2 - 1;
314 GfxDrawLine(tx, ycentre, tx + offset - (rtl ? -1 : 1), ycentre, linecolour,
WidgetDimensions::scaled.fullbevel.top);
320 DrawSprite(
Group::Get(g_id)->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED, PAL_NONE, x + indent * level_width, y + (this->tiny_step_height - this->column_size[
VGC_FOLD].
height) / 2);
326 str = STR_GROUP_ALL_TRAINS + this->
vli.
vtype;
327 }
else if (IsDefaultGroupID(g_id)) {
328 str = STR_GROUP_DEFAULT_TRAINS + this->
vli.
vtype;
331 str = STR_GROUP_NAME;
338 if (protection)
DrawSprite(SPR_GROUP_REPLACE_PROTECT, PAL_NONE, x, y + (this->tiny_step_height - this->column_size[
VGC_PROTECT].
height) / 2);
349 if (num_vehicle_min_age == 0) {
351 }
else if (profit_last_year_min_age < 0) {
352 spr = SPR_PROFIT_NEGATIVE;
354 spr = SPR_PROFIT_SOME;
356 spr = SPR_PROFIT_LOT;
364 if (
IsAllGroupID(g_id) || IsDefaultGroupID(g_id) || num_vehicle_with_subgroups == num_vehicle) {
369 SetDParam(1, num_vehicle_with_subgroups - num_vehicle);
383 }
else if (IsDefaultGroupID(this->group_over)) {
406 this->group_sb->
SetCount(this->groups.size());
408 this->GetWidget<NWidgetCore>(
WID_GL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->
vli.
vtype;
420 this->BuildVehicleList();
421 this->SortVehicleList();
447 d.height += padding.height;
455 size.height = 4 *
resize.height;
464 size.width = std::max(size.width,
GetStringListWidth(this->vehicle_group_none_sorter_names_wallclock));
465 size.width = std::max(size.width,
GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_calendar));
466 size.width = std::max(size.width,
GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_wallclock));
467 size.width += padding.width;
476 d.height += padding.height;
477 d.width += padding.width;
489 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
513 void SetStringParameters(
WidgetID widget)
const override
548 this->BuildVehicleList();
549 this->SortVehicleList();
553 this->group_sb->
SetCount(this->groups.size());
586 uint16_t protect_sprite = SPR_GROUP_REPLACE_OFF_TRAIN;
599 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
613 uint64_t occupancy = 0;
616 assert(v->owner == this->owner);
618 this_year += v->GetDisplayProfitThisYear();
619 last_year += v->GetDisplayProfitLastYear();
620 occupancy += v->trip_occupancy;
635 DrawString(tr, STR_GROUP_OCCUPANCY, TC_BLACK);
636 const size_t vehicle_count = this->vehicles.size();
637 if (vehicle_count > 0) {
648 for (
auto it = first; it != last; ++it) {
649 const Group *g = it->group;
651 assert(g->
owner == this->owner);
657 if ((uint)this->group_sb->
GetPosition() + this->group_sb->GetCapacity() > this->groups.size()) {
672 for (
auto it = first; it != last; ++it) {
673 const Vehicle *v = it->GetSingleVehicle();
674 if (v->
group_id != this->vli.index) {
677 mr = mr.
Translate(0, this->resize.step_height);
686 static void DeleteGroupCallback(
Window *win,
bool confirmed)
695 bool last_overlay_state;
704 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
733 if (!IsDefaultGroupID(this->
vli.
index)) {
742 if (it == this->groups.end())
return;
744 if (it->group->folded || (std::next(it) != std::end(this->groups) && std::next(it)->indent > it->indent)) {
746 NWidgetCore *group_display = this->GetWidget<NWidgetCore>(widget);
750 if (click_count > 1 || (pt.x >= x && pt.x < (
int)(x + this->column_size[
VGC_FOLD].width))) {
756 if (g == it->group->index) {
763 Group::Get(it->group->index)->folded = !it->group->folded;
771 this->group_sel = this->
vli.
index = it->group->index;
790 const Vehicle *v2 = vehgroup.GetSingleVehicle();
796 case GB_SHARED_ORDERS: {
797 assert(vehgroup.NumVehicles() > 0);
840 this->group_confirm = this->
vli.
index;
841 ShowQuery(STR_QUERY_GROUP_DELETE_CAPTION, STR_GROUP_DELETE_QUERY_TEXT,
this, DeleteGroupCallback);
846 this->ShowRenameGroupWindow(this->
vli.
index,
false);
898 if (this->group_sel != new_g && g->
parent != new_g) {
947 const Vehicle *v = vehgroup.GetSingleVehicle();
954 case GB_SHARED_ORDERS: {
957 if (vindex == v->
index) {
958 if (vehgroup.NumVehicles() == 1) {
961 ShowVehicleListWindow(v);
978 if (this->vehicle_sel !=
INVALID_VEHICLE) OnDragDrop_Vehicle(pt, widget);
979 if (this->group_sel !=
INVALID_GROUP) OnDragDrop_Group(pt, widget);
984 void OnQueryTextFinished(std::optional<std::string> str)
override
996 void OnDropdownSelect(
WidgetID widget,
int index)
override
1000 this->UpdateVehicleGroupBy(
static_cast<GroupBy
>(index));
1012 assert(!this->vehicles.empty());
1024 case ADI_CREATE_GROUP:
1028 case ADI_ADD_SHARED:
1033 case ADI_REMOVE_ALL:
1038 default: NOT_REACHED();
1042 default: NOT_REACHED();
1050 if (this->groups.
NeedResort() || this->vehgroups.NeedResort()) {
1078 new_group_over = it == this->groups.end() ?
NEW_GROUP : it->group->index;
1091 if (new_group_over != this->group_over) {
1093 this->group_over = new_group_over;
1098 void ShowRenameGroupWindow(
GroupID group,
bool empty)
1101 this->group_rename = group;
1106 str = STR_GROUP_NAME;
1134 auto found = std::find_if(std::begin(this->groups), std::end(this->groups), [g](
const auto &item) {
return item.group == g; });
1135 if (found == std::end(this->groups)) {
1142 this->group_sb->
SetCount(this->groups.size());
1143 found = std::find_if(std::begin(this->groups), std::end(this->groups), [g](
const auto &item) {
return item.group == g; });
1145 if (found != std::end(this->groups)) this->group_sb->
ScrollTowards(std::distance(std::begin(this->groups), found));
1158 _nested_group_widgets
1162 WDP_AUTO,
"list_groups_train", 525, 246,
1165 _nested_group_widgets
1182 w = AllocateWindowDescFront<VehicleGroupWindow>(_train_group_desc, num, need_existing_window);
1185 w = AllocateWindowDescFront<VehicleGroupWindow>(_other_group_desc, num, need_existing_window);
1217 if (w !=
nullptr) w->ShowRenameGroupWindow(gid,
true);
1229 if (result.
Failed())
return;
1242 if (result.
Failed())
return;
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
Show the autoreplace configuration window for a particular group.
Functions related to the autoreplace GUIs.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T AssignBit(T &x, const uint8_t y, bool value)
Assigns a bit in a variable.
Common return value for all commands.
bool Failed() const
Did this command fail?
void RebuildDone()
Notify the sortlist that the rebuild is done.
bool IsDescSortOrder() const
Check if the sort order is descending.
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here.
bool NeedRebuild() const
Check if a rebuild is needed.
void ForceRebuild()
Force that a rebuild is needed.
bool Sort(Comp compare)
Sort the list.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
uint8_t SortType() const
Get the sorttype of the list.
Listing GetListing() const
Export current sort conditions.
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0.
void SetSortType(uint8_t n_type)
Set the sorttype of the list.
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
void UnselectVehicle(VehicleID vehicle)
Tests whether a given vehicle is selected in the window, and unselects it if necessary.
void DirtyHighlightedGroupWidget()
Mark the widget containing the currently highlighted group as dirty.
GroupID group_sel
Selected group (for drag/drop)
GroupID group_rename
Group being renamed, INVALID_GROUP if none.
void BuildGroupList(Owner owner)
(Re)Build the group list.
uint tiny_step_height
Step height for the group list.
void OnResize() override
Called after the window got resized.
void OnGameTick() override
Called once per (game) tick.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Dimension column_size[VGC_END]
Size of the columns in the group list.
GroupID group_confirm
Group awaiting delete confirmation.
GUIGroupList groups
List of groups.
GroupID group_over
Group over which a vehicle is dragged, INVALID_GROUP if none.
uint ComputeGroupInfoSize()
Compute tiny_step_height and column_size.
void DrawGroupInfo(int y, int left, int right, GroupID g_id, uint16_t level_mask=0, uint8_t indent=0, bool protection=false, bool has_children=false) const
Draw a row in the group list.
@ VGC_AUTOREPLACE
Autoreplace active icon.
@ VGC_FOLD
Fold / Unfold button.
@ VGC_PROTECT
Autoreplace protect icon.
@ VGC_NUMBER
Number of vehicles in the group.
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
void SelectGroup(const GroupID g_id)
Selects the specified group in the list.
void OnPaint() override
The window must be repainted.
Functions related to commands.
Commands
List of commands.
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
CompanyID _current_company
Company currently doing an action.
Functions related to companies.
GUI Functions related to companies.
Owner
Enum for all companies/owners.
Some simple functions to help with accessing containers.
void ShowDropDownMenu(Window *w, std::span< const StringID > strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
Dimension GetDropDownListDimension(const DropDownList &list)
Determine width and height required to fully display a DropDownList.
Functions related to the drop down widget.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
bool _ctrl_pressed
Is Ctrl pressed?
uint GetStringListWidth(std::span< const StringID > list, FontSize fontsize)
Get maximum width of a list of strings.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Functions related to the gfx engine.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
@ SA_RIGHT
Right align the text (must be a single bit).
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
@ FS_SMALL
Index of the small font in the font tables.
@ FS_NORMAL
Index of the normal font in the font tables.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Money GetGroupProfitLastYearMinAge(CompanyID company, GroupID id_g, VehicleType type)
Get last year's profit of vehicles above minimum age for the group with GroupID id_g and its sub-grou...
@ GF_REPLACE_PROTECTION
If set to true, the global autoreplace has no effect on the group.
bool IsAllGroupID(GroupID id_g)
Checks if a GroupID stands for all vehicles of a company.
uint GetGroupNumVehicle(CompanyID company, GroupID id_g, VehicleType type)
Get the number of vehicles in the group with GroupID id_g and its sub-groups.
uint GetGroupNumVehicleMinAge(CompanyID company, GroupID id_g, VehicleType type)
Get the number of vehicles above profit minimum age in the group with GroupID id_g and its sub-groups...
Command definitions related to engine groups.
@ Rename
Change group name.
@ SetParent
Change group parent.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type, GroupID group, bool need_existing_window)
Show the group window for the given company and vehicle type.
void DeleteGroupHighlightOfVehicle(const Vehicle *v)
Removes the highlight of a vehicle in a group window.
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.
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.
static VehicleGroupWindow * FindVehicleGroupWindow(VehicleType vt, Owner owner)
Finds a group list window determined by vehicle type and owner.
void ShowCompanyGroupForVehicle(const Vehicle *v)
Show the group window for the given vehicle.
static void CcCreateGroup(GroupID gid, VehicleType veh_type)
Opens a 'Rename group' window for newly created group.
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.
Functions/definitions that have something to do with groups.
uint16_t GroupID
Type for all group identifiers.
static const GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
static const GroupID NEW_GROUP
Sentinel for a to-be-created group.
static const uint MAX_LENGTH_GROUP_NAME_CHARS
The maximum length of a group name in characters including '\0'.
static const GroupID INVALID_GROUP
Sentinel for invalid groups.
static const GroupID ALL_GROUP
All vehicles are in this group.
GUI functions that shouldn't be here.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
uint8_t GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
A number of safeguards to prevent using unsafe methods.
This file contains all sprite-related enums and defines.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Definition of base types and functions in a cross-platform compatible way.
int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
Functions related to low-level strings.
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
TextDirection _current_text_dir
Text direction of the currently selected language.
Functions related to OTTD's strings.
@ TD_RTL
Text is written right-to-left by default.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
CargoID cargo_filter_criteria
Selected cargo filter index.
VehicleListIdentifier vli
Identifier of the vehicle list we want to currently show.
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const
Draw all the vehicle list items.
VehicleID vehicle_sel
Selected vehicle.
Listing * sorting
Pointer to the vehicle type related sorting.
void SetCargoFilter(uint8_t index)
Set cargo filter for the vehicle group list.
GroupBy grouping
How we want to group the list.
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group, bool show_create)
Compute the size for the Action dropdown.
DropDownList BuildActionDropdownList(bool show_autoreplace, bool show_group, bool show_create)
Display the Action dropdown window.
VehicleList vehicles
List of vehicles. This is the buffer for vehgroups to point into; if this is structurally modified,...
GUIVehicleGroupList vehgroups
List of (groups of) vehicles. This stores iterators of vehicles, and should be rebuilt if vehicles is...
DropDownList BuildCargoDropDownList(bool full) const
Build drop down list for cargo filter selection.
VehicleType type
Type of vehicle.
bool vehchain
vehicle chain is dragged
Dimensions (a width and height) of a rectangle in 2D.
VehicleList::const_iterator vehicles_begin
Pointer to beginning element of this vehicle group.
Statistics and caches on the vehicles in a group.
uint16_t num_vehicle
Number of vehicles.
bool autoreplace_defined
Are any autoreplace rules set?
static GroupStatistics & Get(CompanyID company, GroupID id_g, VehicleType type)
Returns the GroupStatistics for a specific group.
bool autoreplace_finished
Have all autoreplacement finished?
GroupID parent
Parent group.
VehicleType vehicle_type
Vehicle type of the group.
bool folded
NOSAVE: Is this group folded in the group view?
uint8_t flags
Group flags.
Coordinates of a point in 2D.
Tindex index
Index of this pool item.
static Titem * Get(size_t index)
Returns Titem with given index.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
The information about a vehicle list.
CompanyID company
The company associated with this list.
uint32_t Pack() const
Pack a VehicleListIdentifier in a single uint32.
VehicleType vtype
The vehicle type associated with this list.
uint32_t index
A vehicle list type specific index.
GroupID group_id
Index of group Pool array.
Owner owner
Which company owns the vehicle?
High level window description.
WindowClass cls
Class of the window,.
Data structure for an opened window.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void DrawWidgets() const
Paint all widgets of a window.
Window * parent
Parent window.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
void DrawSortButtonState(WidgetID widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
ResizeInfo resize
Resize information.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
int left
x position of left edge of the window
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
int height
Height of the window (number of pixels down in y direction)
int width
width of the window (number of pixels to the right in x direction)
WindowNumber window_number
Window number within the window class.
Stuff related to the text buffer GUI.
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
@ QSF_LEN_IN_CHARS
the length of the string is counted in characters
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
@ HT_DRAG
dragging items in the depot windows
Base class for all vehicles.
Command definitions for vehicles.
Functions related to vehicles.
static const Money VEHICLE_PROFIT_THRESHOLD
Threshold for a vehicle to be considered making good profit.
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
uint GetVehicleListHeight(VehicleType type, uint divisor)
Get the height of a vehicle in the vehicle list GUIs.
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
bool ShowCargoIconOverlay()
Test if cargo icon overlays should be drawn.
Functions related to the vehicle's GUIs.
WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
Functions/classes shared between the different vehicle list GUIs.
@ EIT_IN_LIST
Vehicle drawn in vehicle list, group list, ...
VehicleType
Available vehicle types.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_TRAIN
Train vehicle type.
uint32_t VehicleID
The type all our vehicle IDs have.
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
@ MassSend
Tells that it's a mass send to depot command (type in VLW flag)
@ Service
The vehicle will leave the depot right after arrival (service only)
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
Window functions not directly related to making/drawing windows.
@ WSM_DRAGDROP
Drag&drop an object.
@ SBS_DOWN
Sort ascending.
@ WDP_AUTO
Find a place automatically.
int32_t WindowNumber
Number to differentiate different windows of the same class.
@ WC_INVALID
Invalid window.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_TRAINS_LIST
Trains list; Window numbers:
@ WC_DROPDOWN_MENU
Drop down menu; Window numbers:
@ WC_QUERY_STRING
Query string window; Window numbers: