# order_gui.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "road_map.h"`
`#include "station_map.h"`
`#include "gui.h"`
`#include "window_gui.h"`
`#include "station.h"`
`#include "town.h"`
`#include "command_func.h"`
`#include "viewport_func.h"`
`#include "gfx_func.h"`
`#include "depot.h"`
`#include "waypoint.h"`
`#include "train.h"`
`#include "water_map.h"`
`#include "vehicle_gui.h"`
`#include "timetable.h"`
`#include "cargotype.h"`
`#include "order.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "vehicle_func.h"`
`#include "settings_type.h"`
`#include "player_func.h"`
`#include "table/sprites.h"`
`#include "table/strings.h"`

Go to the source code of this file.

## Typedefs

typedef void | OnButtonVehClick (Window *w, const Vehicle *v)

## Enumerations

enum

OrderWindowWidgets {
ORDER_WIDGET_CLOSEBOX = 0, ORDER_WIDGET_CAPTION, ORDER_WIDGET_TIMETABLE_VIEW, ORDER_WIDGET_ORDER_LIST,
ORDER_WIDGET_SCROLLBAR, ORDER_WIDGET_SKIP, ORDER_WIDGET_DELETE, ORDER_WIDGET_NON_STOP,
ORDER_WIDGET_GOTO, ORDER_WIDGET_FULL_LOAD, ORDER_WIDGET_UNLOAD, ORDER_WIDGET_REFIT,
ORDER_WIDGET_TRANSFER, ORDER_WIDGET_SHARED_ORDER_LIST, ORDER_WIDGET_RESIZE_BAR, ORDER_WIDGET_RESIZE
}

## Functions

static int | OrderGetSel (const Window *w)
| Return the memorised selected order.
static int | GetOrderFromOrderWndPt (Window *w, int y, const Vehicle *v)
| Calculate the selected order.
static void | DrawOrdersWindow (Window *w)
static Order | GetOrderCmdFromTile (const Vehicle *v, TileIndex tile)
static bool | HandleOrderVehClick (const Vehicle *v, const Vehicle *u, Window *w)
static void | OrdersPlaceObj (const Vehicle *v, TileIndex tile, Window *w)
static void | OrderClick_Goto (Window *w, const Vehicle *v)
| Handle the click on the goto button.
static void | OrderClick_FullLoad (Window *w, const Vehicle *v)
| Handle the click on the full load button.
static void | OrderClick_Unload (Window *w, const Vehicle *v)
| Handle the click on the unload button.
static void | OrderClick_Nonstop (Window *w, const Vehicle *v)
| Handle the click on the nonstop button.
static void | OrderClick_Transfer (Window *w, const Vehicle *v)
| Handle the click on the transfer button.
static void | OrderClick_Skip (Window *w, const Vehicle *v)
| Handle the click on the skip button.
static void | OrderClick_Delete (Window *w, const Vehicle *v)
| Handle the click on the unload button.
static void | OrderClick_Refit (Window *w, const Vehicle *v)
| Handle the click on the refit button.
static void | OrdersWndProc (Window *w, WindowEvent *e)
void | ShowOrdersWindow (const Vehicle *v)

## Variables

static StringID | StationOrderStrings []
static OnButtonVehClick *const | _order_button_proc []
| Keycode function mapping.
static const uint16 | _order_keycodes []
static const Widget | _orders_train_widgets []
| Widget definition for player train orders.
static const WindowDesc | _orders_train_desc
static const Widget | _orders_widgets []
| Widget definition for player orders (!train).
static const WindowDesc | _orders_desc
static const Widget | _other_orders_widgets []
| Widget definition for competitor orders.
static const WindowDesc | _other_orders_desc

## Detailed Description

Definition in file order_gui.cpp.

## Function Documentation

static int GetOrderFromOrderWndPt | ( | Window * | w,
|  | int | y,
|  | const Vehicle * | v |
| ) |  |  | `[static]`

Calculate the selected order.

The calculation is based on the relative (to the window) y click position and the position of the scrollbar.

