Data Structures | Functions | Variables
autoreplace_gui.cpp File Reference

GUI for autoreplace handling. More...

#include "stdafx.h"
#include "command_func.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "rail.h"
#include "strings_func.h"
#include "window_func.h"
#include "autoreplace_func.h"
#include "company_func.h"
#include "engine_base.h"
#include "window_gui.h"
#include "engine_gui.h"
#include "settings_func.h"
#include "core/geometry_func.hpp"
#include "rail_gui.h"
#include "widgets/dropdown_func.h"
#include "widgets/autoreplace_widget.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

class  ReplaceVehicleWindow
 Window for the autoreplacing of vehicles. More...


void DrawEngineList (VehicleType type, int x, int r, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group)
 Engine drawing loop. More...
static int CDECL EngineNumberSorter (const EngineID *a, const EngineID *b)
void InvalidateAutoreplaceWindow (EngineID e, GroupID id_g)
 Rebuild the left autoreplace list if an engine is removed or added. More...
void AddRemoveEngineFromAutoreplaceAndBuildWindows (VehicleType type)
 When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists. More...
void ShowReplaceGroupVehicleWindow (GroupID id_g, VehicleType vehicletype)
 Show the autoreplace configuration window for a particular group. More...


static const StringID _start_replace_dropdown []
static const NWidgetPart _nested_replace_rail_vehicle_widgets []
static WindowDesc _replace_rail_vehicle_desc (WDP_AUTO, "replace_vehicle_train", 500, 140, WC_REPLACE_VEHICLE, WC_NONE, WDF_CONSTRUCTION, _nested_replace_rail_vehicle_widgets, lengthof(_nested_replace_rail_vehicle_widgets))
static const NWidgetPart _nested_replace_vehicle_widgets []
static WindowDesc _replace_vehicle_desc (WDP_AUTO, "replace_vehicle", 456, 118, WC_REPLACE_VEHICLE, WC_NONE, WDF_CONSTRUCTION, _nested_replace_vehicle_widgets, lengthof(_nested_replace_vehicle_widgets))

Detailed Description

GUI for autoreplace handling.

Definition in file autoreplace_gui.cpp.

Function Documentation

◆ AddRemoveEngineFromAutoreplaceAndBuildWindows()

void AddRemoveEngineFromAutoreplaceAndBuildWindows ( VehicleType  type)

When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists.

typeThe type of engine

Definition at line 65 of file autoreplace_gui.cpp.

References InvalidateWindowClassesData(), InvalidateWindowData(), WC_BUILD_VEHICLE, and WC_REPLACE_VEHICLE.

Referenced by CalcEngineReliability(), and CmdSetVehicleVisibility().

◆ DrawEngineList()

void DrawEngineList ( VehicleType  type,
int  l,
int  r,
int  y,
const GUIEngineList eng_list,
uint16  min,
uint16  max,
EngineID  selected_id,
bool  show_count,
GroupID  selected_group 

Engine drawing loop.

typeType of vehicle (VEH_*)
lThe left most location of the list
rThe right most location of the list
yThe top most location of the list
eng_listWhat engines to draw
minwhere to start in the list
maxwhere in the list to end
selected_idwhat engine to highlight as selected, if any
show_countWhether to show the amount of engines or not
selected_groupthe group to list the engines of

Definition at line 894 of file build_vehicle_gui.cpp.

Referenced by BuildVehicleWindow::DrawWidget().

◆ InvalidateAutoreplaceWindow()

void InvalidateAutoreplaceWindow ( EngineID  e,
GroupID  id_g 

Rebuild the left autoreplace list if an engine is removed or added.

eEngine to check if it is removed or added
id_gThe group the engine belongs to Note: this function only works if it is called either
  • when a new vehicle is build, but before it's counted in num_engines
  • when a vehicle is deleted and after it's subtracted from num_engines
  • when not changing the count (used when changing replace orders)

Definition at line 51 of file autoreplace_gui.cpp.

References _local_company, ALL_GROUP, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetGroupNumEngines(), InvalidateWindowData(), and WC_REPLACE_VEHICLE.

◆ ShowReplaceGroupVehicleWindow()

void ShowReplaceGroupVehicleWindow ( GroupID  id_g,
VehicleType  vehicletype 

Show the autoreplace configuration window for a particular group.

id_gThe group to replace the vehicles for.
vehicletypeThe type of vehicles in the group.

Definition at line 705 of file autoreplace_gui.cpp.

References DeleteWindowById(), VEH_TRAIN, and WC_REPLACE_VEHICLE.

Variable Documentation

◆ _start_replace_dropdown

const StringID _start_replace_dropdown[]
Initial value:
= {
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:19

Definition at line 71 of file autoreplace_gui.cpp.