src/order_gui.cpp
author rubidium
Tue, 25 Dec 2007 11:26:07 +0000
changeset 8627 448ebf3a8291
parent 8617 931e0970d509
child 8635 3bbb6f87fced
permissions -rw-r--r--
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6677
0578c2e31ed1 (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents: 6655
diff changeset
     3
/** @file order_gui.cpp */
0578c2e31ed1 (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents: 6655
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1857
diff changeset
     6
#include "openttd.h"
3144
426b825578f9 (svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents: 3071
diff changeset
     7
#include "road_map.h"
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents: 3269
diff changeset
     8
#include "station_map.h"
1363
01d3de5d8039 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1334
diff changeset
     9
#include "table/sprites.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 395
diff changeset
    10
#include "table/strings.h"
679
e959706a3e4d (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 560
diff changeset
    11
#include "map.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "gui.h"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
    13
#include "window_gui.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "vehicle.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "station.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "town.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
    17
#include "command_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
#include "viewport.h"
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1256
diff changeset
    19
#include "depot.h"
1542
2ca6d1624e6d (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1530
diff changeset
    20
#include "waypoint.h"
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2668
diff changeset
    21
#include "train.h"
3392
7c330e18dfe1 (svn r4200) -Codechange: Make use of water map accessors when getting the Index of a Ship Depot. TODO: Store the depot index in the map
celestar
parents: 3387
diff changeset
    22
#include "water_map.h"
4668
8b6035c51188 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
    23
#include "vehicle_gui.h"
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
    24
#include "timetable.h"
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 6310
diff changeset
    25
#include "cargotype.h"
8560
8472721356cf (svn r11625) -Codechange: add CO_* enum at some places, add includes of order.h too
smatz
parents: 8553
diff changeset
    26
#include "order.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8604
diff changeset
    27
#include "strings_func.h"
8627
448ebf3a8291 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8617
diff changeset
    28
#include "window_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    30
enum OrderWindowWidgets {
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    31
	ORDER_WIDGET_CLOSEBOX = 0,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    32
	ORDER_WIDGET_CAPTION,
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
    33
	ORDER_WIDGET_TIMETABLE_VIEW,
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    34
	ORDER_WIDGET_ORDER_LIST,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    35
	ORDER_WIDGET_SCROLLBAR,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    36
	ORDER_WIDGET_SKIP,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    37
	ORDER_WIDGET_DELETE,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    38
	ORDER_WIDGET_NON_STOP,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    39
	ORDER_WIDGET_GOTO,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    40
	ORDER_WIDGET_FULL_LOAD,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    41
	ORDER_WIDGET_UNLOAD,
6080
a56f432ef1b1 (svn r8395) -Cleanup: [orders window] moved the refit button two places up, so the order of the widget array fits the placement on the screen
bjarni
parents: 6079
diff changeset
    42
	ORDER_WIDGET_REFIT,
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    43
	ORDER_WIDGET_TRANSFER,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    44
	ORDER_WIDGET_SHARED_ORDER_LIST,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    45
	ORDER_WIDGET_RESIZE_BAR,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    46
	ORDER_WIDGET_RESIZE,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    47
};
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    48
7328
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    49
/**
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    50
 * Return the memorised selected order.
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    51
 *
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    52
 * @param w current window
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    53
 * @return the memorised order if it is a vaild one
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    54
 *  else return the number of orders
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    55
 */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
    56
static int OrderGetSel(const Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
    58
	const Vehicle *v = GetVehicle(w->window_number);
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
    59
	int num = WP(w, order_d).sel;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
    61
	return (num >= 0 && num < v->num_orders) ? num : v->num_orders;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
7328
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    64
/**
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    65
 * Calculate the selected order.
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    66
 * The calculation is based on the relative (to the window) y click position and
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    67
 *  the position of the scrollbar.
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    68
 *
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    69
 * @param w current window
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    70
 * @param y Y-value of the click relative to the window origin
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    71
 * @param v current vehicle
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    72
 * @return the new selected order if the order is valid else return that
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    73
 *  an invalid one has been selected.
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    74
 */
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    75
static int GetOrderFromOrderWndPt(Window *w, int y, const Vehicle *v)
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    76
{
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    77
	/*
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    78
	 * Calculation description:
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    79
	 * 15 = 14 (w->widget[ORDER_WIDGET_ORDER_LIST].top) + 1 (frame-line)
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    80
	 * 10 = order text hight
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    81
	 */
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    82
	int sel = (y - 15) / 10;
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    83
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    84
	if ((uint)sel >= w->vscroll.cap) return INVALID_ORDER;
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    85
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    86
	sel += w->vscroll.pos;
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    87
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    88
	return (sel <= v->num_orders && sel >= 0) ? sel : INVALID_ORDER;
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    89
}
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
    90
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    91
static StringID StationOrderStrings[] = {
1937
0c1f7f4083c7 (svn r2443) -Fix: somehow I delete one line too many :(
celestar
parents: 1935
diff changeset
    92
	STR_8806_GO_TO,
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    93
	STR_8807_GO_TO_TRANSFER,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    94
	STR_8808_GO_TO_UNLOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    95
	STR_8809_GO_TO_TRANSFER_UNLOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    96
	STR_880A_GO_TO_LOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    97
	STR_880B_GO_TO_TRANSFER_LOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    98
	STR_NULL,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    99
	STR_NULL,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   100
	STR_880C_GO_NON_STOP_TO,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   101
	STR_880D_GO_TO_NON_STOP_TRANSFER,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   102
	STR_880E_GO_NON_STOP_TO_UNLOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   103
	STR_880F_GO_TO_NON_STOP_TRANSFER_UNLOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   104
	STR_8810_GO_NON_STOP_TO_LOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   105
	STR_8811_GO_TO_NON_STOP_TRANSFER_LOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   106
	STR_NULL
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   107
};
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   108
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
static void DrawOrdersWindow(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   111
	const Vehicle *v;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   112
	const Order *order;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   113
	StringID str;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   114
	int sel;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
	int y, i;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   116
	bool shared_orders;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   118
	v = GetVehicle(w->window_number);
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   119
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   120
	shared_orders = IsOrderListShared(v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   122
	SetVScrollCount(w, v->num_orders + 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
	sel = OrderGetSel(w);
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   125
	SetDParam(2, STR_8827_FULL_LOAD);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   126
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   127
	order = GetVehicleOrder(v, sel);
725
d6543c8b2428 (svn r1177) Enable non-stop flag for waypoints
tron
parents: 679
diff changeset
   128
4949
fa564e9c2aea (svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents: 4935
diff changeset
   129
	if (v->owner == _local_player) {
fa564e9c2aea (svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents: 4935
diff changeset
   130
		/* skip */
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   131
		w->SetWidgetDisabledState(ORDER_WIDGET_SKIP, v->num_orders <= 1);
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
   132
4949
fa564e9c2aea (svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents: 4935
diff changeset
   133
		/* delete */
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   134
		w->SetWidgetDisabledState(ORDER_WIDGET_DELETE,
6310
076a4a571714 (svn r8685) -Feature: selecting "end of orders" and clicking delete will delete all the vehicle's orders
bjarni
parents: 6215
diff changeset
   135
				(uint)v->num_orders + ((shared_orders || v->num_orders != 0) ? 1 : 0) <= (uint)WP(w, order_d).sel);
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   136
4949
fa564e9c2aea (svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents: 4935
diff changeset
   137
		/* non-stop only for trains */
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   138
		w->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP,  v->type != VEH_TRAIN || order == NULL);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   139
		w->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD, order == NULL); // full load
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   140
		w->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD,    order == NULL); // unload
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   141
		w->SetWidgetDisabledState(ORDER_WIDGET_TRANSFER,  order == NULL); // transfer
4949
fa564e9c2aea (svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents: 4935
diff changeset
   142
		/* Disable list of vehicles with the same shared orders if there is no list */
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   143
		w->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || v->orders == NULL);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   144
		w->SetWidgetDisabledState(ORDER_WIDGET_REFIT,     order == NULL); // Refit
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   145
		w->HideWidget(ORDER_WIDGET_REFIT); // Refit
4949
fa564e9c2aea (svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents: 4935
diff changeset
   146
	} else {
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   147
		w->DisableWidget(ORDER_WIDGET_TRANSFER);
4949
fa564e9c2aea (svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents: 4935
diff changeset
   148
	}
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   149
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   150
	w->ShowWidget(ORDER_WIDGET_UNLOAD); // Unload
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
   151
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   152
	if (order != NULL) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   153
		switch (order->type) {
8553
66a54e0c1c4a (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx
parents: 8524
diff changeset
   154
			case OT_GOTO_STATION:
66a54e0c1c4a (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx
parents: 8524
diff changeset
   155
				if (!GetStation(order->dest)->IsBuoy()) break;
66a54e0c1c4a (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx
parents: 8524
diff changeset
   156
				/* Fall-through */
66a54e0c1c4a (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx
parents: 8524
diff changeset
   157
66a54e0c1c4a (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx
parents: 8524
diff changeset
   158
			case OT_GOTO_WAYPOINT:
66a54e0c1c4a (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx
parents: 8524
diff changeset
   159
				w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
66a54e0c1c4a (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx
parents: 8524
diff changeset
   160
				w->DisableWidget(ORDER_WIDGET_UNLOAD);
66a54e0c1c4a (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx
parents: 8524
diff changeset
   161
				w->DisableWidget(ORDER_WIDGET_TRANSFER);
66a54e0c1c4a (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx
parents: 8524
diff changeset
   162
				break;
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   163
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   164
			case OT_GOTO_DEPOT:
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   165
				w->DisableWidget(ORDER_WIDGET_TRANSFER);
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   166
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   167
				/* Remove unload and replace it with refit */
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   168
				w->HideWidget(ORDER_WIDGET_UNLOAD);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   169
				w->ShowWidget(ORDER_WIDGET_REFIT);
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   170
				SetDParam(2,STR_SERVICE);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   171
				break;
725
d6543c8b2428 (svn r1177) Enable non-stop flag for waypoints
tron
parents: 679
diff changeset
   172
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4668
diff changeset
   173
			default: // every other orders
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   174
				w->DisableWidget(ORDER_WIDGET_NON_STOP);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   175
				w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   176
				w->DisableWidget(ORDER_WIDGET_UNLOAD);
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   177
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
7545
9a4834d48970 (svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents: 7476
diff changeset
   180
	SetDParam(0, v->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
	DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	y = 15;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   185
	i = w->vscroll.pos;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   186
	order = GetVehicleOrder(v, i);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   187
	while (order != NULL) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   188
		str = (v->cur_order_index == i) ? STR_8805 : STR_8804;
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   189
		SetDParam(3, STR_EMPTY);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   191
		if (i - w->vscroll.pos < w->vscroll.cap) {
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   192
			SetDParam(1, 6);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   193
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   194
			switch (order->type) {
7808
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   195
				case OT_DUMMY:
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   196
					SetDParam(1, STR_INVALID_ORDER);
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   197
					SetDParam(2, order->dest);
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   198
					break;
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   199
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   200
				case OT_GOTO_STATION:
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   201
					SetDParam(1, StationOrderStrings[order->flags]);
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   202
					SetDParam(2, order->dest);
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   203
					break;
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   204
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   205
				case OT_GOTO_DEPOT: {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   206
					StringID s = STR_NULL;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   207
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   208
					if (v->type == VEH_AIRCRAFT) {
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   209
						s = STR_GO_TO_AIRPORT_HANGAR;
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   210
						SetDParam(2, order->dest);
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   211
					} else {
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   212
						SetDParam(2, GetDepot(order->dest)->town_index);
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   213
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   214
						switch (v->type) {
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   215
							case VEH_TRAIN: s = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   216
							case VEH_ROAD:  s = STR_9038_GO_TO_ROADVEH_DEPOT; break;
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   217
							case VEH_SHIP:  s = STR_GO_TO_SHIP_DEPOT; break;
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   218
							default: break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   219
						}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
					}
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   221
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   222
					if (order->flags & OF_FULL_LOAD) s++; /* service at */
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   223
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   224
					SetDParam(1, s);
4782
3ee91034a50e (svn r6696) -Codechange: changed all comparision for refit cargo in orders against CT_NO_REFIT to checks for valid cargo IDs
bjarni
parents: 4719
diff changeset
   225
					if (order->refit_cargo < NUM_CARGO) {
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   226
						SetDParam(3, STR_REFIT_ORDER);
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 6310
diff changeset
   227
						SetDParam(4, GetCargo(order->refit_cargo)->name);
4782
3ee91034a50e (svn r6696) -Codechange: changed all comparision for refit cargo in orders against CT_NO_REFIT to checks for valid cargo IDs
bjarni
parents: 4719
diff changeset
   228
					} else {
3ee91034a50e (svn r6696) -Codechange: changed all comparision for refit cargo in orders against CT_NO_REFIT to checks for valid cargo IDs
bjarni
parents: 4719
diff changeset
   229
						SetDParam(3, STR_EMPTY);
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   230
					}
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   231
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
				}
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   233
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   234
				case OT_GOTO_WAYPOINT:
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   235
					SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   236
					SetDParam(2, order->dest);
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   237
					break;
4351
63ae31104f07 (svn r6052) -Codechange: change OrderType (order->type) in a typedef
truelight
parents: 4344
diff changeset
   238
63ae31104f07 (svn r6052) -Codechange: change OrderType (order->type) in a typedef
truelight
parents: 4344
diff changeset
   239
				default: break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
			}
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   241
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   242
			SetDParam(0, i + 1);
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
   243
			DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK);
7808
70bb84732406 (svn r10664) -Codechange: simplify a small piece of code (skidd13)
truelight
parents: 7762
diff changeset
   244
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
		i++;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   249
		order = order->next;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   250
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   252
	if (i - w->vscroll.pos < w->vscroll.cap) {
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   253
		str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS;
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
   254
		DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2186
diff changeset
   258
static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
{
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   260
	Order order;
3387
5d14492dce35 (svn r4195) - Codechange: Initialize order variables to avoid a compiler warning. These are unused anyway... (smells of r3476-7, but not the same)
peter1138
parents: 3338
diff changeset
   261
	order.next  = NULL;
5d14492dce35 (svn r4195) - Codechange: Initialize order variables to avoid a compiler warning. These are unused anyway... (smells of r3476-7, but not the same)
peter1138
parents: 3338
diff changeset
   262
	order.index = 0;
4715
7ab95d47d2eb (svn r6627) -Fix r6624: fixed some warnings
bjarni
parents: 4712
diff changeset
   263
	order.refit_cargo   = CT_INVALID;
7ab95d47d2eb (svn r6627) -Fix r6624: fixed some warnings
bjarni
parents: 4712
diff changeset
   264
	order.refit_subtype = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
	// check depot first
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
	if (_patches.gotodepot) {
1214
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   268
		switch (GetTileType(tile)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
		case MP_RAILWAY:
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   270
			if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_player)) {
4182
20d711816338 (svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents: 4171
diff changeset
   271
				if (IsRailDepot(tile)) {
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   272
					order.type = OT_GOTO_DEPOT;
1530
caa16c506a22 (svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents: 1363
diff changeset
   273
					order.flags = OF_PART_OF_ORDERS;
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   274
					order.dest = GetDepotByTile(tile)->index;
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   275
					return order;
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   276
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
7866
e19fda04e8d3 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents: 7837
diff changeset
   280
		case MP_ROAD:
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   281
			if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) {
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   282
				order.type = OT_GOTO_DEPOT;
1530
caa16c506a22 (svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents: 1363
diff changeset
   283
				order.flags = OF_PART_OF_ORDERS;
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   284
				order.dest = GetDepotByTile(tile)->index;
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   285
				return order;
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   286
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
		case MP_STATION:
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   290
			if (v->type != VEH_AIRCRAFT) break;
3338
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3315
diff changeset
   291
			if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   292
				order.type = OT_GOTO_DEPOT;
2778
0002d4b696a0 (svn r3325) - Fix: You couldn't send an airplane to a hangar for mandatory servicing, the NON_STOP flag failed the command.
Darkvater
parents: 2725
diff changeset
   293
				order.flags = OF_PART_OF_ORDERS;
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   294
				order.dest = GetStationIndex(tile);
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   295
				return order;
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   296
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
		case MP_WATER:
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   300
			if (v->type != VEH_SHIP) break;
1334
e33a521c3e12 (svn r1838) Ship depots are on water, not roads
tron
parents: 1330
diff changeset
   301
			if (IsTileDepotType(tile, TRANSPORT_WATER) &&
e33a521c3e12 (svn r1838) Ship depots are on water, not roads
tron
parents: 1330
diff changeset
   302
					IsTileOwner(tile, _local_player)) {
3392
7c330e18dfe1 (svn r4200) -Codechange: Make use of water map accessors when getting the Index of a Ship Depot. TODO: Store the depot index in the map
celestar
parents: 3387
diff changeset
   303
				TileIndex tile2 = GetOtherShipDepotTile(tile);
7c330e18dfe1 (svn r4200) -Codechange: Make use of water map accessors when getting the Index of a Ship Depot. TODO: Store the depot index in the map
celestar
parents: 3387
diff changeset
   304
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   305
				order.type = OT_GOTO_DEPOT;
1530
caa16c506a22 (svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents: 1363
diff changeset
   306
				order.flags = OF_PART_OF_ORDERS;
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   307
				order.dest = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   308
				return order;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
			}
1214
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   310
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   311
			default:
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   312
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
395
4c990f33dab7 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 319
diff changeset
   316
	// check waypoint
1901
fb05044cf5c3 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   317
	if (IsTileType(tile, MP_RAILWAY) &&
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   318
			v->type == VEH_TRAIN &&
1901
fb05044cf5c3 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   319
			IsTileOwner(tile, _local_player) &&
2668
54d9f9d4dca3 (svn r3210) -Codechange: use IsRailWaypoint where possible (instead of magicnumbers)
truelight
parents: 2643
diff changeset
   320
			IsRailWaypoint(tile)) {
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   321
		order.type = OT_GOTO_WAYPOINT;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   322
		order.flags = 0;
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   323
		order.dest = GetWaypointByTile(tile)->index;
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   324
		return order;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   325
	}
319
1891d07574d6 (svn r329) Fix: [ 1035066 ] 'Allow goto depot' turned off, no checkpoints in orders
dominik
parents: 193
diff changeset
   326
1035
0a170deb6e33 (svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents: 1024
diff changeset
   327
	if (IsTileType(tile, MP_STATION)) {
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents: 3269
diff changeset
   328
		StationID st_index = GetStationIndex(tile);
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   329
		const Station *st = GetStation(st_index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
		if (st->owner == _current_player || st->owner == OWNER_NONE) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
			byte facil;
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   333
			(facil=FACIL_DOCK, v->type == VEH_SHIP) ||
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   334
			(facil=FACIL_TRAIN, v->type == VEH_TRAIN) ||
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   335
			(facil=FACIL_AIRPORT, v->type == VEH_AIRCRAFT) ||
6655
951b0ba32eb1 (svn r9301) -Codechange: Use cargo class to determine if a road vehicle can stop in bus or truck stops.
peter1138
parents: 6589
diff changeset
   336
			(facil=FACIL_BUS_STOP, v->type == VEH_ROAD && IsCargoInClass(v->cargo_type, CC_PASSENGERS)) ||
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
			(facil=FACIL_TRUCK_STOP, 1);
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   338
			if (st->facilities & facil) {
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   339
				order.type = OT_GOTO_STATION;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   340
				order.flags = 0;
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   341
				order.dest = st_index;
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   342
				return order;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   343
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
	// not found
6589
addf4b6946d0 (svn r9072) -Codechange: [Orders] added methods to orders to free them and check if they are in use
bjarni
parents: 6585
diff changeset
   348
	order.Free();
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   349
	order.dest = INVALID_STATION;
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   350
	return order;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   353
static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
{
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   355
	if (u->type != v->type) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
8044
72c3e2bc6429 (svn r11068) -Codechange: remove Vehicle::HasFront as all vehicles have the Vehicle::first pointer correctly set.
rubidium
parents: 7993
diff changeset
   357
	if (!u->IsPrimaryVehicle()) {
7993
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7866
diff changeset
   358
		u = u->First();
7269
c7f39d91255e (svn r10009) -Codechange: Add and use Vehicle::IsPrimaryVehicle to replace individual checks depending on the vehicle type.
maedhros
parents: 6988
diff changeset
   359
		if (!u->IsPrimaryVehicle()) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
	// v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
	// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   364
	if (v->num_orders != 0 && _ctrl_pressed == 0) return false;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   365
8560
8472721356cf (svn r11625) -Codechange: add CO_* enum at some places, add includes of order.h too
smatz
parents: 8553
diff changeset
   366
	if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY, NULL,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
		_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) {
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
   368
		WP(w, order_d).sel = -1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   375
static void OrdersPlaceObj(const Vehicle *v, TileIndex tile, Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
{
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   377
	Order cmd;
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   378
	const Vehicle *u;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   379
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
	// check if we're clicking on a vehicle first.. clone orders in that case.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
	u = CheckMouseOverVehicle();
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   382
	if (u != NULL && HandleOrderVehClick(v, u, w)) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
	cmd = GetOrderCmdFromTile(v, tile);
6589
addf4b6946d0 (svn r9072) -Codechange: [Orders] added methods to orders to free them and check if they are in use
bjarni
parents: 6585
diff changeset
   385
	if (!cmd.IsValid()) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   387
	if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), PackOrder(&cmd), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
   388
		if (WP(w, order_d).sel != -1) WP(w,order_d).sel++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   393
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   394
 * Handle the click on the goto button.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   395
 *
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   396
 * @param w current window
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   397
 * @param v current vehicle
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   398
 */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   399
static void OrderClick_Goto(Window *w, const Vehicle *v)
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   400
{
8524
baf4ab1ba18d (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 8493
diff changeset
   401
	w->InvalidateWidget(ORDER_WIDGET_GOTO);
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   402
	w->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO);
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   403
	if (w->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   404
		_place_clicked_vehicle = NULL;
8385
aedd7656cfd1 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 8320
diff changeset
   405
		SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, VHM_RECT, w);
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   406
	} else {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   407
		ResetObjectToPlace();
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   408
	}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   409
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   410
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   411
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   412
 * Handle the click on the full load button.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   413
 *
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   414
 * @param w current window
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   415
 * @param v current vehicle
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   416
 */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   417
static void OrderClick_FullLoad(Window *w, const Vehicle *v)
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   418
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   419
	DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_FULL_LOAD, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   420
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   421
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   422
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   423
 * Handle the click on the unload button.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   424
 *
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   425
 * @param w current window
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   426
 * @param v current vehicle
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   427
 */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   428
static void OrderClick_Unload(Window *w, const Vehicle *v)
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   429
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   430
	DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_UNLOAD,    NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   431
}
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   432
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   433
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   434
 * Handle the click on the nonstop button.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   435
 *
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   436
 * @param w current window
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   437
 * @param v current vehicle
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   438
 */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   439
static void OrderClick_Nonstop(Window *w, const Vehicle *v)
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   440
{
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   441
	DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_NON_STOP,  NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   442
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   443
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   444
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   445
 * Handle the click on the transfer button.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   446
 *
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   447
 * @param w current window
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   448
 * @param v current vehicle
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   449
 */
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   450
static void OrderClick_Transfer(Window* w, const Vehicle* v)
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   451
{
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   452
	DoCommandP(v->tile, v->index + (OrderGetSel(w) <<  16), OFB_TRANSFER, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   453
}
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   454
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   455
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   456
 * Handle the click on the skip button.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   457
 * If ctrl is pressed skip to selected order.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   458
 *  Else skip to current order + 1
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   459
 *
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   460
 * @param w current window
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   461
 * @param v current vehicle
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   462
 */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   463
static void OrderClick_Skip(Window *w, const Vehicle *v)
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   464
{
7290
647d6416cdfe (svn r10033) -Feature [FS#760]: skip to the selected order in the order list when clicking on the "skip" button while pressing CTRL.
rubidium
parents: 7269
diff changeset
   465
	/* Don't skip when there's nothing to skip */
647d6416cdfe (svn r10033) -Feature [FS#760]: skip to the selected order in the order list when clicking on the "skip" button while pressing CTRL.
rubidium
parents: 7269
diff changeset
   466
	if (_ctrl_pressed && v->cur_order_index == OrderGetSel(w)) return;
647d6416cdfe (svn r10033) -Feature [FS#760]: skip to the selected order in the order list when clicking on the "skip" button while pressing CTRL.
rubidium
parents: 7269
diff changeset
   467
647d6416cdfe (svn r10033) -Feature [FS#760]: skip to the selected order in the order list when clicking on the "skip" button while pressing CTRL.
rubidium
parents: 7269
diff changeset
   468
	DoCommandP(v->tile, v->index, _ctrl_pressed ? OrderGetSel(w) : ((v->cur_order_index + 1) % v->num_orders),
647d6416cdfe (svn r10033) -Feature [FS#760]: skip to the selected order in the order list when clicking on the "skip" button while pressing CTRL.
rubidium
parents: 7269
diff changeset
   469
			NULL, CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_CAN_T_SKIP_TO_ORDER : STR_CAN_T_SKIP_ORDER));
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   470
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   471
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   472
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   473
 * Handle the click on the unload button.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   474
 *
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   475
 * @param w current window
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   476
 * @param v current vehicle
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   477
 */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   478
static void OrderClick_Delete(Window *w, const Vehicle *v)
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   479
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   480
	DoCommandP(v->tile, v->index, OrderGetSel(w), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER));
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   481
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   482
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   483
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   484
 * Handle the click on the refit button.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   485
 * If ctrl is pressed cancel refitting.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   486
 *  Else show the refit window.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   487
 *
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   488
 * @param w current window
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   489
 * @param v current vehicle
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   490
 */
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   491
static void OrderClick_Refit(Window *w, const Vehicle *v)
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   492
{
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   493
	if (_ctrl_pressed) {
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   494
		/* Cancel refitting */
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
   495
		DoCommandP(v->tile, v->index, (WP(w, order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT);
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   496
	} else {
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
   497
		ShowVehicleRefitWindow(v, WP(w, order_d).sel);
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   498
	}
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   499
}
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   500
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   501
typedef void OnButtonVehClick(Window *w, const Vehicle *v);
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   502
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   503
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   504
 * Keycode function mapping.
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   505
 *
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   506
 * @see _order_keycodes[]
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   507
 * @note Keep them allways in sync with _order_keycodes[]!
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   508
 */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   509
static OnButtonVehClick* const _order_button_proc[] = {
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   510
	OrderClick_Skip,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   511
	OrderClick_Delete,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   512
	OrderClick_Nonstop,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   513
	OrderClick_Goto,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   514
	OrderClick_FullLoad,
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   515
	OrderClick_Unload,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   516
	OrderClick_Transfer
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   517
};
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   518
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   519
static const uint16 _order_keycodes[] = {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   520
	'D', //skip order
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   521
	'F', //delete order
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   522
	'G', //non-stop
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   523
	'H', //goto order
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   524
	'J', //full load
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   525
	'K'  //unload
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   526
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
static void OrdersWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
{
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   530
	switch (e->event) {
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   531
		case WE_CREATE:
6082
35923f392ade (svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents: 6080
diff changeset
   532
			/* Ensure that the refit and unload buttons always remain at the same location.
35923f392ade (svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents: 6080
diff changeset
   533
			 * Only one of them can be active at any one time and takes turns on being disabled.
35923f392ade (svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents: 6080
diff changeset
   534
			 * To ensure that they stay at the same location, we also verify that they behave the same
35923f392ade (svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents: 6080
diff changeset
   535
			 * when resizing. */
35923f392ade (svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents: 6080
diff changeset
   536
			if (GetVehicle(w->window_number)->owner == _local_player) { // only the vehicle owner got these buttons
35923f392ade (svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents: 6080
diff changeset
   537
				assert(w->widget[ORDER_WIDGET_REFIT].left          == w->widget[ORDER_WIDGET_UNLOAD].left);
35923f392ade (svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents: 6080
diff changeset
   538
				assert(w->widget[ORDER_WIDGET_REFIT].right         == w->widget[ORDER_WIDGET_UNLOAD].right);
35923f392ade (svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents: 6080
diff changeset
   539
				assert(w->widget[ORDER_WIDGET_REFIT].top           == w->widget[ORDER_WIDGET_UNLOAD].top);
35923f392ade (svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents: 6080
diff changeset
   540
				assert(w->widget[ORDER_WIDGET_REFIT].bottom        == w->widget[ORDER_WIDGET_UNLOAD].bottom);
35923f392ade (svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents: 6080
diff changeset
   541
				assert(w->widget[ORDER_WIDGET_REFIT].display_flags == w->widget[ORDER_WIDGET_UNLOAD].display_flags);
35923f392ade (svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents: 6080
diff changeset
   542
			}
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   543
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   544
			if (_patches.timetabling) {
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   545
				w->widget[ORDER_WIDGET_CAPTION].right -= 61;
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   546
			} else {
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   547
				w->HideWidget(ORDER_WIDGET_TIMETABLE_VIEW);
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   548
			}
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   549
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   550
			break;
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   551
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
		DrawOrdersWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
	case WE_CLICK: {
7328
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   557
		const Vehicle *v = GetVehicle(w->window_number);
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   558
		switch (e->we.click.widget) {
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   559
		case ORDER_WIDGET_ORDER_LIST: {
7328
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   560
			ResetObjectToPlace();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
7328
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   562
			int sel = GetOrderFromOrderWndPt(w, e->we.click.pt.y, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
7419
f8af4d3bd1df (svn r10176) -Fix (r10071): Deselect the currently selected order when clicking on an empty part of the orders window.
maedhros
parents: 7328
diff changeset
   564
			if (sel == INVALID_ORDER) {
f8af4d3bd1df (svn r10176) -Fix (r10071): Deselect the currently selected order when clicking on an empty part of the orders window.
maedhros
parents: 7328
diff changeset
   565
				/* This was a click on an empty part of the orders window, so
f8af4d3bd1df (svn r10176) -Fix (r10071): Deselect the currently selected order when clicking on an empty part of the orders window.
maedhros
parents: 7328
diff changeset
   566
				 * deselect the currently selected order. */
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
   567
				WP(w, order_d).sel = -1;
7419
f8af4d3bd1df (svn r10176) -Fix (r10071): Deselect the currently selected order when clicking on an empty part of the orders window.
maedhros
parents: 7328
diff changeset
   568
				SetWindowDirty(w);
f8af4d3bd1df (svn r10176) -Fix (r10071): Deselect the currently selected order when clicking on an empty part of the orders window.
maedhros
parents: 7328
diff changeset
   569
				return;
f8af4d3bd1df (svn r10176) -Fix (r10071): Deselect the currently selected order when clicking on an empty part of the orders window.
maedhros
parents: 7328
diff changeset
   570
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   572
			if (_ctrl_pressed && sel < v->num_orders) {
1043
123072ba6ced (svn r1544) -Fix: SwapOrder did not use AssignOrder, which caused the saveroutine to
truelight
parents: 1035
diff changeset
   573
				const Order *ord = GetVehicleOrder(v, sel);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   574
				TileIndex xy;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   575
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   576
				switch (ord->type) {
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   577
					case OT_GOTO_STATION:  xy = GetStation(ord->dest)->xy ; break;
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   578
					case OT_GOTO_DEPOT:    xy = (v->type == VEH_AIRCRAFT) ?  GetStation(ord->dest)->xy : GetDepot(ord->dest)->xy;    break;
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4408
diff changeset
   579
					case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->dest)->xy; break;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   580
					default:               xy = 0; break;
44
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   581
				}
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   582
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   583
				if (xy != 0) ScrollMainWindowToTile(xy);
44
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   584
				return;
7328
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   585
			} else {
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
   586
				if (sel == WP(w, order_d).sel) {
7328
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   587
					/* Deselect clicked order */
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
   588
					WP(w, order_d).sel = -1;
7328
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   589
				} else {
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   590
					/* Select clicked order */
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
   591
					WP(w, order_d).sel = sel;
7328
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   592
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   593
					if (v->owner == _local_player) {
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   594
						/* Activate drag and drop */
8385
aedd7656cfd1 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 8320
diff changeset
   595
						SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, VHM_DRAG, w);
7328
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   596
					}
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   597
				}
44
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   598
			}
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   599
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
			SetWindowDirty(w);
6988
76eba6a9cc6f (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6677
diff changeset
   601
		} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   603
		case ORDER_WIDGET_SKIP:
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   604
			OrderClick_Skip(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   605
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   607
		case ORDER_WIDGET_DELETE:
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   608
			OrderClick_Delete(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   611
		case ORDER_WIDGET_NON_STOP:
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   612
			OrderClick_Nonstop(w, v);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   613
			break;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   614
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   615
		case ORDER_WIDGET_GOTO:
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   616
			OrderClick_Goto(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   617
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   618
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   619
		case ORDER_WIDGET_FULL_LOAD:
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   620
			OrderClick_FullLoad(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   622
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   623
		case ORDER_WIDGET_UNLOAD:
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   624
			OrderClick_Unload(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
			break;
6080
a56f432ef1b1 (svn r8395) -Cleanup: [orders window] moved the refit button two places up, so the order of the widget array fits the placement on the screen
bjarni
parents: 6079
diff changeset
   626
		case ORDER_WIDGET_REFIT:
a56f432ef1b1 (svn r8395) -Cleanup: [orders window] moved the refit button two places up, so the order of the widget array fits the placement on the screen
bjarni
parents: 6079
diff changeset
   627
			OrderClick_Refit(w, v);
a56f432ef1b1 (svn r8395) -Cleanup: [orders window] moved the refit button two places up, so the order of the widget array fits the placement on the screen
bjarni
parents: 6079
diff changeset
   628
			break;
a56f432ef1b1 (svn r8395) -Cleanup: [orders window] moved the refit button two places up, so the order of the widget array fits the placement on the screen
bjarni
parents: 6079
diff changeset
   629
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   630
		case ORDER_WIDGET_TRANSFER:
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   631
			OrderClick_Transfer(w, v);
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   632
			break;
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   633
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   634
		case ORDER_WIDGET_TIMETABLE_VIEW:
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   635
			ShowTimetableWindow(v);
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   636
			break;
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   637
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   638
		case ORDER_WIDGET_SHARED_ORDER_LIST:
5996
d4b66530ded4 (svn r8293) -Codechange: overloaded ShowVehicleListWindow() so it can open all types of vehicle lists (depending on arguments)
bjarni
parents: 5919
diff changeset
   639
			ShowVehicleListWindow(v);
4408
84ec2899adfa (svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents: 4389
diff changeset
   640
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
	} break;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   643
7328
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   644
	case WE_DRAGDROP: {
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   645
		const Vehicle *v = GetVehicle(w->window_number);
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   646
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   647
		switch (e->we.click.widget) {
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   648
			case ORDER_WIDGET_ORDER_LIST: {
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   649
				int from_order = OrderGetSel(w);
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   650
				int to_order = GetOrderFromOrderWndPt(w, e->we.dragdrop.pt.y, v);
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   651
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   652
				if (!(from_order == to_order || from_order == INVALID_ORDER || from_order > v->num_orders || to_order == INVALID_ORDER || to_order > v->num_orders) &&
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   653
						DoCommandP(v->tile, v->index, from_order | (to_order << 16), NULL, CMD_MOVE_ORDER | CMD_MSG(STR_CAN_T_MOVE_THIS_ORDER))) {
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   654
					WP(w, order_d).sel = -1;
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   655
				}
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   656
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   657
				break;
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   658
			}
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   659
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   660
			case ORDER_WIDGET_DELETE:
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   661
				OrderClick_Delete(w, v);
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   662
				break;
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   663
		}
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   664
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   665
		ResetObjectToPlace();
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   666
		break;
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   667
	}
8ac64204c17f (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 7303
diff changeset
   668
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   669
	case WE_KEYPRESS: {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   670
		Vehicle *v = GetVehicle(w->window_number);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   671
		uint i;
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   672
4949
fa564e9c2aea (svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents: 4935
diff changeset
   673
		if (v->owner != _local_player) break;
fa564e9c2aea (svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents: 4935
diff changeset
   674
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2921
diff changeset
   675
		for (i = 0; i < lengthof(_order_keycodes); i++) {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   676
			if (e->we.keypress.keycode == _order_keycodes[i]) {
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   677
				e->we.keypress.cont = false;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   678
				//see if the button is disabled
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   679
				if (!w->IsWidgetDisabled(i + ORDER_WIDGET_SKIP)) _order_button_proc[i](w, v);
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   680
				break;
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   681
			}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   682
		}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   683
		break;
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   684
	}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   685
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   686
	case WE_RCLICK: {
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   687
		const Vehicle *v = GetVehicle(w->window_number);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   688
		int s = OrderGetSel(w);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   689
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   690
		if (e->we.click.widget != ORDER_WIDGET_FULL_LOAD) break;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   691
		if (s == v->num_orders || GetVehicleOrder(v, s)->type != OT_GOTO_DEPOT) {
1256
696eba311737 (svn r1760) -Fix: [ 1113399 ] Game no longer crashes when right-clicking a disabled Full Load button
celestar
parents: 1242
diff changeset
   692
			GuiShowTooltips(STR_8857_MAKE_THE_HIGHLIGHTED_ORDER);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   693
		} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   694
			GuiShowTooltips(STR_SERVICE_HINT);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   695
		}
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   696
	} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   697
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
	case WE_PLACE_OBJ: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4547
diff changeset
   699
		OrdersPlaceObj(GetVehicle(w->window_number), e->we.place.tile, w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   700
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   702
	case WE_ABORT_PLACE_OBJ: {
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   703
		w->RaiseWidget(ORDER_WIDGET_GOTO);
8524
baf4ab1ba18d (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 8493
diff changeset
   704
		w->InvalidateWidget(ORDER_WIDGET_GOTO);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   706
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
	// check if a vehicle in a depot was clicked..
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   708
	case WE_MOUSELOOP: {
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   709
		const Vehicle *v = _place_clicked_vehicle;
25
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   710
		/*
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   711
		 * Check if we clicked on a vehicle
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   712
		 * and if the GOTO button of this window is pressed
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   713
		 * This is because of all open order windows WE_MOUSELOOP is called
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   714
		 * and if you have 3 windows open, and this check is not done
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   715
		 * the order is copied to the last open window instead of the
4949
fa564e9c2aea (svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents: 4935
diff changeset
   716
		 * one where GOTO is enabled
25
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   717
		 */
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   718
		if (v != NULL && w->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   719
			_place_clicked_vehicle = NULL;
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   720
			HandleOrderVehClick(GetVehicle(w->window_number), v, w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   721
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   722
	} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   723
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   724
	case WE_RESIZE:
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   725
		/* Update the scroll + matrix */
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   726
		w->vscroll.cap = (w->widget[ORDER_WIDGET_ORDER_LIST].bottom - w->widget[ORDER_WIDGET_ORDER_LIST].top) / 10;
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   727
		break;
5013
79a6e510c41f (svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents: 4968
diff changeset
   728
79a6e510c41f (svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents: 4968
diff changeset
   729
	case WE_TIMEOUT: { // handle button unclick ourselves...
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
   730
		// unclick all buttons except for the 'goto' button (ORDER_WIDGET_GOTO), which is 'persistent'
5235
3c309f43f0a6 (svn r7355) -Codechange: replace 'for (i = 0; w->widget[i].type != WWT_TYPE; i++)'-type for loops with 'for (i = 0; i < w->widget_count; i++)'-type for loops
rubidium
parents: 5071
diff changeset
   731
		uint i;
3c309f43f0a6 (svn r7355) -Codechange: replace 'for (i = 0; w->widget[i].type != WWT_TYPE; i++)'-type for loops with 'for (i = 0; i < w->widget_count; i++)'-type for loops
rubidium
parents: 5071
diff changeset
   732
		for (i = 0; i < w->widget_count; i++) {
8493
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   733
			if (w->IsWidgetLowered(i) && i != ORDER_WIDGET_GOTO) {
3ab458f7cff4 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 8385
diff changeset
   734
				w->RaiseWidget(i);
8524
baf4ab1ba18d (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 8493
diff changeset
   735
				w->InvalidateWidget(i);
5013
79a6e510c41f (svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents: 4968
diff changeset
   736
			}
79a6e510c41f (svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents: 4968
diff changeset
   737
		}
79a6e510c41f (svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents: 4968
diff changeset
   738
	} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   740
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   741
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   742
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   743
 * Widget definition for player train orders
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   744
 */
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   745
static const Widget _orders_train_widgets[] = {
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   746
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},               // ORDER_WIDGET_CLOSEBOX
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   747
	{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   398,     0,    13, STR_8829_ORDERS,         STR_018C_WINDOW_TITLE_DRAG_THIS},     // ORDER_WIDGET_CAPTION
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   748
	{ WWT_PUSHTXTBTN,   RESIZE_LR,      14,   338,   398,     0,    13, STR_TIMETABLE_VIEW,      STR_TIMETABLE_VIEW_TOOLTIP},          // ORDER_WIDGET_TIMETABLE_VIEW
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   749
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   750
	{      WWT_PANEL,   RESIZE_RB,      14,     0,   386,    14,    75, 0x0,                     STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   751
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   752
	{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   387,   398,    14,    75, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},    // ORDER_WIDGET_SCROLLBAR
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   753
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   754
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,    52,    76,    87, STR_8823_SKIP,           STR_8853_SKIP_THE_CURRENT_ORDER},     // ORDER_WIDGET_SKIP
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   755
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,    53,   105,    76,    87, STR_8824_DELETE,         STR_8854_DELETE_THE_HIGHLIGHTED},     // ORDER_WIDGET_DELETE
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   756
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   106,   158,    76,    87, STR_8825_NON_STOP,       STR_8855_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_NON_STOP
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   757
	{    WWT_TEXTBTN,   RESIZE_TB,      14,   159,   211,    76,    87, STR_8826_GO_TO,          STR_8856_INSERT_A_NEW_ORDER_BEFORE},  // ORDER_WIDGET_GOTO
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   758
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   212,   264,    76,    87, STR_FULLLOAD_OR_SERVICE, STR_NULL},                            // ORDER_WIDGET_FULL_LOAD
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   759
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   265,   319,    76,    87, STR_8828_UNLOAD,         STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_UNLOAD
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   760
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   265,   319,    76,    87, STR_REFIT,               STR_REFIT_TIP},                       // ORDER_WIDGET_REFIT
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   761
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   320,   372,    76,    87, STR_886F_TRANSFER,       STR_886D_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_TRANSFER
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   762
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   763
	{ WWT_PUSHIMGBTN,   RESIZE_TB,      14,   373,   386,    76,    87, SPR_SHARED_ORDERS_ICON,  STR_VEH_WITH_SHARED_ORDERS_LIST_TIP}, // ORDER_WIDGET_SHARED_ORDER_LIST
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   764
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   765
	{      WWT_PANEL,   RESIZE_RTB,     14,   387,   386,    76,    87, 0x0,                     STR_NULL},                            // ORDER_WIDGET_RESIZE_BAR
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   766
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   767
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   387,   398,    76,    87, 0x0,                     STR_RESIZE_BUTTON},                   // ORDER_WIDGET_RESIZE
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   768
	{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   769
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   770
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   771
static const WindowDesc _orders_train_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7808
diff changeset
   772
	WDP_AUTO, WDP_AUTO, 399, 88, 399, 88,
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   773
	WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
5013
79a6e510c41f (svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents: 4968
diff changeset
   774
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   775
	_orders_train_widgets,
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   776
	OrdersWndProc
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   777
};
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   778
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   779
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   780
 * Widget definition for player orders (!train)
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   781
 */
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   782
static const Widget _orders_widgets[] = {
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   783
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},               // ORDER_WIDGET_CLOSEBOX
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   784
	{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   409,     0,    13, STR_8829_ORDERS,         STR_018C_WINDOW_TITLE_DRAG_THIS},     // ORDER_WIDGET_CAPTION
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   785
	{ WWT_PUSHTXTBTN,   RESIZE_LR,      14,   349,   409,     0,    13, STR_TIMETABLE_VIEW,      STR_TIMETABLE_VIEW_TOOLTIP},          // ORDER_WIDGET_TIMETABLE_VIEW
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   786
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   787
	{      WWT_PANEL,   RESIZE_RB,      14,     0,   397,    14,    75, 0x0,                     STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   788
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   789
	{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   398,   409,    14,    75, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},    // ORDER_WIDGET_SCROLLBAR
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   790
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   791
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,    63,    76,    87, STR_8823_SKIP,           STR_8853_SKIP_THE_CURRENT_ORDER},     // ORDER_WIDGET_SKIP
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   792
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,    64,   128,    76,    87, STR_8824_DELETE,         STR_8854_DELETE_THE_HIGHLIGHTED},     // ORDER_WIDGET_DELETE
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   793
	{      WWT_EMPTY,   RESIZE_TB,      14,     0,     0,    76,    87, 0x0,                     0x0},                                 // ORDER_WIDGET_NON_STOP
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   794
	{    WWT_TEXTBTN,   RESIZE_TB,      14,   129,   192,    76,    87, STR_8826_GO_TO,          STR_8856_INSERT_A_NEW_ORDER_BEFORE},  // ORDER_WIDGET_GOTO
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   795
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   193,   256,    76,    87, STR_FULLLOAD_OR_SERVICE, STR_NULL},                            // ORDER_WIDGET_FULL_LOAD
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   796
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   257,   319,    76,    87, STR_8828_UNLOAD,         STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_UNLOAD
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   797
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   257,   319,    76,    87, STR_REFIT,               STR_REFIT_TIP},                       // ORDER_WIDGET_REFIT
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   798
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   320,   383,    76,    87, STR_886F_TRANSFER,       STR_886D_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_TRANSFER
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   799
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   800
	{ WWT_PUSHIMGBTN,   RESIZE_TB,      14,   384,   397,    76,    87, SPR_SHARED_ORDERS_ICON,  STR_VEH_WITH_SHARED_ORDERS_LIST_TIP}, // ORDER_WIDGET_SHARED_ORDER_LIST
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   801
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   802
	{      WWT_PANEL,   RESIZE_RTB,     14,   397,   396,    76,    87, 0x0,                     STR_NULL},                            // ORDER_WIDGET_RESIZE_BAR
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   803
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   804
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   398,   409,    76,    87, 0x0,                     STR_RESIZE_BUTTON},                   // ORDER_WIDGET_RESIZE
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   805
	{   WIDGETS_END},
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   806
};
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   807
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   808
static const WindowDesc _orders_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7808
diff changeset
   809
	WDP_AUTO, WDP_AUTO, 410, 88, 410, 88,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   810
	WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
5013
79a6e510c41f (svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents: 4968
diff changeset
   811
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   812
	_orders_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   813
	OrdersWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   814
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   815
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   816
/**
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   817
 * Widget definition for competitor orders
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   818
 */
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   819
static const Widget _other_orders_widgets[] = {
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   820
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,           STR_018B_CLOSE_WINDOW},               // ORDER_WIDGET_CLOSEBOX
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   821
	{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   331,     0,    13, STR_A00B_ORDERS,    STR_018C_WINDOW_TITLE_DRAG_THIS},     // ORDER_WIDGET_CAPTION
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   822
	{ WWT_PUSHTXTBTN,   RESIZE_LR,      14,   271,   331,     0,    13, STR_TIMETABLE_VIEW, STR_TIMETABLE_VIEW_TOOLTIP},          // ORDER_WIDGET_TIMETABLE_VIEW
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   823
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   824
	{      WWT_PANEL,   RESIZE_RB,      14,     0,   319,    14,    75, 0x0,                STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   825
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   826
	{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   320,   331,    14,    75, 0x0,                STR_0190_SCROLL_BAR_SCROLLS_LIST},    // ORDER_WIDGET_SCROLLBAR
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   827
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   828
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_SKIP
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   829
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_DELETE
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   830
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_NON_STOP
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   831
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_GOTO
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   832
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_FULL_LOAD
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   833
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_UNLOAD
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   834
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_REFIT
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   835
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_TRANSFER
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   836
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   837
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_SHARED_ORDER_LIST
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   838
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   839
	{      WWT_PANEL,   RESIZE_RTB,     14,     0,   319,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_RESIZE_BAR
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   840
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7419
diff changeset
   841
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   320,   331,    76,    87, 0x0,                STR_RESIZE_BUTTON},                   // ORDER_WIDGET_RESIZE
7303
be60ddc5a626 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 7290
diff changeset
   842
	{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   843
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   844
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   845
static const WindowDesc _other_orders_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7808
diff changeset
   846
	WDP_AUTO, WDP_AUTO, 332, 88, 332, 88,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   847
	WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   848
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   849
	_other_orders_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   850
	OrdersWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   851
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   852
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   853
void ShowOrdersWindow(const Vehicle *v)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   854
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   855
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   856
	VehicleID veh = v->index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   857
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   858
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   859
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   860
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   861
	if (v->owner != _local_player) {
5071
14f432b47034 (svn r7129) -Codechange: Get rid of a global variable that only sets a window's number.
Darkvater
parents: 5070
diff changeset
   862
		w = AllocateWindowDescFront(&_other_orders_desc, veh);
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   863
	} else {
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6417
diff changeset
   864
		w = AllocateWindowDescFront((v->type == VEH_TRAIN) ? &_orders_train_desc : &_orders_desc, veh);
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   865
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   866
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   867
	if (w != NULL) {
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   868
		w->caption_color = v->owner;
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   869
		w->vscroll.cap = 6;
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   870
		w->resize.step_height = 10;
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8560
diff changeset
   871
		WP(w, order_d).sel = -1;
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   872
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   873
}