Parameters:

  | w | current window
  | y | Y-value of the click relative to the window origin
  | v | current vehicle

Returns:
  the new selected order if the order is valid else return that an invalid one has been selected.

Definition at line 78 of file order_gui.cpp.

static void OrderClick_Delete | ( | Window * | w,
|  | const Vehicle * | v |
| ) |  |  | `[static]`

Handle the click on the unload button.

Parameters:

  | w | current window
  | v | current vehicle

Definition at line 481 of file order_gui.cpp.

References CMD_DELETE_ORDER, CMD_MSG, DoCommandP(), and OrderGetSel().

static void OrderClick_FullLoad | ( | Window * | w,
|  | const Vehicle * | v |
| ) |  |  | `[static]`

Handle the click on the full load button.

Parameters:

  | w | current window
  | v | current vehicle

Definition at line 420 of file order_gui.cpp.

References CMD_MODIFY_ORDER, CMD_MSG, DoCommandP(), and OrderGetSel().

static void OrderClick_Goto | ( | Window * | w,
|  | const Vehicle * | v |
| ) |  |  | `[static]`

Handle the click on the goto button.

Parameters:

  | w | current window
  | v | current vehicle

Definition at line 402 of file order_gui.cpp.

References ANIMCURSOR_PICKSTATION, and VHM_RECT.

static void OrderClick_Nonstop | ( | Window * | w,
|  | const Vehicle * | v |
| ) |  |  | `[static]`

Handle the click on the nonstop button.

Parameters:

  | w | current window
  | v | current vehicle

Definition at line 442 of file order_gui.cpp.

References CMD_MODIFY_ORDER, CMD_MSG, DoCommandP(), and OrderGetSel().

static void OrderClick_Refit | ( | Window * | w,
|  | const Vehicle * | v |
| ) |  |  | `[static]`

Handle the click on the refit button.

If ctrl is pressed cancel refitting. Else show the refit window.

Parameters:

  | w | current window
  | v | current vehicle

Definition at line 494 of file order_gui.cpp.

References _ctrl_pressed, CMD_ORDER_REFIT, DoCommandP(), and ShowVehicleRefitWindow().

static void OrderClick_Skip | ( | Window * | w,
|  | const Vehicle * | v |
| ) |  |  | `[static]`

Handle the click on the skip button.

If ctrl is pressed skip to selected order. Else skip to current order + 1

Parameters:

  | w | current window
  | v | current vehicle

Definition at line 466 of file order_gui.cpp.

References _ctrl_pressed, CMD_MSG, CMD_SKIP_TO_ORDER, DoCommandP(), and OrderGetSel().

static void OrderClick_Transfer | ( | Window * | w,
|  | const Vehicle * | v |
| ) |  |  | `[static]`

Handle the click on the transfer button.

Parameters:

  | w | current window
  | v | current vehicle

Definition at line 453 of file order_gui.cpp.

References CMD_MODIFY_ORDER, CMD_MSG, DoCommandP(), and OrderGetSel().

static void OrderClick_Unload | ( | Window * | w,
|  | const Vehicle * | v |
| ) |  |  | `[static]`

Handle the click on the unload button.

Parameters:

  | w | current window
  | v | current vehicle

Definition at line 431 of file order_gui.cpp.

References CMD_MODIFY_ORDER, CMD_MSG, DoCommandP(), and OrderGetSel().

static int OrderGetSel | ( | const Window * | w | ) | `[static]`

Return the memorised selected order.

Parameters:

  | w | current window

Returns:
  the memorised order if it is a vaild one else return the number of orders

Definition at line 59 of file order_gui.cpp.

Referenced by OrderClick_Delete(), OrderClick_FullLoad(), OrderClick_Nonstop(), OrderClick_Skip(), OrderClick_Transfer(), and OrderClick_Unload().

## Variable Documentation

OnButtonVehClick* const _order_button_proc[]`[static]`

Initial value:

     {
      OrderClick_Skip,
      OrderClick_Delete,
      OrderClick_Nonstop,
      OrderClick_Goto,
      OrderClick_FullLoad,
      OrderClick_Unload,
      OrderClick_Transfer
    }

