src/autoreplace_gui.cpp
author convert-repo
Mon, 07 Apr 2008 16:21:55 +0000
changeset 10076 dfd70e42c4ae
parent 9282 2bb9703aeb39
child 10296 a1b48fc82022
permissions -rw-r--r--
update tags
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6443
b8f06d8eb7be (svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents: 6206
diff changeset
     3
/** @file autoreplace_gui.cpp */
b8f06d8eb7be (svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents: 6206
diff changeset
     4
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1859
diff changeset
     6
#include "openttd.h"
1299
0a6510cc889b (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1294
diff changeset
     7
#include "debug.h"
842
ebfd36603ab9 (svn r1323) Adding autoreplace feature
bjarni
parents: 594
diff changeset
     8
#include "gui.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
     9
#include "command_func.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2154
diff changeset
    10
#include "variables.h"
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2154
diff changeset
    11
#include "vehicle_gui.h"
2962
dbd168a4703a (svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents: 2951
diff changeset
    12
#include "newgrf_engine.h"
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
    13
#include "group.h"
8599
b609cdeeff3f (svn r11664) -Codechange: use more specific ("rail_type.h" instead of "rail.h" that includes way more than only "rail_type.h") includes at some places.
rubidium
parents: 8578
diff changeset
    14
#include "rail.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8602
diff changeset
    15
#include "strings_func.h"
8627
448ebf3a8291 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8612
diff changeset
    16
#include "window_func.h"
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8627
diff changeset
    17
#include "vehicle_func.h"
8708
0c29fbc79be4 (svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents: 8670
diff changeset
    18
#include "autoreplace_func.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8708
diff changeset
    19
#include "gfx_func.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8720
diff changeset
    20
#include "player_func.h"
8780
6f3f3ec6c69a (svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents: 8760
diff changeset
    21
#include "widgets/dropdown_func.h"
9282
2bb9703aeb39 (svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium
parents: 9266
diff changeset
    22
#include "engine_func.h"
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    23
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    24
#include "table/sprites.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    25
#include "table/strings.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    26
9266
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    27
struct replaceveh_d {
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    28
	byte sel_index[2];
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    29
	EngineID sel_engine[2];
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    30
	uint16 count[2];
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    31
	bool wagon_btnstate; ///< true means engine is selected
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    32
	EngineList list[2];
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    33
	bool update_left;
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    34
	bool update_right;
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    35
	bool init_lists;
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    36
	GroupID sel_group;
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    37
};
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    38
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d));
416385a64dcb (svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium
parents: 8975
diff changeset
    39
6060
8388a1bcb7c8 (svn r8371) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni
parents: 6059
diff changeset
    40
static RailType _railtype_selected_in_replace_gui;
505
11582dcada49 (svn r813) Push two tables from vehicle_gui.h into vehicle_gui.c - they were in the binary 48 (!) times.
tron
parents: 243
diff changeset
    41
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
    42
static bool _rebuild_left_list;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
    43
static bool _rebuild_right_list;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
    44
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    45
static const StringID _rail_types_list[] = {
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    46
	STR_RAIL_VEHICLES,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    47
	STR_ELRAIL_VEHICLES,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    48
	STR_MONORAIL_VEHICLES,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    49
	STR_MAGLEV_VEHICLES,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    50
	INVALID_STRING_ID
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    51
};
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    52
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    53
enum ReplaceVehicleWindowWidgets {
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    54
	RVW_WIDGET_LEFT_DETAILS = 3,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    55
	RVW_WIDGET_START_REPLACE,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    56
	RVW_WIDGET_INFO_TAB,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    57
	RVW_WIDGET_STOP_REPLACE,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    58
	RVW_WIDGET_LEFT_MATRIX,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    59
	RVW_WIDGET_LEFT_SCROLLBAR,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    60
	RVW_WIDGET_RIGHT_MATRIX,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    61
	RVW_WIDGET_RIGHT_SCROLLBAR,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    62
	RVW_WIDGET_RIGHT_DETAILS,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    63
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    64
	RVW_WIDGET_TRAIN_ENGINEWAGON_TOGGLE,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    65
	RVW_WIDGET_TRAIN_FLUFF_LEFT,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    66
	RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    67
	RVW_WIDGET_TRAIN_FLUFF_RIGHT,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    68
	RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE,
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    69
};
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
    70
8670
121000504b2c (svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window.
peter1138
parents: 8640
diff changeset
    71
static int CDECL TrainEngineNumberSorter(const void *a, const void *b)
121000504b2c (svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window.
peter1138
parents: 8640
diff changeset
    72
{
121000504b2c (svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window.
peter1138
parents: 8640
diff changeset
    73
	const EngineID va = *(const EngineID*)a;
121000504b2c (svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window.
peter1138
parents: 8640
diff changeset
    74
	const EngineID vb = *(const EngineID*)b;
121000504b2c (svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window.
peter1138
parents: 8640
diff changeset
    75
	int r = ListPositionOfEngine(va) - ListPositionOfEngine(vb);
121000504b2c (svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window.
peter1138
parents: 8640
diff changeset
    76
121000504b2c (svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window.
peter1138
parents: 8640
diff changeset
    77
	return r;
121000504b2c (svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window.
peter1138
parents: 8640
diff changeset
    78
}
121000504b2c (svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window.
peter1138
parents: 8640
diff changeset
    79
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    80
/* General Vehicle GUI based procedures that are independent of vehicle types */
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6443
diff changeset
    81
void InitializeVehiclesGuiList()
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    82
{
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    83
	_railtype_selected_in_replace_gui = RAILTYPE_RAIL;
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    84
}
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    85
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
    86
/** Rebuild the left autoreplace list if an engine is removed or added
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
    87
 * @param e Engine to check if it is removed or added
7592
48055c5dd43d (svn r10363) -Fix [FS#911]: invalidating autoreplace windows didn't take account of vehicle group (Matthias Wolf)
peter1138
parents: 7555
diff changeset
    88
 * @param id_g The group the engine belongs to
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
    89
 *  Note: this function only works if it is called either
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
    90
 *   - when a new vehicle is build, but before it's counted in num_engines
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
    91
 *   - when a vehicle is deleted and after it's substracted from num_engines
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
    92
 *   - when not changing the count (used when changing replace orders)
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    93
 */
7592
48055c5dd43d (svn r10363) -Fix [FS#911]: invalidating autoreplace windows didn't take account of vehicle group (Matthias Wolf)
peter1138
parents: 7555
diff changeset
    94
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    95
{
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
    96
	Player *p = GetPlayer(_local_player);
8975
303deb99982d (svn r12054) -Cleanup: Use VehicleType instead of byte for vehicle types...
peter1138
parents: 8915
diff changeset
    97
	VehicleType type = GetEngine(e)->type;
7977
b10b1a884892 (svn r10992) -Fix [FS#1132]: huge amount of vehicles in the "ungrouped" group. Patch by frosch.
rubidium
parents: 7837
diff changeset
    98
	uint num_engines = GetGroupNumEngines(_local_player, id_g, e);
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
    99
7592
48055c5dd43d (svn r10363) -Fix [FS#911]: invalidating autoreplace windows didn't take account of vehicle group (Matthias Wolf)
peter1138
parents: 7555
diff changeset
   100
	if (num_engines == 0 || p->num_engines[e] == 0) {
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   101
		/* We don't have any of this engine type.
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   102
		 * Either we just sold the last one, we build a new one or we stopped replacing it.
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   103
		 * In all cases, we need to update the left list */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   104
		_rebuild_left_list = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   105
	} else {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   106
		_rebuild_left_list = false;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   107
	}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   108
	_rebuild_right_list = false;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   109
	InvalidateWindowData(WC_REPLACE_VEHICLE, type);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   110
}
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   111
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   112
/** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   113
 * @param type The type of engine
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   114
 */
7134
c5a90dd41166 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents: 6894
diff changeset
   115
void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   116
{
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   117
	_rebuild_left_list = false; // left list is only for the vehicles the player owns and is not related to being buildable
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   118
	_rebuild_right_list = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   119
	InvalidateWindowData(WC_REPLACE_VEHICLE, type); // Update the autoreplace window
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   120
	InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   121
}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   122
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   123
/** Get the default cargo type for an engine
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   124
 * @param engine the EngineID to get the cargo for
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   125
 * @return the cargo type carried by the engine (CT_INVALID if engine got no cargo capacity)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   126
 */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   127
static CargoID EngineCargo(EngineID engine)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   128
{
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   129
	if (engine == INVALID_ENGINE) return CT_INVALID; // surely INVALID_ENGINE can't carry anything but CT_INVALID
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   130
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   131
	switch (GetEngine(engine)->type) {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   132
		default: NOT_REACHED();
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6573
diff changeset
   133
		case VEH_TRAIN:
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   134
			if (RailVehInfo(engine)->capacity == 0) return CT_INVALID; // no capacity -> can't carry cargo
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   135
			return RailVehInfo(engine)->cargo_type;
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6573
diff changeset
   136
		case VEH_ROAD:       return RoadVehInfo(engine)->cargo_type;
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6573
diff changeset
   137
		case VEH_SHIP:       return ShipVehInfo(engine)->cargo_type;
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6573
diff changeset
   138
		case VEH_AIRCRAFT:   return CT_PASSENGERS; // all planes are build with passengers by default
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   139
	}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   140
}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   141
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   142
/** Figure out if an engine should be added to a list
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   143
 * @param e The EngineID
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   144
 * @param draw_left If true, then the left list is drawn (the engines specific to the railtype you selected)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   145
 * @param show_engines if truem then locomotives are drawn, else wagons (never both)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   146
 * @return true if the engine should be in the list (based on this check)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   147
 */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   148
static bool GenerateReplaceRailList(EngineID e, bool draw_left, bool show_engines)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   149
{
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   150
	const RailVehicleInfo *rvi = RailVehInfo(e);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   151
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   152
	/* Ensure that the wagon/engine selection fits the engine. */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   153
	if ((rvi->railveh_type == RAILVEH_WAGON) == show_engines) return false;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   154
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   155
	if (draw_left && show_engines) {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   156
		/* Ensure that the railtype is specific to the selected one */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   157
		if (rvi->railtype != _railtype_selected_in_replace_gui) return false;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   158
	} else {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   159
		/* Ensure that it's a compatible railtype to the selected one (like electric <-> diesel)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   160
		 * The vehicle do not have to have power on the railtype in question, only able to drive (pulled if needed) */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   161
		if (!IsCompatibleRail(rvi->railtype, _railtype_selected_in_replace_gui)) return false;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   162
	}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   163
	return true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   164
}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   165
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   166
/** Figure out if two engines got at least one type of cargo in common (refitting if needed)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   167
 * @param engine_a one of the EngineIDs
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   168
 * @param engine_b the other EngineID
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   169
 * @return true if they can both carry the same type of cargo (or at least one of them got no capacity at all)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   170
 */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   171
static bool EnginesGotCargoInCommon(EngineID engine_a, EngineID engine_b)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   172
{
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   173
	CargoID a = EngineCargo(engine_a);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   174
	CargoID b = EngineCargo(engine_b);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   175
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   176
	 /* we should always be able to refit to/from locomotives without capacity
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   177
	  * Because of that, CT_INVALID shoudl always return true */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   178
	if (a == CT_INVALID || b == CT_INVALID || a == b) return true; // they carry no ro the same type by default
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   179
	if (EngInfo(engine_a)->refit_mask & EngInfo(engine_b)->refit_mask) return true; // both can refit to the same
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   180
	if (CanRefitTo(engine_a, b) || CanRefitTo(engine_b, a)) return true; // one can refit to what the other one carries
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   181
	return false;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   182
}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   183
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   184
/** Generate a list
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   185
 * @param w Window, that contains the list
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   186
 * @param draw_left true if generating the left list, otherwise false
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   187
 */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   188
static void GenerateReplaceVehList(Window *w, bool draw_left)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   189
{
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   190
	EngineID e;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   191
	EngineID selected_engine = INVALID_ENGINE;
8975
303deb99982d (svn r12054) -Cleanup: Use VehicleType instead of byte for vehicle types...
peter1138
parents: 8915
diff changeset
   192
	VehicleType type = (VehicleType)w->window_number;
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   193
	byte i = draw_left ? 0 : 1;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   194
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   195
	EngineList *list = &WP(w, replaceveh_d).list[i];
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   196
	EngList_RemoveAll(list);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   197
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   198
	FOR_ALL_ENGINEIDS_OF_TYPE(e, type) {
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6573
diff changeset
   199
		if (type == VEH_TRAIN && !GenerateReplaceRailList(e, draw_left, WP(w, replaceveh_d).wagon_btnstate)) continue; // special rules for trains
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   200
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   201
		if (draw_left) {
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   202
			const GroupID selected_group = WP(w, replaceveh_d).sel_group;
7977
b10b1a884892 (svn r10992) -Fix [FS#1132]: huge amount of vehicles in the "ungrouped" group. Patch by frosch.
rubidium
parents: 7837
diff changeset
   203
			const uint num_engines = GetGroupNumEngines(_local_player, selected_group, e);
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   204
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   205
			/* Skip drawing the engines we don't have any of and haven't set for replacement */
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   206
			if (num_engines == 0 && EngineReplacementForPlayer(GetPlayer(_local_player), e, selected_group) == INVALID_ENGINE) continue;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   207
		} else {
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   208
			/* This is for engines we can replace to and they should depend on what we selected to replace from */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   209
			if (!IsEngineBuildable(e, type, _local_player)) continue; // we need to be able to build the engine
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   210
			if (!EnginesGotCargoInCommon(e, WP(w, replaceveh_d).sel_engine[0])) continue; // the engines needs to be able to carry the same cargo
7183
23b20a982228 (svn r9919) -Codechange: prepare some more places for more road types.
rubidium
parents: 7139
diff changeset
   211
23b20a982228 (svn r9919) -Codechange: prepare some more places for more road types.
rubidium
parents: 7139
diff changeset
   212
			/* Road vehicles can't be replaced by trams and vice-versa */
8424
4a488a90ccab (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 8320
diff changeset
   213
			if (type == VEH_ROAD && HasBit(EngInfo(WP(w, replaceveh_d).sel_engine[0])->misc_flags, EF_ROAD_TRAM) != HasBit(EngInfo(e)->misc_flags, EF_ROAD_TRAM)) continue;
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   214
			if (e == WP(w, replaceveh_d).sel_engine[0]) continue; // we can't replace an engine into itself (that would be autorenew)
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   215
		}
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   216
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   217
		EngList_Add(list, e);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   218
		if (e == WP(w, replaceveh_d).sel_engine[i]) selected_engine = e; // The selected engine is still in the list
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   219
	}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   220
	WP(w, replaceveh_d).sel_engine[i] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore)
8670
121000504b2c (svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window.
peter1138
parents: 8640
diff changeset
   221
	if (type == VEH_TRAIN) EngList_Sort(list, &TrainEngineNumberSorter);
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   222
}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   223
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   224
/** Generate the lists
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   225
 * @param w Window containing the lists
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   226
 */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   227
static void GenerateLists(Window *w)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   228
{
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   229
	EngineID e = WP(w, replaceveh_d).sel_engine[0];
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   230
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   231
	if (WP(w, replaceveh_d).update_left == true) {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   232
		/* We need to rebuild the left list */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   233
		GenerateReplaceVehList(w, true);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   234
		SetVScrollCount(w, EngList_Count(&WP(w, replaceveh_d).list[0]));
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   235
		if (WP(w, replaceveh_d).init_lists && WP(w, replaceveh_d).sel_engine[0] == INVALID_ENGINE && EngList_Count(&WP(w, replaceveh_d).list[0]) != 0) {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   236
			WP(w, replaceveh_d).sel_engine[0] = WP(w, replaceveh_d).list[0][0];
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   237
		}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   238
	}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   239
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   240
	if (WP(w, replaceveh_d).update_right || e != WP(w, replaceveh_d).sel_engine[0]) {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   241
		/* Either we got a request to rebuild the right list or the left list selected a different engine */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   242
		if (WP(w, replaceveh_d).sel_engine[0] == INVALID_ENGINE) {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   243
			/* Always empty the right list when nothing is selected in the left list */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   244
			EngList_RemoveAll(&WP(w, replaceveh_d).list[1]);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   245
			WP(w, replaceveh_d).sel_engine[1] = INVALID_ENGINE;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   246
		} else {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   247
			GenerateReplaceVehList(w, false);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   248
			SetVScroll2Count(w, EngList_Count(&WP(w, replaceveh_d).list[1]));
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   249
			if (WP(w, replaceveh_d).init_lists && WP(w, replaceveh_d).sel_engine[1] == INVALID_ENGINE && EngList_Count(&WP(w, replaceveh_d).list[1]) != 0) {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   250
				WP(w, replaceveh_d).sel_engine[1] = WP(w, replaceveh_d).list[1][0];
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   251
			}
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   252
		}
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   253
	}
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   254
	/* Reset the flags about needed updates */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   255
	WP(w, replaceveh_d).update_left  = false;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   256
	WP(w, replaceveh_d).update_right = false;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   257
	WP(w, replaceveh_d).init_lists   = false;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   258
}
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   259
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   260
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   261
void DrawEngineList(VehicleType type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group);
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   262
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   263
static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   264
{
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   265
	/* Strings for the pulldown menu */
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   266
	static const StringID _vehicle_type_names[] = {
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   267
		STR_019F_TRAIN,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   268
		STR_019C_ROAD_VEHICLE,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   269
		STR_019E_SHIP,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   270
		STR_019D_AIRCRAFT
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   271
	};
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   272
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   273
	switch (e->event) {
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   274
		case WE_CREATE:
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   275
			WP(w, replaceveh_d).wagon_btnstate = true; // start with locomotives (all other vehicles will not read this bool)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   276
			EngList_Create(&WP(w, replaceveh_d).list[0]);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   277
			EngList_Create(&WP(w, replaceveh_d).list[1]);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   278
			WP(w, replaceveh_d).update_left   = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   279
			WP(w, replaceveh_d).update_right  = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   280
			WP(w, replaceveh_d).init_lists    = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   281
			WP(w, replaceveh_d).sel_engine[0] = INVALID_ENGINE;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   282
			WP(w, replaceveh_d).sel_engine[1] = INVALID_ENGINE;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   283
			break;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   284
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   285
		case WE_PAINT: {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   286
			if (WP(w, replaceveh_d).update_left || WP(w, replaceveh_d).update_right) GenerateLists(w);
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   287
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   288
			Player *p = GetPlayer(_local_player);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   289
			EngineID selected_id[2];
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
   290
			const GroupID selected_group = WP(w, replaceveh_d).sel_group;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   291
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   292
			selected_id[0] = WP(w, replaceveh_d).sel_engine[0];
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   293
			selected_id[1] = WP(w, replaceveh_d).sel_engine[1];
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   294
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   295
			/* Disable the "Start Replacing" button if:
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   296
			 *    Either list is empty
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   297
			 * or The selected replacement engine has a replacement (to prevent loops)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   298
			 * or The right list (new replacement) has the existing replacement vehicle selected */
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   299
			w->SetWidgetDisabledState(RVW_WIDGET_START_REPLACE,
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   300
										 selected_id[0] == INVALID_ENGINE ||
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   301
										 selected_id[1] == INVALID_ENGINE ||
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   302
										 EngineReplacementForPlayer(p, selected_id[1], selected_group) != INVALID_ENGINE ||
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   303
										 EngineReplacementForPlayer(p, selected_id[0], selected_group) == selected_id[1]);
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   304
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   305
			/* Disable the "Stop Replacing" button if:
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   306
			 *   The left list (existing vehicle) is empty
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   307
			 *   or The selected vehicle has no replacement set up */
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   308
			w->SetWidgetDisabledState(RVW_WIDGET_STOP_REPLACE,
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   309
										 selected_id[0] == INVALID_ENGINE ||
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   310
										 !EngineHasReplacementForPlayer(p, selected_id[0], selected_group));
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   311
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   312
			/* now the actual drawing of the window itself takes place */
6206
67358999d80d (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 6195
diff changeset
   313
			SetDParam(0, _vehicle_type_names[w->window_number]);
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   314
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6573
diff changeset
   315
			if (w->window_number == VEH_TRAIN) {
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   316
				/* set on/off for renew_keep_length */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   317
				SetDParam(1, p->renew_keep_length ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   318
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   319
				/* set wagon/engine button */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   320
				SetDParam(2, WP(w, replaceveh_d).wagon_btnstate ? STR_ENGINES : STR_WAGONS);
6894
02bad4ca936e (svn r9528) -Fix r8610: don't try to modify non-existent widgets (many thanks to Bruce Perence, the libefence developer)
glx
parents: 6585
diff changeset
   321
02bad4ca936e (svn r9528) -Fix r8610: don't try to modify non-existent widgets (many thanks to Bruce Perence, the libefence developer)
glx
parents: 6585
diff changeset
   322
				/* sets the colour of that art thing */
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   323
				w->widget[RVW_WIDGET_TRAIN_FLUFF_LEFT].color  = _player_colors[_local_player];
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   324
				w->widget[RVW_WIDGET_TRAIN_FLUFF_RIGHT].color = _player_colors[_local_player];
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   325
			}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   326
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6573
diff changeset
   327
			if (w->window_number == VEH_TRAIN) {
8842
69a6737d61d3 (svn r11912) -Codechange: use dropdown widget for autoreplace, station builder and (second?) vehicle list windows
peter1138
parents: 8841
diff changeset
   328
				/* Show the selected railtype in the pulldown menu */
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   329
				RailType railtype = _railtype_selected_in_replace_gui;
8842
69a6737d61d3 (svn r11912) -Codechange: use dropdown widget for autoreplace, station builder and (second?) vehicle list windows
peter1138
parents: 8841
diff changeset
   330
				w->widget[RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN].data = _rail_types_list[railtype];
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   331
			}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   332
8842
69a6737d61d3 (svn r11912) -Codechange: use dropdown widget for autoreplace, station builder and (second?) vehicle list windows
peter1138
parents: 8841
diff changeset
   333
			DrawWindowWidgets(w);
69a6737d61d3 (svn r11912) -Codechange: use dropdown widget for autoreplace, station builder and (second?) vehicle list windows
peter1138
parents: 8841
diff changeset
   334
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   335
			/* sets up the string for the vehicle that is being replaced to */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   336
			if (selected_id[0] != INVALID_ENGINE) {
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   337
				if (!EngineHasReplacementForPlayer(p, selected_id[0], selected_group)) {
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   338
					SetDParam(0, STR_NOT_REPLACING);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   339
				} else {
7555
e20900912fa2 (svn r10324) -Codechange: reference engine names by index
peter1138
parents: 7183
diff changeset
   340
					SetDParam(0, STR_ENGINE_NAME);
e20900912fa2 (svn r10324) -Codechange: reference engine names by index
peter1138
parents: 7183
diff changeset
   341
					SetDParam(1, EngineReplacementForPlayer(p, selected_id[0], selected_group));
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   342
				}
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   343
			} else {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   344
				SetDParam(0, STR_NOT_REPLACING_VEHICLE_SELECTED);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   345
			}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   346
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   347
			DrawString(145, w->widget[RVW_WIDGET_INFO_TAB].top + 1, STR_02BD, TC_BLACK);
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   348
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   349
			/* Draw the lists */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   350
			for(byte i = 0; i < 2; i++) {
8848
96987946673f (svn r11918) -Codechange: Draw engine lists at widget positions instead of fixed pixel positions
peter1138
parents: 8842
diff changeset
   351
				uint widget     = (i == 0) ? RVW_WIDGET_LEFT_MATRIX : RVW_WIDGET_RIGHT_MATRIX;
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   352
				EngineList list = WP(w, replaceveh_d).list[i]; // which list to draw
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   353
				EngineID start  = i == 0 ? w->vscroll.pos : w->vscroll2.pos; // what is the offset for the start (scrolling)
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   354
				EngineID end    = min((i == 0 ? w->vscroll.cap : w->vscroll2.cap) + start, EngList_Count(&list));
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   355
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   356
				/* Do the actual drawing */
8848
96987946673f (svn r11918) -Codechange: Draw engine lists at widget positions instead of fixed pixel positions
peter1138
parents: 8842
diff changeset
   357
				DrawEngineList((VehicleType)w->window_number, w->widget[widget].left + 2, w->widget[widget].top + 1, list, start, end, WP(w, replaceveh_d).sel_engine[i], i == 0, selected_group);
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   358
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   359
				/* Also draw the details if an engine is selected */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   360
				if (WP(w, replaceveh_d).sel_engine[i] != INVALID_ENGINE) {
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   361
					const Widget *wi = &w->widget[i == 0 ? RVW_WIDGET_LEFT_DETAILS : RVW_WIDGET_RIGHT_DETAILS];
8915
db4c2ae09c4b (svn r11989) -Fix: Resize autoreplace window to fit purchase information text if it is too large.
peter1138
parents: 8848
diff changeset
   362
					int text_end = DrawVehiclePurchaseInfo(wi->left + 2, wi->top + 1, wi->right - wi->left - 2, WP(w, replaceveh_d).sel_engine[i]);
db4c2ae09c4b (svn r11989) -Fix: Resize autoreplace window to fit purchase information text if it is too large.
peter1138
parents: 8848
diff changeset
   363
db4c2ae09c4b (svn r11989) -Fix: Resize autoreplace window to fit purchase information text if it is too large.
peter1138
parents: 8848
diff changeset
   364
					if (text_end > wi->bottom) {
db4c2ae09c4b (svn r11989) -Fix: Resize autoreplace window to fit purchase information text if it is too large.
peter1138
parents: 8848
diff changeset
   365
						SetWindowDirty(w);
db4c2ae09c4b (svn r11989) -Fix: Resize autoreplace window to fit purchase information text if it is too large.
peter1138
parents: 8848
diff changeset
   366
						ResizeWindowForWidget(w, i == 0 ? RVW_WIDGET_LEFT_DETAILS : RVW_WIDGET_RIGHT_DETAILS, 0, text_end - wi->bottom);
db4c2ae09c4b (svn r11989) -Fix: Resize autoreplace window to fit purchase information text if it is too large.
peter1138
parents: 8848
diff changeset
   367
						SetWindowDirty(w);
db4c2ae09c4b (svn r11989) -Fix: Resize autoreplace window to fit purchase information text if it is too large.
peter1138
parents: 8848
diff changeset
   368
					}
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   369
				}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   370
			}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   371
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   372
		} break;   // end of paint
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   373
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   374
		case WE_CLICK: {
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   375
			switch (e->we.click.widget) {
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   376
				case RVW_WIDGET_TRAIN_ENGINEWAGON_TOGGLE:
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   377
					WP(w, replaceveh_d).wagon_btnstate = !(WP(w, replaceveh_d).wagon_btnstate);
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   378
					WP(w, replaceveh_d).update_left = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   379
					WP(w, replaceveh_d).init_lists  = true;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   380
					SetWindowDirty(w);
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   381
					break;
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   382
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   383
				case RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: /* Railtype selection dropdown menu */
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   384
					ShowDropDownMenu(w, _rail_types_list, _railtype_selected_in_replace_gui, RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN, 0, ~GetPlayer(_local_player)->avail_railtypes);
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   385
					break;
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   386
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   387
				case RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE: /* toggle renew_keep_length */
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   388
					DoCommandP(0, 5, GetPlayer(_local_player)->renew_keep_length ? 0 : 1, NULL, CMD_SET_AUTOREPLACE);
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   389
					break;
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   390
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   391
				case RVW_WIDGET_START_REPLACE: { /* Start replacing */
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   392
					EngineID veh_from = WP(w, replaceveh_d).sel_engine[0];
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   393
					EngineID veh_to = WP(w, replaceveh_d).sel_engine[1];
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   394
					DoCommandP(0, 3 + (WP(w, replaceveh_d).sel_group << 16) , veh_from + (veh_to << 16), NULL, CMD_SET_AUTOREPLACE);
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   395
				} break;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   396
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   397
				case RVW_WIDGET_STOP_REPLACE: { /* Stop replacing */
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   398
					EngineID veh_from = WP(w, replaceveh_d).sel_engine[0];
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   399
					DoCommandP(0, 3 + (WP(w, replaceveh_d).sel_group << 16), veh_from + (INVALID_ENGINE << 16), NULL, CMD_SET_AUTOREPLACE);
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   400
				} break;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   401
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   402
				case RVW_WIDGET_LEFT_MATRIX:
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   403
				case RVW_WIDGET_RIGHT_MATRIX: {
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   404
					uint i = (e->we.click.pt.y - 14) / w->resize.step_height;
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   405
					uint16 click_scroll_pos = e->we.click.widget == RVW_WIDGET_LEFT_MATRIX ? w->vscroll.pos : w->vscroll2.pos;
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   406
					uint16 click_scroll_cap = e->we.click.widget == RVW_WIDGET_LEFT_MATRIX ? w->vscroll.cap : w->vscroll2.cap;
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   407
					byte click_side         = e->we.click.widget == RVW_WIDGET_LEFT_MATRIX ? 0 : 1;
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   408
					uint16 engine_count     = EngList_Count(&WP(w, replaceveh_d).list[click_side]);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   409
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   410
					if (i < click_scroll_cap) {
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   411
						i += click_scroll_pos;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   412
						EngineID e = engine_count > i ? WP(w, replaceveh_d).list[click_side][i] : INVALID_ENGINE;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   413
						if (e == WP(w, replaceveh_d).sel_engine[click_side]) break; // we clicked the one we already selected
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   414
						WP(w, replaceveh_d).sel_engine[click_side] = e;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   415
						if (click_side == 0) {
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   416
							WP(w, replaceveh_d).update_right = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   417
							WP(w, replaceveh_d).init_lists   = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   418
						}
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   419
						SetWindowDirty(w);
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   420
						}
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   421
					break;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   422
					}
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   423
			}
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   424
			break;
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   425
		}
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   426
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   427
		case WE_DROPDOWN_SELECT: { /* we have selected a dropdown item in the list */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   428
			RailType temp = (RailType)e->we.dropdown.index;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   429
			if (temp == _railtype_selected_in_replace_gui) break; // we didn't select a new one. No need to change anything
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   430
			_railtype_selected_in_replace_gui = temp;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   431
			/* Reset scrollbar positions */
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   432
			w->vscroll.pos  = 0;
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   433
			w->vscroll2.pos = 0;
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   434
			/* Rebuild the lists */
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   435
			WP(w, replaceveh_d).update_left  = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   436
			WP(w, replaceveh_d).update_right = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   437
			WP(w, replaceveh_d).init_lists   = true;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   438
			SetWindowDirty(w);
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   439
		} break;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   440
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   441
		case WE_RESIZE:
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   442
			w->vscroll.cap  += e->we.sizing.diff.y / (int)w->resize.step_height;
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   443
			w->vscroll2.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   444
8841
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   445
			w->widget[RVW_WIDGET_LEFT_MATRIX].data  = (w->vscroll.cap  << 8) + 1;
e015d01a960e (svn r11911) -Codechange: use enum for autoreplace window widgets
peter1138
parents: 8829
diff changeset
   446
			w->widget[RVW_WIDGET_RIGHT_MATRIX].data = (w->vscroll2.cap << 8) + 1;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   447
			break;
6195
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   448
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   449
		case WE_INVALIDATE_DATA:
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   450
			if (_rebuild_left_list) WP(w, replaceveh_d).update_left = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   451
			if (_rebuild_right_list) WP(w, replaceveh_d).update_right = true;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   452
			SetWindowDirty(w);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   453
			break;
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   454
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   455
		case WE_DESTROY:
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   456
			EngList_RemoveAll(&WP(w, replaceveh_d).list[0]);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   457
			EngList_RemoveAll(&WP(w, replaceveh_d).list[1]);
b90cf92697b9 (svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents: 6144
diff changeset
   458
		break;
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   459
	}
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   460
}
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   461
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   462
static const Widget _replace_rail_vehicle_widgets[] = {
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   463
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,       STR_018B_CLOSE_WINDOW},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   464
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES_WHITE, STR_018C_WINDOW_TITLE_DRAG_THIS},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   465
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, STR_NULL,       STR_STICKY_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   466
{      WWT_PANEL,     RESIZE_TB,    14,     0,   227,   126,   227, 0x0,            STR_NULL},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   467
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   138,   240,   251, STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   468
{      WWT_PANEL,     RESIZE_TB,    14,   139,   316,   228,   239, 0x0,            STR_REPLACE_HELP_REPLACE_INFO_TAB},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   469
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   306,   443,   240,   251, STR_REPLACE_VEHICLES_STOP,  STR_REPLACE_HELP_STOP_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   470
{     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   215,    14,   125, 0x801,          STR_REPLACE_HELP_LEFT_ARRAY},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   471
{  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   216,   227,    14,   125, STR_NULL,       STR_0190_SCROLL_BAR_SCROLLS_LIST},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   472
{     WWT_MATRIX, RESIZE_BOTTOM,    14,   228,   443,    14,   125, 0x801,          STR_REPLACE_HELP_RIGHT_ARRAY},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   473
{ WWT_SCROLL2BAR, RESIZE_BOTTOM,    14,   444,   455,    14,   125, STR_NULL,       STR_0190_SCROLL_BAR_SCROLLS_LIST},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   474
{      WWT_PANEL,     RESIZE_TB,    14,   228,   455,   126,   227, 0x0,            STR_NULL},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   475
// train specific stuff
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   476
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   138,   228,   239, STR_REPLACE_ENGINE_WAGON_SELECT,       STR_REPLACE_ENGINE_WAGON_SELECT_HELP},  // widget 12
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   477
{      WWT_PANEL,     RESIZE_TB,    14,   139,   153,   240,   251, 0x0,            STR_NULL},
8842
69a6737d61d3 (svn r11912) -Codechange: use dropdown widget for autoreplace, station builder and (second?) vehicle list windows
peter1138
parents: 8841
diff changeset
   478
{   WWT_DROPDOWN,     RESIZE_TB,    14,   154,   289,   240,   251, 0x0,            STR_REPLACE_HELP_RAILTYPE},
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   479
{      WWT_PANEL,     RESIZE_TB,    14,   290,   305,   240,   251, 0x0,            STR_NULL},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   480
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   317,   455,   228,   239, STR_REPLACE_REMOVE_WAGON,       STR_REPLACE_REMOVE_WAGON_HELP},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   481
// end of train specific stuff
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   482
{  WWT_RESIZEBOX,     RESIZE_TB,    14,   444,   455,   240,   251, STR_NULL,       STR_RESIZE_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   483
{   WIDGETS_END},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   484
};
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   485
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   486
static const Widget _replace_road_vehicle_widgets[] = {
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   487
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   488
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES_WHITE,  STR_018C_WINDOW_TITLE_DRAG_THIS},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   489
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, STR_NULL,                    STR_STICKY_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   490
{      WWT_PANEL,     RESIZE_TB,    14,     0,   227,   126,   217, 0x0,                         STR_NULL},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   491
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   138,   218,   229, STR_REPLACE_VEHICLES_START,  STR_REPLACE_HELP_START_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   492
{      WWT_PANEL,     RESIZE_TB,    14,   139,   305,   218,   229, 0x0,                         STR_REPLACE_HELP_REPLACE_INFO_TAB},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   493
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   306,   443,   218,   229, STR_REPLACE_VEHICLES_STOP,   STR_REPLACE_HELP_STOP_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   494
{     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   215,    14,   125, 0x801,                       STR_REPLACE_HELP_LEFT_ARRAY},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   495
{  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   216,   227,    14,   125, STR_NULL,                    STR_0190_SCROLL_BAR_SCROLLS_LIST},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   496
{     WWT_MATRIX, RESIZE_BOTTOM,    14,   228,   443,    14,   125, 0x801,                       STR_REPLACE_HELP_RIGHT_ARRAY},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   497
{ WWT_SCROLL2BAR, RESIZE_BOTTOM,    14,   444,   455,    14,   125, STR_NULL,                    STR_0190_SCROLL_BAR_SCROLLS_LIST},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   498
{      WWT_PANEL,     RESIZE_TB,    14,   228,   455,   126,   217, 0x0,                         STR_NULL},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   499
{  WWT_RESIZEBOX,     RESIZE_TB,    14,   444,   455,   218,   229, STR_NULL,                    STR_RESIZE_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   500
{   WIDGETS_END},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   501
};
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   502
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   503
static const Widget _replace_ship_aircraft_vehicle_widgets[] = {
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   504
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                    STR_018B_CLOSE_WINDOW},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   505
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES_WHITE,  STR_018C_WINDOW_TITLE_DRAG_THIS},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   506
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, STR_NULL,                    STR_STICKY_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   507
{      WWT_PANEL,     RESIZE_TB,    14,     0,   227,   110,   201, 0x0,                         STR_NULL},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   508
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   138,   202,   213, STR_REPLACE_VEHICLES_START,  STR_REPLACE_HELP_START_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   509
{      WWT_PANEL,     RESIZE_TB,    14,   139,   305,   202,   213, 0x0,                         STR_REPLACE_HELP_REPLACE_INFO_TAB},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   510
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   306,   443,   202,   213, STR_REPLACE_VEHICLES_STOP,   STR_REPLACE_HELP_STOP_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   511
{     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   215,    14,   109, 0x401,                       STR_REPLACE_HELP_LEFT_ARRAY},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   512
{  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   216,   227,    14,   109, STR_NULL,                    STR_0190_SCROLL_BAR_SCROLLS_LIST},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   513
{     WWT_MATRIX, RESIZE_BOTTOM,    14,   228,   443,    14,   109, 0x401,                       STR_REPLACE_HELP_RIGHT_ARRAY},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   514
{ WWT_SCROLL2BAR, RESIZE_BOTTOM,    14,   444,   455,    14,   109, STR_NULL,                    STR_0190_SCROLL_BAR_SCROLLS_LIST},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   515
{      WWT_PANEL,     RESIZE_TB,    14,   228,   455,   110,   201, 0x0,                         STR_NULL},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   516
{  WWT_RESIZEBOX,     RESIZE_TB,    14,   444,   455,   202,   213, STR_NULL,                    STR_RESIZE_BUTTON},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   517
{   WIDGETS_END},
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   518
};
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   519
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   520
static const WindowDesc _replace_rail_vehicle_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
   521
	WDP_AUTO, WDP_AUTO, 456, 252, 456, 252,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6119
diff changeset
   522
	WC_REPLACE_VEHICLE, WC_NONE,
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   523
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   524
	_replace_rail_vehicle_widgets,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   525
	ReplaceVehicleWndProc
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   526
};
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   527
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   528
static const WindowDesc _replace_road_vehicle_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
   529
	WDP_AUTO, WDP_AUTO, 456, 230, 456, 230,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6119
diff changeset
   530
	WC_REPLACE_VEHICLE, WC_NONE,
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   531
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   532
	_replace_road_vehicle_widgets,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   533
	ReplaceVehicleWndProc
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   534
};
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   535
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   536
static const WindowDesc _replace_ship_aircraft_vehicle_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
   537
	WDP_AUTO, WDP_AUTO, 456, 214, 456, 214,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6119
diff changeset
   538
	WC_REPLACE_VEHICLE, WC_NONE,
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   539
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   540
	_replace_ship_aircraft_vehicle_widgets,
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   541
	ReplaceVehicleWndProc
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   542
};
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   543
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   544
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   545
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   546
{
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   547
	Window *w;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   548
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   549
	DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype);
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   550
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   551
	switch (vehicletype) {
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   552
		default: NOT_REACHED();
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   553
		case VEH_TRAIN:
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   554
			w = AllocateWindowDescFront(&_replace_rail_vehicle_desc, vehicletype);
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   555
			w->vscroll.cap  = 8;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   556
			w->resize.step_height = 14;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   557
			WP(w, replaceveh_d).wagon_btnstate = true;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   558
			break;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   559
		case VEH_ROAD:
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   560
			w = AllocateWindowDescFront(&_replace_road_vehicle_desc, vehicletype);
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   561
			w->vscroll.cap  = 8;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   562
			w->resize.step_height = 14;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   563
			break;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   564
		case VEH_SHIP:
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   565
		case VEH_AIRCRAFT:
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   566
			w = AllocateWindowDescFront(&_replace_ship_aircraft_vehicle_desc, vehicletype);
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   567
			w->vscroll.cap  = 4;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   568
			w->resize.step_height = 24;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   569
			break;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   570
	}
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   571
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   572
	w->caption_color = _local_player;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   573
	WP(w, replaceveh_d).sel_group = id_g;
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7134
diff changeset
   574
	w->vscroll2.cap = w->vscroll.cap;   // these two are always the same
6059
14d457867d5e (svn r8370) -Revert (r8363): the autoreplace GUI move cleared the file history
bjarni
parents: 6052
diff changeset
   575
}