#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "gui.h"
#include "command_func.h"
#include "variables.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "group.h"
#include "rail.h"
#include "strings_func.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "autoreplace_func.h"
#include "gfx_func.h"
#include "player_func.h"
#include "widgets/dropdown_func.h"
#include "table/sprites.h"
#include "table/strings.h"
Go to the source code of this file.
Enumerations | |
enum | ReplaceVehicleWindowWidgets { RVW_WIDGET_LEFT_DETAILS = 3, RVW_WIDGET_START_REPLACE, RVW_WIDGET_INFO_TAB, RVW_WIDGET_STOP_REPLACE, RVW_WIDGET_LEFT_MATRIX, RVW_WIDGET_LEFT_SCROLLBAR, RVW_WIDGET_RIGHT_MATRIX, RVW_WIDGET_RIGHT_SCROLLBAR, RVW_WIDGET_RIGHT_DETAILS, RVW_WIDGET_TRAIN_ENGINEWAGON_TOGGLE, RVW_WIDGET_TRAIN_FLUFF_LEFT, RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN, RVW_WIDGET_TRAIN_FLUFF_RIGHT, RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE } |
Functions | |
static int CDECL | TrainEngineNumberSorter (const void *a, const void *b) |
void | InitializeVehiclesGuiList () |
void | InvalidateAutoreplaceWindow (EngineID e, GroupID id_g) |
Rebuild the left autoreplace list if an engine is removed or added. | |
void | AddRemoveEngineFromAutoreplaceAndBuildWindows (VehicleType type) |
When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists. | |
static CargoID | EngineCargo (EngineID engine) |
Get the default cargo type for an engine. | |
static bool | GenerateReplaceRailList (EngineID e, bool draw_left, bool show_engines) |
Figure out if an engine should be added to a list. | |
static bool | EnginesGotCargoInCommon (EngineID engine_a, EngineID engine_b) |
Figure out if two engines got at least one type of cargo in common (refitting if needed). | |
static void | GenerateReplaceVehList (Window *w, bool draw_left) |
Generate a list. | |
static void | GenerateLists (Window *w) |
Generate the lists. | |
void | DrawEngineList (VehicleType type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group) |
Engine drawing loop. | |
static void | ReplaceVehicleWndProc (Window *w, WindowEvent *e) |
void | ShowReplaceGroupVehicleWindow (GroupID id_g, VehicleType vehicletype) |
Variables | |
static RailType | _railtype_selected_in_replace_gui |
static bool | _rebuild_left_list |
static bool | _rebuild_right_list |
static const StringID | _rail_types_list [] |
static const Widget | _replace_rail_vehicle_widgets [] |
static const Widget | _replace_road_vehicle_widgets [] |
static const Widget | _replace_ship_aircraft_vehicle_widgets [] |
static const WindowDesc | _replace_rail_vehicle_desc |
static const WindowDesc | _replace_road_vehicle_desc |
static const WindowDesc | _replace_ship_aircraft_vehicle_desc |
Definition in file autoreplace_gui.cpp.
void AddRemoveEngineFromAutoreplaceAndBuildWindows | ( | VehicleType | type | ) |
When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists.
type | The type of engine |
Definition at line 101 of file autoreplace_gui.cpp.
void DrawEngineList | ( | VehicleType | type, | |
int | x, | |||
int | y, | |||
const EngineList | eng_list, | |||
uint16 | min, | |||
uint16 | max, | |||
EngineID | selected_id, | |||
bool | show_count, | |||
GroupID | selected_group | |||
) |
Engine drawing loop.
type | Type of vehicle (VEH_*) | |
x,y | Where should the list start | |
eng_list | What engines to draw | |
min | where to start in the list | |
max | where in the list to end | |
selected_id | what engine to highlight as selected, if any | |
show_count | Display the number of vehicles (used by autoreplace) |
Definition at line 946 of file build_vehicle_gui.cpp.
References EngList_Count(), GetEnginePalette(), and GetGroupNumEngines().
static CargoID EngineCargo | ( | EngineID | engine | ) | [static] |
Get the default cargo type for an engine.
engine | the EngineID to get the cargo for |
Definition at line 113 of file autoreplace_gui.cpp.
Referenced by EnginesGotCargoInCommon().
static bool EnginesGotCargoInCommon | ( | EngineID | engine_a, | |
EngineID | engine_b | |||
) | [static] |
Figure out if two engines got at least one type of cargo in common (refitting if needed).
engine_a | one of the EngineIDs | |
engine_b | the other EngineID |
Definition at line 157 of file autoreplace_gui.cpp.
References CanRefitTo(), and EngineCargo().
Referenced by GenerateReplaceVehList().
static void GenerateLists | ( | Window * | w | ) | [static] |
Generate the lists.
w | Window containing the lists |
Definition at line 213 of file autoreplace_gui.cpp.
References EngList_Count(), EngList_RemoveAll(), and GenerateReplaceVehList().
static bool GenerateReplaceRailList | ( | EngineID | e, | |
bool | draw_left, | |||
bool | show_engines | |||
) | [static] |
Figure out if an engine should be added to a list.
e | The EngineID | |
draw_left | If true, then the left list is drawn (the engines specific to the railtype you selected) | |
show_engines | if truem then locomotives are drawn, else wagons (never both) |
Definition at line 134 of file autoreplace_gui.cpp.
References IsCompatibleRail(), and RAILVEH_WAGON.
Referenced by GenerateReplaceVehList().
static void GenerateReplaceVehList | ( | Window * | w, | |
bool | draw_left | |||
) | [static] |
Generate a list.
w | Window, that contains the list | |
draw_left | true if generating the left list, otherwise false |
Definition at line 174 of file autoreplace_gui.cpp.
References EF_ROAD_TRAM, EngineReplacementForPlayer(), EnginesGotCargoInCommon(), EngList_Add(), EngList_RemoveAll(), EngList_Sort(), GenerateReplaceRailList(), GetGroupNumEngines(), HasBit(), and IsEngineBuildable().
Referenced by GenerateLists().
void InvalidateAutoreplaceWindow | ( | EngineID | e, | |
GroupID | id_g | |||
) |
Rebuild the left autoreplace list if an engine is removed or added.
e | Engine to check if it is removed or added | |
id_g | The group the engine belongs to Note: this function only works if it is called either
|
Definition at line 80 of file autoreplace_gui.cpp.
References GetGroupNumEngines().
Referenced by CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVeh(), CmdBuildShip(), and CmdSetAutoReplace().
const StringID _rail_types_list[] [static] |
Initial value:
{ STR_RAIL_VEHICLES, STR_ELRAIL_VEHICLES, STR_MONORAIL_VEHICLES, STR_MAGLEV_VEHICLES, INVALID_STRING_ID }
Definition at line 31 of file autoreplace_gui.cpp.
const WindowDesc _replace_rail_vehicle_desc [static] |
Initial value:
{ WDP_AUTO, WDP_AUTO, 456, 252, 456, 252, WC_REPLACE_VEHICLE, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, _replace_rail_vehicle_widgets, ReplaceVehicleWndProc }
Definition at line 506 of file autoreplace_gui.cpp.
const Widget _replace_rail_vehicle_widgets[] [static] |
Initial value:
{ { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_NONE, 14, 11, 443, 0, 13, STR_REPLACE_VEHICLES_WHITE, STR_018C_WINDOW_TITLE_DRAG_THIS}, { WWT_STICKYBOX, RESIZE_NONE, 14, 444, 455, 0, 13, STR_NULL, STR_STICKY_BUTTON}, { WWT_PANEL, RESIZE_TB, 14, 0, 227, 126, 227, 0x0, STR_NULL}, { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 138, 240, 251, STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON}, { WWT_PANEL, RESIZE_TB, 14, 139, 316, 228, 239, 0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB}, { WWT_PUSHTXTBTN, RESIZE_TB, 14, 306, 443, 240, 251, STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON}, { WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 215, 14, 125, 0x801, STR_REPLACE_HELP_LEFT_ARRAY}, { WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 216, 227, 14, 125, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_MATRIX, RESIZE_BOTTOM, 14, 228, 443, 14, 125, 0x801, STR_REPLACE_HELP_RIGHT_ARRAY}, { WWT_SCROLL2BAR, RESIZE_BOTTOM, 14, 444, 455, 14, 125, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_PANEL, RESIZE_TB, 14, 228, 455, 126, 227, 0x0, STR_NULL}, { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 138, 228, 239, STR_REPLACE_ENGINE_WAGON_SELECT, STR_REPLACE_ENGINE_WAGON_SELECT_HELP}, { WWT_PANEL, RESIZE_TB, 14, 139, 153, 240, 251, 0x0, STR_NULL}, { WWT_DROPDOWN, RESIZE_TB, 14, 154, 289, 240, 251, 0x0, STR_REPLACE_HELP_RAILTYPE}, { WWT_PANEL, RESIZE_TB, 14, 290, 305, 240, 251, 0x0, STR_NULL}, { WWT_PUSHTXTBTN, RESIZE_TB, 14, 317, 455, 228, 239, STR_REPLACE_REMOVE_WAGON, STR_REPLACE_REMOVE_WAGON_HELP}, { WWT_RESIZEBOX, RESIZE_TB, 14, 444, 455, 240, 251, STR_NULL, STR_RESIZE_BUTTON}, { WIDGETS_END}, }
Definition at line 448 of file autoreplace_gui.cpp.
const WindowDesc _replace_road_vehicle_desc [static] |
Initial value:
{ WDP_AUTO, WDP_AUTO, 456, 230, 456, 230, WC_REPLACE_VEHICLE, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, _replace_road_vehicle_widgets, ReplaceVehicleWndProc }
Definition at line 514 of file autoreplace_gui.cpp.
const Widget _replace_road_vehicle_widgets[] [static] |
Initial value:
{ { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_NONE, 14, 11, 443, 0, 13, STR_REPLACE_VEHICLES_WHITE, STR_018C_WINDOW_TITLE_DRAG_THIS}, { WWT_STICKYBOX, RESIZE_NONE, 14, 444, 455, 0, 13, STR_NULL, STR_STICKY_BUTTON}, { WWT_PANEL, RESIZE_TB, 14, 0, 227, 126, 217, 0x0, STR_NULL}, { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 138, 218, 229, STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON}, { WWT_PANEL, RESIZE_TB, 14, 139, 305, 218, 229, 0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB}, { WWT_PUSHTXTBTN, RESIZE_TB, 14, 306, 443, 218, 229, STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON}, { WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 215, 14, 125, 0x801, STR_REPLACE_HELP_LEFT_ARRAY}, { WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 216, 227, 14, 125, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_MATRIX, RESIZE_BOTTOM, 14, 228, 443, 14, 125, 0x801, STR_REPLACE_HELP_RIGHT_ARRAY}, { WWT_SCROLL2BAR, RESIZE_BOTTOM, 14, 444, 455, 14, 125, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_PANEL, RESIZE_TB, 14, 228, 455, 126, 217, 0x0, STR_NULL}, { WWT_RESIZEBOX, RESIZE_TB, 14, 444, 455, 218, 229, STR_NULL, STR_RESIZE_BUTTON}, { WIDGETS_END}, }
Definition at line 472 of file autoreplace_gui.cpp.
const WindowDesc _replace_ship_aircraft_vehicle_desc [static] |
Initial value:
{ WDP_AUTO, WDP_AUTO, 456, 214, 456, 214, WC_REPLACE_VEHICLE, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, _replace_ship_aircraft_vehicle_widgets, ReplaceVehicleWndProc }
Definition at line 522 of file autoreplace_gui.cpp.
const Widget _replace_ship_aircraft_vehicle_widgets[] [static] |
Initial value:
{ { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_NONE, 14, 11, 443, 0, 13, STR_REPLACE_VEHICLES_WHITE, STR_018C_WINDOW_TITLE_DRAG_THIS}, { WWT_STICKYBOX, RESIZE_NONE, 14, 444, 455, 0, 13, STR_NULL, STR_STICKY_BUTTON}, { WWT_PANEL, RESIZE_TB, 14, 0, 227, 110, 201, 0x0, STR_NULL}, { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 138, 202, 213, STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON}, { WWT_PANEL, RESIZE_TB, 14, 139, 305, 202, 213, 0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB}, { WWT_PUSHTXTBTN, RESIZE_TB, 14, 306, 443, 202, 213, STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON}, { WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 215, 14, 109, 0x401, STR_REPLACE_HELP_LEFT_ARRAY}, { WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 216, 227, 14, 109, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_MATRIX, RESIZE_BOTTOM, 14, 228, 443, 14, 109, 0x401, STR_REPLACE_HELP_RIGHT_ARRAY}, { WWT_SCROLL2BAR, RESIZE_BOTTOM, 14, 444, 455, 14, 109, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_PANEL, RESIZE_TB, 14, 228, 455, 110, 201, 0x0, STR_NULL}, { WWT_RESIZEBOX, RESIZE_TB, 14, 444, 455, 202, 213, STR_NULL, STR_RESIZE_BUTTON}, { WIDGETS_END}, }
Definition at line 489 of file autoreplace_gui.cpp.