src/order_gui.cpp
author rubidium
Wed, 17 Dec 2008 23:08:11 +0000
changeset 10434 3659467c844c
parent 10285 82fa43e7b8f3
permissions -rw-r--r--
(svn r14687) -Change: log all configure errors to config.log
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8969
diff changeset
     3
/** @file order_gui.cpp GUI related to orders. */
6351
8d0b6cce8d6d (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents: 6329
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1857
diff changeset
     6
#include "openttd.h"
3144
33e42feae531 (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
c9d989783c55 (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"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    10
#include "window_gui.h"
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8784
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"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    13
#include "command_func.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8211
diff changeset
    14
#include "viewport_func.h"
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8211
diff changeset
    15
#include "gfx_func.h"
8962
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8961
diff changeset
    16
#include "depot_base.h"
1542
62a03537ad0b (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1530
diff changeset
    17
#include "waypoint.h"
2676
59b65b4fb480 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2668
diff changeset
    18
#include "train.h"
3392
469942e8a0ca (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
f7256d0e7682 (svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents: 4634
diff changeset
    20
#include "vehicle_gui.h"
6980
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6923
diff changeset
    21
#include "timetable.h"
6091
c8827d9ae04a (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: 5984
diff changeset
    22
#include "cargotype.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8108
diff changeset
    23
#include "strings_func.h"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8121
diff changeset
    24
#include "window_func.h"
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8139
diff changeset
    25
#include "vehicle_func.h"
8211
29a8510dfd62 (svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium
parents: 8144
diff changeset
    26
#include "settings_type.h"
10208
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
    27
#include "company_func.h"
8787
41d9d5adbe87 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents: 8785
diff changeset
    28
#include "newgrf_cargo.h"
8877
f09f03b0dc64 (svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
rubidium
parents: 8876
diff changeset
    29
#include "widgets/dropdown_func.h"
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
    30
#include "textbuf_gui.h"
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
    31
#include "string_func.h"
8962
1b263c69799d (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 8961
diff changeset
    32
#include "depot_base.h"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9116
diff changeset
    33
#include "tilehighlight_func.h"
10184
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
    34
#include "network/network.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    36
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    37
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    38
5828
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    39
enum OrderWindowWidgets {
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    40
	ORDER_WIDGET_CLOSEBOX = 0,
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    41
	ORDER_WIDGET_CAPTION,
6980
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6923
diff changeset
    42
	ORDER_WIDGET_TIMETABLE_VIEW,
5828
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    43
	ORDER_WIDGET_ORDER_LIST,
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    44
	ORDER_WIDGET_SCROLLBAR,
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    45
	ORDER_WIDGET_SKIP,
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    46
	ORDER_WIDGET_DELETE,
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
    47
	ORDER_WIDGET_NON_STOP_DROPDOWN,
5828
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    48
	ORDER_WIDGET_NON_STOP,
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
    49
	ORDER_WIDGET_GOTO_DROPDOWN,
5828
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    50
	ORDER_WIDGET_GOTO,
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
    51
	ORDER_WIDGET_FULL_LOAD_DROPDOWN,
5828
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    52
	ORDER_WIDGET_FULL_LOAD,
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
    53
	ORDER_WIDGET_UNLOAD_DROPDOWN,
5828
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    54
	ORDER_WIDGET_UNLOAD,
5829
580c0b309122 (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: 5828
diff changeset
    55
	ORDER_WIDGET_REFIT,
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
    56
	ORDER_WIDGET_SERVICE_DROPDOWN,
8874
db064c1eb143 (svn r12641) -Codechange: do not use the same button for two completely distinct tasks, just make an extra button for it and hide them when not needed.
rubidium
parents: 8873
diff changeset
    57
	ORDER_WIDGET_SERVICE,
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
    58
	ORDER_WIDGET_COND_VARIABLE,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
    59
	ORDER_WIDGET_COND_COMPARATOR,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
    60
	ORDER_WIDGET_COND_VALUE,
8874
db064c1eb143 (svn r12641) -Codechange: do not use the same button for two completely distinct tasks, just make an extra button for it and hide them when not needed.
rubidium
parents: 8873
diff changeset
    61
	ORDER_WIDGET_RESIZE_BAR,
5828
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    62
	ORDER_WIDGET_SHARED_ORDER_LIST,
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    63
	ORDER_WIDGET_RESIZE,
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    64
};
e7b332dac5e8 (svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents: 5745
diff changeset
    65
8876
e5bf23efad87 (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 8874
diff changeset
    66
/** Order load types that could be given to station orders. */
e5bf23efad87 (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 8874
diff changeset
    67
static const StringID _station_load_types[][5] = {
8845
f9ef3bb70e47 (svn r12595) -Codechange: hide Order's flags in the last few cases.
rubidium
parents: 8843
diff changeset
    68
	{
8876
e5bf23efad87 (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 8874
diff changeset
    69
		STR_EMPTY,
8885
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    70
		INVALID_STRING_ID,
8876
e5bf23efad87 (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 8874
diff changeset
    71
		STR_ORDER_FULL_LOAD,
e5bf23efad87 (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 8874
diff changeset
    72
		STR_ORDER_FULL_LOAD_ANY,
e5bf23efad87 (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 8874
diff changeset
    73
		STR_ORDER_NO_LOAD,
8845
f9ef3bb70e47 (svn r12595) -Codechange: hide Order's flags in the last few cases.
rubidium
parents: 8843
diff changeset
    74
	}, {
8885
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    75
		STR_ORDER_UNLOAD,
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    76
		INVALID_STRING_ID,
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    77
		STR_ORDER_UNLOAD_FULL_LOAD,
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    78
		STR_ORDER_UNLOAD_FULL_LOAD_ANY,
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    79
		STR_ORDER_UNLOAD_NO_LOAD,
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    80
	}, {
8876
e5bf23efad87 (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 8874
diff changeset
    81
		STR_ORDER_TRANSFER,
8885
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    82
		INVALID_STRING_ID,
8876
e5bf23efad87 (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 8874
diff changeset
    83
		STR_ORDER_TRANSFER_FULL_LOAD,
e5bf23efad87 (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 8874
diff changeset
    84
		STR_ORDER_TRANSFER_FULL_LOAD_ANY,
8885
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    85
		STR_ORDER_TRANSFER_NO_LOAD,
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    86
	}, {
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    87
		/* Unload and transfer do not work together. */
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    88
		INVALID_STRING_ID,
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    89
		INVALID_STRING_ID,
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
    90
		INVALID_STRING_ID,
8876
e5bf23efad87 (svn r12643) -Codechange: be more explicit about the orders a vehicle has (non stop and full load are ambiguous and depend on some patch settings).
rubidium
parents: 8874
diff changeset
    91
		INVALID_STRING_ID,
8883
baee554a9449 (svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium
parents: 8882
diff changeset
    92
	}, {
baee554a9449 (svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium
parents: 8882
diff changeset
    93
		STR_ORDER_NO_UNLOAD,
baee554a9449 (svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium
parents: 8882
diff changeset
    94
		INVALID_STRING_ID,
baee554a9449 (svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium
parents: 8882
diff changeset
    95
		STR_ORDER_NO_UNLOAD_FULL_LOAD,
baee554a9449 (svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium
parents: 8882
diff changeset
    96
		STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
baee554a9449 (svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium
parents: 8882
diff changeset
    97
		INVALID_STRING_ID,
8845
f9ef3bb70e47 (svn r12595) -Codechange: hide Order's flags in the last few cases.
rubidium
parents: 8843
diff changeset
    98
	}
1935
164d58b9137c (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    99
};
164d58b9137c (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   100
8888
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   101
static const StringID _order_non_stop_drowdown[] = {
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   102
	STR_ORDER_GO_TO,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   103
	STR_ORDER_GO_NON_STOP_TO,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   104
	STR_ORDER_GO_VIA,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   105
	STR_ORDER_GO_NON_STOP_VIA,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   106
	INVALID_STRING_ID
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   107
};
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   108
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   109
static const StringID _order_full_load_drowdown[] = {
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   110
	STR_ORDER_DROP_LOAD_IF_POSSIBLE,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   111
	STR_EMPTY,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   112
	STR_ORDER_DROP_FULL_LOAD_ALL,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   113
	STR_ORDER_DROP_FULL_LOAD_ANY,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   114
	STR_ORDER_DROP_NO_LOADING,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   115
	INVALID_STRING_ID
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   116
};
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   117
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   118
static const StringID _order_unload_drowdown[] = {
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   119
	STR_ORDER_DROP_UNLOAD_IF_ACCEPTED,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   120
	STR_ORDER_DROP_UNLOAD,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   121
	STR_ORDER_DROP_TRANSFER,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   122
	STR_EMPTY,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   123
	STR_ORDER_DROP_NO_UNLOADING,
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   124
	INVALID_STRING_ID
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   125
};
19fb42a62eb4 (svn r12655) -Change: show the current state in the drop down 'buttons'.
rubidium
parents: 8887
diff changeset
   126
8894
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   127
static const StringID _order_goto_dropdown[] = {
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   128
	STR_ORDER_GO_TO,
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   129
	STR_ORDER_GO_TO_NEAREST_DEPOT,
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   130
	STR_ORDER_CONDITIONAL,
8894
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   131
	INVALID_STRING_ID
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   132
};
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   133
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   134
static const StringID _order_goto_dropdown_aircraft[] = {
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   135
	STR_ORDER_GO_TO,
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   136
	STR_ORDER_GO_TO_NEAREST_HANGAR,
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   137
	STR_ORDER_CONDITIONAL,
8894
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   138
	INVALID_STRING_ID
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   139
};
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   140
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   141
static const StringID _order_conditional_variable[] = {
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   142
	STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   143
	STR_ORDER_CONDITIONAL_RELIABILITY,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   144
	STR_ORDER_CONDITIONAL_MAX_SPEED,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   145
	STR_ORDER_CONDITIONAL_AGE,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   146
	STR_ORDER_CONDITIONAL_REQUIRES_SERVICE,
8903
04bcd0e7d4d6 (svn r12670) -Add: unconditional/always order 'jump/skip' variable.
rubidium
parents: 8900
diff changeset
   147
	STR_ORDER_CONDITIONAL_UNCONDITIONALLY,
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   148
	INVALID_STRING_ID,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   149
};
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   150
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   151
static const StringID _order_conditional_condition[] = {
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   152
	STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   153
	STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   154
	STR_ORDER_CONDITIONAL_COMPARATOR_LESS_THAN,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   155
	STR_ORDER_CONDITIONAL_COMPARATOR_LESS_EQUALS,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   156
	STR_ORDER_CONDITIONAL_COMPARATOR_MORE_THAN,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   157
	STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   158
	STR_ORDER_CONDITIONAL_COMPARATOR_IS_TRUE,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   159
	STR_ORDER_CONDITIONAL_COMPARATOR_IS_FALSE,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   160
	INVALID_STRING_ID,
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   161
};
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   162
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   163
extern uint ConvertSpeedToDisplaySpeed(uint speed);
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   164
extern uint ConvertDisplaySpeedToSpeed(uint speed);
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   165
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   166
static const StringID _order_depot_action_dropdown[] = {
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   167
	STR_ORDER_DROP_GO_ALWAYS_DEPOT,
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   168
	STR_ORDER_DROP_SERVICE_DEPOT,
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   169
	STR_ORDER_DROP_HALT_DEPOT,
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   170
	INVALID_STRING_ID
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   171
};
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   172
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   173
static int DepotActionStringIndex(const Order *order)
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   174
{
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   175
	if (order->GetDepotActionType() & ODATFB_HALT) {
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   176
		return DA_STOP;
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   177
	} else if (order->GetDepotOrderType() & ODTFB_SERVICE) {
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   178
		return DA_SERVICE;
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   179
	} else {
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   180
		return DA_ALWAYS_GO;
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   181
	}
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   182
}
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   183
9639
58530f2b5fdc (svn r13702) -Fix: do not overflow the order/timetable window when 'long' orders are displayed.
rubidium
parents: 9485
diff changeset
   184
void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable, int width)
8929
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   185
{
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   186
	StringID str = (v->cur_order_index == order_index) ? STR_8805 : STR_8804;
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   187
	SetDParam(6, STR_EMPTY);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   188
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   189
	switch (order->GetType()) {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   190
		case OT_DUMMY:
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   191
			SetDParam(1, STR_INVALID_ORDER);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   192
			SetDParam(2, order->GetDestination());
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   193
			break;
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   194
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   195
		case OT_GOTO_STATION: {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   196
			OrderLoadFlags load = order->GetLoadType();
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   197
			OrderUnloadFlags unload = order->GetUnloadType();
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   198
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   199
			SetDParam(1, STR_GO_TO_STATION);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   200
			SetDParam(2, STR_ORDER_GO_TO + ((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? order->GetNonStopType() : 0));
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   201
			SetDParam(3, order->GetDestination());
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   202
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   203
			if (timetable) {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   204
				SetDParam(4, STR_EMPTY);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   205
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   206
				if (order->wait_time > 0) {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   207
					SetDParam(6, STR_TIMETABLE_STAY_FOR);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   208
					SetTimetableParams(7, 8, order->wait_time);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   209
				}
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   210
			} else {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   211
				SetDParam(4, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ? STR_EMPTY : _station_load_types[unload][load]);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   212
			}
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   213
		} break;
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   214
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   215
		case OT_GOTO_DEPOT:
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   216
			if (v->type == VEH_AIRCRAFT) {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   217
				if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   218
					SetDParam(1, STR_GO_TO_NEAREST_DEPOT);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   219
					SetDParam(3, STR_ORDER_NEAREST_HANGAR);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   220
				} else {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   221
					SetDParam(1, STR_GO_TO_HANGAR);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   222
					SetDParam(3, order->GetDestination());
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   223
				}
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   224
				SetDParam(4, STR_EMPTY);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   225
			} else {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   226
				if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   227
					SetDParam(1, STR_GO_TO_NEAREST_DEPOT);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   228
					SetDParam(3, STR_ORDER_NEAREST_DEPOT);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   229
				} else {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   230
					SetDParam(1, STR_GO_TO_DEPOT);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   231
					SetDParam(3, GetDepot(order->GetDestination())->town_index);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   232
				}
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   233
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   234
				switch (v->type) {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   235
					case VEH_TRAIN: SetDParam(4, STR_ORDER_TRAIN_DEPOT); break;
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   236
					case VEH_ROAD:  SetDParam(4, STR_ORDER_ROAD_DEPOT); break;
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   237
					case VEH_SHIP:  SetDParam(4, STR_ORDER_SHIP_DEPOT); break;
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   238
					default: NOT_REACHED();
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   239
				}
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   240
			}
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   241
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   242
			if (order->GetDepotOrderType() & ODTFB_SERVICE) {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   243
				SetDParam(2, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_SERVICE_NON_STOP_AT : STR_ORDER_SERVICE_AT);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   244
			} else {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   245
				SetDParam(2, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO : STR_ORDER_GO_TO);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   246
			}
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   247
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   248
			if (!timetable && (order->GetDepotActionType() & ODATFB_HALT)) {
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   249
				SetDParam(6, STR_STOP_ORDER);
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   250
			}
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   251
8929
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   252
			if (!timetable && order->IsRefit()) {
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   253
				SetDParam(6, (order->GetDepotActionType() & ODATFB_HALT) ? STR_REFIT_STOP_ORDER : STR_REFIT_ORDER);
8929
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   254
				SetDParam(7, GetCargo(order->GetRefitCargo())->name);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   255
			}
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   256
			break;
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   257
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   258
		case OT_GOTO_WAYPOINT:
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   259
			SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   260
			SetDParam(2, order->GetDestination());
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   261
			break;
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   262
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   263
		case OT_CONDITIONAL:
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   264
			SetDParam(2, order->GetConditionSkipToOrder() + 1);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   265
			if (order->GetConditionVariable() == OCV_UNCONDITIONALLY) {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   266
				SetDParam(1, STR_CONDITIONAL_UNCONDITIONAL);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   267
			} else {
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   268
				OrderConditionComparator occ = order->GetConditionComparator();
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   269
				SetDParam(1, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_CONDITIONAL_TRUE_FALSE : STR_CONDITIONAL_NUM);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   270
				SetDParam(3, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable());
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   271
				SetDParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   272
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   273
				uint value = order->GetConditionValue();
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   274
				if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   275
				SetDParam(5, value);
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   276
			}
9641
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
   277
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
   278
			if (timetable && order->wait_time > 0) {
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
   279
				SetDParam(6, STR_TIMETABLE_AND_TRAVEL_FOR);
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
   280
				SetTimetableParams(7, 8, order->wait_time);
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
   281
			} else {
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
   282
				SetDParam(6, STR_EMPTY);
a854c7cf6af5 (svn r13704) -Fix: make timetables work more sensible when used in conjunction with conditional orders, i.e. make it possibly to tell how long to travel to the next destination if you jump.
rubidium
parents: 9639
diff changeset
   283
			}
8929
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   284
			break;
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   285
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   286
		default: NOT_REACHED();
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   287
	}
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   288
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   289
	SetDParam(0, order_index + 1);
9639
58530f2b5fdc (svn r13702) -Fix: do not overflow the order/timetable window when 'long' orders are displayed.
rubidium
parents: 9485
diff changeset
   290
	DrawStringTruncated(2, y, str, selected ? TC_WHITE : TC_BLACK, width);
8929
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   291
}
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   292
ebb6e864b545 (svn r12699) -Codechange: Unify the order drawing code for orders and timetables.
maedhros
parents: 8919
diff changeset
   293
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2186
diff changeset
   294
static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
{
558
1ae2a752501e (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   296
	Order order;
3387
a779ba33aab4 (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
   297
	order.next  = NULL;
a779ba33aab4 (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
   298
	order.index = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   300
	/* check depot first */
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   301
	if (_settings_game.order.gotodepot) {
1214
8262981ac274 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   302
		switch (GetTileType(tile)) {
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   303
			case MP_RAILWAY:
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
   304
				if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_company)) {
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   305
					if (IsRailDepot(tile)) {
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   306
						order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   307
						if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   308
						return order;
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   309
					}
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   310
				}
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   311
				break;
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   312
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   313
			case MP_ROAD:
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
   314
				if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_company)) {
8853
3266f0374302 (svn r12615) -Codechange: rename some enums related to depot orders to make it more clear that they are no loading/unloading flags. Also add more type strictness.
rubidium
parents: 8848
diff changeset
   315
					order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   316
					if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
558
1ae2a752501e (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   317
					return order;
560
60e198893a41 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   318
				}
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   319
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   321
			case MP_STATION:
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   322
				if (v->type != VEH_AIRCRAFT) break;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
   323
				if (IsHangar(tile) && IsTileOwner(tile, _local_company)) {
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   324
					order.MakeGoToDepot(GetStationIndex(tile), ODTFB_PART_OF_ORDERS);
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   325
					return order;
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   326
				}
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   327
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   329
			case MP_WATER:
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   330
				if (v->type != VEH_SHIP) break;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
   331
				if (IsShipDepot(tile) && IsTileOwner(tile, _local_company)) {
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   332
					TileIndex tile2 = GetOtherShipDepotTile(tile);
3392
469942e8a0ca (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
   333
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   334
					order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS);
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   335
					return order;
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   336
				}
1214
8262981ac274 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   337
8262981ac274 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   338
			default:
8262981ac274 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   339
				break;
0
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
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   343
	/* check waypoint */
10099
a42cafcba550 (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz
parents: 9942
diff changeset
   344
	if (IsRailWaypointTile(tile) &&
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6091
diff changeset
   345
			v->type == VEH_TRAIN &&
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
   346
			IsTileOwner(tile, _local_company)) {
8836
f6f1ea3d7e93 (svn r12584) -Codechange: do not access the order type directly.
rubidium
parents: 8787
diff changeset
   347
		order.MakeGoToWaypoint(GetWaypointByTile(tile)->index);
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   348
		if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
558
1ae2a752501e (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   349
		return order;
1ae2a752501e (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   350
	}
319
1769185de5f5 (svn r329) Fix: [ 1035066 ] 'Allow goto depot' turned off, no checkpoints in orders
dominik
parents: 193
diff changeset
   351
1035
812f837ee03f (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
   352
	if (IsTileType(tile, MP_STATION)) {
3315
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents: 3269
diff changeset
   353
		StationID st_index = GetStationIndex(tile);
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   354
		const Station *st = GetStation(st_index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
   356
		if (st->owner == _current_company || st->owner == OWNER_NONE) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
			byte facil;
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   358
			(facil = FACIL_DOCK, v->type == VEH_SHIP) ||
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   359
			(facil = FACIL_TRAIN, v->type == VEH_TRAIN) ||
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   360
			(facil = FACIL_AIRPORT, v->type == VEH_AIRCRAFT) ||
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   361
			(facil = FACIL_BUS_STOP, v->type == VEH_ROAD && IsCargoInClass(v->cargo_type, CC_PASSENGERS)) ||
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   362
			(facil = FACIL_TRUCK_STOP, 1);
558
1ae2a752501e (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   363
			if (st->facilities & facil) {
8836
f6f1ea3d7e93 (svn r12584) -Codechange: do not access the order type directly.
rubidium
parents: 8787
diff changeset
   364
				order.MakeGoToStation(st_index);
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   365
				if (_settings_client.gui.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
558
1ae2a752501e (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   366
				return order;
1ae2a752501e (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   367
			}
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
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   371
	/* not found */
6263
6bd0726c74e2 (svn r9072) -Codechange: [Orders] added methods to orders to free them and check if they are in use
bjarni
parents: 6259
diff changeset
   372
	order.Free();
558
1ae2a752501e (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   373
	return order;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   376
struct OrdersWindow : public Window {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   377
private:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   378
	/** Under what reason are we using the PlaceObject functionality? */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   379
	enum OrderPlaceObjectState {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   380
		OPOS_GOTO,
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   381
		OPOS_CONDITIONAL,
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   382
	};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   384
	int selected_order;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   385
	OrderPlaceObjectState goto_type;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   386
	const Vehicle *vehicle;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   388
	/**
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   389
	 * Return the memorised selected order.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   390
	 * @return the memorised order if it is a vaild one
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   391
	 *  else return the number of orders
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   392
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   393
	int OrderGetSel()
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   394
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   395
		int num = this->selected_order;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   396
		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
   397
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   399
	/**
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   400
	 * Calculate the selected order.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   401
	 * The calculation is based on the relative (to the window) y click position and
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   402
	 *  the position of the scrollbar.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   403
	 *
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   404
	 * @param y Y-value of the click relative to the window origin
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   405
	 * @param v current vehicle
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   406
	 * @return the new selected order if the order is valid else return that
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   407
	 *  an invalid one has been selected.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   408
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   409
	int GetOrderFromPt(int y)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   410
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   411
		/*
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   412
		 * Calculation description:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   413
		 * 15 = 14 (w->widget[ORDER_WIDGET_ORDER_LIST].top) + 1 (frame-line)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   414
		 * 10 = order text hight
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   415
		 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   416
		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
   417
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   418
		if ((uint)sel >= this->vscroll.cap) return INVALID_ORDER;
1000
db05d7d665b4 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   419
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   420
		sel += this->vscroll.pos;
8869
8a3dac8dc505 (svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium
parents: 8861
diff changeset
   421
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   422
		return (sel <= vehicle->num_orders && sel >= 0) ? sel : INVALID_ORDER;
8881
ad608e8305ad (svn r12648) -Feature: allow four different non-stop types in a single game instead of two. The "TTDP compatible order" setting now only sets the default behaviour of new trains.
rubidium
parents: 8877
diff changeset
   423
	}
8894
66472a0a6eb2 (svn r12661) -Add: ability to send a vehicle (using default orders) to the nearest depot.
rubidium
parents: 8893
diff changeset
   424
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   425
	bool HandleOrderVehClick(const Vehicle *u)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   426
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   427
		if (u->type != this->vehicle->type) return false;
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   428
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   429
		if (!u->IsPrimaryVehicle()) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   430
			u = u->First();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   431
			if (!u->IsPrimaryVehicle()) return false;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   432
		}
8869
8a3dac8dc505 (svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium
parents: 8861
diff changeset
   433
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   434
		/* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   435
		 * obviously if you press CTRL on a non-empty orders vehicle you know what you are doing */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   436
		if (this->vehicle->num_orders != 0 && _ctrl_pressed == 0) return false;
8885
647cda0e9312 (svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
rubidium
parents: 8883
diff changeset
   437
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   438
		if (DoCommandP(this->vehicle->tile, this->vehicle->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY, NULL,
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   439
			_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   440
			this->selected_order = -1;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   441
			ResetObjectToPlace();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   442
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   443
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   444
		return true;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   445
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   446
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   447
	/**
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   448
	 * Handle the click on the goto button.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   449
	 *
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   450
	 * @param w current window
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   451
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   452
	static void OrderClick_Goto(OrdersWindow *w, int i)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   453
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   454
		w->InvalidateWidget(ORDER_WIDGET_GOTO);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   455
		w->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   456
		if (w->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   457
			_place_clicked_vehicle = NULL;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   458
			SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, VHM_RECT, w);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   459
			w->goto_type = OPOS_GOTO;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   460
		} else {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   461
			ResetObjectToPlace();
8883
baee554a9449 (svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium
parents: 8882
diff changeset
   462
		}
baee554a9449 (svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium
parents: 8882
diff changeset
   463
	}
baee554a9449 (svn r12650) -Feature: ability to force a vehicle to not load at a station.
rubidium
parents: 8882
diff changeset
   464
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   465
	/**
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   466
	 * Handle the click on the full load button.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   467
	 *
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   468
	 * @param w current window
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   469
	 * @param load_type the way to load.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   470
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   471
	static void OrderClick_FullLoad(OrdersWindow *w, int load_type)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   472
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   473
		VehicleOrderID sel_ord = w->OrderGetSel();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   474
		const Order *order = GetVehicleOrder(w->vehicle, sel_ord);
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   475
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   476
		if (order == NULL || order->GetLoadType() == load_type) return;
8869
8a3dac8dc505 (svn r12636) -Codechange: make CmdModifyOrder a little more flexible and remove 'hack' that used the full load flag to set the service if needed flag.
rubidium
parents: 8861
diff changeset
   477
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   478
		if (load_type < 0) {
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   479
			load_type = order->GetLoadType() == OLF_LOAD_IF_POSSIBLE ? OLF_FULL_LOAD_ANY : OLF_LOAD_IF_POSSIBLE;
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   480
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   481
		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));
8877
f09f03b0dc64 (svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
rubidium
parents: 8876
diff changeset
   482
	}
f09f03b0dc64 (svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
rubidium
parents: 8876
diff changeset
   483
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   484
	/**
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   485
	 * Handle the click on the service.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   486
	 *
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   487
	 * @param w current window
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   488
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   489
	static void OrderClick_Service(OrdersWindow *w, int i)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   490
	{
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   491
		VehicleOrderID sel_ord = w->OrderGetSel();
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   492
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   493
		if (i < 0) {
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   494
			const Order *order = GetVehicleOrder(w->vehicle, sel_ord);
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   495
			if (order == NULL) return;
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   496
			i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE;
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   497
		}
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   498
		DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_DEPOT_ACTION | (i << 4), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
4712
4335ad42e163 (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   499
	}
1000
db05d7d665b4 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   500
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   501
	/**
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   502
	 * Handle the click on the service in nearest depot button.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   503
	 *
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   504
	 * @param w current window
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   505
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   506
	static void OrderClick_NearestDepot(OrdersWindow *w, int i)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   507
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   508
		Order order;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   509
		order.next = NULL;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   510
		order.index = 0;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   511
		order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   512
		order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
6832
fec0caeac27d (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 6807
diff changeset
   513
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   514
		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));
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   515
	}
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   516
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   517
	/**
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   518
	 * Handle the click on the conditional order button.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   519
	 *
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   520
	 * @param w current window
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   521
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   522
	static void OrderClick_Conditional(OrdersWindow *w, int i)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   523
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   524
		w->InvalidateWidget(ORDER_WIDGET_GOTO);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   525
		w->LowerWidget(ORDER_WIDGET_GOTO);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   526
		SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, VHM_RECT, w);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   527
		w->goto_type = OPOS_CONDITIONAL;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   528
	}
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   529
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   530
	/**
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   531
	 * Handle the click on the unload button.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   532
	 *
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   533
	 * @param w current window
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   534
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   535
	static void OrderClick_Unload(OrdersWindow *w, int unload_type)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   536
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   537
		VehicleOrderID sel_ord = w->OrderGetSel();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   538
		const Order *order = GetVehicleOrder(w->vehicle, sel_ord);
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   539
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   540
		if (order == NULL || order->GetUnloadType() == unload_type) return;
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   541
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   542
		if (unload_type < 0) {
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   543
			unload_type = order->GetUnloadType() == OUF_UNLOAD_IF_POSSIBLE ? OUFB_UNLOAD : OUF_UNLOAD_IF_POSSIBLE;
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   544
		}
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   545
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   546
		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));
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   547
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   548
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   549
	/**
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   550
	 * Handle the click on the nonstop button.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   551
	 *
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   552
	 * @param w current window
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   553
	 * @param non_stop what non-stop type to use; -1 to use the 'next' one.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   554
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   555
	static void OrderClick_Nonstop(OrdersWindow *w, int non_stop)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   556
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   557
		VehicleOrderID sel_ord = w->OrderGetSel();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   558
		const Order *order = GetVehicleOrder(w->vehicle, sel_ord);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   559
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   560
		if (order == NULL || order->GetNonStopType() == non_stop) return;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   561
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   562
		/* Keypress if negative, so 'toggle' to the next */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   563
		if (non_stop < 0) {
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   564
			non_stop = order->GetNonStopType() ^ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS;
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   565
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   566
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   567
		w->InvalidateWidget(ORDER_WIDGET_NON_STOP);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   568
		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));
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   569
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   570
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   571
	/**
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   572
	 * Handle the click on the skip button.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   573
	 * If ctrl is pressed skip to selected order.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   574
	 *  Else skip to current order + 1
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   575
	 *
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   576
	 * @param w current window
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   577
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   578
	static void OrderClick_Skip(OrdersWindow *w, int i)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   579
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   580
		/* Don't skip when there's nothing to skip */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   581
		if (_ctrl_pressed && w->vehicle->cur_order_index == w->OrderGetSel()) return;
10184
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   582
		if (w->vehicle->num_orders <= 1) return;
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   583
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   584
		DoCommandP(w->vehicle->tile, w->vehicle->index, _ctrl_pressed ? w->OrderGetSel() : ((w->vehicle->cur_order_index + 1) % w->vehicle->num_orders),
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   585
				NULL, CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_CAN_T_SKIP_TO_ORDER : STR_CAN_T_SKIP_ORDER));
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   586
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   587
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   588
	/**
10184
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   589
	 * Handle the click on the delete button.
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   590
	 *
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   591
	 * @param w current window
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   592
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   593
	static void OrderClick_Delete(OrdersWindow *w, int i)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   594
	{
10184
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   595
		/* When networking, move one order lower */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   596
		int selected = w->selected_order + (int)_networking;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   597
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   598
		if (DoCommandP(w->vehicle->tile, w->vehicle->index, w->OrderGetSel(), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER))) {
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   599
			w->selected_order = selected >= w->vehicle->num_orders ? -1 : selected;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   600
		}
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   601
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   602
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   603
	/**
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   604
	 * Handle the click on the refit button.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   605
	 * If ctrl is pressed cancel refitting.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   606
	 *  Else show the refit window.
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   607
	 *
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   608
	 * @param w current window
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   609
	 */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   610
	static void OrderClick_Refit(OrdersWindow *w, int i)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   611
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   612
		if (_ctrl_pressed) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   613
			/* Cancel refitting */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   614
			DoCommandP(w->vehicle->tile, w->vehicle->index, (w->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   615
		} else {
10184
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   616
			ShowVehicleRefitWindow(w->vehicle, w->OrderGetSel(), w);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   617
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   618
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   619
	typedef void Handler(OrdersWindow*, int);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   620
	struct KeyToEvent {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   621
		uint16 keycode;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   622
		Handler *proc;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   623
	};
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   624
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   625
public:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   626
	OrdersWindow(const WindowDesc *desc, const Vehicle *v) : Window(desc, v->index)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   627
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   628
		this->caption_color = v->owner;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   629
		this->vscroll.cap = 6;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   630
		this->resize.step_height = 10;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   631
		this->selected_order = -1;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   632
		this->vehicle = v;
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   633
		if (_settings_game.order.timetabling) {
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   634
			this->widget[ORDER_WIDGET_CAPTION].right -= 61;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   635
		} else {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   636
			this->HideWidget(ORDER_WIDGET_TIMETABLE_VIEW);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   637
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   638
		this->FindWindowPlacementAndResize(desc);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   639
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   640
10184
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   641
	virtual void OnInvalidateData(int data)
9862
f801c7d84353 (svn r14007) -Fix [FS#2098]: Notify vehicle windows when their internal state is botched up from outside.
frosch
parents: 9760
diff changeset
   642
	{
10184
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   643
		switch (data) {
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   644
			case 0:
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   645
				/* Autoreplace replaced the vehicle */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   646
				this->vehicle = GetVehicle(this->window_number);
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   647
				break;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   648
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   649
			case -1:
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   650
				/* Removed / replaced all orders (after deleting / sharing) */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   651
				if (this->selected_order == -1) break;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   652
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   653
				this->DeleteChildWindows();
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   654
				HideDropDownMenu(this);
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   655
				this->selected_order = -1;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   656
				break;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   657
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   658
			default: {
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   659
				/* Moving an order. If one of these is INVALID_VEH_ORDER_ID, then
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   660
				 * the order is being created / removed */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   661
				if (this->selected_order == -1) break;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   662
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   663
				VehicleOrderID from = GB(data, 0, 8);
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   664
				VehicleOrderID to   = GB(data, 8, 8);
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   665
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   666
				if (from == to) break; // no need to change anything
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   667
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   668
				if (from != this->selected_order) {
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   669
					/* Moving from preceeding order? */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   670
					this->selected_order -= (int)(from <= this->selected_order);
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   671
					/* Moving to   preceeding order? */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   672
					this->selected_order += (int)(to   <= this->selected_order);
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   673
					break;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   674
				}
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   675
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   676
				/* Now we are modifying the selected order */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   677
				if (to == INVALID_VEH_ORDER_ID) {
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   678
					/* Deleting selected order */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   679
					this->DeleteChildWindows();
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   680
					HideDropDownMenu(this);
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   681
					this->selected_order = -1;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   682
					break;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   683
				}
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   684
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   685
				/* Moving selected order */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   686
				this->selected_order = to;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   687
			} break;
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   688
		}
9862
f801c7d84353 (svn r14007) -Fix [FS#2098]: Notify vehicle windows when their internal state is botched up from outside.
frosch
parents: 9760
diff changeset
   689
	}
f801c7d84353 (svn r14007) -Fix [FS#2098]: Notify vehicle windows when their internal state is botched up from outside.
frosch
parents: 9760
diff changeset
   690
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   691
	virtual void OnPaint()
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   692
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   693
		bool shared_orders = this->vehicle->IsOrderListShared();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   694
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   695
		SetVScrollCount(this, this->vehicle->num_orders + 1);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   696
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   697
		int sel = OrderGetSel();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   698
		const Order *order = GetVehicleOrder(this->vehicle, sel);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   699
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
   700
		if (this->vehicle->owner == _local_company) {
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   701
			/* Set the strings for the dropdown boxes. */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   702
			this->widget[ORDER_WIDGET_COND_VARIABLE].data   = _order_conditional_variable[order == NULL ? 0 : order->GetConditionVariable()];
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   703
			this->widget[ORDER_WIDGET_COND_COMPARATOR].data = _order_conditional_condition[order == NULL ? 0 : order->GetConditionComparator()];
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   704
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   705
			/* skip */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   706
			this->SetWidgetDisabledState(ORDER_WIDGET_SKIP, this->vehicle->num_orders <= 1);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   707
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   708
			/* delete */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   709
			this->SetWidgetDisabledState(ORDER_WIDGET_DELETE,
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   710
					(uint)this->vehicle->num_orders + ((shared_orders || this->vehicle->num_orders != 0) ? 1 : 0) <= (uint)this->selected_order);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   711
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   712
			/* non-stop only for trains */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   713
			this->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP,  (this->vehicle->type != VEH_TRAIN && this->vehicle->type != VEH_ROAD) || order == NULL);
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   714
			this->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP_DROPDOWN, this->IsWidgetDisabled(ORDER_WIDGET_NON_STOP));
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   715
			this->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD, order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // full load
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   716
			this->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD_DROPDOWN, this->IsWidgetDisabled(ORDER_WIDGET_FULL_LOAD));
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   717
			this->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD,    order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   718
			this->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD_DROPDOWN, this->IsWidgetDisabled(ORDER_WIDGET_UNLOAD));
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   719
			/* Disable list of vehicles with the same shared orders if there is no list */
9942
c3677fa5563f (svn r14097) -Fix [FS#2085]: one couldn't get a list of vehicles sharing an order when the number of orders was 0; you could see that the vehicles had a shared order though.
rubidium
parents: 9862
diff changeset
   720
			this->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   721
			this->SetWidgetDisabledState(ORDER_WIDGET_REFIT,     order == NULL); // Refit
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   722
			this->SetWidgetDisabledState(ORDER_WIDGET_SERVICE,   order == NULL); // Service
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   723
			this->SetWidgetDisabledState(ORDER_WIDGET_SERVICE_DROPDOWN,   order == NULL); // Service
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   724
			this->HideWidget(ORDER_WIDGET_REFIT); // Refit
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   725
			this->HideWidget(ORDER_WIDGET_SERVICE); // Service
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   726
			this->HideWidget(ORDER_WIDGET_SERVICE_DROPDOWN); // Service
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   727
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   728
			this->HideWidget(ORDER_WIDGET_COND_VARIABLE);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   729
			this->HideWidget(ORDER_WIDGET_COND_COMPARATOR);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   730
			this->HideWidget(ORDER_WIDGET_COND_VALUE);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   731
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   732
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   733
		this->ShowWidget(ORDER_WIDGET_NON_STOP_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   734
		this->ShowWidget(ORDER_WIDGET_NON_STOP);
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   735
		this->ShowWidget(ORDER_WIDGET_UNLOAD_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   736
		this->ShowWidget(ORDER_WIDGET_UNLOAD);
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   737
		this->ShowWidget(ORDER_WIDGET_FULL_LOAD_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   738
		this->ShowWidget(ORDER_WIDGET_FULL_LOAD);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   739
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   740
		this->RaiseWidget(ORDER_WIDGET_NON_STOP);
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   741
		this->RaiseWidget(ORDER_WIDGET_FULL_LOAD);
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   742
		this->RaiseWidget(ORDER_WIDGET_UNLOAD);
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   743
		this->RaiseWidget(ORDER_WIDGET_SERVICE);
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   744
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   745
		if (order != NULL) {
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   746
			this->SetWidgetLoweredState(ORDER_WIDGET_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   747
			switch (order->GetType()) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   748
				case OT_GOTO_STATION:
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   749
					if (!GetStation(order->GetDestination())->IsBuoy()) {
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   750
						this->SetWidgetLoweredState(ORDER_WIDGET_FULL_LOAD, order->GetLoadType() == OLF_FULL_LOAD_ANY);
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   751
						this->SetWidgetLoweredState(ORDER_WIDGET_UNLOAD, order->GetUnloadType() == OUFB_UNLOAD);
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   752
						break;
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   753
					}
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   754
					/* Fall-through */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   755
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   756
				case OT_GOTO_WAYPOINT:
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   757
					this->DisableWidget(ORDER_WIDGET_FULL_LOAD_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   758
					this->DisableWidget(ORDER_WIDGET_FULL_LOAD);
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   759
					this->DisableWidget(ORDER_WIDGET_UNLOAD_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   760
					this->DisableWidget(ORDER_WIDGET_UNLOAD);
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   761
					break;
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   762
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   763
				case OT_GOTO_DEPOT:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   764
					/* Remove unload and replace it with refit */
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   765
					this->HideWidget(ORDER_WIDGET_UNLOAD_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   766
					this->HideWidget(ORDER_WIDGET_UNLOAD);
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   767
					this->HideWidget(ORDER_WIDGET_FULL_LOAD_DROPDOWN);
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   768
					this->HideWidget(ORDER_WIDGET_FULL_LOAD);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   769
					this->ShowWidget(ORDER_WIDGET_REFIT);
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   770
					this->ShowWidget(ORDER_WIDGET_SERVICE_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   771
					this->ShowWidget(ORDER_WIDGET_SERVICE);
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   772
					this->SetWidgetLoweredState(ORDER_WIDGET_SERVICE, order->GetDepotOrderType() & ODTFB_SERVICE);
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   773
					break;
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
   774
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   775
				case OT_CONDITIONAL: {
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   776
					this->HideWidget(ORDER_WIDGET_NON_STOP_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   777
					this->HideWidget(ORDER_WIDGET_NON_STOP);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   778
					this->HideWidget(ORDER_WIDGET_UNLOAD);
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   779
					this->HideWidget(ORDER_WIDGET_UNLOAD_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   780
					this->HideWidget(ORDER_WIDGET_FULL_LOAD);
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   781
					this->HideWidget(ORDER_WIDGET_FULL_LOAD_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   782
					this->ShowWidget(ORDER_WIDGET_COND_VARIABLE);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   783
					this->ShowWidget(ORDER_WIDGET_COND_COMPARATOR);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   784
					this->ShowWidget(ORDER_WIDGET_COND_VALUE);
8877
f09f03b0dc64 (svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
rubidium
parents: 8876
diff changeset
   785
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   786
					OrderConditionVariable ocv = order->GetConditionVariable();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   787
					this->SetWidgetDisabledState(ORDER_WIDGET_COND_COMPARATOR, ocv == OCV_UNCONDITIONALLY);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   788
					this->SetWidgetDisabledState(ORDER_WIDGET_COND_VALUE, ocv == OCV_REQUIRES_SERVICE || ocv == OCV_UNCONDITIONALLY);
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   789
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   790
					uint value = order->GetConditionValue();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   791
					if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   792
					SetDParam(1, value);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   793
				} break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   794
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   795
				default: // every other orders
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   796
					this->DisableWidget(ORDER_WIDGET_NON_STOP_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   797
					this->DisableWidget(ORDER_WIDGET_NON_STOP);
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   798
					this->DisableWidget(ORDER_WIDGET_FULL_LOAD_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   799
					this->DisableWidget(ORDER_WIDGET_FULL_LOAD);
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   800
					this->DisableWidget(ORDER_WIDGET_UNLOAD_DROPDOWN);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   801
					this->DisableWidget(ORDER_WIDGET_UNLOAD);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   802
			}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   803
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   804
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   805
		SetDParam(0, this->vehicle->index);
9273
35e0224ea8f1 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 9258
diff changeset
   806
		this->DrawWidgets();
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   807
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   808
		int y = 15;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   809
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   810
		int i = this->vscroll.pos;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   811
		order = GetVehicleOrder(this->vehicle, i);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   812
		StringID str;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   813
		while (order != NULL) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   814
			/* Don't draw anything if it extends past the end of the window. */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   815
			if (i - this->vscroll.pos >= this->vscroll.cap) break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   816
9639
58530f2b5fdc (svn r13702) -Fix: do not overflow the order/timetable window when 'long' orders are displayed.
rubidium
parents: 9485
diff changeset
   817
			DrawOrderString(this->vehicle, order, i, y, i == this->selected_order, false, this->widget[ORDER_WIDGET_ORDER_LIST].right - 4);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   818
			y += 10;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   819
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   820
			i++;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   821
			order = order->next;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   822
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   823
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   824
		if (i - this->vscroll.pos < this->vscroll.cap) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   825
			str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   826
			DrawString(2, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   827
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   828
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   829
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   830
	virtual void OnClick(Point pt, int widget)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   831
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   832
		if (this->widget[widget].type != WWT_DROPDOWN) HideDropDownMenu(this);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   833
		switch (widget) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   834
			case ORDER_WIDGET_ORDER_LIST: {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   835
				ResetObjectToPlace();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   836
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   837
				int sel = this->GetOrderFromPt(pt.y);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   838
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   839
				if (_ctrl_pressed && sel < this->vehicle->num_orders) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   840
					const Order *ord = GetVehicleOrder(this->vehicle, sel);
10185
1303c1c01a5a (svn r14396) -Fix: ctrl+right click at 'Go to nearest depot' order scrolled to depot with DepotID == 0
smatz
parents: 10184
diff changeset
   841
					TileIndex xy = 0;
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   842
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   843
					switch (ord->GetType()) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   844
						case OT_GOTO_STATION:  xy = GetStation(ord->GetDestination())->xy ; break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   845
						case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->GetDestination())->xy; break;
10185
1303c1c01a5a (svn r14396) -Fix: ctrl+right click at 'Go to nearest depot' order scrolled to depot with DepotID == 0
smatz
parents: 10184
diff changeset
   846
						case OT_GOTO_DEPOT:
1303c1c01a5a (svn r14396) -Fix: ctrl+right click at 'Go to nearest depot' order scrolled to depot with DepotID == 0
smatz
parents: 10184
diff changeset
   847
							if ((ord->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) break;
1303c1c01a5a (svn r14396) -Fix: ctrl+right click at 'Go to nearest depot' order scrolled to depot with DepotID == 0
smatz
parents: 10184
diff changeset
   848
							xy = (this->vehicle->type == VEH_AIRCRAFT) ?  GetStation(ord->GetDestination())->xy : GetDepot(ord->GetDestination())->xy;
1303c1c01a5a (svn r14396) -Fix: ctrl+right click at 'Go to nearest depot' order scrolled to depot with DepotID == 0
smatz
parents: 10184
diff changeset
   849
							break;
1303c1c01a5a (svn r14396) -Fix: ctrl+right click at 'Go to nearest depot' order scrolled to depot with DepotID == 0
smatz
parents: 10184
diff changeset
   850
						default:
1303c1c01a5a (svn r14396) -Fix: ctrl+right click at 'Go to nearest depot' order scrolled to depot with DepotID == 0
smatz
parents: 10184
diff changeset
   851
							break;
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   852
					}
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   853
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   854
					if (xy != 0) ScrollMainWindowToTile(xy);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   855
					return;
10184
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   856
				}
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   857
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   858
				/* This order won't be selected any more, close all child windows and dropdowns */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   859
				this->DeleteChildWindows();
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   860
				HideDropDownMenu(this);
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   861
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   862
				if (sel == INVALID_ORDER || sel == this->selected_order) {
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   863
					/* Deselect clicked order */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   864
					this->selected_order = -1;
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   865
				} else {
10184
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   866
					/* Select clicked order */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   867
					this->selected_order = sel;
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   868
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
   869
					if (this->vehicle->owner == _local_company) {
10184
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   870
						/* Activate drag and drop */
bf4e3ff4cf16 (svn r14395) -Fix [FS#2285]: crashes and GUI desyncs when order is deleted/modified while the timetable window is open
smatz
parents: 10168
diff changeset
   871
						SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, VHM_DRAG, this);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   872
					}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   873
				}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   874
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   875
				this->SetDirty();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   876
			} break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   877
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   878
			case ORDER_WIDGET_SKIP:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   879
				OrderClick_Skip(this, 0);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   880
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   881
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   882
			case ORDER_WIDGET_DELETE:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   883
				OrderClick_Delete(this, 0);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   884
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   885
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   886
			case ORDER_WIDGET_NON_STOP:
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   887
				OrderClick_Nonstop(this, -1);
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   888
				break;
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   889
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   890
			case ORDER_WIDGET_NON_STOP_DROPDOWN: {
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   891
				const Order *o = GetVehicleOrder(this->vehicle, this->OrderGetSel());
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   892
				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));
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   893
			} break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   894
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   895
			case ORDER_WIDGET_GOTO:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   896
				OrderClick_Goto(this, 0);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   897
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   898
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   899
			case ORDER_WIDGET_GOTO_DROPDOWN:
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   900
				ShowDropDownMenu(this, this->vehicle->type == VEH_AIRCRAFT ? _order_goto_dropdown_aircraft : _order_goto_dropdown, 0, ORDER_WIDGET_GOTO_DROPDOWN, 0, 0);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   901
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   902
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   903
			case ORDER_WIDGET_FULL_LOAD:
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   904
				OrderClick_FullLoad(this, -1);
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   905
				break;
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   906
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   907
			case ORDER_WIDGET_FULL_LOAD_DROPDOWN:
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   908
				ShowDropDownMenu(this, _order_full_load_drowdown, GetVehicleOrder(this->vehicle, this->OrderGetSel())->GetLoadType(), ORDER_WIDGET_FULL_LOAD_DROPDOWN, 0, 2);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   909
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   910
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   911
			case ORDER_WIDGET_UNLOAD:
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   912
				OrderClick_Unload(this, -1);
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   913
				break;
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   914
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   915
			case ORDER_WIDGET_UNLOAD_DROPDOWN:
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   916
				ShowDropDownMenu(this, _order_unload_drowdown, GetVehicleOrder(this->vehicle, this->OrderGetSel())->GetUnloadType(), ORDER_WIDGET_UNLOAD_DROPDOWN, 0, 8);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   917
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   918
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   919
			case ORDER_WIDGET_REFIT:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   920
				OrderClick_Refit(this, 0);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   921
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   922
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   923
			case ORDER_WIDGET_SERVICE:
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   924
				OrderClick_Service(this, -1);
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   925
				break;
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   926
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   927
			case ORDER_WIDGET_SERVICE_DROPDOWN:
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
   928
				ShowDropDownMenu(this, _order_depot_action_dropdown, DepotActionStringIndex(GetVehicleOrder(this->vehicle, this->OrderGetSel())), ORDER_WIDGET_SERVICE_DROPDOWN, 0, 0);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   929
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   930
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   931
			case ORDER_WIDGET_TIMETABLE_VIEW:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   932
				ShowTimetableWindow(this->vehicle);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   933
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   934
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   935
			case ORDER_WIDGET_COND_VARIABLE:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   936
				ShowDropDownMenu(this, _order_conditional_variable, GetVehicleOrder(this->vehicle, this->OrderGetSel())->GetConditionVariable(), ORDER_WIDGET_COND_VARIABLE, 0, 0);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   937
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   938
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   939
			case ORDER_WIDGET_COND_COMPARATOR: {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   940
				const Order *o = GetVehicleOrder(this->vehicle, this->OrderGetSel());
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   941
				ShowDropDownMenu(this, _order_conditional_condition, o->GetConditionComparator(), ORDER_WIDGET_COND_COMPARATOR, 0, (o->GetConditionVariable() == OCV_REQUIRES_SERVICE) ? 0x3F : 0xC0);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   942
			} break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   943
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   944
			case ORDER_WIDGET_COND_VALUE: {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   945
				const Order *order = GetVehicleOrder(this->vehicle, this->OrderGetSel());
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   946
				uint value = order->GetConditionValue();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   947
				if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   948
				SetDParam(0, value);
10145
849ba8b8626b (svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
smatz
parents: 10099
diff changeset
   949
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, 100, this, CS_NUMERAL, QSF_NONE);
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   950
			} break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   951
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   952
			case ORDER_WIDGET_SHARED_ORDER_LIST:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   953
				ShowVehicleListWindow(this->vehicle);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   954
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   955
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   956
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   957
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   958
	virtual void OnQueryTextFinished(char *str)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   959
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   960
		if (!StrEmpty(str)) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   961
			VehicleOrderID sel = this->OrderGetSel();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   962
			uint value = atoi(str);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   963
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   964
			switch (GetVehicleOrder(this->vehicle, sel)->GetConditionVariable()) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   965
				case OCV_MAX_SPEED:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   966
					value = ConvertDisplaySpeedToSpeed(value);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   967
					break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   968
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   969
				case OCV_RELIABILITY:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   970
				case OCV_LOAD_PERCENTAGE:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   971
					value = Clamp(value, 0, 100);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   972
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   973
				default:
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
   974
					break;
6832
fec0caeac27d (svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents: 6807
diff changeset
   975
			}
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   976
			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));
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   977
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   978
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   979
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   980
	virtual void OnDropdownSelect(int widget, int index)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   981
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   982
		switch (widget) {
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   983
			case ORDER_WIDGET_NON_STOP_DROPDOWN:
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   984
				OrderClick_Nonstop(this, index);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   985
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   986
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   987
			case ORDER_WIDGET_FULL_LOAD_DROPDOWN:
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   988
				OrderClick_FullLoad(this, index);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   989
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   990
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   991
			case ORDER_WIDGET_UNLOAD_DROPDOWN:
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   992
				OrderClick_Unload(this, index);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   993
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   994
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   995
			case ORDER_WIDGET_GOTO_DROPDOWN:
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   996
				switch (index) {
9485
23ccef6cec89 (svn r13444) -Codechange: make the order GUI somewhat more efficient. The most used options can be done with a single click now.
rubidium
parents: 9475
diff changeset
   997
					case 0: OrderClick_Goto(this, 0); break;
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   998
					case 1: OrderClick_NearestDepot(this, 0); break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
   999
					case 2: OrderClick_Conditional(this, 0); break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1000
					default: NOT_REACHED();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1001
				}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1002
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1003
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
  1004
			case ORDER_WIDGET_SERVICE_DROPDOWN:
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
  1005
				OrderClick_Service(this, index);
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
  1006
				break;
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
  1007
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1008
			case ORDER_WIDGET_COND_VARIABLE:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1009
				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));
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1010
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1011
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1012
			case ORDER_WIDGET_COND_COMPARATOR:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1013
				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));
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1014
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1015
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1016
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1017
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1018
	virtual void OnDragDrop(Point pt, int widget)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1019
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1020
		switch (widget) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1021
			case ORDER_WIDGET_ORDER_LIST: {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1022
				int from_order = this->OrderGetSel();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1023
				int to_order = this->GetOrderFromPt(pt.y);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1024
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1025
				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) &&
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1026
						DoCommandP(this->vehicle->tile, this->vehicle->index, from_order | (to_order << 16), NULL, CMD_MOVE_ORDER | CMD_MSG(STR_CAN_T_MOVE_THIS_ORDER))) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1027
					this->selected_order = -1;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1028
				}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1029
			} break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1030
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1031
			case ORDER_WIDGET_DELETE:
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1032
				OrderClick_Delete(this, 0);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1033
				break;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1034
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1035
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1036
		ResetObjectToPlace();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1037
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1038
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9273
diff changeset
  1039
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1040
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1041
		static const KeyToEvent keytoevent[] = {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1042
			{'D', OrderClick_Skip},
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1043
			{'F', OrderClick_Delete},
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1044
			{'G', OrderClick_Goto},
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1045
			{'H', OrderClick_Nonstop},
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1046
			{'J', OrderClick_FullLoad},
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1047
			{'K', OrderClick_Unload},
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1048
			//('?', OrderClick_Service},
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1049
		};
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1050
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
  1051
		if (this->vehicle->owner != _local_company) return ES_NOT_HANDLED;
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1052
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1053
		for (uint i = 0; i < lengthof(keytoevent); i++) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1054
			if (keycode == keytoevent[i].keycode) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1055
				keytoevent[i].proc(this, -1);
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9273
diff changeset
  1056
				return ES_HANDLED;
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1057
			}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1058
		}
9285
235e5e2d7f55 (svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents: 9273
diff changeset
  1059
		return ES_NOT_HANDLED;
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1060
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1061
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1062
	virtual void OnPlaceObject(Point pt, TileIndex tile)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1063
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1064
		if (this->goto_type == OPOS_GOTO) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1065
			/* check if we're clicking on a vehicle first.. clone orders in that case. */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1066
			const Vehicle *v = CheckMouseOverVehicle();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1067
			if (v != NULL && this->HandleOrderVehClick(v)) return;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1068
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1069
			const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1070
			if (!cmd.IsValid()) return;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1071
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1072
			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))) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1073
				ResetObjectToPlace();
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1074
			}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1075
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1076
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1077
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1078
	virtual void OnPlaceObjectAbort()
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1079
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1080
		if (this->goto_type == OPOS_CONDITIONAL) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1081
			this->goto_type = OPOS_GOTO;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1082
			if (_cursor.pos.x >= (this->left + this->widget[ORDER_WIDGET_ORDER_LIST].left) &&
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1083
					_cursor.pos.y >= (this->top  + this->widget[ORDER_WIDGET_ORDER_LIST].top) &&
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1084
					_cursor.pos.x <= (this->left + this->widget[ORDER_WIDGET_ORDER_LIST].right) &&
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1085
					_cursor.pos.y <= (this->top  + this->widget[ORDER_WIDGET_ORDER_LIST].bottom)) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1086
				int order_id = this->GetOrderFromPt(_cursor.pos.y - this->top);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1087
				if (order_id != INVALID_ORDER) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1088
					Order order;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1089
					order.next = NULL;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1090
					order.index = 0;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1091
					order.MakeConditional(order_id);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1092
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1093
					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));
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
  1094
				}
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
  1095
			}
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1096
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1097
		this->RaiseWidget(ORDER_WIDGET_GOTO);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1098
		this->InvalidateWidget(ORDER_WIDGET_GOTO);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1099
	}
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
  1100
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1101
	virtual void OnMouseLoop()
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1102
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1103
		const Vehicle *v = _place_clicked_vehicle;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1104
		/*
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1105
		* Check if we clicked on a vehicle
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1106
		* and if the GOTO button of this window is pressed
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1107
		* This is because of all open order windows WE_MOUSELOOP is called
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1108
		* and if you have 3 windows open, and this check is not done
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1109
		* the order is copied to the last open window instead of the
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1110
		* one where GOTO is enabled
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1111
		*/
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1112
		if (v != NULL && this->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1113
			_place_clicked_vehicle = NULL;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1114
			this->HandleOrderVehClick(v);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1115
		}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1116
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1117
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1118
	virtual void OnResize(Point new_size, Point delta)
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1119
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1120
		/* Update the scroll + matrix */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1121
		this->vscroll.cap = (this->widget[ORDER_WIDGET_ORDER_LIST].bottom - this->widget[ORDER_WIDGET_ORDER_LIST].top) / 10;
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1122
	}
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1123
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1124
	virtual void OnTimeout()
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1125
	{
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1126
		/* unclick all buttons except for the 'goto' button (ORDER_WIDGET_GOTO), which is 'persistent' */
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1127
		for (uint i = 0; i < this->widget_count; i++) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1128
			if (this->IsWidgetLowered(i) && i != ORDER_WIDGET_GOTO) {
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1129
				this->RaiseWidget(i);
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1130
				this->InvalidateWidget(i);
8871
2fbfd7ec3a5d (svn r12638) -Codechange: give order_gui.cpp a touch of coding style.
rubidium
parents: 8869
diff changeset
  1131
			}
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1132
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1133
	}
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1134
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1135
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1136
/**
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
  1137
 * Widget definition for "your" train orders
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1138
 */
1081
0d79fc43fae2 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1139
static const Widget _orders_train_widgets[] = {
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1140
	{   WWT_CLOSEBOX,   RESIZE_NONE,   COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},               // ORDER_WIDGET_CLOSEBOX
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1141
	{    WWT_CAPTION,   RESIZE_RIGHT,  COLOUR_GREY,    11,   385,     0,    13, STR_8829_ORDERS,         STR_018C_WINDOW_TITLE_DRAG_THIS},     // ORDER_WIDGET_CAPTION
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1142
	{ WWT_PUSHTXTBTN,   RESIZE_LR,     COLOUR_GREY,   325,   385,     0,    13, STR_TIMETABLE_VIEW,      STR_TIMETABLE_VIEW_TOOLTIP},          // ORDER_WIDGET_TIMETABLE_VIEW
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1143
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1144
	{      WWT_PANEL,   RESIZE_RB,     COLOUR_GREY,     0,   373,    14,    75, 0x0,                     STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
8877
f09f03b0dc64 (svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
rubidium
parents: 8876
diff changeset
  1145
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1146
	{  WWT_SCROLLBAR,   RESIZE_LRB,    COLOUR_GREY,   374,   385,    14,    75, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},    // ORDER_WIDGET_SCROLLBAR
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
  1147
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1148
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,     0,   123,    88,    99, STR_8823_SKIP,           STR_8853_SKIP_THE_CURRENT_ORDER},     // ORDER_WIDGET_SKIP
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1149
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,   124,   247,    88,    99, STR_8824_DELETE,         STR_8854_DELETE_THE_HIGHLIGHTED},     // ORDER_WIDGET_DELETE
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1150
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,     0,   123,    76,    87, STR_NULL,                STR_ORDER_TOOLTIP_NON_STOP},          // ORDER_WIDGET_NON_STOP_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1151
	{    WWT_TEXTBTN,   RESIZE_TB,     COLOUR_GREY,     0,   111,    76,    87, STR_ORDER_NON_STOP,      STR_ORDER_TOOLTIP_NON_STOP},          // ORDER_WIDGET_NON_STOP
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1152
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,   248,   371,    88,    99, STR_EMPTY,               STR_ORDER_GO_TO_DROPDOWN_TOOLTIP},    // ORDER_WIDGET_GOTO_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1153
	{    WWT_TEXTBTN,   RESIZE_TB,     COLOUR_GREY,   248,   359,    88,    99, STR_8826_GO_TO,          STR_8856_INSERT_A_NEW_ORDER_BEFORE},  // ORDER_WIDGET_GOTO
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1154
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,   124,   247,    76,    87, STR_NULL,                STR_ORDER_TOOLTIP_FULL_LOAD},         // ORDER_WIDGET_FULL_LOAD_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1155
	{    WWT_TEXTBTN,   RESIZE_TB,     COLOUR_GREY,   124,   235,    76,    87, STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD},      // ORDER_WIDGET_FULL_LOAD
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1156
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,   248,   371,    76,    87, STR_NULL,                STR_ORDER_TOOLTIP_UNLOAD},            // ORDER_WIDGET_UNLOAD_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1157
	{    WWT_TEXTBTN,   RESIZE_TB,     COLOUR_GREY,   248,   359,    76,    87, STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD},            // ORDER_WIDGET_UNLOAD
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1158
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,   124,   247,    76,    87, STR_REFIT,               STR_REFIT_TIP},                       // ORDER_WIDGET_REFIT
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
  1159
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,   248,   371,    76,    87, STR_NULL,                STR_SERVICE_HINT},                    // ORDER_WIDGET_SERVICE_DROPDOWN
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
  1160
	{    WWT_TEXTBTN,   RESIZE_TB,     COLOUR_GREY,   248,   359,    76,    87, STR_SERVICE,             STR_SERVICE_HINT},                    // ORDER_WIDGET_SERVICE
8877
f09f03b0dc64 (svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
rubidium
parents: 8876
diff changeset
  1161
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1162
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,     0,   123,    76,    87, STR_NULL,                STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP},   // ORDER_WIDGET_COND_VARIABLE
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1163
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,   124,   247,    76,    87, STR_NULL,                STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP}, // ORDER_WIDGET_COND_COMPARATOR
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1164
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,   248,   371,    76,    87, STR_CONDITIONAL_VALUE,   STR_ORDER_CONDITIONAL_VALUE_TOOLTIP},      // ORDER_WIDGET_COND_VALUE
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1165
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1166
	{      WWT_PANEL,   RESIZE_RTB,    COLOUR_GREY,   372,   373,    76,    99, 0x0,                     STR_NULL},                            // ORDER_WIDGET_RESIZE_BAR
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1167
	{ WWT_PUSHIMGBTN,   RESIZE_LRTB,   COLOUR_GREY,   372,   385,    76,    87, SPR_SHARED_ORDERS_ICON,  STR_VEH_WITH_SHARED_ORDERS_LIST_TIP}, // ORDER_WIDGET_SHARED_ORDER_LIST
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1168
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1169
	{  WWT_RESIZEBOX,   RESIZE_LRTB,   COLOUR_GREY,   374,   385,    88,    99, 0x0,                     STR_RESIZE_BUTTON},                   // ORDER_WIDGET_RESIZE
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1170
	{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1171
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1172
1081
0d79fc43fae2 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1173
static const WindowDesc _orders_train_desc = {
8877
f09f03b0dc64 (svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
rubidium
parents: 8876
diff changeset
  1174
	WDP_AUTO, WDP_AUTO, 386, 100, 386, 100,
8969
6d1c74e0e2cd (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 8962
diff changeset
  1175
	WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
5013
1d20ebec3510 (svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents: 4968
diff changeset
  1176
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
1081
0d79fc43fae2 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1177
	_orders_train_widgets,
0d79fc43fae2 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1178
};
0d79fc43fae2 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1179
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1180
/**
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
  1181
 * Widget definition for "your" orders (!train)
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1182
 */
1081
0d79fc43fae2 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1183
static const Widget _orders_widgets[] = {
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1184
	{   WWT_CLOSEBOX,   RESIZE_NONE,   COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},               // ORDER_WIDGET_CLOSEBOX
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1185
	{    WWT_CAPTION,   RESIZE_RIGHT,  COLOUR_GREY,    11,   385,     0,    13, STR_8829_ORDERS,         STR_018C_WINDOW_TITLE_DRAG_THIS},     // ORDER_WIDGET_CAPTION
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1186
	{ WWT_PUSHTXTBTN,   RESIZE_LR,     COLOUR_GREY,   325,   385,     0,    13, STR_TIMETABLE_VIEW,      STR_TIMETABLE_VIEW_TOOLTIP},          // ORDER_WIDGET_TIMETABLE_VIEW
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1187
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1188
	{      WWT_PANEL,   RESIZE_RB,     COLOUR_GREY,     0,   373,    14,    75, 0x0,                     STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
  1189
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1190
	{  WWT_SCROLLBAR,   RESIZE_LRB,    COLOUR_GREY,   374,   385,    14,    75, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},    // ORDER_WIDGET_SCROLLBAR
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1191
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1192
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,     0,   123,    88,    99, STR_8823_SKIP,           STR_8853_SKIP_THE_CURRENT_ORDER},     // ORDER_WIDGET_SKIP
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1193
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,   124,   247,    88,    99, STR_8824_DELETE,         STR_8854_DELETE_THE_HIGHLIGHTED},     // ORDER_WIDGET_DELETE
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1194
	{      WWT_EMPTY,   RESIZE_TB,     COLOUR_GREY,     0,     0,    76,    87, 0x0,                     0x0},                                 // ORDER_WIDGET_NON_STOP_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1195
	{      WWT_EMPTY,   RESIZE_TB,     COLOUR_GREY,     0,     0,    76,    87, 0x0,                     0x0},                                 // ORDER_WIDGET_NON_STOP
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1196
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,   248,   371,    88,    99, STR_EMPTY,               STR_ORDER_GO_TO_DROPDOWN_TOOLTIP},    // ORDER_WIDGET_GOTO_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1197
	{    WWT_TEXTBTN,   RESIZE_TB,     COLOUR_GREY,   248,   359,    88,    99, STR_8826_GO_TO,          STR_8856_INSERT_A_NEW_ORDER_BEFORE},  // ORDER_WIDGET_GOTO
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1198
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,     0,   185,    76,    87, STR_NULL,                STR_ORDER_TOOLTIP_FULL_LOAD},         // ORDER_WIDGET_FULL_LOAD_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1199
	{    WWT_TEXTBTN,   RESIZE_TB,     COLOUR_GREY,     0,   173,    76,    87, STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD},      // ORDER_WIDGET_FULL_LOAD
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1200
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,   186,   371,    76,    87, STR_NULL,                STR_ORDER_TOOLTIP_UNLOAD},            // ORDER_WIDGET_UNLOAD_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1201
	{    WWT_TEXTBTN,   RESIZE_TB,     COLOUR_GREY,   186,   359,    76,    87, STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD},            // ORDER_WIDGET_UNLOAD
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1202
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,     0,   185,    76,    87, STR_REFIT,               STR_REFIT_TIP},                       // ORDER_WIDGET_REFIT
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
  1203
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,   186,   371,    76,    87, STR_NULL,                STR_SERVICE_HINT},                    // ORDER_WIDGET_SERVICE_DROPDOWN
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
  1204
	{    WWT_TEXTBTN,   RESIZE_TB,     COLOUR_GREY,   186,   359,    76,    87, STR_SERVICE,             STR_SERVICE_HINT},                    // ORDER_WIDGET_SERVICE
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1205
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1206
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,     0,   123,    76,    87, STR_NULL,                STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP},   // ORDER_WIDGET_COND_VARIABLE
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1207
	{   WWT_DROPDOWN,   RESIZE_TB,     COLOUR_GREY,   124,   247,    76,    87, STR_NULL,                STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP}, // ORDER_WIDGET_COND_COMPARATOR
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1208
	{ WWT_PUSHTXTBTN,   RESIZE_TB,     COLOUR_GREY,   248,   371,    76,    87, STR_CONDITIONAL_VALUE,   STR_ORDER_CONDITIONAL_VALUE_TOOLTIP},      // ORDER_WIDGET_COND_VALUE
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1209
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1210
	{      WWT_PANEL,   RESIZE_RTB,    COLOUR_GREY,   372,   373,    76,    99, 0x0,                     STR_NULL},                            // ORDER_WIDGET_RESIZE_BAR
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1211
	{ WWT_PUSHIMGBTN,   RESIZE_LRTB,   COLOUR_GREY,   372,   385,    76,    87, SPR_SHARED_ORDERS_ICON,  STR_VEH_WITH_SHARED_ORDERS_LIST_TIP}, // ORDER_WIDGET_SHARED_ORDER_LIST
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1212
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1213
	{  WWT_RESIZEBOX,   RESIZE_LRTB,   COLOUR_GREY,   374,   385,    88,    99, 0x0,                     STR_RESIZE_BUTTON},                   // ORDER_WIDGET_RESIZE
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1214
	{   WIDGETS_END},
1081
0d79fc43fae2 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1215
};
0d79fc43fae2 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
  1216
995
0a8d27dcc231 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
  1217
static const WindowDesc _orders_desc = {
8877
f09f03b0dc64 (svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
rubidium
parents: 8876
diff changeset
  1218
	WDP_AUTO, WDP_AUTO, 386, 100, 386, 100,
8969
6d1c74e0e2cd (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 8962
diff changeset
  1219
	WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
5013
1d20ebec3510 (svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents: 4968
diff changeset
  1220
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
995
0a8d27dcc231 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
  1221
	_orders_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1222
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1223
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1224
/**
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1225
 * Widget definition for competitor orders
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1226
 */
995
0a8d27dcc231 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
  1227
static const Widget _other_orders_widgets[] = {
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1228
	{   WWT_CLOSEBOX,   RESIZE_NONE,   COLOUR_GREY,     0,    10,     0,    13, STR_00C5,           STR_018B_CLOSE_WINDOW},               // ORDER_WIDGET_CLOSEBOX
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1229
	{    WWT_CAPTION,   RESIZE_RIGHT,  COLOUR_GREY,    11,   385,     0,    13, STR_8829_ORDERS,    STR_018C_WINDOW_TITLE_DRAG_THIS},     // ORDER_WIDGET_CAPTION
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1230
	{ WWT_PUSHTXTBTN,   RESIZE_LR,     COLOUR_GREY,   325,   385,     0,    13, STR_TIMETABLE_VIEW, STR_TIMETABLE_VIEW_TOOLTIP},          // ORDER_WIDGET_TIMETABLE_VIEW
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1231
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1232
	{      WWT_PANEL,   RESIZE_RB,     COLOUR_GREY,     0,   373,    14,    75, 0x0,                STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
6980
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6923
diff changeset
  1233
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1234
	{  WWT_SCROLLBAR,   RESIZE_LRB,    COLOUR_GREY,   374,   385,    14,    75, 0x0,                STR_0190_SCROLL_BAR_SCROLLS_LIST},    // ORDER_WIDGET_SCROLLBAR
8900
a49f442299b8 (svn r12667) -Feature: conditional 'skip/jump' orders.
rubidium
parents: 8896
diff changeset
  1235
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1236
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_SKIP
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1237
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_DELETE
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1238
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_NON_STOP_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1239
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_NON_STOP
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1240
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_GOTO_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1241
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_GOTO
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1242
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_FULL_LOAD_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1243
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_FULL_LOAD
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1244
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_UNLOAD_DROPDOWN
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1245
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_UNLOAD
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1246
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_REFIT
10285
82fa43e7b8f3 (svn r14524) -Add: stop-in-depot as part of orders (PhilSophus)
rubidium
parents: 10208
diff changeset
  1247
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_SERVICE_DROPDOWN
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1248
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_SERVICE
6980
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6923
diff changeset
  1249
9760
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1250
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_COND_VARIABLE
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1251
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_COND_COMPARATOR
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1252
	{      WWT_EMPTY,   RESIZE_NONE,   COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_COND_VALUE
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1253
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1254
	{      WWT_PANEL,   RESIZE_RTB,    COLOUR_GREY,     0,   373,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_RESIZE_BAR
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1255
	{      WWT_EMPTY,   RESIZE_TB,     COLOUR_GREY,     0,     0,    76,    87, 0x0,                STR_NULL},                            // ORDER_WIDGET_SHARED_ORDER_LIST
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1256
92202f8b455a (svn r13896) -Codechange: Replace numbers with Colours enum on newgrf, order and osk guis
belugas
parents: 9641
diff changeset
  1257
	{  WWT_RESIZEBOX,   RESIZE_LRTB,   COLOUR_GREY,   374,   385,    76,    87, 0x0,                STR_RESIZE_BUTTON},                   // ORDER_WIDGET_RESIZE
6807
89fba17b6cd3 (svn r10046) -Documentation: add some documentation in order_gui (skidd13).
rubidium
parents: 6794
diff changeset
  1258
	{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1259
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1260
995
0a8d27dcc231 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
  1261
static const WindowDesc _other_orders_desc = {
8877
f09f03b0dc64 (svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
rubidium
parents: 8876
diff changeset
  1262
	WDP_AUTO, WDP_AUTO, 386, 88, 386, 88,
8969
6d1c74e0e2cd (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 8962
diff changeset
  1263
	WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
1242
1ca216c50426 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
  1264
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
995
0a8d27dcc231 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
  1265
	_other_orders_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1266
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1267
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
  1268
void ShowOrdersWindow(const Vehicle *v)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1269
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1270
	VehicleID veh = v->index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1271
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1272
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1273
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1274
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10185
diff changeset
  1275
	if (v->owner != _local_company) {
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1276
		new OrdersWindow(&_other_orders_desc, v);
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
  1277
	} else {
9258
21d5b2c3ec8d (svn r13124) -Codechange: make a class of the OrdersWindow.
glx
parents: 9143
diff changeset
  1278
		new OrdersWindow((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? &_orders_train_desc : &_orders_desc, v);
1242
1ca216c50426 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
  1279
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1280
}