|
|
/* $Id$ */
|
|
|
|
|
|
/** @file order_gui.cpp */
|
|
|
/** @file order_gui.cpp GUI related to orders. */
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
#include "openttd.h"
|
|
|
#include "road_map.h"
|
|
|
#include "station_map.h"
|
|
|
#include "gui.h"
|
|
|
#include "window_gui.h"
|
|
|
#include "station_base.h"
|
|
|
#include "town.h"
|
|
|
#include "command_func.h"
|
|
|
#include "viewport_func.h"
|
|
|
#include "gfx_func.h"
|
|
|
#include "depot_base.h"
|
|
|
#include "waypoint.h"
|
|
|
#include "train.h"
|
|
|
#include "water_map.h"
|
|
|
#include "vehicle_gui.h"
|
|
|
#include "timetable.h"
|
|
|
#include "cargotype.h"
|
|
|
#include "strings_func.h"
|
|
|
#include "window_func.h"
|
|
|
#include "vehicle_func.h"
|
|
|
#include "settings_type.h"
|
|
|
#include "player_func.h"
|
|
|
#include "newgrf_cargo.h"
|
|
|
#include "widgets/dropdown_func.h"
|
|
|
#include "textbuf_gui.h"
|
|
|
#include "string_func.h"
|
|
|
#include "depot_base.h"
|
|
|
|
|
|
#include "table/sprites.h"
|
|
|
#include "table/strings.h"
|
|
|
|
|
|
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_GOTO_DROPDOWN,
|
|
|
ORDER_WIDGET_FULL_LOAD,
|
|
|
ORDER_WIDGET_UNLOAD,
|
|
|
ORDER_WIDGET_REFIT,
|
|
|
ORDER_WIDGET_SERVICE,
|
|
|
ORDER_WIDGET_COND_VARIABLE,
|
|
|
ORDER_WIDGET_COND_COMPARATOR,
|
|
|
ORDER_WIDGET_COND_VALUE,
|
|
|
ORDER_WIDGET_RESIZE_BAR,
|
|
|
ORDER_WIDGET_SHARED_ORDER_LIST,
|
|
|
ORDER_WIDGET_RESIZE,
|
|
|
};
|
|
|
|
|
|
/** Under what reason are we using the PlaceObject functionality? */
|
|
|
enum OrderPlaceObjectState {
|
|
|
OPOS_GOTO,
|
|
|
OPOS_CONDITIONAL,
|
|
|
};
|
|
|
|
|
|
struct order_d {
|
|
|
int sel;
|
|
|
OrderPlaceObjectState goto_type;
|
|
|
};
|
|
|
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d));
|
|
|
|
|
|
/**
|
|
|
* Return the memorised selected order.
|
|
|
*
|
|
|
* @param w current window
|
|
|
* @return the memorised order if it is a vaild one
|
|
|
* else return the number of orders
|
|
|
*/
|
|
|
static int OrderGetSel(const Window *w)
|
|
|
{
|
|
|
const Vehicle *v = GetVehicle(w->window_number);
|
|
|
int num = WP(w, order_d).sel;
|
|
|
|
|
|
return (num >= 0 && num < v->num_orders) ? num : v->num_orders;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Calculate the selected order.
|
|
|
* The calculation is based on the relative (to the window) y click position and
|
|
|
* the position of the scrollbar.
|
|
|
*
|
|
|
* @param w current window
|
|
|
* @param y Y-value of the click relative to the window origin
|
|
|
* @param v current vehicle
|
|
|
* @return the new selected order if the order is valid else return that
|
|
|
* an invalid one has been selected.
|
|
|
*/
|
|
|
static int GetOrderFromOrderWndPt(Window *w, int y, const Vehicle *v)
|
|
|
{
|