src/order_gui.cpp
author richk
Tue, 17 Jun 2008 13:22:13 +0000
branchNewGRF_ports
changeset 10994 cd9968b6f96b
parent 10991 d8811e327d12
permissions -rw-r--r--
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
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
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
     3
/** @file order_gui.cpp GUI related to orders. */
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
     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"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "gui.h"
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    10
#include "window_gui.h"
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    11
#include "station_base.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "town.h"
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    13
#include "command_func.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    14
#include "viewport_func.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    15
#include "gfx_func.h"
10242
52b4a9006029 (svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents: 10210
diff changeset
    16
#include "depot_base.h"
1542
2ca6d1624e6d (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1530
diff changeset
    17
#include "waypoint.h"
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2668
diff changeset
    18
#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
    19
#include "water_map.h"
4668
8b6035c51188 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
    20
#include "vehicle_gui.h"
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
    21
#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
    22
#include "cargotype.h"
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    23
#include "strings_func.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    24
#include "window_func.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    25
#include "vehicle_func.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    26
#include "settings_type.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    27
#include "player_func.h"
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    28
#include "newgrf_cargo.h"
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    29
#include "widgets/dropdown_func.h"
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
    30
#include "textbuf_gui.h"
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
    31
#include "string_func.h"
10242
52b4a9006029 (svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents: 10210
diff changeset
    32
#include "depot_base.h"
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
    33
#include "tilehighlight_func.h"
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    34
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    35
#include "table/sprites.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6871
diff changeset
    36
#include "table/strings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    38
enum OrderWindowWidgets {
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    39
	ORDER_WIDGET_CLOSEBOX = 0,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    40
	ORDER_WIDGET_CAPTION,
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
    41
	ORDER_WIDGET_TIMETABLE_VIEW,
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    42
	ORDER_WIDGET_ORDER_LIST,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    43
	ORDER_WIDGET_SCROLLBAR,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    44
	ORDER_WIDGET_SKIP,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    45
	ORDER_WIDGET_DELETE,
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
    46
	ORDER_WIDGET_NON_STOP_DROPDOWN,
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    47
	ORDER_WIDGET_NON_STOP,
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
    48
	ORDER_WIDGET_GOTO_DROPDOWN,
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    49
	ORDER_WIDGET_GOTO,
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
    50
	ORDER_WIDGET_FULL_LOAD_DROPDOWN,
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    51
	ORDER_WIDGET_FULL_LOAD,
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
    52
	ORDER_WIDGET_UNLOAD_DROPDOWN,
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    53
	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
    54
	ORDER_WIDGET_REFIT,
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    55
	ORDER_WIDGET_SERVICE,
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
    56
	ORDER_WIDGET_COND_VARIABLE,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
    57
	ORDER_WIDGET_COND_COMPARATOR,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
    58
	ORDER_WIDGET_COND_VALUE,
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    59
	ORDER_WIDGET_RESIZE_BAR,
6079
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    60
	ORDER_WIDGET_SHARED_ORDER_LIST,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    61
	ORDER_WIDGET_RESIZE,
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    62
};
46605a85887c (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5996
diff changeset
    63
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    64
/** Order load types that could be given to station orders. */
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    65
static const StringID _station_load_types[][5] = {
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    66
	{
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    67
		STR_EMPTY,
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    68
		INVALID_STRING_ID,
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    69
		STR_ORDER_FULL_LOAD,
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    70
		STR_ORDER_FULL_LOAD_ANY,
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    71
		STR_ORDER_NO_LOAD,
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    72
	}, {
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    73
		STR_ORDER_UNLOAD,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    74
		INVALID_STRING_ID,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    75
		STR_ORDER_UNLOAD_FULL_LOAD,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    76
		STR_ORDER_UNLOAD_FULL_LOAD_ANY,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    77
		STR_ORDER_UNLOAD_NO_LOAD,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    78
	}, {
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    79
		STR_ORDER_TRANSFER,
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    80
		INVALID_STRING_ID,
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    81
		STR_ORDER_TRANSFER_FULL_LOAD,
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    82
		STR_ORDER_TRANSFER_FULL_LOAD_ANY,
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    83
		STR_ORDER_TRANSFER_NO_LOAD,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    84
	}, {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    85
		/* Unload and transfer do not work together. */
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    86
		INVALID_STRING_ID,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    87
		INVALID_STRING_ID,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    88
		INVALID_STRING_ID,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    89
		INVALID_STRING_ID,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    90
	}, {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    91
		STR_ORDER_NO_UNLOAD,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    92
		INVALID_STRING_ID,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    93
		STR_ORDER_NO_UNLOAD_FULL_LOAD,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    94
		STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    95
		INVALID_STRING_ID,
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
    96
	}
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    97
};
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    98
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
    99
static const StringID _order_non_stop_drowdown[] = {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   100
	STR_ORDER_GO_TO,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   101
	STR_ORDER_GO_NON_STOP_TO,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   102
	STR_ORDER_GO_VIA,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   103
	STR_ORDER_GO_NON_STOP_VIA,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   104
	INVALID_STRING_ID
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   105
};
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   106
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   107
static const StringID _order_full_load_drowdown[] = {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   108
	STR_ORDER_DROP_LOAD_IF_POSSIBLE,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   109
	STR_EMPTY,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   110
	STR_ORDER_DROP_FULL_LOAD_ALL,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   111
	STR_ORDER_DROP_FULL_LOAD_ANY,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   112
	STR_ORDER_DROP_NO_LOADING,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   113
	INVALID_STRING_ID
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   114
};
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   115
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   116
static const StringID _order_unload_drowdown[] = {
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   117
	STR_ORDER_DROP_UNLOAD_IF_ACCEPTED,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   118
	STR_ORDER_DROP_UNLOAD,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   119
	STR_ORDER_DROP_TRANSFER,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   120
	STR_EMPTY,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   121
	STR_ORDER_DROP_NO_UNLOADING,
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   122
	INVALID_STRING_ID
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   123
};
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   124
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   125
static const StringID _order_goto_dropdown[] = {
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   126
	STR_ORDER_GO_TO,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   127
	STR_ORDER_GO_TO_NEAREST_DEPOT,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   128
	STR_ORDER_CONDITIONAL,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   129
	INVALID_STRING_ID
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   130
};
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   131
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   132
static const StringID _order_goto_dropdown_aircraft[] = {
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   133
	STR_ORDER_GO_TO,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   134
	STR_ORDER_GO_TO_NEAREST_HANGAR,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   135
	STR_ORDER_CONDITIONAL,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   136
	INVALID_STRING_ID
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   137
};
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   138
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   139
static const StringID _order_conditional_variable[] = {
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   140
	STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   141
	STR_ORDER_CONDITIONAL_RELIABILITY,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   142
	STR_ORDER_CONDITIONAL_MAX_SPEED,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   143
	STR_ORDER_CONDITIONAL_AGE,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   144
	STR_ORDER_CONDITIONAL_REQUIRES_SERVICE,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   145
	STR_ORDER_CONDITIONAL_UNCONDITIONALLY,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   146
	INVALID_STRING_ID,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   147
};
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   148
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   149
static const StringID _order_conditional_condition[] = {
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   150
	STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   151
	STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   152
	STR_ORDER_CONDITIONAL_COMPARATOR_LESS_THAN,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   153
	STR_ORDER_CONDITIONAL_COMPARATOR_LESS_EQUALS,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   154
	STR_ORDER_CONDITIONAL_COMPARATOR_MORE_THAN,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   155
	STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   156
	STR_ORDER_CONDITIONAL_COMPARATOR_IS_TRUE,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   157
	STR_ORDER_CONDITIONAL_COMPARATOR_IS_FALSE,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   158
	INVALID_STRING_ID,
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   159
};
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   160
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   161
extern uint ConvertSpeedToDisplaySpeed(uint speed);
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   162
extern uint ConvertDisplaySpeedToSpeed(uint speed);
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   163
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   164
10210
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   165
void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable)
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   166
{
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   167
	StringID str = (v->cur_order_index == order_index) ? STR_8805 : STR_8804;
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   168
	SetDParam(6, STR_EMPTY);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   169
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   170
	switch (order->GetType()) {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   171
		case OT_DUMMY:
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   172
			SetDParam(1, STR_INVALID_ORDER);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   173
			SetDParam(2, order->GetDestination());
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   174
			break;
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   175
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   176
		case OT_GOTO_STATION: {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   177
			OrderLoadFlags load = order->GetLoadType();
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   178
			OrderUnloadFlags unload = order->GetUnloadType();
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   179
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   180
			SetDParam(1, STR_GO_TO_STATION);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   181
			SetDParam(2, STR_ORDER_GO_TO + ((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? order->GetNonStopType() : 0));
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   182
			SetDParam(3, order->GetDestination());
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   183
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   184
			if (timetable) {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   185
				SetDParam(4, STR_EMPTY);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   186
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   187
				if (order->wait_time > 0) {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   188
					SetDParam(6, STR_TIMETABLE_STAY_FOR);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   189
					SetTimetableParams(7, 8, order->wait_time);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   190
				}
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   191
			} else {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   192
				SetDParam(4, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ? STR_EMPTY : _station_load_types[unload][load]);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   193
			}
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   194
		} break;
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   195
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   196
		case OT_GOTO_DEPOT:
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   197
			if (v->type == VEH_AIRCRAFT) {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   198
				if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   199
					SetDParam(1, STR_GO_TO_NEAREST_DEPOT);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   200
					SetDParam(3, STR_ORDER_NEAREST_HANGAR);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   201
				} else {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   202
					SetDParam(1, STR_GO_TO_HANGAR);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   203
					SetDParam(3, order->GetDestination());
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   204
				}
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   205
				SetDParam(4, STR_EMPTY);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   206
			} else {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   207
				if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   208
					SetDParam(1, STR_GO_TO_NEAREST_DEPOT);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   209
					SetDParam(3, STR_ORDER_NEAREST_DEPOT);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   210
				} else {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   211
					SetDParam(1, STR_GO_TO_DEPOT);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   212
					SetDParam(3, GetDepot(order->GetDestination())->town_index);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   213
				}
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   214
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   215
				switch (v->type) {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   216
					case VEH_TRAIN: SetDParam(4, STR_ORDER_TRAIN_DEPOT); break;
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   217
					case VEH_ROAD:  SetDParam(4, STR_ORDER_ROAD_DEPOT); break;
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   218
					case VEH_SHIP:  SetDParam(4, STR_ORDER_SHIP_DEPOT); break;
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   219
					default: NOT_REACHED();
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   220
				}
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   221
			}
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   222
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   223
			if (order->GetDepotOrderType() & ODTFB_SERVICE) {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   224
				SetDParam(2, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_SERVICE_NON_STOP_AT : STR_ORDER_SERVICE_AT);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   225
			} else {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   226
				SetDParam(2, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO : STR_ORDER_GO_TO);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   227
			}
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   228
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   229
			if (!timetable && order->IsRefit()) {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   230
				SetDParam(6, STR_REFIT_ORDER);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   231
				SetDParam(7, GetCargo(order->GetRefitCargo())->name);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   232
			}
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   233
			break;
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   234
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   235
		case OT_GOTO_WAYPOINT:
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   236
			SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   237
			SetDParam(2, order->GetDestination());
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   238
			break;
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   239
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   240
		case OT_CONDITIONAL:
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   241
			SetDParam(2, order->GetConditionSkipToOrder() + 1);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   242
			if (order->GetConditionVariable() == OCV_UNCONDITIONALLY) {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   243
				SetDParam(1, STR_CONDITIONAL_UNCONDITIONAL);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   244
			} else {
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   245
				OrderConditionComparator occ = order->GetConditionComparator();
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   246
				SetDParam(1, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_CONDITIONAL_TRUE_FALSE : STR_CONDITIONAL_NUM);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   247
				SetDParam(3, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable());
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   248
				SetDParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   249
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   250
				uint value = order->GetConditionValue();
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   251
				if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   252
				SetDParam(5, value);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   253
			}
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   254
			break;
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   255
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   256
		default: NOT_REACHED();
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   257
	}
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   258
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   259
	SetDParam(0, order_index + 1);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   260
	DrawString(2, y, str, selected ? TC_WHITE : TC_BLACK);
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   261
}
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   262
a2131f7a315d (svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
richk
parents: 10200
diff changeset
   263
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
   264
static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
{
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   266
	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
   267
	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
   268
	order.index = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   270
	/* check depot first */
10991
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10731
diff changeset
   271
	if (_settings_game.order.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
   272
		switch (GetTileType(tile)) {
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   273
			case MP_RAILWAY:
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   274
				if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_player)) {
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   275
					if (IsRailDepot(tile)) {
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   276
						order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
10991
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10731
diff changeset
   277
						if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   278
						return order;
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   279
					}
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   280
				}
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   281
				break;
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   282
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   283
			case MP_ROAD:
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   284
				if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) {
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   285
					order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
10991
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10731
diff changeset
   286
					if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   287
					return order;
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   288
				}
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   289
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   291
			case MP_STATION:
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   292
				if (v->type != VEH_AIRCRAFT) break;
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   293
				if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   294
					order.MakeGoToDepot(GetStationIndex(tile), ODTFB_PART_OF_ORDERS);
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   295
					return order;
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   296
				}
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   297
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   299
			case MP_WATER:
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   300
				if (v->type != VEH_SHIP) break;
10242
52b4a9006029 (svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents: 10210
diff changeset
   301
				if (IsShipDepot(tile) && IsTileOwner(tile, _local_player)) {
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   302
					TileIndex tile2 = GetOtherShipDepotTile(tile);
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
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   304
					order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS);
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   305
					return order;
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   306
				}
1214
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   307
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   308
			default:
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   309
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   313
	/* 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
   314
	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
   315
			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
   316
			IsTileOwner(tile, _local_player) &&
2668
54d9f9d4dca3 (svn r3210) -Codechange: use IsRailWaypoint where possible (instead of magicnumbers)
truelight
parents: 2643
diff changeset
   317
			IsRailWaypoint(tile)) {
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   318
		order.MakeGoToWaypoint(GetWaypointByTile(tile)->index);
10991
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10731
diff changeset
   319
		if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   320
		return order;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   321
	}
319
1891d07574d6 (svn r329) Fix: [ 1035066 ] 'Allow goto depot' turned off, no checkpoints in orders
dominik
parents: 193
diff changeset
   322
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
   323
	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
   324
		StationID st_index = GetStationIndex(tile);
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   325
		const Station *st = GetStation(st_index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
		if (st->owner == _current_player || st->owner == OWNER_NONE) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
			byte facil;
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   329
			(facil = FACIL_DOCK, v->type == VEH_SHIP) ||
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   330
			(facil = FACIL_TRAIN, v->type == VEH_TRAIN) ||
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   331
			(facil = FACIL_AIRPORT, v->type == VEH_AIRCRAFT) ||
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   332
			(facil = FACIL_BUS_STOP, v->type == VEH_ROAD && IsCargoInClass(v->cargo_type, CC_PASSENGERS)) ||
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   333
			(facil = FACIL_TRUCK_STOP, 1);
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   334
			if (st->facilities & facil) {
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   335
				order.MakeGoToStation(st_index);
10991
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10731
diff changeset
   336
				if (_settings_client.gui.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   337
				return order;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   338
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   342
	/* 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
   343
	order.Free();
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   344
	return order;
0
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
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   347
struct OrdersWindow : public Window {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   348
private:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   349
	/** Under what reason are we using the PlaceObject functionality? */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   350
	enum OrderPlaceObjectState {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   351
		OPOS_GOTO,
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   352
		OPOS_CONDITIONAL,
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   353
	};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   355
	int selected_order;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   356
	OrderPlaceObjectState goto_type;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   357
	const Vehicle *vehicle;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   359
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   360
	 * Return the memorised selected order.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   361
	 * @return the memorised order if it is a vaild one
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   362
	 *  else return the number of orders
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   363
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   364
	int OrderGetSel()
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   365
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   366
		int num = this->selected_order;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   367
		return (num >= 0 && num < vehicle->num_orders) ? num : vehicle->num_orders;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   370
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   371
	 * Calculate the selected order.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   372
	 * The calculation is based on the relative (to the window) y click position and
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   373
	 *  the position of the scrollbar.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   374
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   375
	 * @param y Y-value of the click relative to the window origin
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   376
	 * @param v current vehicle
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   377
	 * @return the new selected order if the order is valid else return that
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   378
	 *  an invalid one has been selected.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   379
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   380
	int GetOrderFromPt(int y)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   381
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   382
		/*
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   383
		 * Calculation description:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   384
		 * 15 = 14 (w->widget[ORDER_WIDGET_ORDER_LIST].top) + 1 (frame-line)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   385
		 * 10 = order text hight
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   386
		 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   387
		int sel = (y - this->widget[ORDER_WIDGET_ORDER_LIST].top - 1) / 10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   389
		if ((uint)sel >= this->vscroll.cap) return INVALID_ORDER;
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   390
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   391
		sel += this->vscroll.pos;
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   392
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   393
		return (sel <= vehicle->num_orders && sel >= 0) ? sel : INVALID_ORDER;
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   394
	}
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   395
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   396
	bool HandleOrderVehClick(const Vehicle *u)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   397
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   398
		if (u->type != this->vehicle->type) return false;
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   399
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   400
		if (!u->IsPrimaryVehicle()) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   401
			u = u->First();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   402
			if (!u->IsPrimaryVehicle()) return false;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   403
		}
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   404
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   405
		/* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   406
		 * obviously if you press CTRL on a non-empty orders vehicle you know what you are doing */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   407
		if (this->vehicle->num_orders != 0 && _ctrl_pressed == 0) return false;
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   408
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   409
		if (DoCommandP(this->vehicle->tile, this->vehicle->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY, NULL,
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   410
			_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   411
			this->selected_order = -1;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   412
			ResetObjectToPlace();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   413
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   414
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   415
		return true;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   416
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   417
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   418
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   419
	 * Handle the click on the goto button.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   420
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   421
	 * @param w current window
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   422
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   423
	static void OrderClick_Goto(OrdersWindow *w, int i)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   424
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   425
		w->InvalidateWidget(ORDER_WIDGET_GOTO);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   426
		w->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   427
		if (w->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   428
			_place_clicked_vehicle = NULL;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   429
			SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, VHM_RECT, w);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   430
			w->goto_type = OPOS_GOTO;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   431
		} else {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   432
			ResetObjectToPlace();
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   433
		}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   434
	}
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
   435
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   436
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   437
	 * Handle the click on the full load button.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   438
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   439
	 * @param w current window
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   440
	 * @param load_type the way to load.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   441
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   442
	static void OrderClick_FullLoad(OrdersWindow *w, int load_type)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   443
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   444
		VehicleOrderID sel_ord = w->OrderGetSel();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   445
		const Order *order = GetVehicleOrder(w->vehicle, sel_ord);
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   446
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   447
		if (order == NULL || order->GetLoadType() == load_type) return;
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   448
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   449
		if (load_type < 0) {
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   450
			load_type = order->GetLoadType() == OLF_LOAD_IF_POSSIBLE ? OLF_FULL_LOAD_ANY : OLF_LOAD_IF_POSSIBLE;
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   451
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   452
		DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_LOAD | (load_type << 4), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   453
	}
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   454
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   455
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   456
	 * Handle the click on the service.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   457
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   458
	 * @param w current window
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   459
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   460
	static void OrderClick_Service(OrdersWindow *w, int i)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   461
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   462
		DoCommandP(w->vehicle->tile, w->vehicle->index + (w->OrderGetSel() << 16), MOF_DEPOT_ACTION, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
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
   463
	}
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   464
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   465
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   466
	 * Handle the click on the service in nearest depot button.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   467
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   468
	 * @param w current window
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   469
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   470
	static void OrderClick_NearestDepot(OrdersWindow *w, int i)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   471
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   472
		Order order;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   473
		order.next = NULL;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   474
		order.index = 0;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   475
		order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   476
		order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   477
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   478
		DoCommandP(w->vehicle->tile, w->vehicle->index + (w->OrderGetSel() << 16), order.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER));
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   479
	}
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   480
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   481
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   482
	 * Handle the click on the conditional order button.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   483
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   484
	 * @param w current window
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   485
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   486
	static void OrderClick_Conditional(OrdersWindow *w, int i)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   487
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   488
		w->InvalidateWidget(ORDER_WIDGET_GOTO);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   489
		w->LowerWidget(ORDER_WIDGET_GOTO);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   490
		SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, VHM_RECT, w);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   491
		w->goto_type = OPOS_CONDITIONAL;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   492
	}
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   493
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   494
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   495
	 * Handle the click on the unload button.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   496
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   497
	 * @param w current window
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   498
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   499
	static void OrderClick_Unload(OrdersWindow *w, int unload_type)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   500
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   501
		VehicleOrderID sel_ord = w->OrderGetSel();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   502
		const Order *order = GetVehicleOrder(w->vehicle, sel_ord);
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   503
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   504
		if (order == NULL || order->GetUnloadType() == unload_type) return;
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   505
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   506
		if (unload_type < 0) {
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   507
			unload_type = order->GetUnloadType() == OUF_UNLOAD_IF_POSSIBLE ? OUFB_UNLOAD : OUF_UNLOAD_IF_POSSIBLE;
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   508
		}
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   509
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   510
		DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_UNLOAD | (unload_type << 4), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   511
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   512
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   513
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   514
	 * Handle the click on the nonstop button.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   515
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   516
	 * @param w current window
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   517
	 * @param non_stop what non-stop type to use; -1 to use the 'next' one.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   518
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   519
	static void OrderClick_Nonstop(OrdersWindow *w, int non_stop)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   520
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   521
		VehicleOrderID sel_ord = w->OrderGetSel();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   522
		const Order *order = GetVehicleOrder(w->vehicle, sel_ord);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   523
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   524
		if (order == NULL || order->GetNonStopType() == non_stop) return;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   525
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   526
		/* Keypress if negative, so 'toggle' to the next */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   527
		if (non_stop < 0) {
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   528
			non_stop = order->GetNonStopType() ^ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS;
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   529
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   530
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   531
		w->InvalidateWidget(ORDER_WIDGET_NON_STOP);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   532
		DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_NON_STOP | non_stop << 4,  NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   533
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   534
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   535
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   536
	 * Handle the click on the transfer button.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   537
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   538
	 * @param w current window
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   539
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   540
	static void OrderClick_Transfer(OrdersWindow *w, int i)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   541
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   542
		VehicleOrderID sel_ord = w->OrderGetSel();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   543
		const Order *order = GetVehicleOrder(w->vehicle, sel_ord);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   544
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   545
		if (order == NULL) return;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   546
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   547
		DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_UNLOAD | ((order->GetUnloadType() & ~OUFB_NO_UNLOAD) ^ OUFB_TRANSFER) << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   548
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   549
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   550
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   551
	 * Handle the click on the skip button.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   552
	 * If ctrl is pressed skip to selected order.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   553
	 *  Else skip to current order + 1
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   554
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   555
	 * @param w current window
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   556
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   557
	static void OrderClick_Skip(OrdersWindow *w, int i)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   558
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   559
		/* Don't skip when there's nothing to skip */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   560
		if (_ctrl_pressed && w->vehicle->cur_order_index == w->OrderGetSel()) return;
10991
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10731
diff changeset
   561
		if (w->vehicle->num_orders == 0) return;
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   562
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   563
		DoCommandP(w->vehicle->tile, w->vehicle->index, _ctrl_pressed ? w->OrderGetSel() : ((w->vehicle->cur_order_index + 1) % w->vehicle->num_orders),
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   564
				NULL, CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_CAN_T_SKIP_TO_ORDER : STR_CAN_T_SKIP_ORDER));
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   565
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   566
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   567
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   568
	 * Handle the click on the unload button.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   569
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   570
	 * @param w current window
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   571
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   572
	static void OrderClick_Delete(OrdersWindow *w, int i)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   573
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   574
		DoCommandP(w->vehicle->tile, w->vehicle->index, w->OrderGetSel(), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER));
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   575
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   576
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   577
	/**
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   578
	 * Handle the click on the refit button.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   579
	 * If ctrl is pressed cancel refitting.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   580
	 *  Else show the refit window.
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   581
	 *
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   582
	 * @param w current window
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   583
	 */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   584
	static void OrderClick_Refit(OrdersWindow *w, int i)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   585
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   586
		if (_ctrl_pressed) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   587
			/* Cancel refitting */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   588
			DoCommandP(w->vehicle->tile, w->vehicle->index, (w->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   589
		} else {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   590
			ShowVehicleRefitWindow(w->vehicle, w->OrderGetSel());
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   591
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   592
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   593
	typedef void Handler(OrdersWindow*, int);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   594
	struct KeyToEvent {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   595
		uint16 keycode;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   596
		Handler *proc;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   597
	};
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   598
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   599
public:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   600
	OrdersWindow(const WindowDesc *desc, const Vehicle *v) : Window(desc, v->index)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   601
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   602
		this->caption_color = v->owner;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   603
		this->vscroll.cap = 6;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   604
		this->resize.step_height = 10;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   605
		this->selected_order = -1;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   606
		this->vehicle = v;
10991
d8811e327d12 (svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents: 10731
diff changeset
   607
		if (_settings_game.order.timetabling) {
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   608
			this->widget[ORDER_WIDGET_CAPTION].right -= 61;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   609
		} else {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   610
			this->HideWidget(ORDER_WIDGET_TIMETABLE_VIEW);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   611
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   612
		this->FindWindowPlacementAndResize(desc);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   613
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   614
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   615
	virtual void OnPaint()
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   616
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   617
		bool shared_orders = this->vehicle->IsOrderListShared();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   618
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   619
		SetVScrollCount(this, this->vehicle->num_orders + 1);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   620
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   621
		int sel = OrderGetSel();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   622
		const Order *order = GetVehicleOrder(this->vehicle, sel);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   623
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   624
		if (this->vehicle->owner == _local_player) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   625
			/* Set the strings for the dropdown boxes. */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   626
			this->widget[ORDER_WIDGET_COND_VARIABLE].data   = _order_conditional_variable[order == NULL ? 0 : order->GetConditionVariable()];
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   627
			this->widget[ORDER_WIDGET_COND_COMPARATOR].data = _order_conditional_condition[order == NULL ? 0 : order->GetConditionComparator()];
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   628
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   629
			/* skip */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   630
			this->SetWidgetDisabledState(ORDER_WIDGET_SKIP, this->vehicle->num_orders <= 1);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   631
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   632
			/* delete */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   633
			this->SetWidgetDisabledState(ORDER_WIDGET_DELETE,
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   634
					(uint)this->vehicle->num_orders + ((shared_orders || this->vehicle->num_orders != 0) ? 1 : 0) <= (uint)this->selected_order);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   635
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   636
			/* non-stop only for trains */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   637
			this->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP,  (this->vehicle->type != VEH_TRAIN && this->vehicle->type != VEH_ROAD) || order == NULL);
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   638
			this->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP_DROPDOWN, this->IsWidgetDisabled(ORDER_WIDGET_NON_STOP));
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   639
			this->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD, order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // full load
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   640
			this->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD_DROPDOWN, this->IsWidgetDisabled(ORDER_WIDGET_FULL_LOAD));
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   641
			this->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD,    order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   642
			this->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD_DROPDOWN, this->IsWidgetDisabled(ORDER_WIDGET_UNLOAD));
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   643
			/* Disable list of vehicles with the same shared orders if there is no list */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   644
			this->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || this->vehicle->orders == NULL);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   645
			this->SetWidgetDisabledState(ORDER_WIDGET_REFIT,     order == NULL); // Refit
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   646
			this->SetWidgetDisabledState(ORDER_WIDGET_SERVICE,   order == NULL); // Refit
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   647
			this->HideWidget(ORDER_WIDGET_REFIT); // Refit
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   648
			this->HideWidget(ORDER_WIDGET_SERVICE); // Service
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   649
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   650
			this->HideWidget(ORDER_WIDGET_COND_VARIABLE);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   651
			this->HideWidget(ORDER_WIDGET_COND_COMPARATOR);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   652
			this->HideWidget(ORDER_WIDGET_COND_VALUE);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   653
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   654
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   655
		this->ShowWidget(ORDER_WIDGET_NON_STOP_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   656
		this->ShowWidget(ORDER_WIDGET_NON_STOP);
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   657
		this->ShowWidget(ORDER_WIDGET_UNLOAD_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   658
		this->ShowWidget(ORDER_WIDGET_UNLOAD);
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   659
		this->ShowWidget(ORDER_WIDGET_FULL_LOAD_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   660
		this->ShowWidget(ORDER_WIDGET_FULL_LOAD);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   661
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   662
		this->RaiseWidget(ORDER_WIDGET_NON_STOP);
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   663
		this->RaiseWidget(ORDER_WIDGET_FULL_LOAD);
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   664
		this->RaiseWidget(ORDER_WIDGET_UNLOAD);
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   665
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   666
		if (order != NULL) {
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   667
			this->SetWidgetLoweredState(ORDER_WIDGET_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   668
			switch (order->GetType()) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   669
				case OT_GOTO_STATION:
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   670
					if (!GetStation(order->GetDestination())->IsBuoy()) {
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   671
						this->SetWidgetLoweredState(ORDER_WIDGET_FULL_LOAD, order->GetLoadType() == OLF_FULL_LOAD_ANY);
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   672
						this->SetWidgetLoweredState(ORDER_WIDGET_UNLOAD, order->GetUnloadType() == OUFB_UNLOAD);
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   673
						break;
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   674
					}
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   675
					/* Fall-through */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   676
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   677
				case OT_GOTO_WAYPOINT:
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   678
					this->DisableWidget(ORDER_WIDGET_FULL_LOAD_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   679
					this->DisableWidget(ORDER_WIDGET_FULL_LOAD);
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   680
					this->DisableWidget(ORDER_WIDGET_UNLOAD_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   681
					this->DisableWidget(ORDER_WIDGET_UNLOAD);
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   682
					break;
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   683
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   684
				case OT_GOTO_DEPOT:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   685
					/* Remove unload and replace it with refit */
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   686
					this->HideWidget(ORDER_WIDGET_UNLOAD_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   687
					this->HideWidget(ORDER_WIDGET_UNLOAD);
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   688
					this->HideWidget(ORDER_WIDGET_FULL_LOAD_DROPDOWN);
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   689
					this->HideWidget(ORDER_WIDGET_FULL_LOAD);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   690
					this->ShowWidget(ORDER_WIDGET_REFIT);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   691
					this->ShowWidget(ORDER_WIDGET_SERVICE);
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   692
					this->SetWidgetLoweredState(ORDER_WIDGET_SERVICE, order->GetDepotOrderType() & ODTFB_SERVICE);
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   693
					break;
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
   694
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   695
				case OT_CONDITIONAL: {
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   696
					this->HideWidget(ORDER_WIDGET_NON_STOP_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   697
					this->HideWidget(ORDER_WIDGET_NON_STOP);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   698
					this->HideWidget(ORDER_WIDGET_UNLOAD);
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   699
					this->HideWidget(ORDER_WIDGET_UNLOAD_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   700
					this->HideWidget(ORDER_WIDGET_FULL_LOAD);
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   701
					this->HideWidget(ORDER_WIDGET_FULL_LOAD_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   702
					this->ShowWidget(ORDER_WIDGET_COND_VARIABLE);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   703
					this->ShowWidget(ORDER_WIDGET_COND_COMPARATOR);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   704
					this->ShowWidget(ORDER_WIDGET_COND_VALUE);
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   705
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   706
					OrderConditionVariable ocv = order->GetConditionVariable();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   707
					this->SetWidgetDisabledState(ORDER_WIDGET_COND_COMPARATOR, ocv == OCV_UNCONDITIONALLY);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   708
					this->SetWidgetDisabledState(ORDER_WIDGET_COND_VALUE, ocv == OCV_REQUIRES_SERVICE || ocv == OCV_UNCONDITIONALLY);
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   709
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   710
					uint value = order->GetConditionValue();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   711
					if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   712
					SetDParam(1, value);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   713
				} break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   714
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   715
				default: // every other orders
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   716
					this->DisableWidget(ORDER_WIDGET_NON_STOP_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   717
					this->DisableWidget(ORDER_WIDGET_NON_STOP);
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   718
					this->DisableWidget(ORDER_WIDGET_FULL_LOAD_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   719
					this->DisableWidget(ORDER_WIDGET_FULL_LOAD);
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   720
					this->DisableWidget(ORDER_WIDGET_UNLOAD_DROPDOWN);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   721
					this->DisableWidget(ORDER_WIDGET_UNLOAD);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   722
			}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   723
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   725
		SetDParam(0, this->vehicle->index);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   726
		this->DrawWidgets();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   727
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   728
		int y = 15;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   729
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   730
		int i = this->vscroll.pos;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   731
		order = GetVehicleOrder(this->vehicle, i);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   732
		StringID str;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   733
		while (order != NULL) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   734
			/* Don't draw anything if it extends past the end of the window. */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   735
			if (i - this->vscroll.pos >= this->vscroll.cap) break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   736
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   737
			DrawOrderString(this->vehicle, order, i, y, i == this->selected_order, false);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   738
			y += 10;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   739
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   740
			i++;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   741
			order = order->next;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   742
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   743
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   744
		if (i - this->vscroll.pos < this->vscroll.cap) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   745
			str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   746
			DrawString(2, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   747
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   748
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   749
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   750
	virtual void OnClick(Point pt, int widget)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   751
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   752
		if (this->widget[widget].type != WWT_DROPDOWN) HideDropDownMenu(this);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   753
		switch (widget) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   754
			case ORDER_WIDGET_ORDER_LIST: {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   755
				ResetObjectToPlace();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   756
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   757
				int sel = this->GetOrderFromPt(pt.y);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   758
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   759
				if (sel == INVALID_ORDER) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   760
					/* This was a click on an empty part of the orders window, so
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   761
					* deselect the currently selected order. */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   762
					this->selected_order = -1;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   763
					this->SetDirty();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   764
					return;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   765
				}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   766
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   767
				if (_ctrl_pressed && sel < this->vehicle->num_orders) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   768
					const Order *ord = GetVehicleOrder(this->vehicle, sel);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   769
					TileIndex xy;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   770
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   771
					switch (ord->GetType()) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   772
						case OT_GOTO_STATION:  xy = GetStation(ord->GetDestination())->xy ; break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   773
						case OT_GOTO_DEPOT:    xy = (this->vehicle->type == VEH_AIRCRAFT) ?  GetStation(ord->GetDestination())->xy : GetDepot(ord->GetDestination())->xy;    break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   774
						case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->GetDestination())->xy; break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   775
						default:               xy = 0; break;
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   776
					}
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   777
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   778
					if (xy != 0) ScrollMainWindowToTile(xy);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   779
					return;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   780
				} else {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   781
					if (sel == this->selected_order) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   782
						/* Deselect clicked order */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   783
						this->selected_order = -1;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   784
					} else {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   785
						/* Select clicked order */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   786
						this->selected_order = sel;
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   787
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   788
						if (this->vehicle->owner == _local_player) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   789
							/* Activate drag and drop */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   790
							SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, VHM_DRAG, this);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   791
						}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   792
					}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   793
				}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   794
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   795
				this->SetDirty();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   796
			} break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   797
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   798
			case ORDER_WIDGET_SKIP:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   799
				OrderClick_Skip(this, 0);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   800
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   801
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   802
			case ORDER_WIDGET_DELETE:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   803
				OrderClick_Delete(this, 0);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   804
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   805
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   806
			case ORDER_WIDGET_NON_STOP:
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   807
				OrderClick_Nonstop(this, -1);
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   808
				break;
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   809
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   810
			case ORDER_WIDGET_NON_STOP_DROPDOWN: {
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   811
				const Order *o = GetVehicleOrder(this->vehicle, this->OrderGetSel());
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   812
				ShowDropDownMenu(this, _order_non_stop_drowdown, o->GetNonStopType(), ORDER_WIDGET_NON_STOP_DROPDOWN, 0, o->IsType(OT_GOTO_STATION) ? 0 : (o->IsType(OT_GOTO_WAYPOINT) ? 3 : 12));
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   813
			} break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   814
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   815
			case ORDER_WIDGET_GOTO:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   816
				OrderClick_Goto(this, 0);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   817
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   818
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   819
			case ORDER_WIDGET_GOTO_DROPDOWN:
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   820
				ShowDropDownMenu(this, this->vehicle->type == VEH_AIRCRAFT ? _order_goto_dropdown_aircraft : _order_goto_dropdown, 0, ORDER_WIDGET_GOTO_DROPDOWN, 0, 0);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   821
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   822
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   823
			case ORDER_WIDGET_FULL_LOAD:
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   824
				OrderClick_FullLoad(this, -1);
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   825
				break;
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   826
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   827
			case ORDER_WIDGET_FULL_LOAD_DROPDOWN:
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   828
				ShowDropDownMenu(this, _order_full_load_drowdown, GetVehicleOrder(this->vehicle, this->OrderGetSel())->GetLoadType(), ORDER_WIDGET_FULL_LOAD_DROPDOWN, 0, 2);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   829
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   830
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   831
			case ORDER_WIDGET_UNLOAD:
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   832
				OrderClick_Unload(this, -1);
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   833
				break;
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   834
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   835
			case ORDER_WIDGET_UNLOAD_DROPDOWN:
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   836
				ShowDropDownMenu(this, _order_unload_drowdown, GetVehicleOrder(this->vehicle, this->OrderGetSel())->GetUnloadType(), ORDER_WIDGET_UNLOAD_DROPDOWN, 0, 8);
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   837
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   838
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   839
			case ORDER_WIDGET_REFIT:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   840
				OrderClick_Refit(this, 0);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   841
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   842
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   843
			case ORDER_WIDGET_SERVICE:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   844
				OrderClick_Service(this, 0);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   845
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   846
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   847
			case ORDER_WIDGET_TIMETABLE_VIEW:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   848
				ShowTimetableWindow(this->vehicle);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   849
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   850
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   851
			case ORDER_WIDGET_COND_VARIABLE:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   852
				ShowDropDownMenu(this, _order_conditional_variable, GetVehicleOrder(this->vehicle, this->OrderGetSel())->GetConditionVariable(), ORDER_WIDGET_COND_VARIABLE, 0, 0);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   853
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   854
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   855
			case ORDER_WIDGET_COND_COMPARATOR: {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   856
				const Order *o = GetVehicleOrder(this->vehicle, this->OrderGetSel());
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   857
				ShowDropDownMenu(this, _order_conditional_condition, o->GetConditionComparator(), ORDER_WIDGET_COND_COMPARATOR, 0, (o->GetConditionVariable() == OCV_REQUIRES_SERVICE) ? 0x3F : 0xC0);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   858
			} break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   859
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   860
			case ORDER_WIDGET_COND_VALUE: {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   861
				const Order *order = GetVehicleOrder(this->vehicle, this->OrderGetSel());
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   862
				uint value = order->GetConditionValue();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   863
				if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   864
				SetDParam(0, value);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   865
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, 100, this, CS_NUMERAL);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   866
			} break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   867
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   868
			case ORDER_WIDGET_SHARED_ORDER_LIST:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   869
				ShowVehicleListWindow(this->vehicle);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   870
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   871
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   872
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   873
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   874
	virtual void OnQueryTextFinished(char *str)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   875
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   876
		if (!StrEmpty(str)) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   877
			VehicleOrderID sel = this->OrderGetSel();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   878
			uint value = atoi(str);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   879
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   880
			switch (GetVehicleOrder(this->vehicle, sel)->GetConditionVariable()) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   881
				case OCV_MAX_SPEED:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   882
					value = ConvertDisplaySpeedToSpeed(value);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   883
					break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   884
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   885
				case OCV_RELIABILITY:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   886
				case OCV_LOAD_PERCENTAGE:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   887
					value = Clamp(value, 0, 100);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   888
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   889
				default:
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
   890
					break;
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
   891
			}
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   892
			DoCommandP(this->vehicle->tile, this->vehicle->index + (sel << 16), MOF_COND_VALUE | Clamp(value, 0, 2047) << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   893
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   894
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   895
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   896
	virtual void OnDropdownSelect(int widget, int index)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   897
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   898
		switch (widget) {
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   899
			case ORDER_WIDGET_NON_STOP_DROPDOWN:
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   900
				OrderClick_Nonstop(this, index);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   901
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   902
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   903
			case ORDER_WIDGET_FULL_LOAD_DROPDOWN:
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   904
				OrderClick_FullLoad(this, index);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   905
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   906
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   907
			case ORDER_WIDGET_UNLOAD_DROPDOWN:
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   908
				OrderClick_Unload(this, index);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   909
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   910
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   911
			case ORDER_WIDGET_GOTO_DROPDOWN:
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   912
				switch (index) {
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
   913
					case 0: OrderClick_Goto(this, 0); break;
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   914
					case 1: OrderClick_NearestDepot(this, 0); break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   915
					case 2: OrderClick_Conditional(this, 0); break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   916
					default: NOT_REACHED();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   917
				}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   918
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   919
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   920
			case ORDER_WIDGET_COND_VARIABLE:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   921
				DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), MOF_COND_VARIABLE | index << 4,  NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   922
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   923
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   924
			case ORDER_WIDGET_COND_COMPARATOR:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   925
				DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), MOF_COND_COMPARATOR | index << 4,  NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   926
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   927
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   928
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   929
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   930
	virtual void OnDragDrop(Point pt, int widget)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   931
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   932
		switch (widget) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   933
			case ORDER_WIDGET_ORDER_LIST: {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   934
				int from_order = this->OrderGetSel();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   935
				int to_order = this->GetOrderFromPt(pt.y);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   936
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   937
				if (!(from_order == to_order || from_order == INVALID_ORDER || from_order > this->vehicle->num_orders || to_order == INVALID_ORDER || to_order > this->vehicle->num_orders) &&
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   938
						DoCommandP(this->vehicle->tile, this->vehicle->index, from_order | (to_order << 16), NULL, CMD_MOVE_ORDER | CMD_MSG(STR_CAN_T_MOVE_THIS_ORDER))) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   939
					this->selected_order = -1;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   940
				}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   941
			} break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   942
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   943
			case ORDER_WIDGET_DELETE:
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   944
				OrderClick_Delete(this, 0);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   945
				break;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   946
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   947
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   948
		ResetObjectToPlace();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   949
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   950
10731
67db0d431d5e (svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents: 10724
diff changeset
   951
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   952
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   953
		static const KeyToEvent keytoevent[] = {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   954
			{'D', OrderClick_Skip},
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   955
			{'F', OrderClick_Delete},
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   956
			{'G', OrderClick_Goto},
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   957
			{'H', OrderClick_Nonstop},
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   958
			{'J', OrderClick_FullLoad},
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   959
			{'K', OrderClick_Unload},
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   960
			//{'?', OrderClick_Transfer},
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   961
			//('?', OrderClick_Service},
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   962
		};
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   963
10731
67db0d431d5e (svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents: 10724
diff changeset
   964
		if (this->vehicle->owner != _local_player) return ES_NOT_HANDLED;
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   965
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   966
		for (uint i = 0; i < lengthof(keytoevent); i++) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   967
			if (keycode == keytoevent[i].keycode) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   968
				keytoevent[i].proc(this, -1);
10731
67db0d431d5e (svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents: 10724
diff changeset
   969
				return ES_HANDLED;
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   970
			}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   971
		}
10731
67db0d431d5e (svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents: 10724
diff changeset
   972
		return ES_NOT_HANDLED;
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   973
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   974
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   975
	virtual void OnPlaceObject(Point pt, TileIndex tile)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   976
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   977
		if (this->goto_type == OPOS_GOTO) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   978
			/* check if we're clicking on a vehicle first.. clone orders in that case. */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   979
			const Vehicle *v = CheckMouseOverVehicle();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   980
			if (v != NULL && this->HandleOrderVehClick(v)) return;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   981
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   982
			const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   983
			if (!cmd.IsValid()) return;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   984
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   985
			if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), cmd.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   986
				if (this->selected_order != -1) this->selected_order++;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   987
				ResetObjectToPlace();
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   988
			}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   989
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   990
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   991
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   992
	virtual void OnPlaceObjectAbort()
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   993
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   994
		if (this->goto_type == OPOS_CONDITIONAL) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   995
			this->goto_type = OPOS_GOTO;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   996
			if (_cursor.pos.x >= (this->left + this->widget[ORDER_WIDGET_ORDER_LIST].left) &&
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   997
					_cursor.pos.y >= (this->top  + this->widget[ORDER_WIDGET_ORDER_LIST].top) &&
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   998
					_cursor.pos.x <= (this->left + this->widget[ORDER_WIDGET_ORDER_LIST].right) &&
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
   999
					_cursor.pos.y <= (this->top  + this->widget[ORDER_WIDGET_ORDER_LIST].bottom)) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1000
				int order_id = this->GetOrderFromPt(_cursor.pos.y - this->top);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1001
				if (order_id != INVALID_ORDER) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1002
					Order order;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1003
					order.next = NULL;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1004
					order.index = 0;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1005
					order.MakeConditional(order_id);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1006
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1007
					DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), order.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER));
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1008
				}
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1009
			}
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1010
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1011
		this->RaiseWidget(ORDER_WIDGET_GOTO);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1012
		this->InvalidateWidget(ORDER_WIDGET_GOTO);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1013
	}
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1014
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1015
	virtual void OnMouseLoop()
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1016
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1017
		const Vehicle *v = _place_clicked_vehicle;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1018
		/*
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1019
		* Check if we clicked on a vehicle
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1020
		* and if the GOTO button of this window is pressed
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1021
		* This is because of all open order windows WE_MOUSELOOP is called
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1022
		* and if you have 3 windows open, and this check is not done
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1023
		* the order is copied to the last open window instead of the
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1024
		* one where GOTO is enabled
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1025
		*/
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1026
		if (v != NULL && this->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1027
			_place_clicked_vehicle = NULL;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1028
			this->HandleOrderVehClick(v);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1029
		}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1030
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1031
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1032
	virtual void OnResize(Point new_size, Point delta)
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1033
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1034
		/* Update the scroll + matrix */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1035
		this->vscroll.cap = (this->widget[ORDER_WIDGET_ORDER_LIST].bottom - this->widget[ORDER_WIDGET_ORDER_LIST].top) / 10;
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1036
	}
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1037
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1038
	virtual void OnTimeout()
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1039
	{
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1040
		/* unclick all buttons except for the 'goto' button (ORDER_WIDGET_GOTO), which is 'persistent' */
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1041
		for (uint i = 0; i < this->widget_count; i++) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1042
			if (this->IsWidgetLowered(i) && i != ORDER_WIDGET_GOTO) {
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1043
				this->RaiseWidget(i);
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1044
				this->InvalidateWidget(i);
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1045
			}
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1046
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1047
	}
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1048
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1049
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1050
/**
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1051
 * Widget definition for player train orders
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1052
 */
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1053
static const Widget _orders_train_widgets[] = {
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1054
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},               // ORDER_WIDGET_CLOSEBOX
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1055
	{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   385,     0,    13, STR_8829_ORDERS,         STR_018C_WINDOW_TITLE_DRAG_THIS},     // ORDER_WIDGET_CAPTION
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1056
	{ WWT_PUSHTXTBTN,   RESIZE_LR,      14,   325,   385,     0,    13, STR_TIMETABLE_VIEW,      STR_TIMETABLE_VIEW_TOOLTIP},          // ORDER_WIDGET_TIMETABLE_VIEW
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1057
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1058
	{      WWT_PANEL,   RESIZE_RB,      14,     0,   373,    14,    75, 0x0,                     STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1059
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1060
	{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   374,   385,    14,    75, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},    // ORDER_WIDGET_SCROLLBAR
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1061
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1062
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,   123,    88,    99, STR_8823_SKIP,           STR_8853_SKIP_THE_CURRENT_ORDER},     // ORDER_WIDGET_SKIP
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1063
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   124,   247,    88,    99, STR_8824_DELETE,         STR_8854_DELETE_THE_HIGHLIGHTED},     // ORDER_WIDGET_DELETE
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1064
	{   WWT_DROPDOWN,   RESIZE_TB,      14,     0,   123,    76,    87, STR_NULL,                STR_ORDER_TOOLTIP_NON_STOP},          // ORDER_WIDGET_NON_STOP_DROPDOWN
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1065
	{    WWT_TEXTBTN,   RESIZE_TB,      14,     0,   111,    76,    87, STR_ORDER_NON_STOP,      STR_ORDER_TOOLTIP_NON_STOP},          // ORDER_WIDGET_NON_STOP
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1066
	{   WWT_DROPDOWN,   RESIZE_TB,      14,   248,   371,    88,    99, STR_EMPTY,               STR_ORDER_GO_TO_DROPDOWN_TOOLTIP},    // ORDER_WIDGET_GOTO_DROPDOWN
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1067
	{    WWT_TEXTBTN,   RESIZE_TB,      14,   248,   359,    88,    99, STR_8826_GO_TO,          STR_8856_INSERT_A_NEW_ORDER_BEFORE},  // ORDER_WIDGET_GOTO
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1068
	{   WWT_DROPDOWN,   RESIZE_TB,      14,   124,   247,    76,    87, STR_NULL,                STR_ORDER_TOOLTIP_FULL_LOAD},         // ORDER_WIDGET_FULL_LOAD_DROPDOWN
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1069
	{    WWT_TEXTBTN,   RESIZE_TB,      14,   124,   235,    76,    87, STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD},      // ORDER_WIDGET_FULL_LOAD
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1070
	{   WWT_DROPDOWN,   RESIZE_TB,      14,   248,   371,    76,    87, STR_NULL,                STR_ORDER_TOOLTIP_UNLOAD},            // ORDER_WIDGET_UNLOAD_DROPDOWN
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1071
	{    WWT_TEXTBTN,   RESIZE_TB,      14,   248,   359,    76,    87, STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD},            // ORDER_WIDGET_UNLOAD
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
  1072
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   124,   247,    76,    87, STR_REFIT,               STR_REFIT_TIP},                       // ORDER_WIDGET_REFIT
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
  1073
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   248,   371,    76,    87, STR_SERVICE,             STR_SERVICE_HINT},                    // ORDER_WIDGET_SERVICE
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1074
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1075
	{   WWT_DROPDOWN,   RESIZE_TB,      14,     0,   123,    76,    87, STR_NULL,                STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP},   // ORDER_WIDGET_COND_VARIABLE
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1076
	{   WWT_DROPDOWN,   RESIZE_TB,      14,   124,   247,    76,    87, STR_NULL,                STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP}, // ORDER_WIDGET_COND_COMPARATOR
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1077
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   248,   371,    76,    87, STR_CONDITIONAL_VALUE,   STR_ORDER_CONDITIONAL_VALUE_TOOLTIP},      // ORDER_WIDGET_COND_VALUE
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1078
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1079
	{      WWT_PANEL,   RESIZE_RTB,     14,   372,   373,    76,    99, 0x0,                     STR_NULL},                            // ORDER_WIDGET_RESIZE_BAR
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1080
	{ WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,   372,   385,    76,    87, SPR_SHARED_ORDERS_ICON,  STR_VEH_WITH_SHARED_ORDERS_LIST_TIP}, // ORDER_WIDGET_SHARED_ORDER_LIST
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1081
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1082
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   374,   385,    88,    99, 0x0,                     STR_RESIZE_BUTTON},                   // ORDER_WIDGET_RESIZE
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1083
	{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1084
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1085
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1086
static const WindowDesc _orders_train_desc = {
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1087
	WDP_AUTO, WDP_AUTO, 386, 100, 386, 100,
10242
52b4a9006029 (svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents: 10210
diff changeset
  1088
	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
  1089
	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
  1090
	_orders_train_widgets,
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1091
};
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1092
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1093
/**
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1094
 * Widget definition for player orders (!train)
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1095
 */
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1096
static const Widget _orders_widgets[] = {
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1097
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},               // ORDER_WIDGET_CLOSEBOX
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1098
	{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   385,     0,    13, STR_8829_ORDERS,         STR_018C_WINDOW_TITLE_DRAG_THIS},     // ORDER_WIDGET_CAPTION
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1099
	{ WWT_PUSHTXTBTN,   RESIZE_LR,      14,   325,   385,     0,    13, STR_TIMETABLE_VIEW,      STR_TIMETABLE_VIEW_TOOLTIP},          // ORDER_WIDGET_TIMETABLE_VIEW
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1100
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1101
	{      WWT_PANEL,   RESIZE_RB,      14,     0,   373,    14,    75, 0x0,                     STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1102
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1103
	{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   374,   385,    14,    75, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},    // ORDER_WIDGET_SCROLLBAR
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1104
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1105
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,   123,    88,    99, STR_8823_SKIP,           STR_8853_SKIP_THE_CURRENT_ORDER},     // ORDER_WIDGET_SKIP
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1106
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   124,   247,    88,    99, STR_8824_DELETE,         STR_8854_DELETE_THE_HIGHLIGHTED},     // ORDER_WIDGET_DELETE
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1107
	{      WWT_EMPTY,   RESIZE_TB,      14,     0,     0,    76,    87, 0x0,                     0x0},                                 // ORDER_WIDGET_NON_STOP_DROPDOWN
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1108
	{      WWT_EMPTY,   RESIZE_TB,      14,     0,     0,    76,    87, 0x0,                     0x0},                                 // ORDER_WIDGET_NON_STOP
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1109
	{   WWT_DROPDOWN,   RESIZE_TB,      14,   248,   371,    88,    99, STR_EMPTY,               STR_ORDER_GO_TO_DROPDOWN_TOOLTIP},    // ORDER_WIDGET_GOTO_DROPDOWN
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1110
	{    WWT_TEXTBTN,   RESIZE_TB,      14,   248,   359,    88,    99, STR_8826_GO_TO,          STR_8856_INSERT_A_NEW_ORDER_BEFORE},  // ORDER_WIDGET_GOTO
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1111
	{   WWT_DROPDOWN,   RESIZE_TB,      14,     0,   185,    76,    87, STR_NULL,                STR_ORDER_TOOLTIP_FULL_LOAD},         // ORDER_WIDGET_FULL_LOAD_DROPDOWN
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1112
	{    WWT_TEXTBTN,   RESIZE_TB,      14,     0,   173,    76,    87, STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD},      // ORDER_WIDGET_FULL_LOAD
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1113
	{   WWT_DROPDOWN,   RESIZE_TB,      14,   186,   371,    76,    87, STR_NULL,                STR_ORDER_TOOLTIP_UNLOAD},            // ORDER_WIDGET_UNLOAD_DROPDOWN
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1114
	{    WWT_TEXTBTN,   RESIZE_TB,      14,   186,   359,    76,    87, STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD},            // ORDER_WIDGET_UNLOAD
10192
195d7f6dcf71 (svn r12723) [NewGRF_ports] -Sync: with trunk r12645:12656.
richk
parents: 10184
diff changeset
  1115
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,   185,    76,    87, STR_REFIT,               STR_REFIT_TIP},                       // ORDER_WIDGET_REFIT
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1116
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   186,   371,    76,    87, STR_SERVICE,             STR_SERVICE_HINT},                    // ORDER_WIDGET_SERVICE
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1117
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1118
	{   WWT_DROPDOWN,   RESIZE_TB,      14,     0,   123,    76,    87, STR_NULL,                STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP},   // ORDER_WIDGET_COND_VARIABLE
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1119
	{   WWT_DROPDOWN,   RESIZE_TB,      14,   124,   247,    76,    87, STR_NULL,                STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP}, // ORDER_WIDGET_COND_COMPARATOR
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1120
	{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   248,   371,    76,    87, STR_CONDITIONAL_VALUE,   STR_ORDER_CONDITIONAL_VALUE_TOOLTIP},      // ORDER_WIDGET_COND_VALUE
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1121
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1122
	{      WWT_PANEL,   RESIZE_RTB,     14,   372,   373,    76,    99, 0x0,                     STR_NULL},                            // ORDER_WIDGET_RESIZE_BAR
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1123
	{ WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,   372,   385,    76,    87, SPR_SHARED_ORDERS_ICON,  STR_VEH_WITH_SHARED_ORDERS_LIST_TIP}, // ORDER_WIDGET_SHARED_ORDER_LIST
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1124
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1125
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   374,   385,    88,    99, 0x0,                     STR_RESIZE_BUTTON},                   // ORDER_WIDGET_RESIZE
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1126
	{   WIDGETS_END},
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1127
};
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1128
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
  1129