Keycode function mapping.

See also:
  _order_keycodes[]

Note:
  Keep them allways in sync with _order_keycodes[]!

Definition at line 512 of file order_gui.cpp.

const uint16 _order_keycodes[]`[static]`

Initial value:

     {
      'D',
      'F',
      'G',
      'H',
      'J',
      'K'
    }

Definition at line 522 of file order_gui.cpp.

const WindowDesc _orders_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 410, 88, 410, 88,
      WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
      _orders_widgets,
      OrdersWndProc
    }

Definition at line 812 of file order_gui.cpp.

const WindowDesc _orders_train_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 399, 88, 399, 88,
      WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
      _orders_train_widgets,
      OrdersWndProc
    }

Definition at line 775 of file order_gui.cpp.

const Widget _orders_train_widgets[]`[static]`

Initial value:

     {
      {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
      {    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   398,     0,    13, STR_8829_ORDERS,         STR_018C_WINDOW_TITLE_DRAG_THIS},
      { WWT_PUSHTXTBTN,   RESIZE_LR,      14,   338,   398,     0,    13, STR_TIMETABLE_VIEW,      STR_TIMETABLE_VIEW_TOOLTIP},

      {      WWT_PANEL,   RESIZE_RB,      14,     0,   386,    14,    75, 0x0,                     STR_8852_ORDERS_LIST_CLICK_ON_ORDER},

      {  WWT_SCROLLBAR,   RESIZE_LRB,     14,   387,   398,    14,    75, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},

      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,    52,    76,    87, STR_8823_SKIP,           STR_8853_SKIP_THE_CURRENT_ORDER},
      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,    53,   105,    76,    87, STR_8824_DELETE,         STR_8854_DELETE_THE_HIGHLIGHTED},
      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,   106,   158,    76,    87, STR_8825_NON_STOP,       STR_8855_MAKE_THE_HIGHLIGHTED_ORDER},
      {    WWT_TEXTBTN,   RESIZE_TB,      14,   159,   211,    76,    87, STR_8826_GO_TO,          STR_8856_INSERT_A_NEW_ORDER_BEFORE},
      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,   212,   264,    76,    87, STR_FULLLOAD_OR_SERVICE, STR_NULL},
      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,   265,   319,    76,    87, STR_8828_UNLOAD,         STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,   265,   319,    76,    87, STR_REFIT,               STR_REFIT_TIP},
      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,   320,   372,    76,    87, STR_TRANSFER,            STR_MAKE_THE_HIGHLIGHTED_ORDER},

      { WWT_PUSHIMGBTN,   RESIZE_TB,      14,   373,   386,    76,    87, SPR_SHARED_ORDERS_ICON,  STR_VEH_WITH_SHARED_ORDERS_LIST_TIP},

      {      WWT_PANEL,   RESIZE_RTB,     14,   387,   386,    76,    87, 0x0,                     STR_NULL},

      {  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   387,   398,    76,    87, 0x0,                     STR_RESIZE_BUTTON},
      {   WIDGETS_END},
    }

Widget definition for player train orders.

Definition at line 749 of file order_gui.cpp.

const Widget _orders_widgets[]`[static]`