static const WindowDesc _orders_desc = {
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1130
	WDP_AUTO, WDP_AUTO, 386, 100, 386, 100,
10242
52b4a9006029 (svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents: 10210
diff changeset
  1131
	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
  1132
	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
  1133
	_orders_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1134
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1135
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1136
/**
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1137
 * Widget definition for competitor orders
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1138
 */
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
  1139
static const Widget _other_orders_widgets[] = {
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1140
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,           STR_018B_CLOSE_WINDOW},               // ORDER_WIDGET_CLOSEBOX
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1141
	{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   385,     0,    13, STR_8829_ORDERS,    STR_018C_WINDOW_TITLE_DRAG_THIS},     // ORDER_WIDGET_CAPTION
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1142
	{ WWT_PUSHTXTBTN,   RESIZE_LR,      14,   325,   385,     0,    13, STR_TIMETABLE_VIEW, STR_TIMETABLE_VIEW_TOOLTIP},          // ORDER_WIDGET_TIMETABLE_VIEW
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1143
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1144
	{      WWT_PANEL,   RESIZE_RB,      14,     0,   373,    14,    75, 0x0,                STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1145
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1146
	{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   374,   385,    14,    75, 0x0,                STR_0190_SCROLL_BAR_SCROLLS_LIST},    // ORDER_WIDGET_SCROLLBAR
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1147
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1148
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_SKIP
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1149
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_DELETE
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1150
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_NON_STOP_DROPDOWN
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1151
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_NON_STOP
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1152
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_GOTO_DROPDOWN
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1153
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_GOTO
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1154
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_FULL_LOAD_DROPDOWN
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1155
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_FULL_LOAD
10994
cd9968b6f96b (svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents: 10991
diff changeset
  1156
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_UNLOAD_DROPDOWN
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1157
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_UNLOAD
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1158
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_REFIT
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1159
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_SERVICE
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1160
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1161
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_COND_VARIABLE
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1162
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_COND_COMPARATOR
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1163
	{      WWT_EMPTY,   RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_COND_VALUE
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1164
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1165
	{      WWT_PANEL,   RESIZE_RTB,     14,     0,   373,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_RESIZE_BAR
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1166
	{      WWT_EMPTY,   RESIZE_TB,      14,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_SHARED_ORDER_LIST
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1167
10200
aba3af04cdbd (svn r12732) [NewGRF_ports] -Sync: with trunk r12657:12672.
richk
parents: 10192
diff changeset
  1168
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   374,   385,    76,    87, 0x0,                STR_RESIZE_BUTTON},                   // ORDER_WIDGET_RESIZE
6720
35756db7e577 (svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents: 6719
diff changeset
  1169
	{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1170
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1171
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
  1172
static const WindowDesc _other_orders_desc = {
10184
fcf5fb2548eb (svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents: 6878
diff changeset
  1173
	WDP_AUTO, WDP_AUTO, 386, 88, 386, 88,
10242
52b4a9006029 (svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents: 10210
diff changeset
  1174
	WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
  1175
	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
  1176
	_other_orders_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1177
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1178
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1179
void ShowOrdersWindow(const Vehicle *v)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1180
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1181
	VehicleID veh = v->index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1182
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1183
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1184
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1185
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1186
	if (v->owner != _local_player) {
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1187
		new OrdersWindow(&_other_orders_desc, v);
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
  1188
	} else {
10724
68a692eacf22 (svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents: 10242
diff changeset
  1189
		new OrdersWindow((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? &_orders_train_desc : &_orders_desc, v);
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
  1190
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1191
}