Initial value:

     {
      {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
      {    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   409,     0,    13, STR_8829_ORDERS,         STR_018C_WINDOW_TITLE_DRAG_THIS},
      { WWT_PUSHTXTBTN,   RESIZE_LR,      14,   349,   409,     0,    13, STR_TIMETABLE_VIEW,      STR_TIMETABLE_VIEW_TOOLTIP},

      {      WWT_PANEL,   RESIZE_RB,      14,     0,   397,    14,    75, 0x0,                     STR_8852_ORDERS_LIST_CLICK_ON_ORDER},

      {  WWT_SCROLLBAR,   RESIZE_LRB,     14,   398,   409,    14,    75, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},

      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,    63,    76,    87, STR_8823_SKIP,           STR_8853_SKIP_THE_CURRENT_ORDER},
      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,    64,   128,    76,    87, STR_8824_DELETE,         STR_8854_DELETE_THE_HIGHLIGHTED},
      {      WWT_EMPTY,   RESIZE_TB,      14,     0,     0,    76,    87, 0x0,                     0x0},
      {    WWT_TEXTBTN,   RESIZE_TB,      14,   129,   192,    76,    87, STR_8826_GO_TO,          STR_8856_INSERT_A_NEW_ORDER_BEFORE},
      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,   193,   256,    76,    87, STR_FULLLOAD_OR_SERVICE, STR_NULL},
      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,   257,   319,    76,    87, STR_8828_UNLOAD,         STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,   257,   319,    76,    87, STR_REFIT,               STR_REFIT_TIP},
      { WWT_PUSHTXTBTN,   RESIZE_TB,      14,   320,   383,    76,    87, STR_TRANSFER,            STR_MAKE_THE_HIGHLIGHTED_ORDER},

      { WWT_PUSHIMGBTN,   RESIZE_TB,      14,   384,   397,    76,    87, SPR_SHARED_ORDERS_ICON,  STR_VEH_WITH_SHARED_ORDERS_LIST_TIP},

      {      WWT_PANEL,   RESIZE_RTB,     14,   397,   396,    76,    87, 0x0,                     STR_NULL},

      {  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   398,   409,    76,    87, 0x0,                     STR_RESIZE_BUTTON},
      {   WIDGETS_END},
    }

Widget definition for player orders (!train).

Definition at line 786 of file order_gui.cpp.

const WindowDesc _other_orders_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 332, 88, 332, 88,
      WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
      _other_orders_widgets,
      OrdersWndProc
    }

Definition at line 849 of file order_gui.cpp.

const Widget _other_orders_widgets[]`[static]`

Initial value:

     {
      {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,           STR_018B_CLOSE_WINDOW},
      {    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   331,     0,    13, STR_A00B_ORDERS,    STR_018C_WINDOW_TITLE_DRAG_THIS},
      { WWT_PUSHTXTBTN,   RESIZE_LR,      14,   271,   331,     0,    13, STR_TIMETABLE_VIEW, STR_TIMETABLE_VIEW_TOOLTIP},

      {      WWT_PANEL,   RESIZE_RB,      14,     0,   319,    14,    75, 0x0,                STR_8852_ORDERS_LIST_CLICK_ON_ORDER},

      {  WWT_SCROLLBAR,   RESIZE_LRB,     14,   320,   331,    14,    75, 0x0,                STR_0190_SCROLL_BAR_SCROLLS_LIST},

      {      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},
      {      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},
      {      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},
      {      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},
      {      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},
      {      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},
      {      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},
      {      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},

      {      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},

      {      WWT_PANEL,   RESIZE_RTB,     14,     0,   319,    76,    87, 0x0,                STR_NULL},

      {  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   320,   331,    76,    87, 0x0,                STR_RESIZE_BUTTON},
      {   WIDGETS_END},
    }

Widget definition for competitor orders.

Definition at line 823 of file order_gui.cpp.

StringID StationOrderStrings[]`[static]`

Initial value:

     {
      STR_8806_GO_TO,
      STR_GO_TO_TRANSFER,
      STR_8807_GO_TO_UNLOAD,
      STR_GO_TO_TRANSFER_UNLOAD,
      STR_8808_GO_TO_LOAD,
      STR_GO_TO_TRANSFER_LOAD,
      STR_NULL,
      STR_NULL,
      STR_880A_GO_NON_STOP_TO,
      STR_GO_TO_NON_STOP_TRANSFER,
      STR_880B_GO_NON_STOP_TO_UNLOAD,
      STR_GO_TO_NON_STOP_TRANSFER_UNLOAD,
      STR_880C_GO_NON_STOP_TO_LOAD,
      STR_GO_TO_NON_STOP_TRANSFER_LOAD,
      STR_NULL
    }

Definition at line 94 of file order_gui.cpp.